summaryrefslogtreecommitdiff
path: root/lib/cdefs.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix compilation errors with CC="clang -D_FORTIFY_SOURCE=2" on Android.Bruno Haible2023-01-291-16/+24
| | | | | | | | | | | Reported by Alexey Rochev <equeim@gmail.com> in <https://lists.gnu.org/archive/html/bug-gnu-libiconv/2023-01/msg00019.html>. * lib/cdefs.h (__bos, __bos0, __glibc_objsize0, __glibc_objsize, __glibc_safe_len_cond, __glibc_unsigned_or_positive, __glibc_safe_or_unknown_len, __glibc_unsafe_len, __glibc_fortify, __glibc_fortify_n): Don't define these macros in Gnulib. * lib/libc-config.h: Don't undefine these macros in Gnulib.
* maint: run 'make update-copyright'Simon Josefsson2023-01-011-1/+1
|
* cdefs: merge from glibcPaul Eggert2022-05-051-6/+6
| | | | | * lib/cdefs.h (__glibc_safe_or_unknown_len): Use glibc’s newer version.
* Port __has_attribute to Apple’s Clang renumberingPaul Eggert2022-02-251-1/+3
| | | | | | | | | Problem reported by Kirill A. Korinsky in: https://lists.gnu.org/r/bug-gnulib/2022-02/msg00034.html * config/srclist.txt: Comment out sys/cdefs.h for now. * lib/cdefs.h (__glibc_has_attribute): * m4/gnulib-common.m4 (gl_COMMON_BODY): Port to Apple’s renumbering of Clang versions.
* autoupdateKarl Berry2022-01-131-1/+2
|
* autoupdatePaul Eggert2022-01-011-1/+1
|
* autoupdateKarl Berry2021-12-161-1/+1
|
* autoupdateKarl Berry2021-10-211-0/+57
|
* autoupdateKarl Berry2021-10-201-0/+10
|
* regex: revert much of previous changePaul Eggert2021-08-261-9/+0
| | | | | Use a more-conservative change that syncs closer with glibc, and then merely marks regexec and __compat_regexec.
* regex: use C99-style array arg syntaxPaul Eggert2021-08-261-0/+9
| | | | | | | | | | | | | | | | | | | | This should help with some static checking. Derived from a suggestion by Martin Sebor in: https://sourceware.org/pipermail/libc-alpha/2021-August/130336.html This also ports recent and relevant Glibc changes to Gnulib and prepares to copy back. * lib/cdefs.h (__ARG_NELTS): New macro. * lib/regex.c: Ignore -Wvla for the whole file. * lib/regex.h (_ARG_NELTS_, _Attr_access_): New macros. Ignore -Wvla when declaring regexec. * lib/regex.h (re_compile_pattern, re_search, re_search_2) (re_match, re_match_2, regcomp, regerror): Use _Attr_access_ where that could help static checking. * lib/regexec.c (regexec, __compat_regexec, re_copy_regs) (re_search_internal, proceed_next_node, push_fail_stack) (pop_fail_stack, set_regs, update_regs): Use __ARG_NELTS for each array parameter whose size is another arg, but which might be null.
* dynarray: merge from glibcPaul Eggert2021-08-111-5/+28
| | | | | | | | | | | | | This also helps document glibc’s direction in using GCC’s memory-allocation checking. * lib/cdefs.h: Omit comments that glibc rejected. (__returns_nonnull, __attr_access_none, __attr_dealloc) (__attr_dealloc_free): New macros. * lib/libc-config.h: Undef the new macros that are defined unconditionally. * lib/malloc/dynarray_at_failure.c [_LIBC]: Do not include stdlib.h. (__libc_dynarray_at_failure) [_LIBC]: Call __libc_fatal, fixing a bad merge previously.
* libc-config: fix include problem on older DebianPaul Eggert2021-04-271-3/+3
| | | | | | | | https://lists.gnu.org/r/bug-gnulib/2021-04/msg00198.html * lib/cdefs.h: Use __GNULIB_CDEFS, not __GLIBC__, to determine whether to include the bits/* files. * lib/libc-config.h (__WORDSIZE): Remove. (__GNULIB_CDEFS): New macro.
* libc-config: port better to Fedora RawhidePaul Eggert2021-04-221-5/+9
| | | | | | | | | | | | | | | Problem reported by Eric Blake in: https://lists.gnu.org/r/bug-gnulib/2021-04/msg00181.html * lib/cdefs.h: Make this closer to glibc, so that we can merge Gnulib into glibc here. (__attribute_maybe_unused__): Make identical to glibc’s definition, though with an additional comment. (__attribute_nonnull__): Add clarifying comment. Make inclusion of bits/wordsize.h, bits/long-double.h dependent on __GLIBC__, not on !__WORDSIZE. * lib/libc-config.h: Use __attribute_nonnull__, not __attribute_maybe_unused__, to detect whether to include sys/cdefs.h.
* libc-config: port to DragonFlyBSD 5.9Paul Eggert2021-03-101-6/+6
| | | | | | | | | | | | DragonFlyBSD defines __nonnull incompatibly with glibc, so avoid the use of __nonnull in Gnulib code. Problem reported by Gavin Smith in: https://lists.gnu.org/r/bug-gnulib/2021-03/msg00066.html * lib/cdefs.h (__attribute_nonnull__): Rename from __nonnull. All uses in Gnulib changed. There should be no need to change glibc code that is not shared with Gnulib. (__nonnull): New macro, defined in terms of __attribute_nonnull__, and which can be used in glibc code that is not shared with Gnulib.
* libc-config: port to Xcode 7Paul Eggert2021-01-231-2/+4
| | | | | | | | | | Problem reported by Mattias Engdegård in: https://lists.gnu.org/r/emacs-devel/2021-01/msg01089.html * lib/cdefs.h (__nonnull): If already defined but glibc is not in use, override the definition with Gnulib’s _GL_ATTRIBUTE_NONNULL. This is needed for Xcode 7, which has a ‘#define __nonnull _Nonnull’ builtin for backwards-compatibility with an older Xcode syntax that GNUish code never uses.
* Port FALLTHROUGH to clang 3.4 and earlierPaul Eggert2021-01-211-1/+3
| | | | | | | | | | Problem reported by Akim Demaille in: https://lists.gnu.org/r/bug-gnulib/2021-01/msg00241.html * lib/cdefs.h (__glibc_has_attribute): * m4/gnulib-common.m4 (gl_COMMON_BODY): Do not trust __has_attribute in clang 3.4 and earlier, as <https://releases.llvm.org/3.5.0/tools/clang/docs/ReleaseNotes.html> says that __has_attribute is unreliable in these old versions.
* dynarray: new modulePaul Eggert2021-01-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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)).
* libc-config: simplify clang __has_* macrosPaul Eggert2021-01-061-41/+28
| | | | | | | | | | | | | | cdefs.h sometimes used names like __glibc_clang_has_attribute and sometimes __glibc_has_attribute. There is no need in glibc or Gnulib to distinguish clang from other compilers here, so be consistent and use the simpler names. * lib/cdefs.h (__glibc_has_builtin, __glibc_has_extension): Rename from __glibc_clang_has_builtin, __glibc_clang_has_extension. All uses changed. (__glibc_clang_has_attribute): Remove. All uses replaced by __glibc_has_attribute. * lib/libc-config.h [!__glibc_likely]: Undef them here too. This fixes a problem where __glibc_has_attribute was not undeffed.
* libc-config: merge from glibcPaul Eggert2021-01-051-26/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use a better way of keeping glibc <sys/cdefs.h> and gnulib lib/cdefs.h mostly in sync, by using lib/cdefs.h only on platforms where <sys/cdefs.h> does not work well enough for Gnulib. * lib/cdefs.h: Go back to using _SYS_CDEFS_H rather than _GL_DEFS_H as an include guard. (__THROW, __THROWNL, __NTH, __NTHNL): Define to noexcept for C++11 and later. (__glibc_objsize, __glibc_objsize0): New, for _FORTIFY_SOURCE=3. (__warndecl): Remove. (__attribute_copy__): New macro, for GCC 9 support. (__LDBL_REDIR, __LDBL_REDIR_DECL, __LDBL_REDIR1) (__LDBL_REDIR1_DECL, __LDBL_REDIR1_NTH, __REDIRECT_NTH_LDBL) (__REDIRECT_LDBL, __LDBL_REDIR_NTH): Redirections for IEEE long double on powerpc64le. (__LDBL_REDIR2_DECL): New macro. (__attr_access): New macro, for GCC 10 bounds checking. (__attribute_returns_twice__): New macro, for setjmp etc. * lib/libc-config.h: Include <cdefs.h> only if __glibc_likely is undefined. The following changes apply only if __glibc_likely is not defined. (__LDBL_REDIR2_DECL, __attr_access, __attribute_returns_twice__) (__glibc_clang_has_attribute, __glibc_clang_has_extension) (__glibc_objsize, __glibc_objsize0): Undef these new (or newer) <cdefs.h> macros. (__P, __PMT, __always_inline): Do not undef, since cdefs.h does that. (__glibc_likely): Do not undef, since this is inside ifndef __glibc_likely. (__warndecl): Do not undef; no longer defined.
* libc-config: Avoid overriding the headers from an installed newer glibc.Bruno Haible2021-01-051-3/+3
| | | | | | | Reported by Paul E Murphy <murphyp@linux.ibm.com> in <https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00106.html>. * lib/cdefs.h: Use a different include guard than glibc's <sys/cdefs.h>.
* maint: run 'make update-copyright'Paul Eggert2020-12-311-1/+1
|
* libc-config: port __THROW to Ubuntu 4Paul Eggert2020-09-171-2/+2
| | | | | | | | | | * lib/cdefs.h (__THROW): Do not use __attribute__ ((__nothrow__)) for GCC 3.3. Problem reported by Jeffrey Walton in: https://lists.gnu.org/r/bug-gnulib/2019-07/msg00058.html The GCC 3.3.4 documentation says the attribute should work, but apparently it does not work on Ubuntu 4’s GCC 3.3. There seems little point or desire to research this circa-2004 platform further, so just avoid the attribute there.
* libc-config: Improve comments.Bruno Haible2020-08-231-1/+5
| | | | | * lib/cdefs.h (__warndecl, __warnattr, __errordecl): Explain why we cannot use clang's __diagnose_if__ here.
* libc-config: avoid Clang’s __diagnose_if__Paul Eggert2020-08-171-1/+1
| | | | | | | | | | * lib/cdefs.h (__warndecl, __warnattr, __errordecl): For now, do not use __diagnose_if__ here, as this fails on Fedora 31 with Clang 9.0.1, with diagnostic "/usr/include/bits/stdio2.h:263:9: error: fgets called with bigger size than length of destination buffer [-Werror,-Wuser-defined-warnings]". I guess Clang 9 warns even for functions that are not called?
* libc-config: Enable __REDIRECT macro also on clang.Bruno Haible2020-08-161-1/+1
| | | | | * lib/cdefs.h (__REDIRECT, __REDIRECT_NTH, __REDIRECT_NTHNL, __ASMNAME, __ASMNAME2): Define on clang like on GCC.
* Use _Static_assert and static_assert primitives when present on clang.Bruno Haible2020-08-161-1/+2
| | | | | | * lib/cdefs.h (_Static_assert): Don't define as a macro on clang. * lib/verify.h (_GL_HAVE__STATIC_ASSERT, _GL_HAVE__STATIC_ASSERT1, _GL_HAVE_STATIC_ASSERT1): Define as appropriate on clang.
* Use 'throw ()' for optimization in C++ mode also on clang.Bruno Haible2020-08-161-1/+1
| | | | | | * lib/cdefs.h (__THROW): Define to 'throw ()' also on clang. * lib/getopt-cdefs.in.h (__THROW): Likewise. * lib/md5.h (__THROW): Likewise.
* Use __restrict also on clang.Bruno Haible2020-08-121-4/+7
| | | | | | | | | * lib/cdefs.h (__restrict): Don't define as a macro on clang. (__restrict_arr): On clang, define like on GCC. * lib/regex.h (_Restrict_): Use '__restrict' also on clang. (_Restrict_arr_): Use _Restrict_ also on clang. * lib/spawn.in.h (_Restrict_): Use '__restrict' also on clang. (_Restrict_arr_): Use _Restrict_ also on clang.
* Use flexible array syntax also on clang.Bruno Haible2020-08-111-2/+2
| | | | | * lib/cdefs.h (__flexarr, __glibc_c99_flexarr_available): For clang, define like for GCC 3.
* Use expression statements also on clang.Bruno Haible2020-08-111-1/+1
| | | | | | | | | | | * lib/cdefs.h (__extension__): Don't define to empty on clang. * lib/obstack.h (__extension__): Likewise. (obstack_object_size, obstack_room, obstack_make_room, obstack_empty_p, obstack_grow, obstack_grow0, obstack_1grow, obstack_ptr_grow, obstack_int_grow, obstack_ptr_grow_fast, obstack_int_grow_fast, obstack_blank, obstack_alloc, obstack_copy, obstack_copy0, obstack_finish, obstack_free): Enable as optimized macros also on clang. * lib/fpucw.h (fpucw_t etc.): Enable the definitions also on clang.
* Use many __attribute__s with clang.Bruno Haible2020-08-111-31/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/gnulib-common.m4 (_Noreturn): Use __attribute__ __noreturn__ also on clang. * lib/cdefs.h (__glibc_clang_has_attribute, __glibc_clang_has_builtin): New macros. (__THROW, __THROWNL, __NTH, __NTHNL): Use __attribute__ __nothrow__ also on clang. (__warndecl, __warnattr, __errordecl): Use __attribute__ __diagnose_if__ also on older clang versions. (__attribute__): Don't define to empty on clang. (__attribute_malloc__): Use __attribute__ __malloc__ also on clang. (__attribute_pure__): Use __attribute__ __pure__ also on clang. (__attribute_const__): Use __attribute__ __const__ also on clang. (__attribute_used__): Use __attribute__ __used__ also on clang. (__attribute_noinline__): Use __attribute__ __noinline__ also on clang. (__attribute_deprecated__): Use __attribute__ __deprecated__ also on clang. (__attribute_format_arg__): Use __attribute__ __format_arg__ also on clang. (__attribute_format_strfmon__): Use __attribute__ __format__ __strfmon__ also on clang. (__nonnull): Use __attribute__ __nonnull__ also on clang. (__attribute_warn_unused_result__): Use __attribute__ __warn_unused_result__ also on clang. (__always_inline): Use __attribute__ __always_inline__ also on clang. (__attribute_artificial__): Use __attribute__ __artificial__ also on clang >= 7. (__glibc_unlikely, __glibc_likely): Use __builtin_expect also on older clang versions. (_Noreturn): Don't redefine on clang >= 3.5. * lib/arg-nonnull.h (_GL_ARG_NONNULL): Use __attribute__ __nonnull__ also on clang. * lib/dirent.in.h (_GL_ATTRIBUTE_PURE): Use __attribute__ __pure__ also on clang. * lib/stdlib.in.h (_GL_ATTRIBUTE_PURE): Likewise. * lib/string.in.h (_GL_ATTRIBUTE_PURE): Likewise. * lib/wchar.in.h (_GL_ATTRIBUTE_PURE): Likewise. * lib/stdio.in.h (_GL_ATTRIBUTE_FORMAT): Use __attribute__ __format__ also on clang. * lib/monetary.in.h (_GL_ATTRIBUTE_FORMAT): Likewise. * lib/textstyle.in.h (ostream_printf, ostream_vprintf): Likewise. * lib/unitypes.in.h (_UC_ATTRIBUTE_CONST): Use __attribute__ __const__ also on clang. (_UC_ATTRIBUTE_PURE): Use __attribute__ __pure__ also on clang. * lib/noreturn.h (_GL_NORETURN_FUNC, _GL_NORETURN_FUNCPTR): Use __attribute__ __noreturn__ also on clang. * lib/obstack.h (__attribute_noreturn__): Likewise. * lib/file-set.h (record_file): Use __attribute__ __nonnull__ also on clang. * lib/argp-help.c (hol_entry_long_iterate): Use __attribute__ always_inline also on clang. * tests/test-printf-posix.c (func1, func2, func3, func4): Test also on clang.
* Add ability to emit user-defined warnings and errors with clang.Bruno Haible2020-08-091-0/+6
| | | | | | | | | * m4/gnulib-common.m4 (gl_COMMON_BODY): Define _GL_ATTRIBUTE_ERROR, _GL_ATTRIBUTE_WARNING using an attribute for clang. * lib/warn-on-use.h (_GL_WARN_ON_USE, _GL_WARN_ON_USE_ATTRIBUTE, _GL_WARN_ON_USE_CXX): Define using an attribute for clang. * lib/cdefs.h (__warndecl, __warnattr, __errordecl): Define using an attribute for clang.
* Use __builtin_expect with clang everywhere.Bruno Haible2020-08-061-1/+1
| | | | | * lib/cdefs.h (__glibc_unlikely, __glibc_likely): Use the GCC built-in also on clang.
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* Fix typos found by codespell.Tim Rühsen2019-01-121-1/+1
| | | | | * lib/*.[hc]: Fix typos in comments. * pygnulib/*.py: Fix typos in error messages and comments.
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* obstack, libc-config: Support HP-UX cc in C99 mode.Bruno Haible2018-12-161-1/+1
| | | | | | | * lib/obstack.h (__FLEXIBLE_ARRAY_MEMBER): Treat HP-UX cc as a pre-C99 compiler, even when in C99 mode. * lib/cdefs.h (__flexarr): Likewise. * lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Update comment.
* libc-config: merge from glibcPaul Eggert2018-10-151-0/+6
| | | | * lib/cdefs.h (__glibc_has_attribute): New macro.
* libc-config: merge from glibcPaul Eggert2018-06-241-6/+30
| | | | | | | | | | | | | | * lib/cdefs.h (__inline, __restrict): Copy from current glibc. This fixes glibc bug 17721, which Gnulib had already fixed in a different way. (__nonnull): Lessen the distance from glibc by using the glibc definition inside an ‘#ifndef __nonnull’. (__attribute_nonstring__): New macro, copied from current glibc. * lib/libc-config.h (__attribute_nonstring__): New undef. (__restrict): Remove; workaround no longer needed. Keep the __inline workaround, though, as it uses HAVE___INLINE to support more compilers than the glibc __inline can.
* libc-config: Fix conflict with FreeBSD include files.Bruno Haible2018-06-231-7/+4
| | | | | * lib/cdefs.h (__nonnull): Remove definition. * lib/libc-config.h (__nonnull): Remove undefinition.
* Fix -Wundef warning in user-included header lib/cdefs.h.Tim Rühsen2018-01-041-1/+1
| | | | * lib/cdefs.h: Check if defined before using __USE_FORTIFY_LEVEL.
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* libc-config: new modulePaul Eggert2017-09-011-0/+487
* MODULES.html.sh: Add libc-config. * lib/cdefs.h: New file, copied from the GNU C Library with very minor changes that can be copied back. * lib/libc-config.h, modules/libc-config: New files.