diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2021-09-21 07:47:45 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2021-09-21 08:00:44 -0700 |
commit | 0b5ca7c3e551e5502f3be3b06453324fe8604e82 (patch) | |
tree | 0c46027d9aee6c5d533cabb0c3fcb7895197d178 /include/intprops.h | |
parent | f3e664563361dc17530113b3205998d1f19dc4d9 (diff) | |
download | glibc-0b5ca7c3e551e5502f3be3b06453324fe8604e82.zip glibc-0b5ca7c3e551e5502f3be3b06453324fe8604e82.tar.gz glibc-0b5ca7c3e551e5502f3be3b06453324fe8604e82.tar.bz2 |
regex: copy back from Gnulib
Copy regex-related files back from Gnulib, to fix a problem with
static checking of regex calls noted by Martin Sebor. This merges the
following changes:
* New macro __attribute_nonnull__ in misc/sys/cdefs.h, for use later
when copying other files back from Gnulib.
* Use __GNULIB_CDEFS instead of __GLIBC__ when deciding
whether to include bits/wordsize.h etc.
* Avoid duplicate entries in epsilon closure table.
* New regex.h macro _REGEX_NELTS to let regexec say that its pmatch
arg should contain nmatch elts. Use that for regexec, instead of
__attr_access (which is incorrect).
* New regex.h macro _Attr_access_ which is like __attr_access except
portable to non-glibc platforms.
* Add some DEBUG_ASSERTs to pacify gcc -fanalyzer and to catch
recently-fixed performance bugs if they recur.
* Add Gnulib-specific stuff to port the dynarray- and lock-using parts
of regex code to non-glibc platforms.
* Fix glibc bug 11053.
* Avoid some undefined behavior when popping an empty fail stack.
Diffstat (limited to 'include/intprops.h')
-rw-r--r-- | include/intprops.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/include/intprops.h b/include/intprops.h index 2b6e5e9..3fe64e8 100644 --- a/include/intprops.h +++ b/include/intprops.h @@ -132,7 +132,8 @@ operators might not yield numerically correct answers due to arithmetic overflow. They do not rely on undefined or implementation-defined behavior. Their implementations are simple - and straightforward, but they are a bit harder to use than the + and straightforward, but they are harder to use and may be less + efficient than the INT_<op>_WRAPV, INT_<op>_OK, and INT_<op>_OVERFLOW macros described below. Example usage: @@ -157,6 +158,9 @@ must have minimum value MIN and maximum MAX. Unsigned types should use a zero MIN of the proper type. + Because all arguments are subject to integer promotions, these + macros typically do not work on types narrower than 'int'. + These macros are tuned for constant MIN and MAX. For commutative operations such as A + B, they are also tuned for constant B. */ @@ -338,9 +342,15 @@ arguments should not have side effects. The WRAPV macros are not constant expressions. They support only - +, binary -, and *. Because the WRAPV macros convert the result, - they report overflow in different circumstances than the OVERFLOW - macros do. + +, binary -, and *. + + Because the WRAPV macros convert the result, they report overflow + in different circumstances than the OVERFLOW macros do. For + example, in the typical case with 16-bit 'short' and 32-bit 'int', + if A, B and R are all of type 'short' then INT_ADD_OVERFLOW (A, B) + returns false because the addition cannot overflow after A and B + are converted to 'int', whereas INT_ADD_WRAPV (A, B, &R) returns + true or false depending on whether the sum fits into 'short'. These macros are tuned for their last input argument being a constant. |