From: Paul Eggert Date: Sat, 28 Jul 2012 14:18:23 +0000 (-0700) Subject: timespec: use extern-inline X-Git-Tag: v0.1~504 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=9defd14457b4a2e3ba0b692ac12866c0f45deb70;p=gnulib.git timespec: use extern-inline * lib/timespec.c: New file. * lib/timespec.h: Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. (_GL_TIMESPEC_INLINE): New macro. Use it instead of 'static inline'. * modules/timespec (Files): Add lib/timespec.c. (Depends-on): Add extern-inline. (lib_SOURCES): Add timespec.c. --- diff --git a/ChangeLog b/ChangeLog index e1ad227bb..cf712d5e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2012-08-01 Paul Eggert + timespec: use extern-inline + * lib/timespec.c: New file. + * lib/timespec.h: Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. + (_GL_TIMESPEC_INLINE): New macro. Use it instead of 'static inline'. + * modules/timespec (Files): Add lib/timespec.c. + (Depends-on): Add extern-inline. + (lib_SOURCES): Add timespec.c. + stat-time: use extern-inline * lib/stat-time.c: New file. * lib/stat-time.h: Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END. diff --git a/lib/timespec.c b/lib/timespec.c new file mode 100644 index 000000000..16a776472 --- /dev/null +++ b/lib/timespec.c @@ -0,0 +1,3 @@ +#include +#define _GL_TIMESPEC_INLINE _GL_EXTERN_INLINE +#include diff --git a/lib/timespec.h b/lib/timespec.h index a58707947..5a6d1c088 100644 --- a/lib/timespec.h +++ b/lib/timespec.h @@ -21,6 +21,8 @@ # include +_GL_INLINE_HEADER_BEGIN + /* Return negative, zero, positive if A < B, A == B, A > B, respectively. For each time stamp T, this code assumes that either: @@ -49,7 +51,11 @@ The (int) cast avoids a gcc -Wconversion warning. */ -static inline int +#ifndef _GL_TIMESPEC_INLINE +# define _GL_TIMESPEC_INLINE _GL_INLINE +#endif + +_GL_TIMESPEC_INLINE int timespec_cmp (struct timespec a, struct timespec b) { return (a.tv_sec < b.tv_sec ? -1 @@ -59,7 +65,7 @@ timespec_cmp (struct timespec a, struct timespec b) /* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be nonnegative. */ -static inline int +_GL_TIMESPEC_INLINE int timespec_sign (struct timespec a) { return a.tv_sec < 0 ? -1 : a.tv_sec || a.tv_nsec; @@ -73,7 +79,7 @@ struct timespec dtotimespec (double) _GL_ATTRIBUTE_CONST; /* Return an approximation to A, of type 'double'. */ -static inline double +_GL_TIMESPEC_INLINE double timespectod (struct timespec a) { return a.tv_sec + a.tv_nsec / 1e9; @@ -82,4 +88,6 @@ timespectod (struct timespec a) void gettime (struct timespec *); int settime (struct timespec const *); +_GL_INLINE_HEADER_END + #endif diff --git a/modules/timespec b/modules/timespec index 8d74632c9..176022c63 100644 --- a/modules/timespec +++ b/modules/timespec @@ -3,15 +3,18 @@ timespec-related declarations Files: lib/timespec.h +lib/timespec.c m4/timespec.m4 Depends-on: +extern-inline time configure.ac: gl_TIMESPEC Makefile.am: +lib_SOURCES += timespec.c Include: "timespec.h"