Skip to content

Commit

Permalink
Fix C11 and POSIX 1003.1b-1993 compliance in time.h
Browse files Browse the repository at this point in the history
Only expose timespec_get in C11, C++17, or BSD code.  Always define
struct timespect if defining timespec_get.

PR:		231425
Reviewed by:	kib
Approved by:	re (gjb)
Differential Revision:	https://reviews.freebsd.org/D17174
  • Loading branch information
brooksdavis committed Sep 18, 2018
1 parent 1ca86e5 commit 39f6c1e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/time.h
Expand Up @@ -207,9 +207,13 @@ time_t posix2time(time_t t);
#include <xlocale/_time.h>
#endif

#if defined(__BSD_VISIBLE) || __ISO_C_VISIBLE >= 2011 || \
(defined(cplusplus) && cplusplus >= 201703)
#include <sys/_timespec.h>
/* ISO/IEC 9899:201x 7.27.2.5 The timespec_get function */
#define TIME_UTC 1 /* time elapsed since epoch */
int timespec_get(struct timespec *ts, int base);
#endif

__END_DECLS

Expand Down

0 comments on commit 39f6c1e

Please sign in to comment.