summaryrefslogtreecommitdiffstats
path: root/gl/cdefs.h
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2024-11-06 08:24:23 (GMT)
committerGitHub <noreply@github.com>2024-11-06 08:24:23 (GMT)
commit9b4df9e50837cc837e113053ba12ee6967d5e6c2 (patch)
treebf989e771579f835bcb49c074637a8e224bcecbc /gl/cdefs.h
parent94150ae347beb25ac369d5773834ceef7f3736d3 (diff)
parent5be04ec2ceb1df77afbca4fcbf9e92a712612d6f (diff)
downloadmonitoring-plugins-9b4df9e50837cc837e113053ba12ee6967d5e6c2.tar.gz
Merge pull request #2037 from RincewindsHat/update/gnulib-1.0
Sync with the latest Gnulib code (d4ec02b3cc) (gnulib v1.0)
Diffstat (limited to 'gl/cdefs.h')
-rw-r--r--gl/cdefs.h46
1 files changed, 27 insertions, 19 deletions
diff --git a/gl/cdefs.h b/gl/cdefs.h
index 09a3d19..d38382a 100644
--- a/gl/cdefs.h
+++ b/gl/cdefs.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2023 Free Software Foundation, Inc. 1/* Copyright (C) 1992-2024 Free Software Foundation, Inc.
2 Copyright The GNU Toolchain Authors. 2 Copyright The GNU Toolchain Authors.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
@@ -42,8 +42,8 @@
42#if (defined __has_attribute \ 42#if (defined __has_attribute \
43 && (!defined __clang_minor__ \ 43 && (!defined __clang_minor__ \
44 || (defined __apple_build_version__ \ 44 || (defined __apple_build_version__ \
45 ? 6000000 <= __apple_build_version__ \ 45 ? 7000000 <= __apple_build_version__ \
46 : 3 < __clang_major__ + (5 <= __clang_minor__)))) 46 : 5 <= __clang_major__)))
47# define __glibc_has_attribute(attr) __has_attribute (attr) 47# define __glibc_has_attribute(attr) __has_attribute (attr)
48#else 48#else
49# define __glibc_has_attribute(attr) 0 49# define __glibc_has_attribute(attr) 0
@@ -140,32 +140,37 @@
140#endif 140#endif
141 141
142 142
143/* Gnulib avoids these definitions, as they don't work on non-glibc platforms.
144 In particular, __bos and __bos0 are defined differently in the Android libc.
145 */
146#ifndef __GNULIB_CDEFS
147
143/* Fortify support. */ 148/* Fortify support. */
144#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) 149# define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
145#define __bos0(ptr) __builtin_object_size (ptr, 0) 150# define __bos0(ptr) __builtin_object_size (ptr, 0)
146 151
147/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */ 152/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
148#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \ 153# if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
149 || __GNUC_PREREQ (12, 0)) 154 || __GNUC_PREREQ (12, 0))
150# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0) 155# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
151# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1) 156# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
152#else 157# else
153# define __glibc_objsize0(__o) __bos0 (__o) 158# define __glibc_objsize0(__o) __bos0 (__o)
154# define __glibc_objsize(__o) __bos (__o) 159# define __glibc_objsize(__o) __bos (__o)
155#endif 160# endif
156 161
157/* Compile time conditions to choose between the regular, _chk and _chk_warn 162/* Compile time conditions to choose between the regular, _chk and _chk_warn
158 variants. These conditions should get evaluated to constant and optimized 163 variants. These conditions should get evaluated to constant and optimized
159 away. */ 164 away. */
160 165
161#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s)) 166# define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
162#define __glibc_unsigned_or_positive(__l) \ 167# define __glibc_unsigned_or_positive(__l) \
163 ((__typeof (__l)) 0 < (__typeof (__l)) -1 \ 168 ((__typeof (__l)) 0 < (__typeof (__l)) -1 \
164 || (__builtin_constant_p (__l) && (__l) > 0)) 169 || (__builtin_constant_p (__l) && (__l) > 0))
165 170
166/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ 171/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
167 condition can be folded to a constant and if it is true, or unknown (-1) */ 172 condition can be folded to a constant and if it is true, or unknown (-1) */
168#define __glibc_safe_or_unknown_len(__l, __s, __osz) \ 173# define __glibc_safe_or_unknown_len(__l, __s, __osz) \
169 ((__osz) == (__SIZE_TYPE__) -1 \ 174 ((__osz) == (__SIZE_TYPE__) -1 \
170 || (__glibc_unsigned_or_positive (__l) \ 175 || (__glibc_unsigned_or_positive (__l) \
171 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ 176 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
@@ -175,7 +180,7 @@
175/* Conversely, we know at compile time that the length is unsafe if the 180/* Conversely, we know at compile time that the length is unsafe if the
176 __L * __S <= __OBJSZ condition can be folded to a constant and if it is 181 __L * __S <= __OBJSZ condition can be folded to a constant and if it is
177 false. */ 182 false. */
178#define __glibc_unsafe_len(__l, __s, __osz) \ 183# define __glibc_unsafe_len(__l, __s, __osz) \
179 (__glibc_unsigned_or_positive (__l) \ 184 (__glibc_unsigned_or_positive (__l) \
180 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ 185 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
181 __s, __osz)) \ 186 __s, __osz)) \
@@ -184,7 +189,7 @@
184/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be 189/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
185 declared. */ 190 declared. */
186 191
187#define __glibc_fortify(f, __l, __s, __osz, ...) \ 192# define __glibc_fortify(f, __l, __s, __osz, ...) \
188 (__glibc_safe_or_unknown_len (__l, __s, __osz) \ 193 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
189 ? __ ## f ## _alias (__VA_ARGS__) \ 194 ? __ ## f ## _alias (__VA_ARGS__) \
190 : (__glibc_unsafe_len (__l, __s, __osz) \ 195 : (__glibc_unsafe_len (__l, __s, __osz) \
@@ -194,13 +199,16 @@
194/* Fortify function f, where object size argument passed to f is the number of 199/* Fortify function f, where object size argument passed to f is the number of
195 elements and not total size. */ 200 elements and not total size. */
196 201
197#define __glibc_fortify_n(f, __l, __s, __osz, ...) \ 202# define __glibc_fortify_n(f, __l, __s, __osz, ...) \
198 (__glibc_safe_or_unknown_len (__l, __s, __osz) \ 203 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
199 ? __ ## f ## _alias (__VA_ARGS__) \ 204 ? __ ## f ## _alias (__VA_ARGS__) \
200 : (__glibc_unsafe_len (__l, __s, __osz) \ 205 : (__glibc_unsafe_len (__l, __s, __osz) \
201 ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \ 206 ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
202 : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \ 207 : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
203 208
209#endif
210
211
204#if __GNUC_PREREQ (4,3) 212#if __GNUC_PREREQ (4,3)
205# define __warnattr(msg) __attribute__((__warning__ (msg))) 213# define __warnattr(msg) __attribute__((__warning__ (msg)))
206# define __errordecl(name, msg) \ 214# define __errordecl(name, msg) \