1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-05-13 15:13:36 +00:00

attribute: new module

This simplifies use of GCC and C2X attributes like ‘deprecated’.
* MODULES.html.sh: Add attribute.
* doc/attribute.texi, lib/attribute.h, modules/attribute: New files.
* doc/gnulib.texi (Particular Modules): Add Attributes.
* lib/backupfile.c, lib/fnmatch.c, lib/freopen-safer.c:
* lib/mbrtoc32.c, lib/mbrtowc.c, lib/nstrftime.c, lib/quotearg.c:
* lib/savewd.c, lib/unistr/u8-uctomb-aux.c, lib/unistr/u8-uctomb.c:
* lib/vasnprintf.c:
Include attribute.h, and let it define FALLTHROUGH.
* lib/bitset/base.h, lib/c-stack.c (__attribute__): Remove macro.
* lib/bitset/base.h (ATTRIBUTE_UNUSED): Define in terms of
_GL_ATTRIBUTE_MAYBE_UNUSED, for forwards compatibility to C2X.
* lib/dfa.c (FALLTHROUGH): Define consistently with gl_COMMON_BODY.
This is a copy since Gawk doesn’t use Gnulib.
* lib/di-set.h (_GL_ATTRIBUTE_NONNULL): Remove definition that
is incompatible with gl_COMMON_BODY’s.  All uses changed.
* lib/fts.c: Include attribte.h, for FALLTHROUGH.
Keep the existing FALLTHROUGH definition since Glibc might use it,
and it does no harm to Gnulib’s FALLTHROUGH.
* lib/fts_.h, lib/inttostr.h:
(__GNUC_PREREQ): Remove; no longer needed.
(__attribute_warn_unused_result__): Remove.  All uses
replaced by _GL_ATTRIBUTE_NODISCARD.
* lib/gl_list.h, lib/gl_map.h, lib/gl_omap.h, lib/gl_oset.h:
* lib/gl_set.h: Prefer _GL_ATTRIBUTE_NODISCARD to an ifdeffed
__attribute__ ((__warn_unused_result__)), for forward
compatibility to C2X.
* lib/hash.h (_GL_ATTRIBUTE_WUR): Remove.  All uses replaced by
_GL_ATTRIBUTE_NODISCARD.
(_GL_ATTRIBUTE_DEPRECATED): Remove, since gl_COMMON_BODY defines it.
* lib/ino-map.h (_GL_ATTRIBUTE_NONNULL): Remove.  All uses
replaced by gl_COMMON_BODY’s implementation, which has a
slightly different signature.
* lib/safe-alloc.h (_GL_ATTRIBUTE_RETURN_CHECK):
Remove.  All uses replaced by _GL_ATTRIBUTE_NODISCARD.
* lib/unused-parameter.h (_GL_UNUSED_PARAMETER):
Define in terms of _GL_ATTRIBUTE_MAYBE_UNUSED.
No doubt all uses should be replaced, at some point.
* m4/gnulib-common.m4 (_GL_GNUC_PREREQ): New macro.
(_Noreturn): Use it.
(_GL_HAS_ATTRIBUTE, _GL_ATTRIBUTE_ALLOC_SIZE)
(_GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_ARTIFICIAL)
(_GL_ATTRIBUTE_COLD)
(_GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR)
(_GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE)
(_GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT)
(_GL_ATTRIBUTE_LEAF, _GL_ATTRIBUTE_MAY_ALIAS)
(_GL_ATTRIBUTE_MAYBE_UNUSED)
(_GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE)
(_GL_ATTRIBUTE_NONNULL, _GL_ATTRIBUTE_NONSTRING)
(_GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, _GL_ATTRIBUTE_PURE)
(_GL_ATTRIBUTE_SENTINEL): New macros.
* modules/backup-rename, modules/backupfile, modules/c-vasnprintf:
* modules/fnmatch, modules/freopen-safer, modules/fts:
* modules/mbrtoc32, modules/mbrtowc, modules/nstrftime:
* modules/quotearg, modules/savewd:
* modules/unistdio/u16-u16-vasnprintf:
* modules/unistdio/u16-vasnprintf:
* modules/unistdio/u32-u32-vasnprintf:
* modules/unistdio/u32-vasnprintf:
* modules/unistdio/u8-u8-vasnprintf:
* modules/unistdio/u8-vasnprintf:
* modules/unistdio/ulc-vasnprintf:
* modules/unistr/u8-uctomb, modules/vasnprintf:
(Depends-on:): Add attribute module.
This commit is contained in:
Paul Eggert
2020-05-01 18:12:12 -07:00
parent 2ac33b29fc
commit c08f85d74f
55 changed files with 477 additions and 361 deletions

View File

@@ -1,3 +1,72 @@
2020-05-03 Paul Eggert <eggert@cs.ucla.edu>
attribute: new module
This simplifies use of GCC and C2X attributes like deprecated.
* MODULES.html.sh: Add attribute.
* doc/attribute.texi, lib/attribute.h, modules/attribute: New files.
* doc/gnulib.texi (Particular Modules): Add Attributes.
* lib/backupfile.c, lib/fnmatch.c, lib/freopen-safer.c:
* lib/mbrtoc32.c, lib/mbrtowc.c, lib/nstrftime.c, lib/quotearg.c:
* lib/savewd.c, lib/unistr/u8-uctomb-aux.c, lib/unistr/u8-uctomb.c:
* lib/vasnprintf.c:
Include attribute.h, and let it define FALLTHROUGH.
* lib/bitset/base.h, lib/c-stack.c (__attribute__): Remove macro.
* lib/bitset/base.h (ATTRIBUTE_UNUSED): Define in terms of
_GL_ATTRIBUTE_MAYBE_UNUSED, for forwards compatibility to C2X.
* lib/dfa.c (FALLTHROUGH): Define consistently with gl_COMMON_BODY.
This is a copy since Gawk doesnt use Gnulib.
* lib/di-set.h (_GL_ATTRIBUTE_NONNULL): Remove definition that
is incompatible with gl_COMMON_BODYs. All uses changed.
* lib/fts.c: Include attribte.h, for FALLTHROUGH.
Keep the existing FALLTHROUGH definition since Glibc might use it,
and it does no harm to Gnulibs FALLTHROUGH.
* lib/fts_.h, lib/inttostr.h:
(__GNUC_PREREQ): Remove; no longer needed.
(__attribute_warn_unused_result__): Remove. All uses
replaced by _GL_ATTRIBUTE_NODISCARD.
* lib/gl_list.h, lib/gl_map.h, lib/gl_omap.h, lib/gl_oset.h:
* lib/gl_set.h: Prefer _GL_ATTRIBUTE_NODISCARD to an ifdeffed
__attribute__ ((__warn_unused_result__)), for forward
compatibility to C2X.
* lib/hash.h (_GL_ATTRIBUTE_WUR): Remove. All uses replaced by
_GL_ATTRIBUTE_NODISCARD.
(_GL_ATTRIBUTE_DEPRECATED): Remove, since gl_COMMON_BODY defines it.
* lib/ino-map.h (_GL_ATTRIBUTE_NONNULL): Remove. All uses
replaced by gl_COMMON_BODYs implementation, which has a
slightly different signature.
* lib/safe-alloc.h (_GL_ATTRIBUTE_RETURN_CHECK):
Remove. All uses replaced by _GL_ATTRIBUTE_NODISCARD.
* lib/unused-parameter.h (_GL_UNUSED_PARAMETER):
Define in terms of _GL_ATTRIBUTE_MAYBE_UNUSED.
No doubt all uses should be replaced, at some point.
* m4/gnulib-common.m4 (_GL_GNUC_PREREQ): New macro.
(_Noreturn): Use it.
(_GL_HAS_ATTRIBUTE, _GL_ATTRIBUTE_ALLOC_SIZE)
(_GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_ARTIFICIAL)
(_GL_ATTRIBUTE_COLD)
(_GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR)
(_GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE)
(_GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT)
(_GL_ATTRIBUTE_LEAF, _GL_ATTRIBUTE_MAY_ALIAS)
(_GL_ATTRIBUTE_MAYBE_UNUSED)
(_GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE)
(_GL_ATTRIBUTE_NONNULL, _GL_ATTRIBUTE_NONSTRING)
(_GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, _GL_ATTRIBUTE_PURE)
(_GL_ATTRIBUTE_SENTINEL): New macros.
* modules/backup-rename, modules/backupfile, modules/c-vasnprintf:
* modules/fnmatch, modules/freopen-safer, modules/fts:
* modules/mbrtoc32, modules/mbrtowc, modules/nstrftime:
* modules/quotearg, modules/savewd:
* modules/unistdio/u16-u16-vasnprintf:
* modules/unistdio/u16-vasnprintf:
* modules/unistdio/u32-u32-vasnprintf:
* modules/unistdio/u32-vasnprintf:
* modules/unistdio/u8-u8-vasnprintf:
* modules/unistdio/u8-vasnprintf:
* modules/unistdio/ulc-vasnprintf:
* modules/unistr/u8-uctomb, modules/vasnprintf:
(Depends-on:): Add attribute module.
2020-05-03 Bruno Haible <bruno@clisp.org>
bison: Fix today's commit.

View File

@@ -2364,6 +2364,7 @@ func_all_modules ()
func_echo "$element"
func_begin_table
func_module attribute
func_module builtin-expect
func_module ieee754-h
func_module limits-h

43
doc/attribute.texi Normal file
View File

@@ -0,0 +1,43 @@
@c attribute module documentation
@c Copyright 2020 Free Software Foundation, Inc.
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
@c copy of the license is at <https://www.gnu.org/licenses/fdl-1.3.en.html>.
@node Attributes
@section Attributes
@cindex Attributes
@findex __attribute__
This module provides a header file @file{attribute.h} that defines
macros related to C and C++ attributes and the GCC
@code{__attribute__} keyword.
Here is an example of its use:
@example
#include <attribute.h>
extern char *crypt (char const *, char const *)
ATTRIBUTE_NOTHROW ATTRIBUTE_LEAF ATTRIBUTE_NONNULL ((1, 2));
@end example
@noindent
@code{ATTRIBUTE_NOTHROW} expands to @code{__attribute__
((__nothrow__))} if the compiler is a recent-enough GCC or GCC-like
compiler, and to nothing otherwise. Similarly for
@code{ATTRIBUTE_LEAF}. @code{ATTRIBUTE_NONNULL ((1, 2))} expands to
@code{__attribute__ ((__nonnull__ (1, 2)))} if the compiler is
recent-enough GCC, and to nothing otherwise.
Most of these attribute names begin with @code{ATTRIBUTE_}.
A few do not, because they are part of C2X and their
names are not likely to clash with other macro names.
These macros are @code{DEPRECATED}, @code{FALLTHROUGH},
@code{MAYBE_UNUSED}, and @code{NODISCARD}, which can
be defined to @code{[[deprecated]]} etc.@: on C2X platforms.

View File

@@ -6654,6 +6654,7 @@ to POSIX that it can be treated like any other Unix-like platform.
* alloca::
* alloca-opt::
* Safe Allocation Macros::
* Attributes::
* Compile-time Assertions::
* Non-returning Functions::
* Integer Properties::
@@ -6685,6 +6686,8 @@ to POSIX that it can be treated like any other Unix-like platform.
@include safe-alloc.texi
@include attribute.texi
@include verify.texi
@include noreturn.texi

View File

@@ -32,7 +32,7 @@
INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the
printable string, which need not start at BUF. */
char * __attribute_warn_unused_result__
char * _GL_ATTRIBUTE_NODISCARD
anytostr (inttype i, char *buf)
{
char *p = buf + INT_STRLEN_BOUND (inttype);

56
lib/attribute.h Normal file
View File

@@ -0,0 +1,56 @@
/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
Copyright 2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_*
macros used within Gnulib. */
#ifndef _GL_ATTRIBUTE_H
#define _GL_ATTRIBUTE_H
/* C2X standard attributes have macro names that do not begin with
'ATTRIBUTE_'. */
#define DEPRECATED _GL_ATTRIBUTE_DEPRECATED
#define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH
#define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
#define NODISCARD _GL_ATTRIBUTE_NODISCARD
/* Attributes from GCC have macro names beginning with 'ATTRIBUTE_' to
avoid name clashes. */
#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE(args)
#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL
#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD
#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
#define ATTRIBUTE_DEPRECATED _GL_ATTRIBUTE_DEPRECATED
#define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR(msg)
#define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
#define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT(spec)
#define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF
#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS
#define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC
#define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE
#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL(args)
#define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING
#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW
#define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED
#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
#define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL(pos)
#define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING(msg)
#endif /* _GL_ATTRIBUTE_H */

View File

@@ -22,6 +22,7 @@
#include "backup-internal.h"
#include "attribute.h"
#include "dirname.h"
#include "opendirat.h"
#include "renameatu.h"
@@ -35,14 +36,6 @@
#include <string.h>
#include <unistd.h>
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
#endif
#ifndef _D_EXACT_NAMLEN
# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name)
#endif

View File

@@ -27,13 +27,7 @@
#include "xalloc.h"
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x)
# endif
#endif
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#define ATTRIBUTE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
/* Currently we support five flavours of bitsets:
BITSET_ARRAY: Array of bits (fixed size, fast for dense bitsets).

View File

@@ -35,12 +35,6 @@
#include <config.h>
#ifndef __attribute__
# if __GNUC__ < 3
# define __attribute__(x)
# endif
#endif
#include "gettext.h"
#define _(msgid) gettext (msgid)

View File

@@ -62,7 +62,9 @@ isasciidigit (char c)
#include "localeinfo.h"
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# if 201710L < __STDC_VERSION__
# define FALLTHROUGH [[__fallthrough__]]
# elif __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))

View File

@@ -3,17 +3,10 @@
# include <sys/types.h>
# undef _GL_ATTRIBUTE_NONNULL
# if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__
# define _GL_ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
# else
# define _GL_ATTRIBUTE_NONNULL(m)
# endif
struct di_set *di_set_alloc (void);
int di_set_insert (struct di_set *, dev_t, ino_t) _GL_ATTRIBUTE_NONNULL (1);
void di_set_free (struct di_set *) _GL_ATTRIBUTE_NONNULL (1);
int di_set_insert (struct di_set *, dev_t, ino_t) _GL_ATTRIBUTE_NONNULL ((1));
void di_set_free (struct di_set *) _GL_ATTRIBUTE_NONNULL ((1));
int di_set_lookup (struct di_set *dis, dev_t dev, ino_t ino)
_GL_ATTRIBUTE_NONNULL (1);
_GL_ATTRIBUTE_NONNULL ((1));
#endif

View File

@@ -63,16 +63,9 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
# define SIZE_MAX ((size_t) -1)
#endif
#include "attribute.h"
#include "flexmember.h"
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
#endif
/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */
#define NO_LEADING_PERIOD(flags) \
((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD))

View File

@@ -21,19 +21,13 @@
#include "stdio-safer.h"
#include "attribute.h"
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <unistd.h>
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
#endif
/* Guarantee that FD is open; all smaller FDs must already be open.
Return true if successful. */
static bool

View File

@@ -70,6 +70,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#include <unistd.h>
#if ! _LIBC
# include "attribute.h"
# include "fcntl--.h"
# include "flexmember.h"
# include "openat.h"

View File

@@ -249,30 +249,13 @@ typedef struct _ftsent {
char fts_name[__FLEXIBLE_ARRAY_MEMBER]; /* file name */
} FTSENT;
#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
#endif
#if __GNUC_PREREQ (3,4)
# undef __attribute_warn_unused_result__
# define __attribute_warn_unused_result__ \
__attribute__ ((__warn_unused_result__))
#else
# define __attribute_warn_unused_result__ /* empty */
#endif
__BEGIN_DECLS
FTSENT *fts_children (FTS *, int) __THROW __attribute_warn_unused_result__;
int fts_close (FTS *) __THROW __attribute_warn_unused_result__;
FTSENT *fts_children (FTS *, int) __THROW _GL_ATTRIBUTE_NODISCARD;
int fts_close (FTS *) __THROW _GL_ATTRIBUTE_NODISCARD;
FTS *fts_open (char * const *, int,
int (*)(const FTSENT **, const FTSENT **))
__THROW __attribute_warn_unused_result__;
FTSENT *fts_read (FTS *) __THROW __attribute_warn_unused_result__;
__THROW _GL_ATTRIBUTE_NODISCARD;
FTSENT *fts_read (FTS *) __THROW _GL_ATTRIBUTE_NODISCARD;
int fts_set (FTS *, FTSENT *, int) __THROW;
__END_DECLS

View File

@@ -197,10 +197,7 @@ extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node,
/* Likewise. Returns 0 upon success, -1 upon out-of-memory. */
extern int gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Returns the node immediately after the given node in the list, or NULL
if the given node is the last (rightmost) one in the list. */
@@ -231,10 +228,7 @@ extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position,
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position,
const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Replaces the element at the first position in the list.
Returns its node.
@@ -243,10 +237,7 @@ extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position,
extern gl_list_node_t gl_list_set_first (gl_list_t list, const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_set_first (gl_list_t list, const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Replaces the element at the last position in the list.
Returns its node.
@@ -255,10 +246,7 @@ extern gl_list_node_t gl_list_nx_set_first (gl_list_t list, const void *elt)
extern gl_list_node_t gl_list_set_last (gl_list_t list, const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_set_last (gl_list_t list, const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Searches whether an element is already in the list.
Returns its node if found, or NULL if not present in the list. */
@@ -301,10 +289,7 @@ extern size_t gl_list_indexof_from_to (gl_list_t list,
extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Adds an element as the last element of the list.
Returns its node. */
@@ -312,10 +297,7 @@ extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt)
extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt);
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Adds an element before a given element node of the list.
Returns its node. */
@@ -326,10 +308,7 @@ extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node,
extern gl_list_node_t gl_list_nx_add_before (gl_list_t list,
gl_list_node_t node,
const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Adds an element after a given element node of the list.
Returns its node. */
@@ -339,10 +318,7 @@ extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node,
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node,
const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Adds an element at a given position in the list.
POSITION must be >= 0 and <= gl_list_size (list). */
@@ -352,10 +328,7 @@ extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position,
/* Likewise. Returns NULL upon out-of-memory. */
extern gl_list_node_t gl_list_nx_add_at (gl_list_t list, size_t position,
const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Removes an element from the list.
Returns true. */
@@ -499,10 +472,7 @@ extern gl_list_node_t gl_sortedlist_add (gl_list_t list,
extern gl_list_node_t gl_sortedlist_nx_add (gl_list_t list,
gl_listelement_compar_fn compar,
const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Searches and removes an element from the list.
The list is assumed to be sorted with COMPAR.
@@ -639,10 +609,7 @@ gl_list_node_value (gl_list_t list, gl_list_node_t node)
->node_value (list, node);
}
GL_LIST_INLINE int
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD int
gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
const void *elt)
{
@@ -683,29 +650,20 @@ gl_list_get_last (gl_list_t list)
return gl_list_get_at (list, gl_list_size (list) - 1);
}
GL_LIST_INLINE gl_list_node_t
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
->nx_set_at (list, position, elt);
}
GL_LIST_INLINE gl_list_node_t
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
gl_list_nx_set_first (gl_list_t list, const void *elt)
{
return gl_list_nx_set_at (list, 0, elt);
}
GL_LIST_INLINE gl_list_node_t
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
gl_list_nx_set_last (gl_list_t list, const void *elt)
{
return gl_list_nx_set_at (list, gl_list_size (list) - 1, elt);
@@ -759,50 +717,35 @@ gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index,
->indexof_from_to (list, start_index, end_index, elt);
}
GL_LIST_INLINE gl_list_node_t
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
gl_list_nx_add_first (gl_list_t list, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
->nx_add_first (list, elt);
}
GL_LIST_INLINE gl_list_node_t
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
gl_list_nx_add_last (gl_list_t list, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
->nx_add_last (list, elt);
}
GL_LIST_INLINE gl_list_node_t
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
->nx_add_before (list, node, elt);
}
GL_LIST_INLINE gl_list_node_t
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
->nx_add_after (list, node, elt);
}
GL_LIST_INLINE gl_list_node_t
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
@@ -913,10 +856,7 @@ gl_sortedlist_indexof_from_to (gl_list_t list, gl_listelement_compar_fn compar,
elt);
}
GL_LIST_INLINE gl_list_node_t
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable

View File

@@ -146,10 +146,7 @@ extern bool gl_map_search (gl_map_t map, const void *key, const void **valuep);
extern bool gl_map_put (gl_map_t map, const void *key, const void *value);
/* Likewise. Returns -1 upon out-of-memory. */
extern int gl_map_nx_put (gl_map_t map, const void *key, const void *value)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Adds a pair to a map and retrieves the previous value.
Returns true if a pair with the given key was not already in the map and so
@@ -162,10 +159,7 @@ extern bool gl_map_getput (gl_map_t map, const void *key, const void *value,
/* Likewise. Returns -1 upon out-of-memory. */
extern int gl_map_nx_getput (gl_map_t map, const void *key, const void *value,
const void **oldvaluep)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Removes a pair from a map.
Returns true if the key was found and its pair removed.
@@ -286,10 +280,7 @@ gl_map_search (gl_map_t map, const void *key, const void **valuep)
->search (map, key, valuep);
}
GL_MAP_INLINE int
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_MAP_INLINE _GL_ATTRIBUTE_NODISCARD int
gl_map_nx_getput (gl_map_t map, const void *key, const void *value,
const void **oldvaluep)
{
@@ -340,10 +331,7 @@ gl_map_get (gl_map_t map, const void *key)
return value;
}
GL_MAP_INLINE int
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_MAP_INLINE _GL_ATTRIBUTE_NODISCARD int
gl_map_nx_put (gl_map_t map, const void *key, const void *value)
{
const void *oldvalue;

View File

@@ -156,10 +156,7 @@ extern bool gl_omap_search_atleast (gl_omap_t map,
extern bool gl_omap_put (gl_omap_t map, const void *key, const void *value);
/* Likewise. Returns -1 upon out-of-memory. */
extern int gl_omap_nx_put (gl_omap_t map, const void *key, const void *value)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Adds a pair to an ordered map and retrieves the previous value.
Returns true if a pair with the given key was not already in the map and so
@@ -172,10 +169,7 @@ extern bool gl_omap_getput (gl_omap_t map, const void *key, const void *value,
/* Likewise. Returns -1 upon out-of-memory. */
extern int gl_omap_nx_getput (gl_omap_t map, const void *key, const void *value,
const void **oldvaluep)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Removes a pair from an ordered map.
Returns true if the key was found and its pair removed.
@@ -304,10 +298,7 @@ gl_omap_search_atleast (gl_omap_t map,
->search_atleast (map, threshold_fn, threshold, keyp, valuep);
}
GL_OMAP_INLINE int
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_OMAP_INLINE _GL_ATTRIBUTE_NODISCARD int
gl_omap_nx_getput (gl_omap_t map, const void *key, const void *value,
const void **oldvaluep)
{
@@ -358,10 +349,7 @@ gl_omap_get (gl_omap_t map, const void *key)
return value;
}
GL_OMAP_INLINE int
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_OMAP_INLINE _GL_ATTRIBUTE_NODISCARD int
gl_omap_nx_put (gl_omap_t map, const void *key, const void *value)
{
const void *oldvalue;

View File

@@ -134,10 +134,7 @@ extern bool gl_oset_search_atleast (gl_oset_t set,
extern bool gl_oset_add (gl_oset_t set, const void *elt);
/* Likewise. Returns -1 upon out-of-memory. */
extern int gl_oset_nx_add (gl_oset_t set, const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Removes an element from an ordered set.
Returns true if it was found and removed. */
@@ -248,10 +245,7 @@ gl_oset_search_atleast (gl_oset_t set,
->search_atleast (set, threshold_fn, threshold, eltp);
}
GL_OSET_INLINE int
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_OSET_INLINE _GL_ATTRIBUTE_NODISCARD int
gl_oset_nx_add (gl_oset_t set, const void *elt)
{
return ((const struct gl_oset_impl_base *) set)->vtable->nx_add (set, elt);

View File

@@ -126,10 +126,7 @@ extern bool gl_set_search (gl_set_t set, const void *elt);
extern bool gl_set_add (gl_set_t set, const void *elt);
/* Likewise. Returns -1 upon out-of-memory. */
extern int gl_set_nx_add (gl_set_t set, const void *elt)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
;
_GL_ATTRIBUTE_NODISCARD;
/* Removes an element from a set.
Returns true if it was found and removed. */
@@ -233,10 +230,7 @@ gl_set_search (gl_set_t set, const void *elt)
return ((const struct gl_set_impl_base *) set)->vtable->search (set, elt);
}
GL_SET_INLINE int
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__ ((__warn_unused_result__))
#endif
GL_SET_INLINE _GL_ATTRIBUTE_NODISCARD int
gl_set_nx_add (gl_set_t set, const void *elt)
{
return ((const struct gl_set_impl_base *) set)->vtable->nx_add (set, elt);

View File

@@ -27,24 +27,6 @@
# include <stdio.h>
# include <stdbool.h>
/* The __attribute__ feature is available in gcc versions 2.5 and later.
The warn_unused_result attribute appeared first in gcc-3.4.0. */
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
# define _GL_ATTRIBUTE_WUR __attribute__ ((__warn_unused_result__))
# else
# define _GL_ATTRIBUTE_WUR /* empty */
# endif
# ifndef _GL_ATTRIBUTE_DEPRECATED
/* The __attribute__((__deprecated__)) feature
is available in gcc versions 3.1 and newer. */
# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)
# define _GL_ATTRIBUTE_DEPRECATED /* empty */
# else
# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
# endif
# endif
typedef size_t (*Hash_hasher) (const void *, size_t);
typedef bool (*Hash_comparator) (const void *, const void *);
typedef void (*Hash_data_freer) (void *);
@@ -88,16 +70,16 @@ size_t hash_string (const char *, size_t) _GL_ATTRIBUTE_PURE;
void hash_reset_tuning (Hash_tuning *);
Hash_table *hash_initialize (size_t, const Hash_tuning *,
Hash_hasher, Hash_comparator,
Hash_data_freer) _GL_ATTRIBUTE_WUR;
Hash_data_freer) _GL_ATTRIBUTE_NODISCARD;
Hash_table *hash_xinitialize (size_t, const Hash_tuning *,
Hash_hasher, Hash_comparator,
Hash_data_freer) _GL_ATTRIBUTE_WUR;
Hash_data_freer) _GL_ATTRIBUTE_NODISCARD;
void hash_clear (Hash_table *);
void hash_free (Hash_table *);
/* Insertion and deletion. */
bool hash_rehash (Hash_table *, size_t) _GL_ATTRIBUTE_WUR;
void *hash_insert (Hash_table *, const void *) _GL_ATTRIBUTE_WUR;
bool hash_rehash (Hash_table *, size_t) _GL_ATTRIBUTE_NODISCARD;
void *hash_insert (Hash_table *, const void *) _GL_ATTRIBUTE_NODISCARD;
int hash_insert_if_absent (Hash_table *table, const void *entry,
const void **matched_ent);

View File

@@ -3,17 +3,10 @@
# include <sys/types.h>
# undef _GL_ATTRIBUTE_NONNULL
# if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__
# define _GL_ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
# else
# define _GL_ATTRIBUTE_NONNULL(m)
# endif
# define INO_MAP_INSERT_FAILURE ((size_t) -1)
struct ino_map *ino_map_alloc (size_t);
void ino_map_free (struct ino_map *) _GL_ATTRIBUTE_NONNULL (1);
size_t ino_map_insert (struct ino_map *, ino_t) _GL_ATTRIBUTE_NONNULL (1);
void ino_map_free (struct ino_map *) _GL_ATTRIBUTE_NONNULL ((1));
size_t ino_map_insert (struct ino_map *, ino_t) _GL_ATTRIBUTE_NONNULL ((1));
#endif

View File

@@ -22,25 +22,8 @@
#include "intprops.h"
#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
#endif
#if __GNUC_PREREQ (3,4)
# undef __attribute_warn_unused_result__
# define __attribute_warn_unused_result__ \
__attribute__ ((__warn_unused_result__))
#else
# define __attribute_warn_unused_result__ /* empty */
#endif
char *imaxtostr (intmax_t, char *) __attribute_warn_unused_result__;
char *inttostr (int, char *) __attribute_warn_unused_result__;
char *offtostr (off_t, char *) __attribute_warn_unused_result__;
char *uinttostr (unsigned int, char *) __attribute_warn_unused_result__;
char *umaxtostr (uintmax_t, char *) __attribute_warn_unused_result__;
char *imaxtostr (intmax_t, char *) _GL_ATTRIBUTE_NODISCARD;
char *inttostr (int, char *) _GL_ATTRIBUTE_NODISCARD;
char *offtostr (off_t, char *) _GL_ATTRIBUTE_NODISCARD;
char *uinttostr (unsigned int, char *) _GL_ATTRIBUTE_NODISCARD;
char *umaxtostr (uintmax_t, char *) _GL_ATTRIBUTE_NODISCARD;

View File

@@ -21,17 +21,11 @@
/* Specification. */
#include <uchar.h>
#include <attribute.h>
#include <errno.h>
#include <stdlib.h>
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
#endif
#if GNULIB_defined_mbstate_t /* AIX, IRIX */
/* Implement mbrtoc32() on top of mbtowc() for the non-UTF-8 locales
and directly for the UTF-8 locales. */

View File

@@ -50,18 +50,11 @@
# endif
# include "attribute.h"
# include "verify.h"
# include "lc-charset-dispatch.h"
# include "mbtowc-lock.h"
# ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
# endif
verify (sizeof (mbstate_t) >= 4);
static char internal_state[4];

View File

@@ -68,16 +68,9 @@ extern char *tzname[];
#include <string.h>
#include <stdbool.h>
#include <attribute.h>
#include <intprops.h>
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
#endif
#ifdef COMPILE_WIDE
# include <endian.h>
# define CHAR_T wchar_t

View File

@@ -29,6 +29,7 @@
#include "quotearg.h"
#include "quote.h"
#include "attribute.h"
#include "minmax.h"
#include "xalloc.h"
#include "c-strcaseeq.h"
@@ -54,14 +55,6 @@
#define INT_BITS (sizeof (int) * CHAR_BIT)
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
#endif
struct quoting_options
{
/* Basic quoting style. */

View File

@@ -31,22 +31,14 @@
# endif
#endif
# ifndef _GL_ATTRIBUTE_RETURN_CHECK
# if __GNUC_PREREQ (3, 4)
# define _GL_ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
# else
# define _GL_ATTRIBUTE_RETURN_CHECK
# endif
# endif
/* Don't call these directly - use the macros below */
int
safe_alloc_alloc_n (void *ptrptr, size_t size, size_t count, int zeroed)
_GL_ATTRIBUTE_RETURN_CHECK;
_GL_ATTRIBUTE_NODISCARD;
int
safe_alloc_realloc_n (void *ptrptr, size_t size, size_t count)
_GL_ATTRIBUTE_RETURN_CHECK;
_GL_ATTRIBUTE_NODISCARD;
/**
* ALLOC:

View File

@@ -33,17 +33,10 @@
#include <unistd.h>
#include "assure.h"
#include "attribute.h"
#include "fcntl-safer.h"
#include "filename.h"
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
#endif
/* Save the working directory into *WD, if it hasn't been saved
already. Return true if a child has been forked to do the real
work. */

View File

@@ -20,13 +20,7 @@
/* Specification. */
#include "unistr.h"
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
#endif
#include "attribute.h"
int
u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n)

View File

@@ -25,13 +25,7 @@
/* Specification. */
#include "unistr.h"
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
#endif
#include "attribute.h"
#if !HAVE_INLINE

View File

@@ -28,9 +28,5 @@
_GL_UNUSED_PARAMETER int *(*param)(void)
*/
#ifndef _GL_UNUSED_PARAMETER
# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
# define _GL_UNUSED_PARAMETER __attribute__ ((__unused__))
# else
# define _GL_UNUSED_PARAMETER
# endif
# define _GL_UNUSED_PARAMETER _GL_ATTRIBUTE_MAYBE_UNUSED
#endif

View File

@@ -94,6 +94,7 @@
/* Checked size_t computations. */
#include "xsize.h"
#include "attribute.h"
#include "verify.h"
#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
@@ -125,14 +126,6 @@
# include "fpucw.h"
#endif
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
# else
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
#endif
/* Default parameters. */
#ifndef VASNPRINTF
# if WIDE_CHAR_VERSION

View File

@@ -1,4 +1,4 @@
# gnulib-common.m4 serial 48
# gnulib-common.m4 serial 49
dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -15,6 +15,15 @@ AC_DEFUN([gl_COMMON], [
AC_REQUIRE([gl_ZZGNULIB])
])
AC_DEFUN([gl_COMMON_BODY], [
AH_VERBATIM([_GL_GNUC_PREREQ],
[/* True if the compiler says it groks GNU C version MAJOR.MINOR. */
#if defined __GNUC__ && defined __GNUC_MINOR__
# define _GL_GNUC_PREREQ(major, minor) \
((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
#else
# define _GL_GNUC_PREREQ(major, minor) 0
#endif
])
AH_VERBATIM([_Noreturn],
[/* The _Noreturn keyword of C11. */
#ifndef _Noreturn
@@ -31,12 +40,12 @@ AC_DEFUN([gl_COMMON_BODY], [
# define _Noreturn [[noreturn]]
# elif ((!defined __cplusplus || defined __clang__) \
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|| 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
|| _GL_GNUC_PREREQ (4, 7) \
|| (defined __apple_build_version__ \
? 6000000 <= __apple_build_version__ \
: 3 < __clang_major__ + (5 <= __clang_minor__))))
/* _Noreturn works as-is. */
# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
# elif _GL_GNUC_PREREQ (2, 8) || 0x5110 <= __SUNPRO_C
# define _Noreturn __attribute__ ((__noreturn__))
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
# define _Noreturn __declspec (noreturn)
@@ -55,48 +64,200 @@ AC_DEFUN([gl_COMMON_BODY], [
#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
# define __GNUC_STDC_INLINE__ 1
#endif])
AH_VERBATIM([unused_parameter],
[/* Define as a marker that can be attached to declarations that might not
be used. This helps to reduce warnings, such as from
GCC -Wunused-parameter. */
#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
# define _GL_UNUSED __attribute__ ((__unused__))
AH_VERBATIM([attribute],
[/* Attributes. */
#ifdef __has_attribute
# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
#else
# define _GL_UNUSED
#endif
/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
is a misnomer outside of parameter lists. */
#define _UNUSED_PARAMETER_ _GL_UNUSED
/* gcc supports the "unused" attribute on possibly unused labels, and
g++ has since version 4.5. Note to support C++ as well as C,
_GL_UNUSED_LABEL should be used with a trailing ; */
#if !defined __cplusplus || __GNUC__ > 4 \
|| (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
# define _GL_UNUSED_LABEL _GL_UNUSED
#else
# define _GL_UNUSED_LABEL
# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
# ifdef _ICC
# define _GL_ATTR_may_alias 0
# else
# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
# endif
# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_warn_unused_result_GL_GNUC_PREREQ (3, 4)
#endif
/* The __pure__ attribute was added in gcc 2.96. */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead.
[
#if _GL_HAS_ATTRIBUTE (alloc_size)
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
#else
# define _GL_ATTRIBUTE_PURE /* empty */
# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
#endif
/* The __const__ attribute was added in gcc 2.95. */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
#if _GL_HAS_ATTRIBUTE (always_inline)
# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
#else
# define _GL_ATTRIBUTE_ALWAYS_INLINE
#endif
#if _GL_HAS_ATTRIBUTE (artificial)
# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
#else
# define _GL_ATTRIBUTE_ARTIFICIAL
#endif
/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
<https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>. */
#if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__
# define _GL_ATTRIBUTE_COLD __attribute__ ((cold))
#else
# define _GL_ATTRIBUTE_COLD
#endif
#if _GL_HAS_ATTRIBUTE (const)
# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
#else
# define _GL_ATTRIBUTE_CONST /* empty */
# define _GL_ATTRIBUTE_CONST
#endif
/* The __malloc__ attribute was added in gcc 3. */
#if 3 <= __GNUC__
#if 201710L < __STDC_VERSION__
# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
#elif _GL_HAS_ATTRIBUTE (deprecated)
# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
#else
# define _GL_ATTRIBUTE_DEPRECATED
#endif
#if _GL_HAS_ATTRIBUTE (error)
# define _GL_ATTRIBUTE_ERROR(msg) __attribute__((__error__ (msg)))
# define _GL_ATTRIBUTE_WARNING(msg) __attribute__((__warning__ (msg)))
#else
# define _GL_ATTRIBUTE_ERROR(msg)
# define _GL_ATTRIBUTE_WARNING(msg)
#endif
#if _GL_HAS_ATTRIBUTE (externally_visible)
# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible))
#else
# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
#endif
/* FALLTHROUGH is special, because it always expands to something. */
#if 201710L < __STDC_VERSION__
# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
#elif _GL_HAS_ATTRIBUTE (fallthrough)
# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
#else
# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0)
#endif
#if _GL_HAS_ATTRIBUTE (format)
# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
#else
# define _GL_ATTRIBUTE_FORMAT(spec)
#endif
#if _GL_HAS_ATTRIBUTE (leaf)
# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__))
#else
# define _GL_ATTRIBUTE_LEAF
#endif
#if _GL_HAS_ATTRIBUTE (may_alias)
# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
#else
# define _GL_ATTRIBUTE_MAY_ALIAS
#endif
#if 201710L < __STDC_VERSION__
# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
#elif _GL_HAS_ATTRIBUTE (unused)
# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
#else
# define _GL_ATTRIBUTE_MAYBE_UNUSED
#endif
/* Earlier spellings of this macro. */
#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
#define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
#if _GL_HAS_ATTRIBUTE (malloc)
# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
#else
# define _GL_ATTRIBUTE_MALLOC /* empty */
# define _GL_ATTRIBUTE_MALLOC
#endif
#if 201710L < __STDC_VERSION__
# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
#elif _GL_HAS_ATTRIBUTE (warn_unused_result)
# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
#else
# define _GL_ATTRIBUTE_NODISCARD
#endif
#if _GL_HAS_ATTRIBUTE (noinline)
# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__))
#else
# define _GL_ATTRIBUTE_NOINLINE
#endif
#if _GL_HAS_ATTRIBUTE (nonnull)
# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args))
#else
# define _GL_ATTRIBUTE_NONNULL(args)
#endif
#if _GL_HAS_ATTRIBUTE (nonstring)
# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
#else
# define _GL_ATTRIBUTE_NONSTRING
#endif
/* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */
#if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
#else
# define _GL_ATTRIBUTE_NOTHROW
#endif
#if _GL_HAS_ATTRIBUTE (packed)
# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
#else
# define _GL_ATTRIBUTE_PACKED
#endif
#if _GL_HAS_ATTRIBUTE (pure)
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
#else
# define _GL_ATTRIBUTE_PURE
#endif
#if _GL_HAS_ATTRIBUTE (sentinel)
# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos))
#else
# define _GL_ATTRIBUTE_SENTINEL(pos)
#endif
]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
[
/* To support C++ as well as C, use _GL_UNUSED_LABEL with trailing ';'. */
#if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5)
# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_MAYBE_UNUSED
#else
# define _GL_UNUSED_LABEL
#endif
])
AH_VERBATIM([async_safe],

19
modules/attribute Normal file
View File

@@ -0,0 +1,19 @@
Description:
C/C++ attributes
Files:
lib/attribute.h
Depends-on:
configure.ac:
Makefile.am:
Include:
License:
LGPLv2+
Maintainer:
all

View File

@@ -10,6 +10,7 @@ m4/backupfile.m4
Depends-on:
argmatch
attribute
closedir
d-ino
dirent-safer

View File

@@ -10,6 +10,7 @@ m4/backupfile.m4
Depends-on:
argmatch
attribute
closedir
d-ino
dirent-safer

View File

@@ -22,6 +22,7 @@ m4/math_h.m4
m4/exponentd.m4
Depends-on:
attribute
isnand-nolibm
isnanl-nolibm
frexpl-nolibm

View File

@@ -10,6 +10,7 @@ m4/fnmatch.m4
Depends-on:
fnmatch-h
alloca [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
attribute [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
builtin-expect [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
flexmember [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]
stdbool [test $HAVE_FNMATCH = 0 || test $REPLACE_FNMATCH = 1]

View File

@@ -7,6 +7,7 @@ lib/stdio-safer.h
lib/freopen-safer.c
Depends-on:
attribute
dup2
freopen
open

View File

@@ -8,6 +8,7 @@ lib/fts-cycle.c
m4/fts.m4
Depends-on:
attribute
closedir
cycle-check
d-ino

View File

@@ -18,6 +18,7 @@ m4/visibility.m4
Depends-on:
uchar
attribute [test $HAVE_MBRTOC32 = 0 || test $REPLACE_MBRTOC32 = 1]
hard-locale [{ test $HAVE_MBRTOC32 = 0 || test $REPLACE_MBRTOC32 = 1; } && test $REPLACE_MBSTATE_T = 0]
mbrtowc [{ test $HAVE_MBRTOC32 = 0 || test $REPLACE_MBRTOC32 = 1; } && test $REPLACE_MBSTATE_T = 0]
localcharset [test $HAVE_MBRTOC32 = 0 || test $REPLACE_MBRTOC32 = 1]

View File

@@ -22,6 +22,7 @@ m4/visibility.m4
Depends-on:
wchar
extensions
attribute [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1]
stdint [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1]
hard-locale [{ test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; } && test $REPLACE_MBSTATE_T = 0]
mbsinit [{ test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; } && test $REPLACE_MBSTATE_T = 0]

View File

@@ -8,6 +8,7 @@ m4/tm_gmtoff.m4
m4/nstrftime.m4
Depends-on:
attribute
extensions
intprops
stdbool

View File

@@ -10,6 +10,7 @@ m4/mbrtowc.m4
m4/quotearg.m4
Depends-on:
attribute
c-strcaseeq
extensions
gettext-h

View File

@@ -8,6 +8,7 @@ m4/savewd.m4
Depends-on:
assure
attribute
chdir
errno
extern-inline

View File

@@ -30,6 +30,7 @@ unistr/u16-strlen
unistr/u16-strmblen
unistr/u32-strlen
unistr/u32-strmblen
attribute
isnand-nolibm
isnanl-nolibm
frexpl-nolibm

View File

@@ -30,6 +30,7 @@ unistr/u16-strlen
unistr/u16-strmblen
unistr/u32-strlen
unistr/u32-strmblen
attribute
isnand-nolibm
isnanl-nolibm
frexpl-nolibm

View File

@@ -30,6 +30,7 @@ unistr/u16-strlen
unistr/u16-strmblen
unistr/u32-strlen
unistr/u32-strmblen
attribute
isnand-nolibm
isnanl-nolibm
frexpl-nolibm

View File

@@ -30,6 +30,7 @@ unistr/u16-strlen
unistr/u16-strmblen
unistr/u32-strlen
unistr/u32-strmblen
attribute
isnand-nolibm
isnanl-nolibm
frexpl-nolibm

View File

@@ -30,6 +30,7 @@ unistr/u16-strlen
unistr/u16-strmblen
unistr/u32-strlen
unistr/u32-strmblen
attribute
isnand-nolibm
isnanl-nolibm
frexpl-nolibm

View File

@@ -30,6 +30,7 @@ unistr/u16-strlen
unistr/u16-strmblen
unistr/u32-strlen
unistr/u32-strmblen
attribute
isnand-nolibm
isnanl-nolibm
frexpl-nolibm

View File

@@ -27,6 +27,7 @@ unistr/u16-strlen
unistr/u16-strmblen
unistr/u32-strlen
unistr/u32-strmblen
attribute
mbsnlen
isnand-nolibm
isnanl-nolibm

View File

@@ -7,6 +7,7 @@ lib/unistr/u8-uctomb-aux.c
Depends-on:
unistr/base
attribute
configure.ac:
gl_MODULE_INDICATOR([unistr/u8-uctomb])

View File

@@ -22,6 +22,7 @@ m4/exponentd.m4
Depends-on:
alloca-opt
attribute
float
stdint
xsize