X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/cbd447e1cdbbebcd2a04144194138bb7936dea9d..1650d7102ae8ea943e4197b7d91198640f0e0ff6:/lib/strtol.c diff --git a/lib/strtol.c b/lib/strtol.c index 1bc143985d..6ef8a9624c 100644 --- a/lib/strtol.c +++ b/lib/strtol.c @@ -1,6 +1,6 @@ /* Convert string representation of a number into an integer value. - Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2015 Free Software + Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2016 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU 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