diff --git a/Makefile b/Makefile index 777c5771..78be86e0 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,10 @@ .PHONY: all all: apps +.PHONY: bsd +bsd: + $(MAKE) BACNET_PORT=bsd -C apps all + .PHONY: win32 win32: $(MAKE) BACNET_PORT=win32 -C apps all diff --git a/ports/bsd/datetime-init.c b/ports/bsd/datetime-init.c index 705302a8..05a6e067 100644 --- a/ports/bsd/datetime-init.c +++ b/ports/bsd/datetime-init.c @@ -51,6 +51,7 @@ bool datetime_local(BACNET_DATE *bdate, * int tm_wday Day of week [0,6] (Sunday =0). * int tm_yday Day of year [0,365]. * int tm_isdst Daylight Savings flag. + * long tm_gmtoff offset from UTC in seconds */ datetime_set_date(bdate, (uint16_t)tblock->tm_year + 1900, (uint8_t)tblock->tm_mon + 1, (uint8_t)tblock->tm_mday); @@ -70,10 +71,10 @@ bool datetime_local(BACNET_DATE *bdate, } /* note: timezone is declared in stdlib. */ if (utc_offset_minutes) { - /* timezone is set to the difference, in seconds, + /* tm_gmtoff is set to the difference, in seconds, between Coordinated Universal Time (UTC) and local standard time */ - *utc_offset_minutes = timezone / 60; + *utc_offset_minutes = tblock->tm_gmtoff / 60; } } diff --git a/ports/bsd/mstimer-init.c b/ports/bsd/mstimer-init.c index a3392783..dc3d4808 100644 --- a/ports/bsd/mstimer-init.c +++ b/ports/bsd/mstimer-init.c @@ -28,9 +28,10 @@ #include #include #include "bacnet/basic/sys/mstimer.h" +#ifdef __MACH__ #include #include - +#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 }