From 76ee46321244f74eee3b5df0800ffdee0e8c3c37 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Thu, 23 Aug 2012 16:25:20 +0100 Subject: [PATCH] : define timespec_get, TIME_UTC, to support implementations --- includes/time.h | 5 ++++- platform/example/internals/_PDCLIB_config.h | 13 +++++++++++++ platform/win32/internals/_PDCLIB_config.h | 13 +++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) 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 */ /* -------------------------------------------------------------------------- */ -- 2.40.0