Module: kamailio Branch: master Commit: ab0a437db098b014ed158434bd98db5ff3b76dd7 URL: https://github.com/kamailio/kamailio/commit/ab0a437db098b014ed158434bd98db5f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2016-05-06T09:06:19+02:00
cdp: keep the ser_clock_gettime() inside the module
- some oses want librt for it
---
Modified: modules/cdp/routing.c
---
Diff: https://github.com/kamailio/kamailio/commit/ab0a437db098b014ed158434bd98db5f... Patch: https://github.com/kamailio/kamailio/commit/ab0a437db098b014ed158434bd98db5f...
---
diff --git a/modules/cdp/routing.c b/modules/cdp/routing.c index 8859a1e..dae24d7 100644 --- a/modules/cdp/routing.c +++ b/modules/cdp/routing.c @@ -34,7 +34,10 @@ * */
-#include "../../ser_time.h" +#ifdef __OS_darwin +#include <mach/clock.h> +#include <mach/mach.h> +#endif
#include "routing.h" #include "config.h" @@ -48,6 +51,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 * @param app_id - the application id to look for