From: Owen Shepherd Date: Thu, 23 Aug 2012 15:25:20 +0000 (+0100) Subject: : define timespec_get, TIME_UTC, to support implementations X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=76ee46321244f74eee3b5df0800ffdee0e8c3c37 : define timespec_get, TIME_UTC, to support implementations --- diff --git a/includes/time.h b/includes/time.h index 57db230..41075db 100644 --- a/includes/time.h +++ b/includes/time.h @@ -17,6 +17,8 @@ typedef _PDCLIB_size_t size_t; typedef _PDCLIB_time_t time_t; typedef _PDCLIB_clock_t clock_t; +#define TIME_UTC _PDCLIB_TIME_UTC + #ifndef _PDCLIB_STRUCT_TIMESPEC_DEFINED #define _PDCLIB_STRUCT_TIMESPEC_DEFINED _PDCLIB_DEFINE_STRUCT_TIMESPEC() @@ -27,7 +29,8 @@ _PDCLIB_DEFINE_STRUCT_TIMESPEC() _PDCLIB_DEFINE_STRUCT_TM() #endif -time_t time(time_t* t) _PDCLIB_nothrow; +time_t time( time_t* t ) _PDCLIB_nothrow; +int timespec_get( struct timespec *ts, int base ) _PDCLIB_nothrow; _PDCLIB_END_EXTERN_C #endif diff --git a/platform/example/internals/_PDCLIB_config.h b/platform/example/internals/_PDCLIB_config.h index 15ee828..0163753 100644 --- a/platform/example/internals/_PDCLIB_config.h +++ b/platform/example/internals/_PDCLIB_config.h @@ -195,6 +195,19 @@ struct _PDCLIB_imaxdiv_t #define _PDCLIB_clock double #define _PDCLIB_CLOCKS_PER_SEC 1000000 +/* : TIME_UTC + * + * The TIME_UTC parameter is passed to the timespec_get function in order to get + * the system time in UTC since an implementation defined epoch (not necessarily + * the same as that used for time_t). That said, on POSIX the obvious + * implementation of timespec_get for TIME_UTC is to wrap + * clock_gettime(CLOCK_REALTIME, ...), which is defined as time in UTC since the + * same epoch. + * + * This may be any non-zero integer value. + */ +#define _PDCLIB_TIME_UTC 1 + /* -------------------------------------------------------------------------- */ /* Floating Point */ /* -------------------------------------------------------------------------- */ diff --git a/platform/win32/internals/_PDCLIB_config.h b/platform/win32/internals/_PDCLIB_config.h index 7caa7cb..1d233eb 100644 --- a/platform/win32/internals/_PDCLIB_config.h +++ b/platform/win32/internals/_PDCLIB_config.h @@ -219,6 +219,19 @@ struct _PDCLIB_imaxdiv_t #define _PDCLIB_clock double #define _PDCLIB_CLOCKS_PER_SEC 1000000 +/* : TIME_UTC + * + * The TIME_UTC parameter is passed to the timespec_get function in order to get + * the system time in UTC since an implementation defined epoch (not necessarily + * the same as that used for time_t). That said, on POSIX the obvious + * implementation of timespec_get for TIME_UTC is to wrap + * clock_gettime(CLOCK_REALTIME, ...), which is defined as time in UTC since the + * same epoch. + * + * This may be any non-zero integer value. + */ +#define _PDCLIB_TIME_UTC 1 + /* -------------------------------------------------------------------------- */ /* Floating Point */ /* -------------------------------------------------------------------------- */