diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-08-01 21:46:10 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-08-01 21:46:10 -0700 |
commit | a0d4efe9c3c01fde58b401ee5ab88f052128fa85 (patch) | |
tree | 70862330c792d4ba0d16d9b389e742d65ddf2004 /lib | |
parent | 13294f95172c68a5e77143f917231e0f17f37537 (diff) | |
download | emacs-a0d4efe9c3c01fde58b401ee5ab88f052128fa85.tar.gz |
Merge from gnulib, for extern-inline.
2012-08-01 extern-inline: new module
2012-08-01 stat-time, timespec, u64, utimens: use extern-inline
* lib/stat-time.c, lib/utimespec.c, lib/u64.c, m4/extern-inline.m4:
New files. The new .c files are for instantiating extern inline
functions.
Fixes: debbugs:12116
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gnulib.mk | 3 | ||||
-rw-r--r-- | lib/stat-time.c | 3 | ||||
-rw-r--r-- | lib/stat-time.h | 23 | ||||
-rw-r--r-- | lib/timespec.c | 3 | ||||
-rw-r--r-- | lib/timespec.h | 13 | ||||
-rw-r--r-- | lib/u64.c | 3 | ||||
-rw-r--r-- | lib/u64.h | 27 | ||||
-rw-r--r-- | lib/utimens.c | 1 | ||||
-rw-r--r-- | lib/utimens.h | 29 |
9 files changed, 83 insertions, 22 deletions
diff --git a/lib/gnulib.mk b/lib/gnulib.mk index c85b923029e..0cc0e68bb7b 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk @@ -465,6 +465,7 @@ EXTRA_libgnu_a_SOURCES += stat.c ## begin gnulib module stat-time +libgnu_a_SOURCES += stat-time.c EXTRA_DIST += stat-time.h @@ -1092,6 +1093,7 @@ EXTRA_libgnu_a_SOURCES += time_r.c ## begin gnulib module timespec +libgnu_a_SOURCES += timespec.c EXTRA_DIST += timespec.h @@ -1111,6 +1113,7 @@ libgnu_a_SOURCES += timespec-sub.c ## begin gnulib module u64 +libgnu_a_SOURCES += u64.c EXTRA_DIST += u64.h diff --git a/lib/stat-time.c b/lib/stat-time.c new file mode 100644 index 00000000000..1a907ef250b --- /dev/null +++ b/lib/stat-time.c @@ -0,0 +1,3 @@ +#include <config.h> +#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE +#include <stat-time.h> diff --git a/lib/stat-time.h b/lib/stat-time.h index 30c2acdab63..74dd00aeb3e 100644 --- a/lib/stat-time.h +++ b/lib/stat-time.h @@ -23,6 +23,11 @@ #include <sys/stat.h> #include <time.h> +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_STAT_TIME_INLINE +# define _GL_STAT_TIME_INLINE _GL_INLINE +#endif + /* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST, ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST, @@ -46,7 +51,7 @@ #endif /* Return the nanosecond component of *ST's access time. */ -static inline long int +_GL_STAT_TIME_INLINE long int get_stat_atime_ns (struct stat const *st) { # if defined STAT_TIMESPEC @@ -59,7 +64,7 @@ get_stat_atime_ns (struct stat const *st) } /* Return the nanosecond component of *ST's status change time. */ -static inline long int +_GL_STAT_TIME_INLINE long int get_stat_ctime_ns (struct stat const *st) { # if defined STAT_TIMESPEC @@ -72,7 +77,7 @@ get_stat_ctime_ns (struct stat const *st) } /* Return the nanosecond component of *ST's data modification time. */ -static inline long int +_GL_STAT_TIME_INLINE long int get_stat_mtime_ns (struct stat const *st) { # if defined STAT_TIMESPEC @@ -85,7 +90,7 @@ get_stat_mtime_ns (struct stat const *st) } /* Return the nanosecond component of *ST's birth time. */ -static inline long int +_GL_STAT_TIME_INLINE long int get_stat_birthtime_ns (struct stat const *st) { # if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC @@ -100,7 +105,7 @@ get_stat_birthtime_ns (struct stat const *st) } /* Return *ST's access time. */ -static inline struct timespec +_GL_STAT_TIME_INLINE struct timespec get_stat_atime (struct stat const *st) { #ifdef STAT_TIMESPEC @@ -114,7 +119,7 @@ get_stat_atime (struct stat const *st) } /* Return *ST's status change time. */ -static inline struct timespec +_GL_STAT_TIME_INLINE struct timespec get_stat_ctime (struct stat const *st) { #ifdef STAT_TIMESPEC @@ -128,7 +133,7 @@ get_stat_ctime (struct stat const *st) } /* Return *ST's data modification time. */ -static inline struct timespec +_GL_STAT_TIME_INLINE struct timespec get_stat_mtime (struct stat const *st) { #ifdef STAT_TIMESPEC @@ -143,7 +148,7 @@ get_stat_mtime (struct stat const *st) /* Return *ST's birth time, if available; otherwise return a value with tv_sec and tv_nsec both equal to -1. */ -static inline struct timespec +_GL_STAT_TIME_INLINE struct timespec get_stat_birthtime (struct stat const *st) { struct timespec t; @@ -186,4 +191,6 @@ get_stat_birthtime (struct stat const *st) return t; } +_GL_INLINE_HEADER_END + #endif diff --git a/lib/timespec.c b/lib/timespec.c new file mode 100644 index 00000000000..16a77647228 --- /dev/null +++ b/lib/timespec.c @@ -0,0 +1,3 @@ +#include <config.h> +#define _GL_TIMESPEC_INLINE _GL_EXTERN_INLINE +#include <timespec.h> diff --git a/lib/timespec.h b/lib/timespec.h index a58707947ce..d0a2194f61d 100644 --- a/lib/timespec.h +++ b/lib/timespec.h @@ -21,6 +21,11 @@ # include <time.h> +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_TIMESPEC_INLINE +# define _GL_TIMESPEC_INLINE _GL_INLINE +#endif + /* Return negative, zero, positive if A < B, A == B, A > B, respectively. For each time stamp T, this code assumes that either: @@ -49,7 +54,7 @@ The (int) cast avoids a gcc -Wconversion warning. */ -static inline int +_GL_TIMESPEC_INLINE int timespec_cmp (struct timespec a, struct timespec b) { return (a.tv_sec < b.tv_sec ? -1 @@ -59,7 +64,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 +78,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 +87,6 @@ timespectod (struct timespec a) void gettime (struct timespec *); int settime (struct timespec const *); +_GL_INLINE_HEADER_END + #endif diff --git a/lib/u64.c b/lib/u64.c new file mode 100644 index 00000000000..30dcb45b61f --- /dev/null +++ b/lib/u64.c @@ -0,0 +1,3 @@ +#include <config.h> +#define _GL_U64_INLINE _GL_EXTERN_INLINE +#include <u64.h> diff --git a/lib/u64.h b/lib/u64.h index f5ec9ebcb3d..6a7d370c12b 100644 --- a/lib/u64.h +++ b/lib/u64.h @@ -19,6 +19,11 @@ #include <stdint.h> +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_U64_INLINE +# define _GL_U64_INLINE _GL_INLINE +#endif + /* Return X rotated left by N bits, where 0 < N < 64. */ #define u64rol(x, n) u64or (u64shl (x, n), u64shr (x, 64 - n)) @@ -54,7 +59,7 @@ typedef struct { uint32_t lo, hi; } u64; /* Given the high and low-order 32-bit quantities HI and LO, return a u64 value representing (HI << 32) + LO. */ -static inline u64 +_GL_U64_INLINE u64 u64hilo (uint32_t hi, uint32_t lo) { u64 r; @@ -64,7 +69,7 @@ u64hilo (uint32_t hi, uint32_t lo) } /* Return a u64 value representing LO. */ -static inline u64 +_GL_U64_INLINE u64 u64lo (uint32_t lo) { u64 r; @@ -74,7 +79,7 @@ u64lo (uint32_t lo) } /* Return a u64 value representing SIZE. */ -static inline u64 +_GL_U64_INLINE u64 u64size (size_t size) { u64 r; @@ -84,14 +89,14 @@ u64size (size_t size) } /* Return X < Y. */ -static inline int +_GL_U64_INLINE int u64lt (u64 x, u64 y) { return x.hi < y.hi || (x.hi == y.hi && x.lo < y.lo); } /* Return X & Y. */ -static inline u64 +_GL_U64_INLINE u64 u64and (u64 x, u64 y) { u64 r; @@ -101,7 +106,7 @@ u64and (u64 x, u64 y) } /* Return X | Y. */ -static inline u64 +_GL_U64_INLINE u64 u64or (u64 x, u64 y) { u64 r; @@ -111,7 +116,7 @@ u64or (u64 x, u64 y) } /* Return X ^ Y. */ -static inline u64 +_GL_U64_INLINE u64 u64xor (u64 x, u64 y) { u64 r; @@ -121,7 +126,7 @@ u64xor (u64 x, u64 y) } /* Return X + Y. */ -static inline u64 +_GL_U64_INLINE u64 u64plus (u64 x, u64 y) { u64 r; @@ -131,7 +136,7 @@ u64plus (u64 x, u64 y) } /* Return X << N. */ -static inline u64 +_GL_U64_INLINE u64 u64shl (u64 x, int n) { u64 r; @@ -149,7 +154,7 @@ u64shl (u64 x, int n) } /* Return X >> N. */ -static inline u64 +_GL_U64_INLINE u64 u64shr (u64 x, int n) { u64 r; @@ -167,3 +172,5 @@ u64shr (u64 x, int n) } #endif + +_GL_INLINE_HEADER_END diff --git a/lib/utimens.c b/lib/utimens.c index c126b9551a6..f06918cc23e 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -21,6 +21,7 @@ #include <config.h> +#define _GL_UTIMENS_INLINE _GL_EXTERN_INLINE #include "utimens.h" #include <assert.h> diff --git a/lib/utimens.h b/lib/utimens.h index 8c47cf93f88..f765d102b77 100644 --- a/lib/utimens.h +++ b/lib/utimens.h @@ -1,3 +1,22 @@ +/* Set file access and modification times. + + Copyright 2012 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3 of the License, or any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert. */ + #include <time.h> int fdutimens (int, char const *, struct timespec const [2]); int utimens (char const *, struct timespec const [2]); @@ -7,13 +26,21 @@ int lutimens (char const *, struct timespec const [2]); # include <fcntl.h> # include <sys/stat.h> +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_UTIMENS_INLINE +# define _GL_UTIMENS_INLINE _GL_INLINE +#endif + int fdutimensat (int fd, int dir, char const *name, struct timespec const [2], int atflag); /* Using this function makes application code slightly more readable. */ -static inline int +_GL_UTIMENS_INLINE int lutimensat (int dir, char const *file, struct timespec const times[2]) { return utimensat (dir, file, times, AT_SYMLINK_NOFOLLOW); } + +_GL_INLINE_HEADER_END + #endif |