message: Avoid clock_gettime because of linking issues
diff: @@ -160,6 +160,8 @@ public:
  }
  };
  #elif defined(__unix__)
  +#include <chrono>
  +
  //---------------------------------------------------------
  // Semaphore (POSIX, Linux)
  //---------------------------------------------------------
  @@ -207,11 +209,22 @@ public:
  bool timed_wait(std::uint64_t usecs)
  {
  struct timespec ts;
  - const int usecs_in_1_sec = 1000000;
  - const int nsecs_in_1_sec = 1000000000;
  - clock_gettime(CLOCK_REALTIME, &ts);
  + // sem_timedwait needs an absolute time
  + // hence we need to first obtain the current time
  + // and then add the maximum time we want to wait
  + // we want to avoid clock_gettime because of linking issues
  + // chrono -> timespec conversion from here: https://embeddedartistry.com/blog/2019/01/31/converting-between-timespec-stdchrono/
  + auto current_time = std::chrono::system_clock::now();
  + auto secs = std::chrono::time_point_cast<seconds>(current_time);
  + auto ns = std::chrono::time_point_cast<nanoseconds>(current_time) - std::chrono::time_point_cast<nanoseconds>(secs);
  +
  + ts.tv_sec = secs.time_since_epoch().count();
  + ts.tv_nsec = ns.count();
  +
  + // now add the time we want to wait
  ts.tv_sec += usecs / usecs_in_1_sec;
  ts.tv_nsec += (usecs % usecs_in_1_sec) * 1000;
  +
  // sem_timedwait bombs if you have more than 1e9 in tv_nsec
  // so we have to clean things up before passing it in
  if (ts.tv_nsec >= nsecs_in_1_sec) {
  