mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 11:31:56 +01:00
Add clock_gettime implementation for OSX.
This commit is contained in:
@@ -42,6 +42,28 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined ZMQ_HAVE_OSX
|
||||||
|
#include <mach/clock.h>
|
||||||
|
#include <mach/mach.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
int clock_gettime (int clock_id, timespec *ts)
|
||||||
|
{
|
||||||
|
// The clock_id specified is not supported on this system.
|
||||||
|
if (clock_id != CLOCK_REALTIME)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
clock_serv_t cclock;
|
||||||
|
mach_timespec_t mts;
|
||||||
|
host_get_clock_service (mach_host_self (), CALENDAR_CLOCK, &cclock);
|
||||||
|
clock_get_time (cclock, &mts);
|
||||||
|
mach_port_deallocate (mach_task_self (), cclock);
|
||||||
|
ts->tv_sec = mts.tv_sec;
|
||||||
|
ts->tv_nsec = mts.tv_nsec;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ZMQ_HAVE_WINDOWS
|
#ifdef ZMQ_HAVE_WINDOWS
|
||||||
typedef ULONGLONG (*f_compatible_get_tick_count64)();
|
typedef ULONGLONG (*f_compatible_get_tick_count64)();
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,16 @@
|
|||||||
|
|
||||||
#include "stdint.hpp"
|
#include "stdint.hpp"
|
||||||
|
|
||||||
|
#if defined ZMQ_HAVE_OSX
|
||||||
|
#include <mach/clock.h>
|
||||||
|
#include <mach/mach.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
int clock_gettime (int clock_id, timespec *ts);
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
#define HAVE_CLOCK_GETTIME
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace zmq
|
namespace zmq
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#define __ZMQ_CONDITON_VARIABLE_HPP_INCLUDED__
|
#define __ZMQ_CONDITON_VARIABLE_HPP_INCLUDED__
|
||||||
|
|
||||||
#include "platform.hpp"
|
#include "platform.hpp"
|
||||||
|
#include "clock.hpp"
|
||||||
#include "err.hpp"
|
#include "err.hpp"
|
||||||
#include "mutex.hpp"
|
#include "mutex.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mailbox_safe.hpp"
|
#include "mailbox_safe.hpp"
|
||||||
|
#include "clock.hpp"
|
||||||
#include "err.hpp"
|
#include "err.hpp"
|
||||||
|
|
||||||
zmq::mailbox_safe_t::mailbox_safe_t (mutex_t* sync_) :
|
zmq::mailbox_safe_t::mailbox_safe_t (mutex_t* sync_) :
|
||||||
|
|||||||
Reference in New Issue
Block a user