diff --git a/modules/cdp/routing.c b/modules/cdp/routing.c index 8859a1ea64e..dae24d7f610 100644 --- a/modules/cdp/routing.c +++ b/modules/cdp/routing.c @@ -34,7 +34,10 @@ * */ -#include "../../ser_time.h" +#ifdef __OS_darwin +#include +#include +#endif #include "routing.h" #include "config.h" @@ -47,6 +50,27 @@ extern dp_config *config; /**< Configuration for this diameter peer */ int gcount = 0; +/** + * portable implementation for clock_gettime(CLOCK_REALTIME, ts) + */ +int ser_clock_gettime(struct timespec *ts) +{ +#ifdef __OS_darwin + clock_serv_t cclock; + mach_timespec_t mts; + + /* OS X does not have clock_gettime, use clock_get_time */ + 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; + return 0; +#else + return clock_gettime(CLOCK_REALTIME, ts); +#endif +} + /** * Returns if the peer advertised support for an Application ID * @param p - the peer to check