gnulib: upgrade to today's version
* tools/snippet/_Noreturn.h, tools/snippet/c++defs.h, tools/snippet/arg-nonnull.h, tools/snippet/warn-on-use.h: Rename to... * lib/_Noreturn.h, lib/c++defs.h, lib/arg-nonnull.h, lib/warn-on-use.h: ... these. * lib/filename.h, lib/getopt-cdefs.in.h, lib/getopt-core.h, lib/getopt-ext.h, lib/getopt-pfx-core.h, lib/getopt-pfx-ext.h, lib/localtime-buffer.c, lib/localtime-buffer.h, lib/malloca.c, lib/malloca.h, lib/malloca.valgrind, lib/stat-w32.c, lib/stat-w32.h, m4/eealloc.m4, m4/localtime-buffer.m4, m4/malloca.m4: New files. * lib/argp-help.c, lib/argp-parse.c, lib/error.c, lib/float.in.h, lib/getopt1.c, lib/getopt.c, lib/getopt.in.h, lib/getopt_int.h, lib/gettext.h, lib/gettimeofday.c, lib/intprops.h, lib/isatty.c, lib/limits.in.h, lib/localcharset.c, lib/Makefile.am, lib/mbrtowc.c, lib/mbsinit.c, lib/msvc-nothrow.c, lib/quotearg.c, lib/stat.c, lib/stdalign.in.h, lib/stdint.in.h, lib/string.in.h, lib/sys_stat.in.h, lib/sys_types.in.h, lib/tempname.c, lib/time.in.h, lib/unistd.in.h, lib/vasnprintf.c, lib/wchar.in.h, lib/wctype.in.h, lib/xalloc.h, lib/xalloc-oversized.h, m4/fcntl-o.m4, m4/float_h.m4, m4/getopt.m4, m4/gettimeofday.m4, m4/gnulib-common.m4, m4/gnulib-comp.m4, m4/include_next.m4, m4/largefile.m4, m4/lstat.m4, m4/mbrtowc.m4, m4/memchr.m4, m4/mkstemp.m4, m4/printf.m4, m4/sleep.m4, m4/stat.m4, m4/stdalign.m4, m4/stdint.m4, m4/strerror.m4, m4/string_h.m4, m4/sys_stat_h.m4, m4/sys_time_h.m4, m4/sys_types_h.m4, m4/time_h.m4, m4/unistd_h.m4, m4/wchar_h.m4, m4/wctype_h.m4, m4/wint_t.m4: Update.
This commit is contained in:
parent
aa8cf6ac92
commit
80d50c5665
81 changed files with 3458 additions and 1954 deletions
|
|
@ -21,7 +21,6 @@
|
|||
#define _GL_INTPROPS_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <verify.h>
|
||||
|
||||
/* Return a value with the common real type of E and V and the value of V. */
|
||||
#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
|
||||
|
|
@ -80,24 +79,7 @@
|
|||
/* This include file assumes that signed types are two's complement without
|
||||
padding bits; the above macros have undefined behavior otherwise.
|
||||
If this is a problem for you, please let us know how to fix it for your host.
|
||||
As a sanity check, test the assumption for some signed types that
|
||||
<limits.h> bounds. */
|
||||
verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
|
||||
verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
|
||||
verify (TYPE_MINIMUM (short int) == SHRT_MIN);
|
||||
verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
|
||||
verify (TYPE_MINIMUM (int) == INT_MIN);
|
||||
verify (TYPE_MAXIMUM (int) == INT_MAX);
|
||||
verify (TYPE_MINIMUM (long int) == LONG_MIN);
|
||||
verify (TYPE_MAXIMUM (long int) == LONG_MAX);
|
||||
#ifdef LLONG_MAX
|
||||
verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
|
||||
verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
|
||||
#endif
|
||||
/* Similarly, sanity-check one ISO/IEC TS 18661-1:2014 macro if defined. */
|
||||
#ifdef UINT_WIDTH
|
||||
verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
|
||||
#endif
|
||||
This assumption is tested by the intprops-tests module. */
|
||||
|
||||
/* Does the __typeof__ keyword work? This could be done by
|
||||
'configure', but for now it's easier to do it by hand. */
|
||||
|
|
@ -237,7 +219,11 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
|
|||
: (max) >> (b) < (a))
|
||||
|
||||
/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */
|
||||
#define _GL_HAS_BUILTIN_OVERFLOW (5 <= __GNUC__)
|
||||
#if 5 <= __GNUC__ && !defined __ICC
|
||||
# define _GL_HAS_BUILTIN_OVERFLOW 1
|
||||
#else
|
||||
# define _GL_HAS_BUILTIN_OVERFLOW 0
|
||||
#endif
|
||||
|
||||
/* True if __builtin_add_overflow_p (A, B, C) works. */
|
||||
#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
|
||||
|
|
@ -389,10 +375,10 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
|
|||
(_Generic \
|
||||
(*(r), \
|
||||
signed char: \
|
||||
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
|
||||
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
|
||||
signed char, SCHAR_MIN, SCHAR_MAX), \
|
||||
short int: \
|
||||
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
|
||||
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
|
||||
short int, SHRT_MIN, SHRT_MAX), \
|
||||
int: \
|
||||
_GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
|
||||
|
|
@ -406,10 +392,10 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
|
|||
#else
|
||||
# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
|
||||
(sizeof *(r) == sizeof (signed char) \
|
||||
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
|
||||
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
|
||||
signed char, SCHAR_MIN, SCHAR_MAX) \
|
||||
: sizeof *(r) == sizeof (short int) \
|
||||
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
|
||||
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
|
||||
short int, SHRT_MIN, SHRT_MAX) \
|
||||
: sizeof *(r) == sizeof (int) \
|
||||
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
|
||||
|
|
@ -431,9 +417,8 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
|
|||
|
||||
/* Store the low-order bits of A <op> B into *R, where the operation
|
||||
is given by OP. Use the unsigned type UT for calculation to avoid
|
||||
overflow problems. *R's type is T, with extremal values TMIN and
|
||||
TMAX. T must be a signed integer type. Return 1 if the result
|
||||
overflows. */
|
||||
overflow problems. *R's type is T, with extrema TMIN and TMAX.
|
||||
T must be a signed integer type. Return 1 if the result overflows. */
|
||||
#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
|
||||
(sizeof ((a) op (b)) < sizeof (t) \
|
||||
? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
|
||||
|
|
@ -442,17 +427,27 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
|
|||
((overflow (a, b) \
|
||||
|| (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
|
||||
|| (tmax) < ((a) op (b))) \
|
||||
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 1) \
|
||||
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 0))
|
||||
? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
|
||||
: (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
|
||||
|
||||
/* Return A <op> B, where the operation is given by OP. Use the
|
||||
unsigned type UT for calculation to avoid overflow problems.
|
||||
Convert the result to type T without overflow by subtracting TMIN
|
||||
from large values before converting, and adding it afterwards.
|
||||
Compilers can optimize all the operations except OP. */
|
||||
#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t, tmin, tmax) \
|
||||
(((ut) (a) op (ut) (b)) <= (tmax) \
|
||||
? (t) ((ut) (a) op (ut) (b)) \
|
||||
: ((t) (((ut) (a) op (ut) (b)) - (tmin)) + (tmin)))
|
||||
/* Return the low-order bits of A <op> B, where the operation is given
|
||||
by OP. Use the unsigned type UT for calculation to avoid undefined
|
||||
behavior on signed integer overflow, and convert the result to type T.
|
||||
UT is at least as wide as T and is no narrower than unsigned int,
|
||||
T is two's complement, and there is no padding or trap representations.
|
||||
Assume that converting UT to T yields the low-order bits, as is
|
||||
done in all known two's-complement C compilers. E.g., see:
|
||||
https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
|
||||
|
||||
According to the C standard, converting UT to T yields an
|
||||
implementation-defined result or signal for values outside T's
|
||||
range. However, code that works around this theoretical problem
|
||||
runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
|
||||
http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00049.html
|
||||
As the compiler bug is real, don't try to work around the
|
||||
theoretical problem. */
|
||||
|
||||
#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
|
||||
((t) ((ut) (a) op (ut) (b)))
|
||||
|
||||
#endif /* _GL_INTPROPS_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue