diff options
| author | Paul Eggert | 2017-11-02 13:18:16 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-11-02 13:21:33 -0700 |
| commit | 04bc1410c26884bfed9fd7ba7376491023df03fc (patch) | |
| tree | b3db4ad7a884f5796c0bd0e147bd46aee8577a1f /lib | |
| parent | 6b08ad5263bc063c79666ffe2bd5ed9ab77a00a0 (diff) | |
| download | emacs-04bc1410c26884bfed9fd7ba7376491023df03fc.tar.gz emacs-04bc1410c26884bfed9fd7ba7376491023df03fc.zip | |
Merge from Gnulib
This incorporates:
2017-10-29 timespec: prefer ‘assume’ to ‘assure’
2017-10-27 timespec.h: use "assure" to avoid a spurious warning
2017-10-09 getopt-posix: Fix build failure if ac_cv_header_getopt_h=no
* build-aux/config.guess, build-aux/config.sub:
* lib/timespec.h, lib/unistd.in.h:
Copy from Gnulib.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/timespec.h | 22 | ||||
| -rw-r--r-- | lib/unistd.in.h | 5 |
2 files changed, 17 insertions, 10 deletions
diff --git a/lib/timespec.h b/lib/timespec.h index 3831301578e..cc34067374f 100644 --- a/lib/timespec.h +++ b/lib/timespec.h | |||
| @@ -33,6 +33,8 @@ _GL_INLINE_HEADER_BEGIN | |||
| 33 | extern "C" { | 33 | extern "C" { |
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | #include "verify.h" | ||
| 37 | |||
| 36 | /* Resolution of timespec timestamps (in units per second), and log | 38 | /* Resolution of timespec timestamps (in units per second), and log |
| 37 | base 10 of the resolution. */ | 39 | base 10 of the resolution. */ |
| 38 | 40 | ||
| @@ -67,23 +69,29 @@ make_timespec (time_t s, long int ns) | |||
| 67 | any platform of interest to the GNU project, since all such | 69 | any platform of interest to the GNU project, since all such |
| 68 | platforms have 32-bit int or wider. | 70 | platforms have 32-bit int or wider. |
| 69 | 71 | ||
| 70 | Replacing "(int) (a.tv_nsec - b.tv_nsec)" with something like | 72 | Replacing "a.tv_nsec - b.tv_nsec" with something like |
| 71 | "a.tv_nsec < b.tv_nsec ? -1 : a.tv_nsec > b.tv_nsec" would cause | 73 | "a.tv_nsec < b.tv_nsec ? -1 : a.tv_nsec > b.tv_nsec" would cause |
| 72 | this function to work in some cases where the above assumption is | 74 | this function to work in some cases where the above assumption is |
| 73 | violated, but not in all cases (e.g., a.tv_sec==1, a.tv_nsec==-2, | 75 | violated, but not in all cases (e.g., a.tv_sec==1, a.tv_nsec==-2, |
| 74 | b.tv_sec==0, b.tv_nsec==999999999) and is arguably not worth the | 76 | b.tv_sec==0, b.tv_nsec==999999999) and is arguably not worth the |
| 75 | extra instructions. Using a subtraction has the advantage of | 77 | extra instructions. Using a subtraction has the advantage of |
| 76 | detecting some invalid cases on platforms that detect integer | 78 | detecting some invalid cases on platforms that detect integer |
| 77 | overflow. | 79 | overflow. */ |
| 78 | |||
| 79 | The (int) cast avoids a gcc -Wconversion warning. */ | ||
| 80 | 80 | ||
| 81 | _GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE | 81 | _GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE |
| 82 | timespec_cmp (struct timespec a, struct timespec b) | 82 | timespec_cmp (struct timespec a, struct timespec b) |
| 83 | { | 83 | { |
| 84 | return (a.tv_sec < b.tv_sec ? -1 | 84 | if (a.tv_sec < b.tv_sec) |
| 85 | : a.tv_sec > b.tv_sec ? 1 | 85 | return -1; |
| 86 | : (int) (a.tv_nsec - b.tv_nsec)); | 86 | if (a.tv_sec > b.tv_sec) |
| 87 | return 1; | ||
| 88 | |||
| 89 | /* Pacify gcc -Wstrict-overflow (bleeding-edge circa 2017-10-02). See: | ||
| 90 | http://lists.gnu.org/archive/html/bug-gnulib/2017-10/msg00006.html */ | ||
| 91 | assume (-1 <= a.tv_nsec && a.tv_nsec <= 2 * TIMESPEC_RESOLUTION); | ||
| 92 | assume (-1 <= b.tv_nsec && b.tv_nsec <= 2 * TIMESPEC_RESOLUTION); | ||
| 93 | |||
| 94 | return a.tv_nsec - b.tv_nsec; | ||
| 87 | } | 95 | } |
| 88 | 96 | ||
| 89 | /* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be | 97 | /* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be |
diff --git a/lib/unistd.in.h b/lib/unistd.in.h index c1dd07ff8cd..ca8090a3526 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h | |||
| @@ -134,9 +134,8 @@ | |||
| 134 | /* The definition of _GL_WARN_ON_USE is copied here. */ | 134 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
| 135 | 135 | ||
| 136 | 136 | ||
| 137 | /* Get getopt(), optarg, optind, opterr, optopt. | 137 | /* Get getopt(), optarg, optind, opterr, optopt. */ |
| 138 | But avoid namespace pollution on glibc systems. */ | 138 | #if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT |
| 139 | #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT | ||
| 140 | # include <getopt-cdefs.h> | 139 | # include <getopt-cdefs.h> |
| 141 | # include <getopt-pfx-core.h> | 140 | # include <getopt-pfx-core.h> |
| 142 | #endif | 141 | #endif |