From: Paul Eggert Date: Thu, 5 May 2022 21:34:23 +0000 (-0700) Subject: cdefs: merge from glibc X-Git-Tag: v1.0~2299 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=7a6346a77c0493b990e326db14a6bdbe804a0e7e;p=gnulib.git cdefs: merge from glibc * lib/cdefs.h (__glibc_safe_or_unknown_len): Use glibc’s newer version. --- diff --git a/ChangeLog b/ChangeLog index 02be5e2317..f1a154027a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2022-05-05 Paul Eggert + + cdefs: merge from glibc + * lib/cdefs.h (__glibc_safe_or_unknown_len): + Use glibc’s newer version. + 2022-05-02 Paul Eggert gettime-res: help the compiler diff --git a/lib/cdefs.h b/lib/cdefs.h index cb2514504f..7b8ed5b344 100644 --- a/lib/cdefs.h +++ b/lib/cdefs.h @@ -164,13 +164,13 @@ || (__builtin_constant_p (__l) && (__l) > 0)) /* Length is known to be safe at compile time if the __L * __S <= __OBJSZ - condition can be folded to a constant and if it is true. The -1 check is - redundant because since it implies that __glibc_safe_len_cond is true. */ + condition can be folded to a constant and if it is true, or unknown (-1) */ #define __glibc_safe_or_unknown_len(__l, __s, __osz) \ - (__glibc_unsigned_or_positive (__l) \ - && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ - __s, __osz)) \ - && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz)) + ((__osz) == (__SIZE_TYPE__) -1 \ + || (__glibc_unsigned_or_positive (__l) \ + && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ + (__s), (__osz))) \ + && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz)))) /* Conversely, we know at compile time that the length is unsafe if the __L * __S <= __OBJSZ condition can be folded to a constant and if it is