aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2013-09-19 14:40:08 -0700
committerPaul Eggert2013-09-19 14:40:08 -0700
commit230fe2a5a10f2bc128f354e3fb1b48536b1f143b (patch)
treeb282d5f242b8ada877d188d03d43da78b175d67a /lib
parentc39cc7d149d28060c40bc206eb8a63f7a0636301 (diff)
downloademacs-230fe2a5a10f2bc128f354e3fb1b48536b1f143b.tar.gz
emacs-230fe2a5a10f2bc128f354e3fb1b48536b1f143b.zip
Merge from gnulib.
This incorporates the following changes: 2013-09-19 stdio: OS X port of putc_unlocked + extern inline 2013-09-19 signal: OS X port of sigaddset etc. + extern inline 2013-09-19 extern-inline: do not always suppress extern inline on OS X 2013-09-17 getgroups: statement without effect 2013-08-28 headers: check that _GL_INLINE_HEADER_BEGIN is defined
Diffstat (limited to 'lib')
-rw-r--r--lib/acl-internal.h3
-rw-r--r--lib/binary-io.h3
-rw-r--r--lib/dtotimespec.c30
-rw-r--r--lib/execinfo.in.h3
-rw-r--r--lib/getgroups.c2
-rw-r--r--lib/openat.h3
-rw-r--r--lib/signal.in.h14
-rw-r--r--lib/stat-time.h3
-rw-r--r--lib/stdio.in.h9
-rw-r--r--lib/timespec-add.c7
-rw-r--r--lib/timespec-sub.c7
-rw-r--r--lib/timespec.h3
-rw-r--r--lib/u64.h3
-rw-r--r--lib/unistd.in.h3
-rw-r--r--lib/utimens.c6
-rw-r--r--lib/utimens.h3
16 files changed, 69 insertions, 33 deletions
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 7e6d77a5fd4..55c224ca883 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -60,6 +60,9 @@ extern int aclsort (int, int, struct acl *);
60# define fchmod(fd, mode) (-1) 60# define fchmod(fd, mode) (-1)
61#endif 61#endif
62 62
63#ifndef _GL_INLINE_HEADER_BEGIN
64 #error "Please include config.h first."
65#endif
63_GL_INLINE_HEADER_BEGIN 66_GL_INLINE_HEADER_BEGIN
64#ifndef ACL_INTERNAL_INLINE 67#ifndef ACL_INTERNAL_INLINE
65# define ACL_INTERNAL_INLINE _GL_INLINE 68# define ACL_INTERNAL_INLINE _GL_INLINE
diff --git a/lib/binary-io.h b/lib/binary-io.h
index 317fe3d3c20..423c2ae3fff 100644
--- a/lib/binary-io.h
+++ b/lib/binary-io.h
@@ -25,6 +25,9 @@
25 so we include it here first. */ 25 so we include it here first. */
26#include <stdio.h> 26#include <stdio.h>
27 27
28#ifndef _GL_INLINE_HEADER_BEGIN
29 #error "Please include config.h first."
30#endif
28_GL_INLINE_HEADER_BEGIN 31_GL_INLINE_HEADER_BEGIN
29#ifndef BINARY_IO_INLINE 32#ifndef BINARY_IO_INLINE
30# define BINARY_IO_INLINE _GL_INLINE 33# define BINARY_IO_INLINE _GL_INLINE
diff --git a/lib/dtotimespec.c b/lib/dtotimespec.c
index ecce2e5bcc5..064f7d3a0a9 100644
--- a/lib/dtotimespec.c
+++ b/lib/dtotimespec.c
@@ -29,41 +29,31 @@
29struct timespec 29struct timespec
30dtotimespec (double sec) 30dtotimespec (double sec)
31{ 31{
32 enum { BILLION = 1000 * 1000 * 1000 };
33 double min_representable = TYPE_MINIMUM (time_t); 32 double min_representable = TYPE_MINIMUM (time_t);
34 double max_representable = 33 double max_representable =
35 ((TYPE_MAXIMUM (time_t) * (double) BILLION + (BILLION - 1)) 34 ((TYPE_MAXIMUM (time_t) * (double) TIMESPEC_RESOLUTION
36 / BILLION); 35 + (TIMESPEC_RESOLUTION - 1))
37 struct timespec r; 36 / TIMESPEC_RESOLUTION);
38 37
39 if (! (min_representable < sec)) 38 if (! (min_representable < sec))
40 { 39 return make_timespec (TYPE_MINIMUM (time_t), 0);
41 r.tv_sec = TYPE_MINIMUM (time_t);
42 r.tv_nsec = 0;
43 }
44 else if (! (sec < max_representable)) 40 else if (! (sec < max_representable))
45 { 41 return make_timespec (TYPE_MAXIMUM (time_t), TIMESPEC_RESOLUTION - 1);
46 r.tv_sec = TYPE_MAXIMUM (time_t);
47 r.tv_nsec = BILLION - 1;
48 }
49 else 42 else
50 { 43 {
51 time_t s = sec; 44 time_t s = sec;
52 double frac = BILLION * (sec - s); 45 double frac = TIMESPEC_RESOLUTION * (sec - s);
53 long ns = frac; 46 long ns = frac;
54 ns += ns < frac; 47 ns += ns < frac;
55 s += ns / BILLION; 48 s += ns / TIMESPEC_RESOLUTION;
56 ns %= BILLION; 49 ns %= TIMESPEC_RESOLUTION;
57 50
58 if (ns < 0) 51 if (ns < 0)
59 { 52 {
60 s--; 53 s--;
61 ns += BILLION; 54 ns += TIMESPEC_RESOLUTION;
62 } 55 }
63 56
64 r.tv_sec = s; 57 return make_timespec (s, ns);
65 r.tv_nsec = ns;
66 } 58 }
67
68 return r;
69} 59}
diff --git a/lib/execinfo.in.h b/lib/execinfo.in.h
index 6cfc8d56d2d..344f26add2b 100644
--- a/lib/execinfo.in.h
+++ b/lib/execinfo.in.h
@@ -20,6 +20,9 @@
20#ifndef _GL_EXECINFO_H 20#ifndef _GL_EXECINFO_H
21#define _GL_EXECINFO_H 21#define _GL_EXECINFO_H
22 22
23#ifndef _GL_INLINE_HEADER_BEGIN
24 #error "Please include config.h first."
25#endif
23_GL_INLINE_HEADER_BEGIN 26_GL_INLINE_HEADER_BEGIN
24#ifndef _GL_EXECINFO_INLINE 27#ifndef _GL_EXECINFO_INLINE
25# define _GL_EXECINFO_INLINE _GL_INLINE 28# define _GL_EXECINFO_INLINE _GL_INLINE
diff --git a/lib/getgroups.c b/lib/getgroups.c
index 9856adc1a4d..e71b5439c7e 100644
--- a/lib/getgroups.c
+++ b/lib/getgroups.c
@@ -86,7 +86,7 @@ rpl_getgroups (int n, gid_t *group)
86 } 86 }
87 saved_errno = errno; 87 saved_errno = errno;
88 free (gbuf); 88 free (gbuf);
89 errno == saved_errno; 89 errno = saved_errno;
90 return result; 90 return result;
91 } 91 }
92 92
diff --git a/lib/openat.h b/lib/openat.h
index eb90990da1d..7208f4459fe 100644
--- a/lib/openat.h
+++ b/lib/openat.h
@@ -26,6 +26,9 @@
26#include <unistd.h> 26#include <unistd.h>
27#include <stdbool.h> 27#include <stdbool.h>
28 28
29#ifndef _GL_INLINE_HEADER_BEGIN
30 #error "Please include config.h first."
31#endif
29_GL_INLINE_HEADER_BEGIN 32_GL_INLINE_HEADER_BEGIN
30 33
31#if !HAVE_OPENAT 34#if !HAVE_OPENAT
diff --git a/lib/signal.in.h b/lib/signal.in.h
index 54849504d77..a531487e355 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -195,6 +195,20 @@ typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1];
195 195
196# endif 196# endif
197 197
198/* When also using extern inline, suppress the use of static inline in
199 standard headers of problematic Apple configurations, as Libc at
200 least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
201 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
202 Perhaps Apple will fix this some day. */
203#if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
204 && (defined __i386__ || defined __x86_64__))
205# undef sigaddset
206# undef sigdelset
207# undef sigemptyset
208# undef sigfillset
209# undef sigismember
210#endif
211
198/* Test whether a given signal is contained in a signal set. */ 212/* Test whether a given signal is contained in a signal set. */
199# if @HAVE_POSIX_SIGNALBLOCKING@ 213# if @HAVE_POSIX_SIGNALBLOCKING@
200/* This function is defined as a macro on Mac OS X. */ 214/* This function is defined as a macro on Mac OS X. */
diff --git a/lib/stat-time.h b/lib/stat-time.h
index 2d3b5cd6514..d58eddde334 100644
--- a/lib/stat-time.h
+++ b/lib/stat-time.h
@@ -23,6 +23,9 @@
23#include <sys/stat.h> 23#include <sys/stat.h>
24#include <time.h> 24#include <time.h>
25 25
26#ifndef _GL_INLINE_HEADER_BEGIN
27 #error "Please include config.h first."
28#endif
26_GL_INLINE_HEADER_BEGIN 29_GL_INLINE_HEADER_BEGIN
27#ifndef _GL_STAT_TIME_INLINE 30#ifndef _GL_STAT_TIME_INLINE
28# define _GL_STAT_TIME_INLINE _GL_INLINE 31# define _GL_STAT_TIME_INLINE _GL_INLINE
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 06cbad00d3d..76e62fba6ba 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -124,6 +124,15 @@
124#define _GL_STDIO_STRINGIZE(token) #token 124#define _GL_STDIO_STRINGIZE(token) #token
125#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) 125#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
126 126
127/* When also using extern inline, suppress the use of static inline in
128 standard headers of problematic Apple configurations, as Libc at
129 least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
130 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
131 Perhaps Apple will fix this some day. */
132#if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
133 && defined __GNUC__ && defined __STDC__)
134# undef putc_unlocked
135#endif
127 136
128#if @GNULIB_DPRINTF@ 137#if @GNULIB_DPRINTF@
129# if @REPLACE_DPRINTF@ 138# if @REPLACE_DPRINTF@
diff --git a/lib/timespec-add.c b/lib/timespec-add.c
index 6ce2c73064f..51323a63207 100644
--- a/lib/timespec-add.c
+++ b/lib/timespec-add.c
@@ -28,11 +28,10 @@
28struct timespec 28struct timespec
29timespec_add (struct timespec a, struct timespec b) 29timespec_add (struct timespec a, struct timespec b)
30{ 30{
31 struct timespec r;
32 time_t rs = a.tv_sec; 31 time_t rs = a.tv_sec;
33 time_t bs = b.tv_sec; 32 time_t bs = b.tv_sec;
34 int ns = a.tv_nsec + b.tv_nsec; 33 int ns = a.tv_nsec + b.tv_nsec;
35 int nsd = ns - 1000000000; 34 int nsd = ns - TIMESPEC_RESOLUTION;
36 int rns = ns; 35 int rns = ns;
37 36
38 if (0 <= nsd) 37 if (0 <= nsd)
@@ -65,7 +64,5 @@ timespec_add (struct timespec a, struct timespec b)
65 else 64 else
66 rs += bs; 65 rs += bs;
67 66
68 r.tv_sec = rs; 67 return make_timespec (rs, rns);
69 r.tv_nsec = rns;
70 return r;
71} 68}
diff --git a/lib/timespec-sub.c b/lib/timespec-sub.c
index 97c9f9de88c..b164a8380d0 100644
--- a/lib/timespec-sub.c
+++ b/lib/timespec-sub.c
@@ -29,7 +29,6 @@
29struct timespec 29struct timespec
30timespec_sub (struct timespec a, struct timespec b) 30timespec_sub (struct timespec a, struct timespec b)
31{ 31{
32 struct timespec r;
33 time_t rs = a.tv_sec; 32 time_t rs = a.tv_sec;
34 time_t bs = b.tv_sec; 33 time_t bs = b.tv_sec;
35 int ns = a.tv_nsec - b.tv_nsec; 34 int ns = a.tv_nsec - b.tv_nsec;
@@ -37,7 +36,7 @@ timespec_sub (struct timespec a, struct timespec b)
37 36
38 if (ns < 0) 37 if (ns < 0)
39 { 38 {
40 rns = ns + 1000000000; 39 rns = ns + TIMESPEC_RESOLUTION;
41 if (rs == TYPE_MINIMUM (time_t)) 40 if (rs == TYPE_MINIMUM (time_t))
42 { 41 {
43 if (bs <= 0) 42 if (bs <= 0)
@@ -65,7 +64,5 @@ timespec_sub (struct timespec a, struct timespec b)
65 else 64 else
66 rs -= bs; 65 rs -= bs;
67 66
68 r.tv_sec = rs; 67 return make_timespec (rs, rns);
69 r.tv_nsec = rns;
70 return r;
71} 68}
diff --git a/lib/timespec.h b/lib/timespec.h
index c7450ad8de0..d0c029b5704 100644
--- a/lib/timespec.h
+++ b/lib/timespec.h
@@ -21,6 +21,9 @@
21 21
22# include <time.h> 22# include <time.h>
23 23
24#ifndef _GL_INLINE_HEADER_BEGIN
25 #error "Please include config.h first."
26#endif
24_GL_INLINE_HEADER_BEGIN 27_GL_INLINE_HEADER_BEGIN
25#ifndef _GL_TIMESPEC_INLINE 28#ifndef _GL_TIMESPEC_INLINE
26# define _GL_TIMESPEC_INLINE _GL_INLINE 29# define _GL_TIMESPEC_INLINE _GL_INLINE
diff --git a/lib/u64.h b/lib/u64.h
index d8009ad3913..af8441f52e5 100644
--- a/lib/u64.h
+++ b/lib/u64.h
@@ -19,6 +19,9 @@
19 19
20#include <stdint.h> 20#include <stdint.h>
21 21
22#ifndef _GL_INLINE_HEADER_BEGIN
23 #error "Please include config.h first."
24#endif
22_GL_INLINE_HEADER_BEGIN 25_GL_INLINE_HEADER_BEGIN
23#ifndef _GL_U64_INLINE 26#ifndef _GL_U64_INLINE
24# define _GL_U64_INLINE _GL_INLINE 27# define _GL_U64_INLINE _GL_INLINE
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 2ea9af43652..874c628a63b 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -116,6 +116,9 @@
116# include <getopt.h> 116# include <getopt.h>
117#endif 117#endif
118 118
119#ifndef _GL_INLINE_HEADER_BEGIN
120 #error "Please include config.h first."
121#endif
119_GL_INLINE_HEADER_BEGIN 122_GL_INLINE_HEADER_BEGIN
120#ifndef _GL_UNISTD_INLINE 123#ifndef _GL_UNISTD_INLINE
121# define _GL_UNISTD_INLINE _GL_INLINE 124# define _GL_UNISTD_INLINE _GL_INLINE
diff --git a/lib/utimens.c b/lib/utimens.c
index 013843d6da4..44a33c1d791 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -90,10 +90,12 @@ validate_timespec (struct timespec timespec[2])
90 assert (timespec); 90 assert (timespec);
91 if ((timespec[0].tv_nsec != UTIME_NOW 91 if ((timespec[0].tv_nsec != UTIME_NOW
92 && timespec[0].tv_nsec != UTIME_OMIT 92 && timespec[0].tv_nsec != UTIME_OMIT
93 && (timespec[0].tv_nsec < 0 || 1000000000 <= timespec[0].tv_nsec)) 93 && ! (0 <= timespec[0].tv_nsec
94 && timespec[0].tv_nsec < TIMESPEC_RESOLUTION))
94 || (timespec[1].tv_nsec != UTIME_NOW 95 || (timespec[1].tv_nsec != UTIME_NOW
95 && timespec[1].tv_nsec != UTIME_OMIT 96 && timespec[1].tv_nsec != UTIME_OMIT
96 && (timespec[1].tv_nsec < 0 || 1000000000 <= timespec[1].tv_nsec))) 97 && ! (0 <= timespec[1].tv_nsec
98 && timespec[1].tv_nsec < TIMESPEC_RESOLUTION)))
97 { 99 {
98 errno = EINVAL; 100 errno = EINVAL;
99 return -1; 101 return -1;
diff --git a/lib/utimens.h b/lib/utimens.h
index 82a72a7a451..f1633c966aa 100644
--- a/lib/utimens.h
+++ b/lib/utimens.h
@@ -26,6 +26,9 @@ int lutimens (char const *, struct timespec const [2]);
26# include <fcntl.h> 26# include <fcntl.h>
27# include <sys/stat.h> 27# include <sys/stat.h>
28 28
29#ifndef _GL_INLINE_HEADER_BEGIN
30 #error "Please include config.h first."
31#endif
29_GL_INLINE_HEADER_BEGIN 32_GL_INLINE_HEADER_BEGIN
30#ifndef _GL_UTIMENS_INLINE 33#ifndef _GL_UTIMENS_INLINE
31# define _GL_UTIMENS_INLINE _GL_INLINE 34# define _GL_UTIMENS_INLINE _GL_INLINE