mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-19 09:53:51 +00:00
* change macOS < 10.12 clock to SYSTEM_CLOCK, fixes #2537 * remove clock_id option from alt_clock_gettime since we always want a monotonic clock. * update header definition for alt_clock_gettime * pass clock definition down to host_get_clock_service for macOS < 10.12 * change to monotonic clocks
This commit is contained in:
parent
45f4a40026
commit
ce602d08db
@ -60,15 +60,9 @@
|
|||||||
|
|
||||||
int alt_clock_gettime (int clock_id, timespec *ts)
|
int alt_clock_gettime (int clock_id, timespec *ts)
|
||||||
{
|
{
|
||||||
// The clock_id specified is not supported on this system.
|
|
||||||
if (clock_id != CLOCK_REALTIME) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
clock_serv_t cclock;
|
clock_serv_t cclock;
|
||||||
mach_timespec_t mts;
|
mach_timespec_t mts;
|
||||||
host_get_clock_service (mach_host_self (), CALENDAR_CLOCK, &cclock);
|
host_get_clock_service (mach_host_self (), clock_id, &cclock);
|
||||||
clock_get_time (cclock, &mts);
|
clock_get_time (cclock, &mts);
|
||||||
mach_port_deallocate (mach_task_self (), cclock);
|
mach_port_deallocate (mach_task_self (), cclock);
|
||||||
ts->tv_sec = mts.tv_sec;
|
ts->tv_sec = mts.tv_sec;
|
||||||
@ -163,7 +157,7 @@ uint64_t zmq::clock_t::now_us ()
|
|||||||
struct timespec tv;
|
struct timespec tv;
|
||||||
|
|
||||||
#if defined ZMQ_HAVE_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200 // less than macOS 10.12
|
#if defined ZMQ_HAVE_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200 // less than macOS 10.12
|
||||||
int rc = alt_clock_gettime (CLOCK_MONOTONIC, &tv);
|
int rc = alt_clock_gettime (SYSTEM_CLOCK, &tv);
|
||||||
#else
|
#else
|
||||||
int rc = clock_gettime (CLOCK_MONOTONIC, &tv);
|
int rc = clock_gettime (CLOCK_MONOTONIC, &tv);
|
||||||
#endif
|
#endif
|
||||||
@ -250,7 +244,7 @@ uint64_t zmq::clock_t::rdtsc ()
|
|||||||
#else
|
#else
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
#if defined ZMQ_HAVE_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200 // less than macOS 10.12
|
#if defined ZMQ_HAVE_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200 // less than macOS 10.12
|
||||||
alt_clock_gettime (CLOCK_MONOTONIC, &ts);
|
alt_clock_gettime (SYSTEM_CLOCK, &ts);
|
||||||
#else
|
#else
|
||||||
clock_gettime (CLOCK_MONOTONIC, &ts);
|
clock_gettime (CLOCK_MONOTONIC, &ts);
|
||||||
#endif
|
#endif
|
||||||
|
@ -214,9 +214,9 @@ namespace zmq
|
|||||||
struct timespec timeout;
|
struct timespec timeout;
|
||||||
|
|
||||||
#if defined ZMQ_HAVE_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200 // less than macOS 10.12
|
#if defined ZMQ_HAVE_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200 // less than macOS 10.12
|
||||||
alt_clock_gettime(CLOCK_REALTIME, &timeout);
|
alt_clock_gettime(SYSTEM_CLOCK, &timeout);
|
||||||
#else
|
#else
|
||||||
clock_gettime(CLOCK_REALTIME, &timeout);
|
clock_gettime(CLOCK_MONOTONIC, &timeout);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
timeout.tv_sec += timeout_ / 1000;
|
timeout.tv_sec += timeout_ / 1000;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user