Fix FreeBSD 11 compile via gmake gcc (#180)

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2021-06-12 19:27:29 -05:00
committed by GitHub
parent 40cce9f97c
commit 89d7af707e
3 changed files with 17 additions and 4 deletions
+10 -2
View File
@@ -28,9 +28,10 @@
#include <stdint.h>
#include <time.h>
#include "bacnet/basic/sys/mstimer.h"
#ifdef __MACH__
#include <mach/clock.h>
#include <mach/mach.h>
#endif
/** @file bsd/timer.c Provides BSD-specific time and timer functions. */
/* counter for the various timers */
@@ -45,6 +46,7 @@ unsigned long timeGetTime(void)
struct timespec now;
unsigned long ticks;
#ifdef __MACH__
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
@@ -52,7 +54,9 @@ unsigned long timeGetTime(void)
mach_port_deallocate(mach_task_self(), cclock);
now.tv_sec = mts.tv_sec;
now.tv_nsec = mts.tv_nsec;
#else
clock_gettime(CLOCK_MONOTONIC, &now);
#endif
ticks = (now.tv_sec - start.tv_sec) * 1000 +
(now.tv_nsec - start.tv_nsec) / 1000000;
@@ -82,6 +86,7 @@ unsigned long mstimer_now(void)
*/
void timer_init(void)
{
#ifdef __MACH__
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
@@ -89,4 +94,7 @@ void timer_init(void)
mach_port_deallocate(mach_task_self(), cclock);
start.tv_sec = mts.tv_sec;
start.tv_nsec = mts.tv_nsec;
#else
clock_gettime(CLOCK_MONOTONIC, &start);
#endif
}