diff --git a/cereal/messaging/messaging.h b/cereal/messaging/messaging.h index f3850130e6..fb9c261f2b 100644 --- a/cereal/messaging/messaging.h +++ b/cereal/messaging/messaging.h @@ -5,20 +5,13 @@ #include #include #include -#include #include #include "cereal/gen/cpp/log.capnp.h" +#include "common/timing.h" #include "msgq/ipc.h" -#ifdef __APPLE__ -#define CLOCK_BOOTTIME CLOCK_MONOTONIC -#endif - -#define MSG_MULTIPLE_PUBLISHERS 100 - - class SubMaster { public: SubMaster(const std::vector &service_list, const std::vector &poll = {}, @@ -53,10 +46,7 @@ public: cereal::Event::Builder initEvent(bool valid = true) { cereal::Event::Builder event = initRoot(); - struct timespec t; - clock_gettime(CLOCK_BOOTTIME, &t); - uint64_t current_time = t.tv_sec * 1000000000ULL + t.tv_nsec; - event.setLogMonoTime(current_time); + event.setLogMonoTime(nanos_since_boot()); event.setValid(valid); return event; } diff --git a/cereal/messaging/socketmaster.cc b/cereal/messaging/socketmaster.cc index cd697b1f51..38b9842414 100644 --- a/cereal/messaging/socketmaster.cc +++ b/cereal/messaging/socketmaster.cc @@ -1,4 +1,3 @@ -#include #include #include #include @@ -7,15 +6,8 @@ #include "cereal/services.h" #include "cereal/messaging/messaging.h" - const bool SIMULATION = (getenv("SIMULATION") != nullptr) && (std::string(getenv("SIMULATION")) == "1"); -static inline uint64_t nanos_since_boot() { - struct timespec t; - clock_gettime(CLOCK_BOOTTIME, &t); - return t.tv_sec * 1000000000ULL + t.tv_nsec; -} - static inline bool inList(const std::vector &list, const char *value) { for (auto &v : list) { if (strcmp(value, v) == 0) return true;