diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-11-02 21:02:12 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-11-02 21:02:12 -0700 |
commit | aa7542467238b06ed056054965ba444595b85453 (patch) | |
tree | 3071c15ff777ef5727ccd254d9ddbf513a06c0cc /lib | |
parent | 5fcfdf433d74e8ecb35f86fdc071ce11ca0b0364 (diff) | |
parent | a87ce5c4b41ca8146c764b1186a6162c069b1933 (diff) | |
download | emacs-aa7542467238b06ed056054965ba444595b85453.tar.gz |
Merge from origin/emacs-26
a87ce5c4b4 * src/lisp.h (GCALIGNED): Clarify comment (Bug#29040).
8a31e9993f ; etc/NEWS: Add cpp-message-min-time-interval. (Bug#28961)
ac0bb9a192 Improve the doc of eshell-cmpl-* custom variables (Bug#25069)
36400c7dc9 Fix mouse-scrollbar offset on GNUstep and old macOS (bug#2...
04bc1410c2 Merge from Gnulib
6b08ad5263 Fix alignment portability problems
a9f8706fa8 Fix completion of colon after CSS property (Bug#29056)
9031dec527 ; * src/alloc.c (sweep_symbols): Fix last change.
fdd3dcfa4e * src/alloc.c (sweep_symbols): Tweak last change
27964af438 In frame parameters documentation mention desktop saving/r...
1bd4e7c243 ; Fix typo in ChangeLog.3
4182a60d31 Don't have frameset save the 'client' parameter (Bug#29067)
9d31a97092 ; Spelling fixes
460a25f212 Handle generic variables in cl-defgeneric Edebug spec
dc0a25c2f9 Give a more sensible message if file-attributes fails (Bug...
8453423c7c Avoid wrong value from file-attributes on Linux kernel bef...
70621e2571 Fix customization of debugger-print-function (Bug#29077)
# Conflicts:
# etc/NEWS
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 extern "C" { #endif +#include "verify.h" + /* Resolution of timespec timestamps (in units per second), and log base 10 of the resolution. */ @@ -67,23 +69,29 @@ make_timespec (time_t s, long int ns) any platform of interest to the GNU project, since all such platforms have 32-bit int or wider. - Replacing "(int) (a.tv_nsec - b.tv_nsec)" with something like + Replacing "a.tv_nsec - b.tv_nsec" with something like "a.tv_nsec < b.tv_nsec ? -1 : a.tv_nsec > b.tv_nsec" would cause this function to work in some cases where the above assumption is violated, but not in all cases (e.g., a.tv_sec==1, a.tv_nsec==-2, b.tv_sec==0, b.tv_nsec==999999999) and is arguably not worth the extra instructions. Using a subtraction has the advantage of detecting some invalid cases on platforms that detect integer - overflow. - - The (int) cast avoids a gcc -Wconversion warning. */ + overflow. */ _GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE timespec_cmp (struct timespec a, struct timespec b) { - return (a.tv_sec < b.tv_sec ? -1 - : a.tv_sec > b.tv_sec ? 1 - : (int) (a.tv_nsec - b.tv_nsec)); + if (a.tv_sec < b.tv_sec) + return -1; + if (a.tv_sec > b.tv_sec) + return 1; + + /* Pacify gcc -Wstrict-overflow (bleeding-edge circa 2017-10-02). See: + http://lists.gnu.org/archive/html/bug-gnulib/2017-10/msg00006.html */ + assume (-1 <= a.tv_nsec && a.tv_nsec <= 2 * TIMESPEC_RESOLUTION); + assume (-1 <= b.tv_nsec && b.tv_nsec <= 2 * TIMESPEC_RESOLUTION); + + return a.tv_nsec - b.tv_nsec; } /* 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 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ -/* Get getopt(), optarg, optind, opterr, optopt. - But avoid namespace pollution on glibc systems. */ -#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT +/* Get getopt(), optarg, optind, opterr, optopt. */ +#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT # include <getopt-cdefs.h> # include <getopt-pfx-core.h> #endif |