aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2015-11-10 12:42:06 -0800
committerPaul Eggert2015-11-10 12:42:32 -0800
commit6c16c9a649ab5a5ea4bec12345fd369752da5dc0 (patch)
tree391b45de20dad761581a15b7b8fa4732c9387921 /lib
parentc92dbd6d0c234ff993acb0a095c024593bc185c8 (diff)
downloademacs-6c16c9a649ab5a5ea4bec12345fd369752da5dc0.tar.gz
emacs-6c16c9a649ab5a5ea4bec12345fd369752da5dc0.zip
Merge from gnulib
This incorporates: 2015-11-10 intprops: new public macro EXPR_SIGNED 2015-11-10 intprops: fix typo in clang port * lib/intprops.h: Copy from gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/intprops.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/intprops.h b/lib/intprops.h
index c55c4db1034..8fff86d4371 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -22,8 +22,7 @@
22 22
23#include <limits.h> 23#include <limits.h>
24 24
25/* Return an integer value, converted to the same type as the integer 25/* Return a value with the common real type of E and V and the value of V. */
26 expression E after integer type promotion. V is the unconverted value. */
27#define _GL_INT_CONVERT(e, v) (0 * (e) + (v)) 26#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
28 27
29/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see 28/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
@@ -48,12 +47,12 @@
48/* True if the signed integer expression E uses two's complement. */ 47/* True if the signed integer expression E uses two's complement. */
49#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1) 48#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1)
50 49
51/* True if the arithmetic type T is signed. */ 50/* True if the real type T is signed. */
52#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) 51#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
53 52
54/* Return 1 if the integer expression E, after integer promotion, has 53/* Return 1 if the real expression E, after promotion, has a
55 a signed type. */ 54 signed or floating type. */
56#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) 55#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
57 56
58 57
59/* Minimum and maximum values for integer types and expressions. These 58/* Minimum and maximum values for integer types and expressions. These
@@ -76,11 +75,11 @@
76/* The maximum and minimum values for the type of the expression E, 75/* The maximum and minimum values for the type of the expression E,
77 after integer promotion. E should not have side effects. */ 76 after integer promotion. E should not have side effects. */
78#define _GL_INT_MINIMUM(e) \ 77#define _GL_INT_MINIMUM(e) \
79 (_GL_INT_SIGNED (e) \ 78 (EXPR_SIGNED (e) \
80 ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \ 79 ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \
81 : _GL_INT_CONVERT (e, 0)) 80 : _GL_INT_CONVERT (e, 0))
82#define _GL_INT_MAXIMUM(e) \ 81#define _GL_INT_MAXIMUM(e) \
83 (_GL_INT_SIGNED (e) \ 82 (EXPR_SIGNED (e) \
84 ? _GL_SIGNED_INT_MAXIMUM (e) \ 83 ? _GL_SIGNED_INT_MAXIMUM (e) \
85 : _GL_INT_NEGATE_CONVERT (e, 1)) 84 : _GL_INT_NEGATE_CONVERT (e, 1))
86#define _GL_SIGNED_INT_MAXIMUM(e) \ 85#define _GL_SIGNED_INT_MAXIMUM(e) \
@@ -354,7 +353,7 @@
354/* Store A <op> B into *R, where OP specifies the operation. 353/* Store A <op> B into *R, where OP specifies the operation.
355 BUILTIN is the builtin operation, and OVERFLOW the overflow predicate. 354 BUILTIN is the builtin operation, and OVERFLOW the overflow predicate.
356 See above for restrictions. */ 355 See above for restrictions. */
357#if 5 <= __GNUC__ || __has_builtin (__builtin_add_oveflow) 356#if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow)
358# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r) 357# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
359#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS 358#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
360# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ 359# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
@@ -411,7 +410,7 @@
411 : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax)) 410 : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax))
412#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \ 411#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \
413 ((overflow (a, b) \ 412 ((overflow (a, b) \
414 || (_GL_INT_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \ 413 || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
415 || (tmax) < ((a) op (b))) \ 414 || (tmax) < ((a) op (b))) \
416 ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 1) \ 415 ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 1) \
417 : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 0)) 416 : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 0))