aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2019-08-17 03:27:58 -0700
committerPaul Eggert2019-08-17 03:29:07 -0700
commit9e2ac2559ab44767a56add8ff6e0993325f31971 (patch)
treed69c948c41fb4593addf9f21a33f4d656a335991 /lib
parentc863170f0c0876b1f0f6740b9bfd25a9d9c87e20 (diff)
downloademacs-9e2ac2559ab44767a56add8ff6e0993325f31971.tar.gz
emacs-9e2ac2559ab44767a56add8ff6e0993325f31971.zip
Update from Gnulib
This incorporates: 2019-08-17 intprops: port to Oracle Developer Studio 12.6 2019-08-14 intprops: support uchar, ushort _WRAPV dests * lib/intprops.h: Copy from Gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/intprops.h57
1 files changed, 34 insertions, 23 deletions
diff --git a/lib/intprops.h b/lib/intprops.h
index d1785ac6f16..fe67c1f305f 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -311,10 +311,9 @@
311 arguments should not have side effects. 311 arguments should not have side effects.
312 312
313 The WRAPV macros are not constant expressions. They support only 313 The WRAPV macros are not constant expressions. They support only
314 +, binary -, and *. The result type must be either signed, or an 314 +, binary -, and *. Because the WRAPV macros convert the result,
315 unsigned type that is 'unsigned int' or wider. Because the WRAPV 315 they report overflow in different circumstances than the OVERFLOW
316 macros convert the result, the report overflow in different 316 macros do.
317 circumstances than the OVERFLOW macros do.
318 317
319 These macros are tuned for their last input argument being a constant. 318 These macros are tuned for their last input argument being a constant.
320 319
@@ -417,29 +416,41 @@
417 unsigned long int, 0, ULONG_MAX), \ 416 unsigned long int, 0, ULONG_MAX), \
418 long long int: \ 417 long long int: \
419 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ 418 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
420 long long int, LLONG_MIN, LLONG_MAX), 419 long long int, LLONG_MIN, LLONG_MAX), \
421 unsigned long long int: \ 420 unsigned long long int: \
422 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ 421 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
423 unsigned long long int, ULLONG_MIN, ULLONG_MAX))) 422 unsigned long long int, 0, ULLONG_MAX)))
424#else 423#else
425/* This fallback implementation uses _GL_SIGNED_TYPE_OR_EXPR, and so 424/* Store the low-order bits of A <op> B into *R, where OP specifies
426 may guess wrong on some non-GNU pre-C11 compilers when the type of 425 the operation and OVERFLOW the overflow predicate. If *R is
427 *R is unsigned char or unsigned short. This is why the 426 signed, its type is ST with bounds SMIN..SMAX; otherwise its type
428 documentation for INT_ADD_WRAPV says that the result type, if 427 is UT with bounds U..UMAX. ST and UT are narrower than int.
429 unsigned, should be unsigned int or wider. */ 428 Return 1 if the result overflows. See above for restrictions. */
429# if _GL_HAVE___TYPEOF__
430# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
431 (TYPE_SIGNED (__typeof__ (*(r))) \
432 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \
433 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax))
434# else
435# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
436 (overflow (a, b, smin, smax) \
437 ? (overflow (a, b, 0, umax) \
438 ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \
439 : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \
440 : (overflow (a, b, 0, umax) \
441 ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \
442 : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0)))
443# endif
444
430# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ 445# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
431 (sizeof *(r) == sizeof (signed char) \ 446 (sizeof *(r) == sizeof (signed char) \
432 ? (_GL_SIGNED_TYPE_OR_EXPR (*(r)) \ 447 ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
433 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ 448 signed char, SCHAR_MIN, SCHAR_MAX, \
434 signed char, SCHAR_MIN, SCHAR_MAX) \ 449 unsigned char, UCHAR_MAX) \
435 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
436 unsigned char, 0, UCHAR_MAX)) \
437 : sizeof *(r) == sizeof (short int) \ 450 : sizeof *(r) == sizeof (short int) \
438 ? (_GL_SIGNED_TYPE_OR_EXPR (*(r)) \ 451 ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
439 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ 452 short int, SHRT_MIN, SHRT_MAX, \
440 short int, SHRT_MIN, SHRT_MAX) \ 453 unsigned short int, USHRT_MAX) \
441 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
442 unsigned short int, 0, USHRT_MAX)) \
443 : sizeof *(r) == sizeof (int) \ 454 : sizeof *(r) == sizeof (int) \
444 ? (EXPR_SIGNED (*(r)) \ 455 ? (EXPR_SIGNED (*(r)) \
445 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ 456 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
@@ -541,8 +552,8 @@
541 <= -1 - (a))) \ 552 <= -1 - (a))) \
542 : INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \ 553 : INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \
543 ? (EXPR_SIGNED (a) \ 554 ? (EXPR_SIGNED (a) \
544 ? 0 < (a) + (tmin) \ 555 ? 0 < (a) + (tmin) \
545 : 0 < (a) && -1 - (tmin) < (a) - 1) \ 556 : 0 < (a) && -1 - (tmin) < (a) - 1) \
546 : (tmin) / (b) < (a)) \ 557 : (tmin) / (b) < (a)) \
547 : (b) == 0 \ 558 : (b) == 0 \
548 ? 0 \ 559 ? 0 \