diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Makefile.am | 2 | ||||
| -rw-r--r-- | lib/gnulib.mk | 5 | ||||
| -rw-r--r-- | lib/makefile.w32-in | 36 | ||||
| -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 | ||||
| -rw-r--r-- | lib/verify.h | 6 |
12 files changed, 118 insertions, 33 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 716510aff92..28fdafd4b45 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am | |||
| @@ -5,6 +5,6 @@ MOSTLYCLEANFILES = | |||
| 5 | noinst_LIBRARIES = | 5 | noinst_LIBRARIES = |
| 6 | 6 | ||
| 7 | AM_CFLAGS = $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) | 7 | AM_CFLAGS = $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) |
| 8 | DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src | 8 | DEFAULT_INCLUDES = -I. -I$(top_srcdir)/lib -I../src -I$(top_srcdir)/src |
| 9 | 9 | ||
| 10 | include gnulib.mk | 10 | include gnulib.mk |
diff --git a/lib/gnulib.mk b/lib/gnulib.mk index 6e2bf89786c..0cc0e68bb7b 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | # the same distribution terms as the rest of that program. | 21 | # the same distribution terms as the rest of that program. |
| 22 | # | 22 | # |
| 23 | # Generated by gnulib-tool. | 23 | # Generated by gnulib-tool. |
| 24 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat --avoid=msvc-inval --avoid=msvc-nothrow --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-strcase careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdarg stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timespec-add timespec-sub utimens warnings | 24 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat --avoid=msvc-inval --avoid=msvc-nothrow --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-strcase careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdalign stdarg stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timespec-add timespec-sub utimens warnings |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | MOSTLYCLEANFILES += core *.stackdump | 27 | MOSTLYCLEANFILES += core *.stackdump |
| @@ -465,6 +465,7 @@ EXTRA_libgnu_a_SOURCES += stat.c | |||
| 465 | 465 | ||
| 466 | ## begin gnulib module stat-time | 466 | ## begin gnulib module stat-time |
| 467 | 467 | ||
| 468 | libgnu_a_SOURCES += stat-time.c | ||
| 468 | 469 | ||
| 469 | EXTRA_DIST += stat-time.h | 470 | EXTRA_DIST += stat-time.h |
| 470 | 471 | ||
| @@ -1092,6 +1093,7 @@ EXTRA_libgnu_a_SOURCES += time_r.c | |||
| 1092 | 1093 | ||
| 1093 | ## begin gnulib module timespec | 1094 | ## begin gnulib module timespec |
| 1094 | 1095 | ||
| 1096 | libgnu_a_SOURCES += timespec.c | ||
| 1095 | 1097 | ||
| 1096 | EXTRA_DIST += timespec.h | 1098 | EXTRA_DIST += timespec.h |
| 1097 | 1099 | ||
| @@ -1111,6 +1113,7 @@ libgnu_a_SOURCES += timespec-sub.c | |||
| 1111 | 1113 | ||
| 1112 | ## begin gnulib module u64 | 1114 | ## begin gnulib module u64 |
| 1113 | 1115 | ||
| 1116 | libgnu_a_SOURCES += u64.c | ||
| 1114 | 1117 | ||
| 1115 | EXTRA_DIST += u64.h | 1118 | EXTRA_DIST += u64.h |
| 1116 | 1119 | ||
diff --git a/lib/makefile.w32-in b/lib/makefile.w32-in index b49195bcb84..11251d55f77 100644 --- a/lib/makefile.w32-in +++ b/lib/makefile.w32-in | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # -*- Makefile -*- for GNU Emacs on the Microsoft W32 API. | 1 | # -*- Makefile -*- for GNU Emacs on the Microsoft Windows API. |
| 2 | # Copyright (C) 2011 Free Software Foundation, Inc. | 2 | # Copyright (C) 2011-2012 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | # This file is part of GNU Emacs. | 4 | # This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -39,6 +39,9 @@ GNULIBOBJS = $(BLD)/c-ctype.$(O) \ | |||
| 39 | $(BLD)/sha1.$(O) \ | 39 | $(BLD)/sha1.$(O) \ |
| 40 | $(BLD)/sha256.$(O) \ | 40 | $(BLD)/sha256.$(O) \ |
| 41 | $(BLD)/sha512.$(O) \ | 41 | $(BLD)/sha512.$(O) \ |
| 42 | $(BLD)/stat-time.$(O) \ | ||
| 43 | $(BLD)/timespec.$(O) \ | ||
| 44 | $(BLD)/u64.$(O) \ | ||
| 42 | $(BLD)/filemode.$(O) | 45 | $(BLD)/filemode.$(O) |
| 43 | 46 | ||
| 44 | # | 47 | # |
| @@ -71,18 +74,19 @@ NT_INC = $(EMACS_ROOT)/nt/inc | |||
| 71 | 74 | ||
| 72 | C_CTYPE_H = $(GNU_LIB)/c-ctype.h \ | 75 | C_CTYPE_H = $(GNU_LIB)/c-ctype.h \ |
| 73 | $(NT_INC)/stdbool.h | 76 | $(NT_INC)/stdbool.h |
| 74 | MS_W32_H = $(SRC)/s/ms-w32.h \ | 77 | MS_W32_H = $(NT_INC)/ms-w32.h \ |
| 75 | $(NT_INC)/sys/stat.h | 78 | $(NT_INC)/sys/stat.h |
| 76 | CONFIG_H = $(SRC)/config.h \ | 79 | CONF_POST_H = $(SRC)/conf_post.h \ |
| 77 | $(MS_W32_H) | 80 | $(MS_W32_H) |
| 81 | CONFIG_H = $(SRC)/config.h \ | ||
| 82 | $(CONF_POST_H) | ||
| 78 | FILEMODE_H = $(GNU_LIB)/filemode.h \ | 83 | FILEMODE_H = $(GNU_LIB)/filemode.h \ |
| 79 | $(NT_INC)/sys/stat.h | 84 | $(NT_INC)/sys/stat.h |
| 80 | FTOASTR_H = $(GNU_LIB)/ftoastr.h \ | 85 | FTOASTR_H = $(GNU_LIB)/ftoastr.h \ |
| 81 | $(GNU_LIB)/intprops.h | 86 | $(GNU_LIB)/intprops.h |
| 82 | FTOASTR_C = $(GNU_LIB)/ftoastr.c \ | 87 | FTOASTR_C = $(GNU_LIB)/ftoastr.c \ |
| 83 | $(CONFIG_H) \ | 88 | $(CONFIG_H) \ |
| 84 | $(FTOASTR_H) \ | 89 | $(FTOASTR_H) |
| 85 | $(GNU_LIB)/ftoastr.h | ||
| 86 | GETOPT_INT_H = $(GNU_LIB)/getopt_int.h \ | 90 | GETOPT_INT_H = $(GNU_LIB)/getopt_int.h \ |
| 87 | $(GNU_LIB)/getopt.h | 91 | $(GNU_LIB)/getopt.h |
| 88 | MD5_H = $(GNU_LIB)/md5.h \ | 92 | MD5_H = $(GNU_LIB)/md5.h \ |
| @@ -94,8 +98,9 @@ SHA256_H = $(GNU_LIB)/sha256.h \ | |||
| 94 | U64_H = $(GNU_LIB)/u64.h \ | 98 | U64_H = $(GNU_LIB)/u64.h \ |
| 95 | $(NT_INC)/stdint.h | 99 | $(NT_INC)/stdint.h |
| 96 | SHA512_H = $(GNU_LIB)/sha512.h \ | 100 | SHA512_H = $(GNU_LIB)/sha512.h \ |
| 97 | $(U64_H) \ | 101 | $(U64_H) |
| 98 | $(GNU_LIB)/u64.h | 102 | STAT_TIME_H = $(GNU_LIB)/stat-time.h \ |
| 103 | $(NT_INC)/sys/stat.h | ||
| 99 | 104 | ||
| 100 | $(BLD)/c-ctype.$(O) : \ | 105 | $(BLD)/c-ctype.$(O) : \ |
| 101 | $(GNU_LIB)/c-ctype.c \ | 106 | $(GNU_LIB)/c-ctype.c \ |
| @@ -194,6 +199,21 @@ $(BLD)/sha512.$(O) : \ | |||
| 194 | $(CONFIG_H) \ | 199 | $(CONFIG_H) \ |
| 195 | $(SHA512_H) | 200 | $(SHA512_H) |
| 196 | 201 | ||
| 202 | $(BLD)/stat-time.$(O) : \ | ||
| 203 | $(GNU_LIB)/stat-time.c \ | ||
| 204 | $(CONFIG_H) \ | ||
| 205 | $(STAT_TIME_H) | ||
| 206 | |||
| 207 | $(BLD)/timespec.$(O) : \ | ||
| 208 | $(GNU_LIB)/timespec.c \ | ||
| 209 | $(GNU_LIB)/timespec.h \ | ||
| 210 | $(CONFIG_H) | ||
| 211 | |||
| 212 | $(BLD)/u64.$(O) : \ | ||
| 213 | $(GNU_LIB)/u64.c \ | ||
| 214 | $(CONFIG_H) \ | ||
| 215 | $(U64_H) | ||
| 216 | |||
| 197 | $(BLD)/filemode.$(O) : \ | 217 | $(BLD)/filemode.$(O) : \ |
| 198 | $(GNU_LIB)/filemode.c \ | 218 | $(GNU_LIB)/filemode.c \ |
| 199 | $(CONFIG_H) \ | 219 | $(CONFIG_H) \ |
diff --git a/lib/stat-time.c b/lib/stat-time.c new file mode 100644 index 00000000000..81b83ddb4fe --- /dev/null +++ b/lib/stat-time.c | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | #include <config.h> | ||
| 2 | #define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE | ||
| 3 | #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 @@ | |||
| 23 | #include <sys/stat.h> | 23 | #include <sys/stat.h> |
| 24 | #include <time.h> | 24 | #include <time.h> |
| 25 | 25 | ||
| 26 | _GL_INLINE_HEADER_BEGIN | ||
| 27 | #ifndef _GL_STAT_TIME_INLINE | ||
| 28 | # define _GL_STAT_TIME_INLINE _GL_INLINE | ||
| 29 | #endif | ||
| 30 | |||
| 26 | /* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type | 31 | /* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type |
| 27 | struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST, | 32 | struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST, |
| 28 | ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST, | 33 | ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST, |
| @@ -46,7 +51,7 @@ | |||
| 46 | #endif | 51 | #endif |
| 47 | 52 | ||
| 48 | /* Return the nanosecond component of *ST's access time. */ | 53 | /* Return the nanosecond component of *ST's access time. */ |
| 49 | static inline long int | 54 | _GL_STAT_TIME_INLINE long int |
| 50 | get_stat_atime_ns (struct stat const *st) | 55 | get_stat_atime_ns (struct stat const *st) |
| 51 | { | 56 | { |
| 52 | # if defined STAT_TIMESPEC | 57 | # if defined STAT_TIMESPEC |
| @@ -59,7 +64,7 @@ get_stat_atime_ns (struct stat const *st) | |||
| 59 | } | 64 | } |
| 60 | 65 | ||
| 61 | /* Return the nanosecond component of *ST's status change time. */ | 66 | /* Return the nanosecond component of *ST's status change time. */ |
| 62 | static inline long int | 67 | _GL_STAT_TIME_INLINE long int |
| 63 | get_stat_ctime_ns (struct stat const *st) | 68 | get_stat_ctime_ns (struct stat const *st) |
| 64 | { | 69 | { |
| 65 | # if defined STAT_TIMESPEC | 70 | # if defined STAT_TIMESPEC |
| @@ -72,7 +77,7 @@ get_stat_ctime_ns (struct stat const *st) | |||
| 72 | } | 77 | } |
| 73 | 78 | ||
| 74 | /* Return the nanosecond component of *ST's data modification time. */ | 79 | /* Return the nanosecond component of *ST's data modification time. */ |
| 75 | static inline long int | 80 | _GL_STAT_TIME_INLINE long int |
| 76 | get_stat_mtime_ns (struct stat const *st) | 81 | get_stat_mtime_ns (struct stat const *st) |
| 77 | { | 82 | { |
| 78 | # if defined STAT_TIMESPEC | 83 | # if defined STAT_TIMESPEC |
| @@ -85,7 +90,7 @@ get_stat_mtime_ns (struct stat const *st) | |||
| 85 | } | 90 | } |
| 86 | 91 | ||
| 87 | /* Return the nanosecond component of *ST's birth time. */ | 92 | /* Return the nanosecond component of *ST's birth time. */ |
| 88 | static inline long int | 93 | _GL_STAT_TIME_INLINE long int |
| 89 | get_stat_birthtime_ns (struct stat const *st) | 94 | get_stat_birthtime_ns (struct stat const *st) |
| 90 | { | 95 | { |
| 91 | # if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC | 96 | # if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC |
| @@ -100,7 +105,7 @@ get_stat_birthtime_ns (struct stat const *st) | |||
| 100 | } | 105 | } |
| 101 | 106 | ||
| 102 | /* Return *ST's access time. */ | 107 | /* Return *ST's access time. */ |
| 103 | static inline struct timespec | 108 | _GL_STAT_TIME_INLINE struct timespec |
| 104 | get_stat_atime (struct stat const *st) | 109 | get_stat_atime (struct stat const *st) |
| 105 | { | 110 | { |
| 106 | #ifdef STAT_TIMESPEC | 111 | #ifdef STAT_TIMESPEC |
| @@ -114,7 +119,7 @@ get_stat_atime (struct stat const *st) | |||
| 114 | } | 119 | } |
| 115 | 120 | ||
| 116 | /* Return *ST's status change time. */ | 121 | /* Return *ST's status change time. */ |
| 117 | static inline struct timespec | 122 | _GL_STAT_TIME_INLINE struct timespec |
| 118 | get_stat_ctime (struct stat const *st) | 123 | get_stat_ctime (struct stat const *st) |
| 119 | { | 124 | { |
| 120 | #ifdef STAT_TIMESPEC | 125 | #ifdef STAT_TIMESPEC |
| @@ -128,7 +133,7 @@ get_stat_ctime (struct stat const *st) | |||
| 128 | } | 133 | } |
| 129 | 134 | ||
| 130 | /* Return *ST's data modification time. */ | 135 | /* Return *ST's data modification time. */ |
| 131 | static inline struct timespec | 136 | _GL_STAT_TIME_INLINE struct timespec |
| 132 | get_stat_mtime (struct stat const *st) | 137 | get_stat_mtime (struct stat const *st) |
| 133 | { | 138 | { |
| 134 | #ifdef STAT_TIMESPEC | 139 | #ifdef STAT_TIMESPEC |
| @@ -143,7 +148,7 @@ get_stat_mtime (struct stat const *st) | |||
| 143 | 148 | ||
| 144 | /* Return *ST's birth time, if available; otherwise return a value | 149 | /* Return *ST's birth time, if available; otherwise return a value |
| 145 | with tv_sec and tv_nsec both equal to -1. */ | 150 | with tv_sec and tv_nsec both equal to -1. */ |
| 146 | static inline struct timespec | 151 | _GL_STAT_TIME_INLINE struct timespec |
| 147 | get_stat_birthtime (struct stat const *st) | 152 | get_stat_birthtime (struct stat const *st) |
| 148 | { | 153 | { |
| 149 | struct timespec t; | 154 | struct timespec t; |
| @@ -186,4 +191,6 @@ get_stat_birthtime (struct stat const *st) | |||
| 186 | return t; | 191 | return t; |
| 187 | } | 192 | } |
| 188 | 193 | ||
| 194 | _GL_INLINE_HEADER_END | ||
| 195 | |||
| 189 | #endif | 196 | #endif |
diff --git a/lib/timespec.c b/lib/timespec.c new file mode 100644 index 00000000000..2b6098ed7bd --- /dev/null +++ b/lib/timespec.c | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | #include <config.h> | ||
| 2 | #define _GL_TIMESPEC_INLINE _GL_EXTERN_INLINE | ||
| 3 | #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 @@ | |||
| 21 | 21 | ||
| 22 | # include <time.h> | 22 | # include <time.h> |
| 23 | 23 | ||
| 24 | _GL_INLINE_HEADER_BEGIN | ||
| 25 | #ifndef _GL_TIMESPEC_INLINE | ||
| 26 | # define _GL_TIMESPEC_INLINE _GL_INLINE | ||
| 27 | #endif | ||
| 28 | |||
| 24 | /* Return negative, zero, positive if A < B, A == B, A > B, respectively. | 29 | /* Return negative, zero, positive if A < B, A == B, A > B, respectively. |
| 25 | 30 | ||
| 26 | For each time stamp T, this code assumes that either: | 31 | For each time stamp T, this code assumes that either: |
| @@ -49,7 +54,7 @@ | |||
| 49 | 54 | ||
| 50 | The (int) cast avoids a gcc -Wconversion warning. */ | 55 | The (int) cast avoids a gcc -Wconversion warning. */ |
| 51 | 56 | ||
| 52 | static inline int | 57 | _GL_TIMESPEC_INLINE int |
| 53 | timespec_cmp (struct timespec a, struct timespec b) | 58 | timespec_cmp (struct timespec a, struct timespec b) |
| 54 | { | 59 | { |
| 55 | return (a.tv_sec < b.tv_sec ? -1 | 60 | return (a.tv_sec < b.tv_sec ? -1 |
| @@ -59,7 +64,7 @@ timespec_cmp (struct timespec a, struct timespec b) | |||
| 59 | 64 | ||
| 60 | /* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be | 65 | /* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be |
| 61 | nonnegative. */ | 66 | nonnegative. */ |
| 62 | static inline int | 67 | _GL_TIMESPEC_INLINE int |
| 63 | timespec_sign (struct timespec a) | 68 | timespec_sign (struct timespec a) |
| 64 | { | 69 | { |
| 65 | return a.tv_sec < 0 ? -1 : a.tv_sec || a.tv_nsec; | 70 | return a.tv_sec < 0 ? -1 : a.tv_sec || a.tv_nsec; |
| @@ -73,7 +78,7 @@ struct timespec dtotimespec (double) | |||
| 73 | _GL_ATTRIBUTE_CONST; | 78 | _GL_ATTRIBUTE_CONST; |
| 74 | 79 | ||
| 75 | /* Return an approximation to A, of type 'double'. */ | 80 | /* Return an approximation to A, of type 'double'. */ |
| 76 | static inline double | 81 | _GL_TIMESPEC_INLINE double |
| 77 | timespectod (struct timespec a) | 82 | timespectod (struct timespec a) |
| 78 | { | 83 | { |
| 79 | return a.tv_sec + a.tv_nsec / 1e9; | 84 | return a.tv_sec + a.tv_nsec / 1e9; |
| @@ -82,4 +87,6 @@ timespectod (struct timespec a) | |||
| 82 | void gettime (struct timespec *); | 87 | void gettime (struct timespec *); |
| 83 | int settime (struct timespec const *); | 88 | int settime (struct timespec const *); |
| 84 | 89 | ||
| 90 | _GL_INLINE_HEADER_END | ||
| 91 | |||
| 85 | #endif | 92 | #endif |
diff --git a/lib/u64.c b/lib/u64.c new file mode 100644 index 00000000000..04cf7a29946 --- /dev/null +++ b/lib/u64.c | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | #include <config.h> | ||
| 2 | #define _GL_U64_INLINE _GL_EXTERN_INLINE | ||
| 3 | #include "u64.h" | ||
| @@ -19,6 +19,11 @@ | |||
| 19 | 19 | ||
| 20 | #include <stdint.h> | 20 | #include <stdint.h> |
| 21 | 21 | ||
| 22 | _GL_INLINE_HEADER_BEGIN | ||
| 23 | #ifndef _GL_U64_INLINE | ||
| 24 | # define _GL_U64_INLINE _GL_INLINE | ||
| 25 | #endif | ||
| 26 | |||
| 22 | /* Return X rotated left by N bits, where 0 < N < 64. */ | 27 | /* Return X rotated left by N bits, where 0 < N < 64. */ |
| 23 | #define u64rol(x, n) u64or (u64shl (x, n), u64shr (x, 64 - n)) | 28 | #define u64rol(x, n) u64or (u64shl (x, n), u64shr (x, 64 - n)) |
| 24 | 29 | ||
| @@ -54,7 +59,7 @@ typedef struct { uint32_t lo, hi; } u64; | |||
| 54 | 59 | ||
| 55 | /* Given the high and low-order 32-bit quantities HI and LO, return a u64 | 60 | /* Given the high and low-order 32-bit quantities HI and LO, return a u64 |
| 56 | value representing (HI << 32) + LO. */ | 61 | value representing (HI << 32) + LO. */ |
| 57 | static inline u64 | 62 | _GL_U64_INLINE u64 |
| 58 | u64hilo (uint32_t hi, uint32_t lo) | 63 | u64hilo (uint32_t hi, uint32_t lo) |
| 59 | { | 64 | { |
| 60 | u64 r; | 65 | u64 r; |
| @@ -64,7 +69,7 @@ u64hilo (uint32_t hi, uint32_t lo) | |||
| 64 | } | 69 | } |
| 65 | 70 | ||
| 66 | /* Return a u64 value representing LO. */ | 71 | /* Return a u64 value representing LO. */ |
| 67 | static inline u64 | 72 | _GL_U64_INLINE u64 |
| 68 | u64lo (uint32_t lo) | 73 | u64lo (uint32_t lo) |
| 69 | { | 74 | { |
| 70 | u64 r; | 75 | u64 r; |
| @@ -74,7 +79,7 @@ u64lo (uint32_t lo) | |||
| 74 | } | 79 | } |
| 75 | 80 | ||
| 76 | /* Return a u64 value representing SIZE. */ | 81 | /* Return a u64 value representing SIZE. */ |
| 77 | static inline u64 | 82 | _GL_U64_INLINE u64 |
| 78 | u64size (size_t size) | 83 | u64size (size_t size) |
| 79 | { | 84 | { |
| 80 | u64 r; | 85 | u64 r; |
| @@ -84,14 +89,14 @@ u64size (size_t size) | |||
| 84 | } | 89 | } |
| 85 | 90 | ||
| 86 | /* Return X < Y. */ | 91 | /* Return X < Y. */ |
| 87 | static inline int | 92 | _GL_U64_INLINE int |
| 88 | u64lt (u64 x, u64 y) | 93 | u64lt (u64 x, u64 y) |
| 89 | { | 94 | { |
| 90 | return x.hi < y.hi || (x.hi == y.hi && x.lo < y.lo); | 95 | return x.hi < y.hi || (x.hi == y.hi && x.lo < y.lo); |
| 91 | } | 96 | } |
| 92 | 97 | ||
| 93 | /* Return X & Y. */ | 98 | /* Return X & Y. */ |
| 94 | static inline u64 | 99 | _GL_U64_INLINE u64 |
| 95 | u64and (u64 x, u64 y) | 100 | u64and (u64 x, u64 y) |
| 96 | { | 101 | { |
| 97 | u64 r; | 102 | u64 r; |
| @@ -101,7 +106,7 @@ u64and (u64 x, u64 y) | |||
| 101 | } | 106 | } |
| 102 | 107 | ||
| 103 | /* Return X | Y. */ | 108 | /* Return X | Y. */ |
| 104 | static inline u64 | 109 | _GL_U64_INLINE u64 |
| 105 | u64or (u64 x, u64 y) | 110 | u64or (u64 x, u64 y) |
| 106 | { | 111 | { |
| 107 | u64 r; | 112 | u64 r; |
| @@ -111,7 +116,7 @@ u64or (u64 x, u64 y) | |||
| 111 | } | 116 | } |
| 112 | 117 | ||
| 113 | /* Return X ^ Y. */ | 118 | /* Return X ^ Y. */ |
| 114 | static inline u64 | 119 | _GL_U64_INLINE u64 |
| 115 | u64xor (u64 x, u64 y) | 120 | u64xor (u64 x, u64 y) |
| 116 | { | 121 | { |
| 117 | u64 r; | 122 | u64 r; |
| @@ -121,7 +126,7 @@ u64xor (u64 x, u64 y) | |||
| 121 | } | 126 | } |
| 122 | 127 | ||
| 123 | /* Return X + Y. */ | 128 | /* Return X + Y. */ |
| 124 | static inline u64 | 129 | _GL_U64_INLINE u64 |
| 125 | u64plus (u64 x, u64 y) | 130 | u64plus (u64 x, u64 y) |
| 126 | { | 131 | { |
| 127 | u64 r; | 132 | u64 r; |
| @@ -131,7 +136,7 @@ u64plus (u64 x, u64 y) | |||
| 131 | } | 136 | } |
| 132 | 137 | ||
| 133 | /* Return X << N. */ | 138 | /* Return X << N. */ |
| 134 | static inline u64 | 139 | _GL_U64_INLINE u64 |
| 135 | u64shl (u64 x, int n) | 140 | u64shl (u64 x, int n) |
| 136 | { | 141 | { |
| 137 | u64 r; | 142 | u64 r; |
| @@ -149,7 +154,7 @@ u64shl (u64 x, int n) | |||
| 149 | } | 154 | } |
| 150 | 155 | ||
| 151 | /* Return X >> N. */ | 156 | /* Return X >> N. */ |
| 152 | static inline u64 | 157 | _GL_U64_INLINE u64 |
| 153 | u64shr (u64 x, int n) | 158 | u64shr (u64 x, int n) |
| 154 | { | 159 | { |
| 155 | u64 r; | 160 | u64 r; |
| @@ -167,3 +172,5 @@ u64shr (u64 x, int n) | |||
| 167 | } | 172 | } |
| 168 | 173 | ||
| 169 | #endif | 174 | #endif |
| 175 | |||
| 176 | _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 @@ | |||
| 21 | 21 | ||
| 22 | #include <config.h> | 22 | #include <config.h> |
| 23 | 23 | ||
| 24 | #define _GL_UTIMENS_INLINE _GL_EXTERN_INLINE | ||
| 24 | #include "utimens.h" | 25 | #include "utimens.h" |
| 25 | 26 | ||
| 26 | #include <assert.h> | 27 | #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 @@ | |||
| 1 | /* Set file access and modification times. | ||
| 2 | |||
| 3 | Copyright 2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify it | ||
| 6 | under the terms of the GNU General Public License as published by the | ||
| 7 | Free Software Foundation; either version 3 of the License, or any | ||
| 8 | later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 17 | |||
| 18 | /* Written by Paul Eggert. */ | ||
| 19 | |||
| 1 | #include <time.h> | 20 | #include <time.h> |
| 2 | int fdutimens (int, char const *, struct timespec const [2]); | 21 | int fdutimens (int, char const *, struct timespec const [2]); |
| 3 | int utimens (char const *, struct timespec const [2]); | 22 | int utimens (char const *, struct timespec const [2]); |
| @@ -7,13 +26,21 @@ int lutimens (char const *, struct timespec const [2]); | |||
| 7 | # include <fcntl.h> | 26 | # include <fcntl.h> |
| 8 | # include <sys/stat.h> | 27 | # include <sys/stat.h> |
| 9 | 28 | ||
| 29 | _GL_INLINE_HEADER_BEGIN | ||
| 30 | #ifndef _GL_UTIMENS_INLINE | ||
| 31 | # define _GL_UTIMENS_INLINE _GL_INLINE | ||
| 32 | #endif | ||
| 33 | |||
| 10 | int fdutimensat (int fd, int dir, char const *name, struct timespec const [2], | 34 | int fdutimensat (int fd, int dir, char const *name, struct timespec const [2], |
| 11 | int atflag); | 35 | int atflag); |
| 12 | 36 | ||
| 13 | /* Using this function makes application code slightly more readable. */ | 37 | /* Using this function makes application code slightly more readable. */ |
| 14 | static inline int | 38 | _GL_UTIMENS_INLINE int |
| 15 | lutimensat (int dir, char const *file, struct timespec const times[2]) | 39 | lutimensat (int dir, char const *file, struct timespec const times[2]) |
| 16 | { | 40 | { |
| 17 | return utimensat (dir, file, times, AT_SYMLINK_NOFOLLOW); | 41 | return utimensat (dir, file, times, AT_SYMLINK_NOFOLLOW); |
| 18 | } | 42 | } |
| 43 | |||
| 44 | _GL_INLINE_HEADER_END | ||
| 45 | |||
| 19 | #endif | 46 | #endif |
diff --git a/lib/verify.h b/lib/verify.h index cef14ad1571..0c320b19ad4 100644 --- a/lib/verify.h +++ b/lib/verify.h | |||
| @@ -125,7 +125,7 @@ | |||
| 125 | extern int (*dummy (void)) [sizeof (struct {...})]; | 125 | extern int (*dummy (void)) [sizeof (struct {...})]; |
| 126 | 126 | ||
| 127 | * GCC warns about duplicate declarations of the dummy function if | 127 | * GCC warns about duplicate declarations of the dummy function if |
| 128 | -Wredundant_decls is used. GCC 4.3 and later have a builtin | 128 | -Wredundant-decls is used. GCC 4.3 and later have a builtin |
| 129 | __COUNTER__ macro that can let us generate unique identifiers for | 129 | __COUNTER__ macro that can let us generate unique identifiers for |
| 130 | each dummy function, to suppress this warning. | 130 | each dummy function, to suppress this warning. |
| 131 | 131 | ||
| @@ -133,6 +133,10 @@ | |||
| 133 | which do not support _Static_assert, also do not warn about the | 133 | which do not support _Static_assert, also do not warn about the |
| 134 | last declaration mentioned above. | 134 | last declaration mentioned above. |
| 135 | 135 | ||
| 136 | * GCC warns if -Wnested-externs is enabled and verify() is used | ||
| 137 | within a function body; but inside a function, you can always | ||
| 138 | arrange to use verify_expr() instead. | ||
| 139 | |||
| 136 | * In C++, any struct definition inside sizeof is invalid. | 140 | * In C++, any struct definition inside sizeof is invalid. |
| 137 | Use a template type to work around the problem. */ | 141 | Use a template type to work around the problem. */ |
| 138 | 142 | ||