|
@@ -34,7 +34,10 @@
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
|
|
|
|
-#include "../../ser_time.h"
|
|
|
|
|
|
+#ifdef __OS_darwin
|
|
|
|
+#include <mach/clock.h>
|
|
|
|
+#include <mach/mach.h>
|
|
|
|
+#endif
|
|
|
|
|
|
#include "routing.h"
|
|
#include "routing.h"
|
|
#include "config.h"
|
|
#include "config.h"
|
|
@@ -47,6 +50,27 @@
|
|
extern dp_config *config; /**< Configuration for this diameter peer */
|
|
extern dp_config *config; /**< Configuration for this diameter peer */
|
|
int gcount = 0;
|
|
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
|
|
* Returns if the peer advertised support for an Application ID
|
|
* @param p - the peer to check
|
|
* @param p - the peer to check
|