diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2018-04-17 21:03:15 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2023-05-05 21:21:37 -0500 |
commit | b1e554e906de3486d5ee82903cb61d4bfc6d4fab (patch) | |
tree | 1a36d3103855418c783fb41b94c38a6c505b5bfb | |
parent | 41735bdeff548ce44afe21aa21f1345047eb18e4 (diff) | |
download | musl-b1e554e906de3486d5ee82903cb61d4bfc6d4fab.tar.gz musl-b1e554e906de3486d5ee82903cb61d4bfc6d4fab.tar.bz2 musl-b1e554e906de3486d5ee82903cb61d4bfc6d4fab.tar.xz musl-b1e554e906de3486d5ee82903cb61d4bfc6d4fab.zip |
time: C11 visibility fixes
The timespec_get function, and TIME_* macros, are only in C11.
Since musl is compiled with -std=c99, TIME_UTC is unavailable in the
timespec_get implementation, so we use the raw value 1.
-rw-r--r-- | compat/time32/timespec_get_time32.c | 1 | ||||
-rw-r--r-- | include/time.h | 10 | ||||
-rw-r--r-- | src/time/timespec_get.c | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/compat/time32/timespec_get_time32.c b/compat/time32/timespec_get_time32.c index e9ca94cb..b39b12ee 100644 --- a/compat/time32/timespec_get_time32.c +++ b/compat/time32/timespec_get_time32.c @@ -1,3 +1,4 @@ +#define _BSD_SOURCE #include "time32.h" #include <time.h> #include <errno.h> diff --git a/include/time.h b/include/time.h index 3d948372..deb4a450 100644 --- a/include/time.h +++ b/include/time.h @@ -60,11 +60,14 @@ struct tm *gmtime (const time_t *); struct tm *localtime (const time_t *); char *asctime (const struct tm *); char *ctime (const time_t *); -int timespec_get(struct timespec *, int); -#define CLOCKS_PER_SEC 1000000L +#if __STDC_VERSION__ >= 201112L || defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +int timespec_get(struct timespec *, int); #define TIME_UTC 1 +#endif + +#define CLOCKS_PER_SEC 1000000L #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ @@ -139,7 +142,10 @@ __REDIR(mktime, __mktime64); __REDIR(gmtime, __gmtime64); __REDIR(localtime, __localtime64); __REDIR(ctime, __ctime64); +# if __STDC_VERSION__ >= 201112L || defined(_BSD_SOURCE) \ + || defined(_GNU_SOURCE) __REDIR(timespec_get, __timespec_get_time64); +# endif #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ || defined(_BSD_SOURCE) diff --git a/src/time/timespec_get.c b/src/time/timespec_get.c index 40ea9c1c..e396da09 100644 --- a/src/time/timespec_get.c +++ b/src/time/timespec_get.c @@ -1,3 +1,4 @@ +#define _BSD_SOURCE #include <time.h> /* There is no other implemented value than TIME_UTC; all other values |