summaryrefslogtreecommitdiff
path: root/lib/cdefs.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-01-08 11:44:19 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2021-01-08 12:02:03 -0800
commit921d2ea19b5eb70293bf110070f04064fd5c9193 (patch)
tree107c6c0c56355ac3878f09ec3e124c0d97ffb937 /lib/cdefs.h
parentbdae9a5d4b2cedfaef23f8c55982ba5432dd69e3 (diff)
downloadgnulib-921d2ea19b5eb70293bf110070f04064fd5c9193.tar.gz
dynarray: new module
* config/srclist.txt: Mention the new files. * lib/cdefs.h (__attribute_maybe_unused__): New macro, like Gnulib’s _GL_ATTRIBUTE_MAYBE_UNUSED but with glibc naming conventions. * lib/libc-config.h: Use it instead of __glibc_likely. * lib/dynarray.h, modules/dynarray: New files. * lib/malloc/dynarray-skeleton.c, lib/malloc/dynarray.h: * lib/malloc/dynarray_at_failure.c: * lib/malloc/dynarray_emplace_enlarge.c: * lib/malloc/dynarray_finalize.c, lib/malloc/dynarray_resize.c: * lib/malloc/dynarray_resize_clear.c, modules/dynarray: New files, from glibc with the following changes needed for portability to compilers that are not recent-enough GCC. * lib/malloc/dynarray_at_failure.c: Include stdlib.h, for abort. (__libc_dynarray_at_failure) [!_LIBC]: Simply abort. * lib/malloc/dynarray_emplace_enlarge.c: * lib/malloc/dynarray_resize.c: Include intprops.h, and use INT_MULTIPLY_WRAPV instead of __builtin_mul_overflow. * lib/malloc/dynarray.h (__libc_dynarray_at_failure): Use _Noreturn instead of __attribute__ ((noreturn)). * lib/malloc/dynarray_resize_clear.c: Do not include stdlib.h; it’s not needed. (__libc_dynarray_resize_clear): Do not do arithmetic on void *. * lib/malloc/dynarray-skeleton.c (struct DYNARRAY_STRUCT): Do not use anonymous unions, as they are not in C99. All uses changed. Use __nonnull (X) instead of __attribute__ ((nonnull X)), and __attribute_maybe_unused__ instead of __attribute__ ((unused)).
Diffstat (limited to 'lib/cdefs.h')
-rw-r--r--lib/cdefs.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/cdefs.h b/lib/cdefs.h
index c4769aa70f..a22ae6db26 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -257,6 +257,14 @@
# define __attribute_const__ /* Ignore */
#endif
+#if defined __STDC_VERSION__ && 201710L < __STDC_VERSION__
+# define __attribute_maybe_unused__ [[__maybe_unused__]]
+#elif __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
+# define __attribute_maybe_unused__ __attribute__ ((__unused__))
+#else
+# define __attribute_maybe_unused__ /* Ignore */
+#endif
+
/* At some point during the gcc 3.1 development the `used' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */