diff options
| author | Paul Eggert | 2019-09-02 12:37:52 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-09-02 12:38:49 -0700 |
| commit | fda015e7b82a1ec3d1cb075799a67772744ce6c1 (patch) | |
| tree | fd24150923a0afb809cfcf063c454b3e1aacdf7a /lib | |
| parent | 7c37b17b3d6a9be06fa25b19f5eccbc72c52f71c (diff) | |
| download | emacs-fda015e7b82a1ec3d1cb075799a67772744ce6c1.tar.gz emacs-fda015e7b82a1ec3d1cb075799a67772744ce6c1.zip | |
Update from Gnulib
This incorporates:
2019-08-25 intprops.h, verify.h: port better to clang
2019-08-21 New strip-trailing-space option for srclist-update
* .gitattributes: Remove doc/misc/texinfo.tex special case,
which is no longer needed now that Gnulib trims blank-at-eol.
* build-aux/install-sh, doc/misc/texinfo.tex, lib/intprops.h:
* lib/regex_internal.c, lib/verify.h: Copy from Gnulib.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/intprops.h | 91 | ||||
| -rw-r--r-- | lib/regex_internal.c | 11 | ||||
| -rw-r--r-- | lib/verify.h | 28 |
3 files changed, 86 insertions, 44 deletions
diff --git a/lib/intprops.h b/lib/intprops.h index fe67c1f305f..36c6359a21f 100644 --- a/lib/intprops.h +++ b/lib/intprops.h | |||
| @@ -22,6 +22,18 @@ | |||
| 22 | 22 | ||
| 23 | #include <limits.h> | 23 | #include <limits.h> |
| 24 | 24 | ||
| 25 | /* If the compiler lacks __has_builtin, define it well enough for this | ||
| 26 | source file only. */ | ||
| 27 | #ifndef __has_builtin | ||
| 28 | # define __has_builtin(x) _GL_HAS_##x | ||
| 29 | # if 5 <= __GNUC__ && !defined __ICC | ||
| 30 | # define _GL_HAS___builtin_add_overflow 1 | ||
| 31 | # else | ||
| 32 | # define _GL_HAS___builtin_add_overflow 0 | ||
| 33 | # endif | ||
| 34 | # define _GL_TEMPDEF___has_builtin | ||
| 35 | #endif | ||
| 36 | |||
| 25 | /* Return a value with the common real type of E and V and the value of V. | 37 | /* Return a value with the common real type of E and V and the value of V. |
| 26 | Do not evaluate E. */ | 38 | Do not evaluate E. */ |
| 27 | #define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v)) | 39 | #define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v)) |
| @@ -220,14 +232,24 @@ | |||
| 220 | ? (a) < (min) >> (b) \ | 232 | ? (a) < (min) >> (b) \ |
| 221 | : (max) >> (b) < (a)) | 233 | : (max) >> (b) < (a)) |
| 222 | 234 | ||
| 223 | /* True if __builtin_add_overflow (A, B, P) works when P is non-null. */ | 235 | /* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow |
| 224 | #if 5 <= __GNUC__ && !defined __ICC | 236 | (A, B, P) work when P is non-null. */ |
| 225 | # define _GL_HAS_BUILTIN_OVERFLOW 1 | 237 | #if __has_builtin (__builtin_add_overflow) |
| 238 | # define _GL_HAS_BUILTIN_ADD_OVERFLOW 1 | ||
| 239 | #else | ||
| 240 | # define _GL_HAS_BUILTIN_ADD_OVERFLOW 0 | ||
| 241 | #endif | ||
| 242 | |||
| 243 | /* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ | ||
| 244 | #ifdef __clang__ | ||
| 245 | /* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */ | ||
| 246 | # define _GL_HAS_BUILTIN_MUL_OVERFLOW 0 | ||
| 226 | #else | 247 | #else |
| 227 | # define _GL_HAS_BUILTIN_OVERFLOW 0 | 248 | # define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW |
| 228 | #endif | 249 | #endif |
| 229 | 250 | ||
| 230 | /* True if __builtin_add_overflow_p (A, B, C) works. */ | 251 | /* True if __builtin_add_overflow_p (A, B, C) works, and similarly for |
| 252 | __builtin_mul_overflow_p and __builtin_mul_overflow_p. */ | ||
| 231 | #define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) | 253 | #define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) |
| 232 | 254 | ||
| 233 | /* The _GL*_OVERFLOW macros have the same restrictions as the | 255 | /* The _GL*_OVERFLOW macros have the same restrictions as the |
| @@ -351,29 +373,33 @@ | |||
| 351 | 373 | ||
| 352 | /* Store the low-order bits of A + B, A - B, A * B, respectively, into *R. | 374 | /* Store the low-order bits of A + B, A - B, A * B, respectively, into *R. |
| 353 | Return 1 if the result overflows. See above for restrictions. */ | 375 | Return 1 if the result overflows. See above for restrictions. */ |
| 354 | #define INT_ADD_WRAPV(a, b, r) \ | 376 | #if _GL_HAS_BUILTIN_ADD_OVERFLOW |
| 355 | _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, \ | 377 | # define INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r) |
| 356 | _GL_INT_ADD_RANGE_OVERFLOW) | 378 | # define INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r) |
| 357 | #define INT_SUBTRACT_WRAPV(a, b, r) \ | 379 | #else |
| 358 | _GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, \ | 380 | # define INT_ADD_WRAPV(a, b, r) \ |
| 359 | _GL_INT_SUBTRACT_RANGE_OVERFLOW) | 381 | _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW) |
| 360 | #define INT_MULTIPLY_WRAPV(a, b, r) \ | 382 | # define INT_SUBTRACT_WRAPV(a, b, r) \ |
| 361 | _GL_INT_OP_WRAPV (a, b, r, *, _GL_BUILTIN_MUL_OVERFLOW, \ | 383 | _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW) |
| 362 | _GL_INT_MULTIPLY_RANGE_OVERFLOW) | 384 | #endif |
| 363 | 385 | #if _GL_HAS_BUILTIN_MUL_OVERFLOW | |
| 364 | /* Like __builtin_mul_overflow, but work around GCC bug 91450. */ | 386 | /* Work around GCC bug 91450. */ |
| 365 | #define _GL_BUILTIN_MUL_OVERFLOW(a, b, r) \ | 387 | # define INT_MULTIPLY_WRAPV(a, b, r) \ |
| 366 | ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \ | 388 | ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \ |
| 367 | && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \ | 389 | && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \ |
| 368 | ? ((void) __builtin_mul_overflow (a, b, r), 1) \ | 390 | ? ((void) __builtin_mul_overflow (a, b, r), 1) \ |
| 369 | : __builtin_mul_overflow (a, b, r)) | 391 | : __builtin_mul_overflow (a, b, r)) |
| 392 | #else | ||
| 393 | # define INT_MULTIPLY_WRAPV(a, b, r) \ | ||
| 394 | _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) | ||
| 395 | #endif | ||
| 370 | 396 | ||
| 371 | /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: | 397 | /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: |
| 372 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 | 398 | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 |
| 373 | https://llvm.org/bugs/show_bug.cgi?id=25390 | 399 | https://llvm.org/bugs/show_bug.cgi?id=25390 |
| 374 | For now, assume all versions of GCC-like compilers generate bogus | 400 | For now, assume all versions of GCC-like compilers generate bogus |
| 375 | warnings for _Generic. This matters only for older compilers that | 401 | warnings for _Generic. This matters only for compilers that |
| 376 | lack __builtin_add_overflow. */ | 402 | lack relevant builtins. */ |
| 377 | #if __GNUC__ | 403 | #if __GNUC__ |
| 378 | # define _GL__GENERIC_BOGUS 1 | 404 | # define _GL__GENERIC_BOGUS 1 |
| 379 | #else | 405 | #else |
| @@ -381,13 +407,10 @@ | |||
| 381 | #endif | 407 | #endif |
| 382 | 408 | ||
| 383 | /* Store the low-order bits of A <op> B into *R, where OP specifies | 409 | /* Store the low-order bits of A <op> B into *R, where OP specifies |
| 384 | the operation. BUILTIN is the builtin operation, and OVERFLOW the | 410 | the operation and OVERFLOW the overflow predicate. Return 1 if the |
| 385 | overflow predicate. Return 1 if the result overflows. See above | 411 | result overflows. See above for restrictions. */ |
| 386 | for restrictions. */ | 412 | #if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS |
| 387 | #if _GL_HAS_BUILTIN_OVERFLOW | 413 | # define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \ |
| 388 | # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r) | ||
| 389 | #elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS | ||
| 390 | # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ | ||
| 391 | (_Generic \ | 414 | (_Generic \ |
| 392 | (*(r), \ | 415 | (*(r), \ |
| 393 | signed char: \ | 416 | signed char: \ |
| @@ -442,7 +465,7 @@ | |||
| 442 | : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0))) | 465 | : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0))) |
| 443 | # endif | 466 | # endif |
| 444 | 467 | ||
| 445 | # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \ | 468 | # define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \ |
| 446 | (sizeof *(r) == sizeof (signed char) \ | 469 | (sizeof *(r) == sizeof (signed char) \ |
| 447 | ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \ | 470 | ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \ |
| 448 | signed char, SCHAR_MIN, SCHAR_MAX, \ | 471 | signed char, SCHAR_MIN, SCHAR_MAX, \ |
| @@ -563,4 +586,10 @@ | |||
| 563 | : (tmin) / (a) < (b)) \ | 586 | : (tmin) / (a) < (b)) \ |
| 564 | : (tmax) / (b) < (a))) | 587 | : (tmax) / (b) < (a))) |
| 565 | 588 | ||
| 589 | #ifdef _GL_TEMPDEF___has_builtin | ||
| 590 | # undef __has_builtin | ||
| 591 | # undef _GL_HAS___builtin_add_overflow | ||
| 592 | # undef _GL_TEMPDEF___has_builtin | ||
| 593 | #endif | ||
| 594 | |||
| 566 | #endif /* _GL_INTPROPS_H */ | 595 | #endif /* _GL_INTPROPS_H */ |
diff --git a/lib/regex_internal.c b/lib/regex_internal.c index b592f06725c..0092cc2a468 100644 --- a/lib/regex_internal.c +++ b/lib/regex_internal.c | |||
| @@ -1311,7 +1311,6 @@ re_node_set_insert (re_node_set *set, Idx elem) | |||
| 1311 | first element separately to skip a check in the inner loop. */ | 1311 | first element separately to skip a check in the inner loop. */ |
| 1312 | if (elem < set->elems[0]) | 1312 | if (elem < set->elems[0]) |
| 1313 | { | 1313 | { |
| 1314 | idx = 0; | ||
| 1315 | for (idx = set->nelem; idx > 0; idx--) | 1314 | for (idx = set->nelem; idx > 0; idx--) |
| 1316 | set->elems[idx] = set->elems[idx - 1]; | 1315 | set->elems[idx] = set->elems[idx - 1]; |
| 1317 | } | 1316 | } |
| @@ -1716,15 +1715,19 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, | |||
| 1716 | { | 1715 | { |
| 1717 | if (newstate->entrance_nodes == &newstate->nodes) | 1716 | if (newstate->entrance_nodes == &newstate->nodes) |
| 1718 | { | 1717 | { |
| 1719 | newstate->entrance_nodes = re_malloc (re_node_set, 1); | 1718 | re_node_set *entrance_nodes = re_malloc (re_node_set, 1); |
| 1720 | if (__glibc_unlikely (newstate->entrance_nodes == NULL)) | 1719 | if (__glibc_unlikely (entrance_nodes == NULL)) |
| 1721 | { | 1720 | { |
| 1722 | free_state (newstate); | 1721 | free_state (newstate); |
| 1723 | return NULL; | 1722 | return NULL; |
| 1724 | } | 1723 | } |
| 1724 | newstate->entrance_nodes = entrance_nodes; | ||
| 1725 | if (re_node_set_init_copy (newstate->entrance_nodes, nodes) | 1725 | if (re_node_set_init_copy (newstate->entrance_nodes, nodes) |
| 1726 | != REG_NOERROR) | 1726 | != REG_NOERROR) |
| 1727 | return NULL; | 1727 | { |
| 1728 | free_state (newstate); | ||
| 1729 | return NULL; | ||
| 1730 | } | ||
| 1728 | nctx_nodes = 0; | 1731 | nctx_nodes = 0; |
| 1729 | newstate->has_constraint = 1; | 1732 | newstate->has_constraint = 1; |
| 1730 | } | 1733 | } |
diff --git a/lib/verify.h b/lib/verify.h index afdc1ad81f1..06e975ebf65 100644 --- a/lib/verify.h +++ b/lib/verify.h | |||
| @@ -56,6 +56,16 @@ | |||
| 56 | # undef _Static_assert | 56 | # undef _Static_assert |
| 57 | #endif | 57 | #endif |
| 58 | 58 | ||
| 59 | /* If the compiler lacks __has_builtin, define it well enough for this | ||
| 60 | source file only. */ | ||
| 61 | #ifndef __has_builtin | ||
| 62 | # define __has_builtin(x) _GL_HAS_##x | ||
| 63 | # define _GL_HAS___builtin_unreachable (4 < __GNUC__ + (5 <= __GNUC_MINOR__)) | ||
| 64 | # define _GL_HAS___builtin_trap \ | ||
| 65 | (3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))) | ||
| 66 | # define _GL_TEMPDEF___has_builtin | ||
| 67 | #endif | ||
| 68 | |||
| 59 | /* Each of these macros verifies that its argument R is nonzero. To | 69 | /* Each of these macros verifies that its argument R is nonzero. To |
| 60 | be portable, R should be an integer constant expression. Unlike | 70 | be portable, R should be an integer constant expression. Unlike |
| 61 | assert (R), there is no run-time overhead. | 71 | assert (R), there is no run-time overhead. |
| @@ -260,24 +270,17 @@ template <int w> | |||
| 260 | # define verify(R) _GL_VERIFY (R, "verify (" #R ")", -) | 270 | # define verify(R) _GL_VERIFY (R, "verify (" #R ")", -) |
| 261 | #endif | 271 | #endif |
| 262 | 272 | ||
| 263 | #ifndef __has_builtin | ||
| 264 | # define __has_builtin(x) 0 | ||
| 265 | #endif | ||
| 266 | |||
| 267 | /* Assume that R always holds. Behavior is undefined if R is false, | 273 | /* Assume that R always holds. Behavior is undefined if R is false, |
| 268 | fails to evaluate, or has side effects. Although assuming R can | 274 | fails to evaluate, or has side effects. Although assuming R can |
| 269 | help a compiler generate better code or diagnostics, performance | 275 | help a compiler generate better code or diagnostics, performance |
| 270 | can suffer if R uses hard-to-optimize features such as function | 276 | can suffer if R uses hard-to-optimize features such as function |
| 271 | calls not inlined by the compiler. */ | 277 | calls not inlined by the compiler. */ |
| 272 | 278 | ||
| 273 | #if (__has_builtin (__builtin_unreachable) \ | 279 | #if __has_builtin (__builtin_unreachable) |
| 274 | || 4 < __GNUC__ + (5 <= __GNUC_MINOR__)) | ||
| 275 | # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) | 280 | # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) |
| 276 | #elif 1200 <= _MSC_VER | 281 | #elif 1200 <= _MSC_VER |
| 277 | # define assume(R) __assume (R) | 282 | # define assume(R) __assume (R) |
| 278 | #elif ((defined GCC_LINT || defined lint) \ | 283 | #elif (defined GCC_LINT || defined lint) && __has_builtin (__builtin_trap) |
| 279 | && (__has_builtin (__builtin_trap) \ | ||
| 280 | || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)))) | ||
| 281 | /* Doing it this way helps various packages when configured with | 284 | /* Doing it this way helps various packages when configured with |
| 282 | --enable-gcc-warnings, which compiles with -Dlint. It's nicer | 285 | --enable-gcc-warnings, which compiles with -Dlint. It's nicer |
| 283 | when 'assume' silences warnings even with older GCCs. */ | 286 | when 'assume' silences warnings even with older GCCs. */ |
| @@ -287,6 +290,13 @@ template <int w> | |||
| 287 | # define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0) | 290 | # define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0) |
| 288 | #endif | 291 | #endif |
| 289 | 292 | ||
| 293 | #ifdef _GL_TEMPDEF___has_builtin | ||
| 294 | # undef __has_builtin | ||
| 295 | # undef _GL_HAS___builtin_unreachable | ||
| 296 | # undef _GL_HAS___builtin_trap | ||
| 297 | # undef _GL_TEMPDEF___has_builtin | ||
| 298 | #endif | ||
| 299 | |||
| 290 | /* @assert.h omit end@ */ | 300 | /* @assert.h omit end@ */ |
| 291 | 301 | ||
| 292 | #endif | 302 | #endif |