summaryrefslogtreecommitdiff
path: root/lib/strtol.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-05-01 18:36:38 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2016-05-01 18:37:01 -0700
commit3707f609cb8017371610a5e2233bd8478416217c (patch)
treefc9ecf2d9754bf95cc33bd9319871d5ebd866fa1 /lib/strtol.c
parent13f4efb0fd5573255c694607552532788ba31c95 (diff)
downloademacs-3707f609cb8017371610a5e2233bd8478416217c.tar.gz
Sync from gnulib
This incorporates: 2016-05-01 mktime: port to stricter signed overflow checking 2016-05-01 mktime: speed up DEBUG_MKTIME benchmarks 2016-05-01 mktime: resurrect DEBUG_MKTIME testing 2016-05-01 mktime: simplify DEBUG_MKTIME 2016-05-01 Port mktime_internal offset to unsigned time_t 2016-04-27 xstrtol: prohibit monstrosities like "1bB" 2016-04-13 mktime: improve integer overflow checking 2016-04-13 intprops: check two's complement assumption 2016-04-13 intprops, mktime, strtol: assume two's complement * lib/intprops.h, lib/mktime-internal.h, lib/mktime.c: * lib/strtol.c, lib/timegm.c, m4/mktime.m4, m4/std-gnu11.m4: Copy from gnulib.
Diffstat (limited to 'lib/strtol.c')
-rw-r--r--lib/strtol.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/lib/strtol.c b/lib/strtol.c
index b0215fce76b..6ef8a9624c9 100644
--- a/lib/strtol.c
+++ b/lib/strtol.c
@@ -121,30 +121,19 @@
/* The extra casts in the following macros work around compiler bugs,
e.g., in Cray C 5.0.3.0. */
-/* True if negative values of the signed integer type T use two's
- complement, ones' complement, or signed magnitude representation,
- respectively. Much GNU code assumes two's complement, but some
- people like to be portable to all possible C hosts. */
-# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
-# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
-# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
-
/* True if the arithmetic type T is signed. */
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The maximum and minimum values for the integer type T. These
- macros have undefined behavior if T is signed and has padding bits.
- If this is a problem for you, please let us know how to fix it for
- your host. */
-# define TYPE_MINIMUM(t) \
- ((t) (! TYPE_SIGNED (t) \
- ? (t) 0 \
- : TYPE_SIGNED_MAGNITUDE (t) \
- ? ~ (t) 0 \
- : ~ TYPE_MAXIMUM (t)))
-# define TYPE_MAXIMUM(t) \
- ((t) (! TYPE_SIGNED (t) \
- ? (t) -1 \
+/* Minimum and maximum values for integer types.
+ These macros have undefined behavior for signed types that either
+ have padding bits or do not use two's complement. If this is a
+ problem for you, please let us know how to fix it for your host. */
+
+/* The maximum and minimum values for the integer type T. */
+# define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
+# define TYPE_MAXIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) -1 \
: ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
# ifndef ULLONG_MAX