headers: properly decorate attributes

Found by:
find -name '*.h' |xargs grep -i 'attribute.*(([a-z]'

For an example of the type of bugs this causes, try compiling this valid
C11 program (it's valid because 'noreturn' is reserved for use in the
user namespace unless you include <stdnoreturn.h>):

$ cat foo.c
#define noreturn __attribute__((noreturn))
#include <stdlib.h>
$ gcc -c -o foo.o -Wall foo.c
In file included from /usr/include/stdlib.h:11:0,
                 from foo.c:2:
foo.c:1:18: error: expected ')' before '__attribute__'
 #define noreturn __attribute__((noreturn))
                  ^
/usr/include/stdlib.h:66:28: error: expected ',' or ';' before ')' token
 _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn)));
                            ^

* libc/machine/spu/spu_timer_internal.h: Decorate attribute names
with __, for namespace safety.
* libc/machine/xscale/machine/profile.h: Likewise.
* libc/include/stdlib.h: Likewise.
* libc/include/_ansi.h: Likewise.
* libc/include/sys/unistd.h: Likewise.
* libc/sys/linux/linuxthreads/libc-symbols.h: Likewise.
* libc/sys/linux/linuxthreads/internals.h: Likewise.
* libc/sys/linux/machine/i386/weakalias.h: Likewise.
* libc/sys/linux/machine/i386/dl-procinfo.h: Likewise.
* libc/sys/linux/machine/i386/dl-machine.h: Likewise.
* libc/sys/linux/libc-symbols.h: Likewise.
* libc/sys/linux/iconv/gconv_charset.h: Likewise.
* libc/sys/linux/include/resolv.h: Likewise.
* libc/sys/linux/sys/unistd.h: Likewise.
* libc/sys/linux/dl/atomicity.h: Likewise.
* libc/sys/linux/dl/dynamic-link.h: Likewise.
* libc/sys/linux/dl/ldsodefs.h: Likewise.
This commit is contained in:
Eric Blake 2014-08-01 15:44:51 +00:00
parent 02206cd3e4
commit ada456dcfe
18 changed files with 85 additions and 64 deletions

View File

@ -1,3 +1,24 @@
2014-08-01 Eric Blake <eblake@redhat.com>
* libc/machine/spu/spu_timer_internal.h: Decorate attribute names
with __, for namespace safety.
* libc/machine/xscale/machine/profile.h: Likewise.
* libc/include/stdlib.h: Likewise.
* libc/include/_ansi.h: Likewise.
* libc/include/sys/unistd.h: Likewise.
* libc/sys/linux/linuxthreads/libc-symbols.h: Likewise.
* libc/sys/linux/linuxthreads/internals.h: Likewise.
* libc/sys/linux/machine/i386/weakalias.h: Likewise.
* libc/sys/linux/machine/i386/dl-procinfo.h: Likewise.
* libc/sys/linux/machine/i386/dl-machine.h: Likewise.
* libc/sys/linux/libc-symbols.h: Likewise.
* libc/sys/linux/iconv/gconv_charset.h: Likewise.
* libc/sys/linux/include/resolv.h: Likewise.
* libc/sys/linux/sys/unistd.h: Likewise.
* libc/sys/linux/dl/atomicity.h: Likewise.
* libc/sys/linux/dl/dynamic-link.h: Likewise.
* libc/sys/linux/dl/ldsodefs.h: Likewise.
2014-07-30 Corinna Vinschen <vinschen@redhat.com>
* libc/string/strerror.c: Fix documentation so makedoc doesn't

View File

@ -35,7 +35,7 @@
#define _END_STD_C }
#endif
#if __GNUC_PREREQ (3, 3)
#define _NOTHROW __attribute__ ((nothrow))
#define _NOTHROW __attribute__ ((__nothrow__))
#else
#define _NOTHROW throw()
#endif

View File

@ -63,7 +63,7 @@ int _EXFUN(__locale_mb_cur_max,(_VOID));
#define MB_CUR_MAX __locale_mb_cur_max()
_VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn)));
_VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((__noreturn__)));
int _EXFUN(abs,(int));
int _EXFUN(atexit,(_VOID (*__func)(_VOID)));
double _EXFUN(atof,(const char *__nptr));
@ -81,7 +81,7 @@ _PTR _EXFUN(bsearch,(const _PTR __key,
__compar_fn_t _compar));
_PTR _EXFUN_NOTHROW(calloc,(size_t __nmemb, size_t __size));
div_t _EXFUN(div,(int __numer, int __denom));
_VOID _EXFUN(exit,(int __status) _ATTRIBUTE ((noreturn)));
_VOID _EXFUN(exit,(int __status) _ATTRIBUTE ((__noreturn__)));
_VOID _EXFUN_NOTHROW(free,(_PTR));
char * _EXFUN(getenv,(const char *__string));
char * _EXFUN(_getenv_r,(struct _reent *, const char *__string));
@ -151,7 +151,7 @@ long _EXFUN(a64l,(const char *__input));
char * _EXFUN(l64a,(long __input));
char * _EXFUN(_l64a_r,(struct _reent *,long __input));
int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg));
_VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((noreturn)));
_VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((__noreturn__)));
int _EXFUN(putenv,(char *__string));
int _EXFUN(_putenv_r,(struct _reent *, char *__string));
_PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t));

View File

@ -15,7 +15,7 @@ extern "C" {
extern char **environ;
void _EXFUN(_exit, (int __status ) _ATTRIBUTE ((noreturn)));
void _EXFUN(_exit, (int __status ) _ATTRIBUTE ((__noreturn__)));
int _EXFUN(access,(const char *__path, int __amode ));
unsigned _EXFUN(alarm, (unsigned __secs ));

View File

@ -53,12 +53,12 @@ typedef enum spu_timer_state
typedef struct spu_timer
{
int tmout __attribute__ ((aligned (16))); /* Time until expiration (tb). */
int intvl __attribute__ ((aligned (16))); /* Interval. */
int id __attribute__ ((aligned (16)));
spu_timer_state_t state __attribute__ ((aligned (16)));
void (*func) (int) __attribute__ ((aligned (16))); /* Handler. */
struct spu_timer *next __attribute__ ((aligned (16)));
int tmout __attribute__ ((__aligned__ (16))); /* Time until expiration (tb). */
int intvl __attribute__ ((__aligned__ (16))); /* Interval. */
int id __attribute__ ((__aligned__ (16)));
spu_timer_state_t state __attribute__ ((__aligned__ (16)));
void (*func) (int) __attribute__ ((__aligned__ (16))); /* Handler. */
struct spu_timer *next __attribute__ ((__aligned__ (16)));
} spu_timer_t;

View File

@ -33,7 +33,7 @@
#endif
#define _MCOUNT_DECL(frompc, selfpc) \
void __attribute__ ((no_instrument_function)) \
void __attribute__ ((__no_instrument_function__)) \
mcount_internal (frompc, selfpc)
/* mcount_internal expects two arguments
@ -53,8 +53,8 @@ mcount_internal (frompc, selfpc)
#ifdef __thumb__
#define MCOUNT \
void __attribute__ ((naked)) \
__attribute__ ((no_instrument_function)) \
void __attribute__ ((__naked__)) \
__attribute__ ((__no_instrument_function__)) \
mcount (void) \
{ \
__asm__("push {r0, r1, r2, r3, lr};" \
@ -69,8 +69,8 @@ mcount (void) \
}
#else
#define MCOUNT \
void __attribute__ ((naked)) \
__attribute__ ((no_instrument_function)) \
void __attribute__ ((__naked__)) \
__attribute__ ((__no_instrument_function__)) \
mcount (void) \
{ \
__asm__("stmdb sp!, {r0, r1, r2, r3, lr};" \

View File

@ -23,7 +23,7 @@
static inline uint32_t
__attribute__ ((unused))
__attribute__ ((__unused__))
exchange_and_add (volatile uint32_t *mem, uint32_t val)
{
register uint32_t result;
@ -33,7 +33,7 @@ exchange_and_add (volatile uint32_t *mem, uint32_t val)
}
static inline void
__attribute__ ((unused))
__attribute__ ((__unused__))
atomic_add (volatile uint32_t *mem, int val)
{
__asm__ __volatile__ ("lock; addl %1,%0"
@ -41,7 +41,7 @@ atomic_add (volatile uint32_t *mem, int val)
}
static inline char
__attribute__ ((unused))
__attribute__ ((__unused__))
compare_and_swap (volatile long int *p, long int oldval, long int newval)
{
char ret;

View File

@ -31,12 +31,12 @@
/* Global read-only variable defined in rtld.c which is nonzero if we
shall give more warning messages. */
extern int _dl_verbose __attribute__ ((unused));
extern int _dl_verbose __attribute__ ((__unused__));
/* Read the dynamic section at DYN and fill in INFO with indices DT_*. */
static void __attribute__ ((unused))
static void __attribute__ ((__unused__))
elf_get_dynamic_info (struct link_map *l)
{
ElfW(Dyn) *dyn = l->l_ld;

View File

@ -162,7 +162,7 @@ struct libname_list
/* Test whether given NAME matches any of the names of the given object. */
static __inline int
__attribute__ ((unused))
__attribute__ ((__unused__))
_dl_name_match_p (const char *__name, struct link_map *__map)
{
int __found = strcmp (__name, __map->l_name) == 0;

View File

@ -53,7 +53,7 @@ strip (char *wp, const char *s)
}
static char * __attribute__ ((unused))
static char * __attribute__ ((__unused__))
upstr (char *dst, const char *str)
{
char *cp = dst;

View File

@ -150,7 +150,7 @@ struct __res_state {
u_int16_t nsinit;
struct sockaddr_in6 *nsaddrs[MAXNS];
unsigned long long int initstamp
__attribute__((packed));
__attribute__((__packed__));
#if 0
unsigned int _initstamp[2];
#endif

View File

@ -91,12 +91,12 @@
/* Define ALIASNAME as a strong alias for NAME. */
# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
# define _strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
extern __typeof (name) aliasname __attribute__ ((__alias__ (#name)));
/* This comes between the return type and function name in
a function definition to make that definition weak. */
# define weak_function __attribute__ ((weak))
# define weak_const_function __attribute__ ((weak, __const__))
# define weak_function __attribute__ ((__weak__))
# define weak_const_function __attribute__ ((__weak__, __const__))
# ifdef HAVE_WEAK_SYMBOLS
@ -104,7 +104,7 @@
If weak aliases are not available, this defines a strong alias. */
# define weak_alias(name, aliasname) _weak_alias (name, aliasname)
# define _weak_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
extern __typeof (name) aliasname __attribute__ ((__weak__, __alias__ (#name)));
/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
# define weak_extern(symbol) _weak_extern (symbol)
@ -213,12 +213,12 @@
# define link_warning(symbol, msg) \
__make_section_unallocated (".gnu.warning." #symbol) \
static const char __evoke_link_warning_##symbol[] \
__attribute__ ((section (".gnu.warning." #symbol "\"\n\t#\""))) = msg;
__attribute__ ((__section__ (".gnu.warning." #symbol "\"\n\t#\""))) = msg;
# else
# define link_warning(symbol, msg) \
__make_section_unallocated (".gnu.warning." #symbol) \
static const char __evoke_link_warning_##symbol[] \
__attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg;
__attribute__ ((__section__ (".gnu.warning." #symbol "\n\t#"))) = msg;
# endif
# else /* Not ELF: a.out */
# ifdef HAVE_XCOFF
@ -267,11 +267,11 @@
because it will need to be relocated at run time anyway. */
# define _elf_set_element(set, symbol) \
static const void *__elf_set_##set##_element_##symbol##__ \
__attribute__ ((unused, section (#set))) = &(symbol)
__attribute__ ((__unused__, __section__ (#set))) = &(symbol)
# else
# define _elf_set_element(set, symbol) \
static const void *const __elf_set_##set##_element_##symbol##__ \
__attribute__ ((unused, section (#set))) = &(symbol)
__attribute__ ((__unused__, __section__ (#set))) = &(symbol)
# endif
/* Define SET as a symbol set. This may be required (it is in a.out) to
@ -367,9 +367,9 @@
special section. */
#ifndef __ASSEMBLER__
# define attribute_compat_text_section \
__attribute__ ((section (".text.compat")))
__attribute__ ((__section__ (".text.compat")))
# define attribute_compat_data_section \
__attribute__ ((section (".data.compat")))
__attribute__ ((__section__ (".data.compat")))
#else
# define compat_text_section .section ".text.compat", "ax";
# define compat_data_section .section ".data.compat", "aw";

View File

@ -187,7 +187,7 @@ struct _pthread_descr_struct {
hp_timing_t p_cpuclock_offset; /* Initial CPU clock for thread. */
#endif
/* New elements must be added at the end. */
} __attribute__ ((aligned(32))); /* We need to align the structure so that
} __attribute__ ((__aligned__(32))); /* We need to align the structure so that
doubles are aligned properly. This is 8
bytes on MIPS and 16 bytes on MIPS64.
32 bytes might give better cache
@ -374,9 +374,9 @@ static inline int nonexisting_handle(pthread_handle h, pthread_t id)
/* Recover thread descriptor for the current thread */
extern pthread_descr __pthread_find_self (void) __attribute__ ((const));
extern pthread_descr __pthread_find_self (void) __attribute__ ((__const__));
static inline pthread_descr thread_self (void) __attribute__ ((const));
static inline pthread_descr thread_self (void) __attribute__ ((__const__));
static inline pthread_descr thread_self (void)
{
#ifdef THREAD_SELF

View File

@ -91,12 +91,12 @@
/* Define ALIASNAME as a strong alias for NAME. */
# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
# define _strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
extern __typeof (name) aliasname __attribute__ ((__alias__ (#name)));
/* This comes between the return type and function name in
a function definition to make that definition weak. */
# define weak_function __attribute__ ((weak))
# define weak_const_function __attribute__ ((weak, __const__))
# define weak_function __attribute__ ((__weak__))
# define weak_const_function __attribute__ ((__weak__, __const__))
# ifdef HAVE_WEAK_SYMBOLS
@ -104,7 +104,7 @@
If weak aliases are not available, this defines a strong alias. */
# define weak_alias(name, aliasname) _weak_alias (name, aliasname)
# define _weak_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
extern __typeof (name) aliasname __attribute__ ((__weak__, __alias__ (#name)));
/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
# define weak_extern(symbol) _weak_extern (symbol)
@ -213,12 +213,12 @@
# define link_warning(symbol, msg) \
__make_section_unallocated (".gnu.warning." #symbol) \
static const char __evoke_link_warning_##symbol[] \
__attribute__ ((section (".gnu.warning." #symbol "\"\n\t#\""))) = msg;
__attribute__ ((__section__ (".gnu.warning." #symbol "\"\n\t#\""))) = msg;
# else
# define link_warning(symbol, msg) \
__make_section_unallocated (".gnu.warning." #symbol) \
static const char __evoke_link_warning_##symbol[] \
__attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg;
__attribute__ ((__section__ (".gnu.warning." #symbol "\n\t#"))) = msg;
# endif
# else /* Not ELF: a.out */
# ifdef HAVE_XCOFF
@ -267,11 +267,11 @@
because it will need to be relocated at run time anyway. */
# define _elf_set_element(set, symbol) \
static const void *__elf_set_##set##_element_##symbol##__ \
__attribute__ ((unused, section (#set))) = &(symbol)
__attribute__ ((__unused__, __section__ (#set))) = &(symbol)
# else
# define _elf_set_element(set, symbol) \
static const void *const __elf_set_##set##_element_##symbol##__ \
__attribute__ ((unused, section (#set))) = &(symbol)
__attribute__ ((__unused__, __section__ (#set))) = &(symbol)
# endif
/* Define SET as a symbol set. This may be required (it is in a.out) to

View File

@ -26,7 +26,7 @@
#include <machine/weakalias.h>
/* Return nonzero iff ELF header is compatible with the running host. */
static inline int __attribute__ ((unused))
static inline int __attribute__ ((__unused__))
elf_machine_matches_host (const Elf32_Ehdr *ehdr)
{
return ehdr->e_machine == EM_386;
@ -36,7 +36,7 @@ elf_machine_matches_host (const Elf32_Ehdr *ehdr)
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
first element of the GOT. This must be inlined in a function which
uses global data. */
static inline Elf32_Addr __attribute__ ((unused))
static inline Elf32_Addr __attribute__ ((__unused__))
elf_machine_dynamic (void)
{
register Elf32_Addr *got asm ("%ebx");
@ -45,7 +45,7 @@ elf_machine_dynamic (void)
/* Return the run-time load address of the shared object. */
static inline Elf32_Addr __attribute__ ((unused))
static inline Elf32_Addr __attribute__ ((__unused__))
elf_machine_load_address (void)
{
Elf32_Addr addr;
@ -65,16 +65,16 @@ elf_machine_load_address (void)
/* GKM FIXME: Fix trampoline to pass bounds so we can do
without the `__unbounded' qualifier. */
static ElfW(Addr) fixup (struct link_map *__unbounded l, ElfW(Word) reloc_offset)
__attribute__ ((regparm (2), unused));
__attribute__ ((__regparm__ (2), __unused__));
static ElfW(Addr) profile_fixup (struct link_map *l, ElfW(Word) reloc_offset,
ElfW(Addr) retaddr)
__attribute__ ((regparm (3), unused));
__attribute__ ((__regparm__ (3), __unused__));
#endif
/* Set up the loaded object described by L so its unrelocated PLT
entries will jump to the on-demand fixup code in dl-runtime.c. */
static inline int __attribute__ ((unused))
static inline int __attribute__ ((__unused__))
elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
{
Elf32_Addr *got;
@ -268,7 +268,7 @@ _dl_start_user:\n\
extern const char *_dl_platform;
static inline void __attribute__ ((unused))
static inline void __attribute__ ((__unused__))
dl_platform_init (void)
{
if (_dl_platform != NULL && *_dl_platform == '\0')
@ -292,13 +292,13 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc,
return value;
}
static inline void __attribute__ ((unused))
static inline void __attribute__ ((__unused__))
elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
const Elf32_Sym *sym, const struct r_found_version *version,
Elf32_Addr *const reloc_addr,
struct r_scope_elem *scope[]);
static inline void __attribute__ ((unused))
static inline void __attribute__ ((__unused__))
elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
Elf32_Addr *const reloc_addr);
@ -313,7 +313,7 @@ elf_machine_lazy_rel (struct link_map *map,
/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
MAP is the object containing the reloc. */
static inline void __attribute__ ((unused))
static inline void __attribute__ ((__unused__))
elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
const Elf32_Sym *sym, const struct r_found_version *version,
Elf32_Addr *const reloc_addr,
@ -396,7 +396,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
}
}
static inline void __attribute__ ((unused))
static inline void __attribute__ ((__unused__))
elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
Elf32_Addr *const reloc_addr)
{

View File

@ -38,7 +38,7 @@ extern const char _dl_x86_platforms[][5];
static inline int
__attribute__ ((unused))
__attribute__ ((__unused__))
_dl_procinfo (int word)
{
/* This table should match the information from arch/i386/kernel/setup.c
@ -57,14 +57,14 @@ _dl_procinfo (int word)
}
static inline const char *
__attribute__ ((unused))
__attribute__ ((__unused__))
_dl_hwcap_string (int idx)
{
return _dl_x86_cap_flags[idx];
};
static inline const char *
__attribute__ ((unused))
__attribute__ ((__unused__))
_dl_platform_string (int idx)
{
return _dl_x86_platforms [idx - _DL_FIRST_PLATFORM];
@ -100,7 +100,7 @@ enum
};
static inline int
__attribute__ ((unused))
__attribute__ ((__unused__))
_dl_string_hwcap (const char *str)
{
int i;
@ -115,7 +115,7 @@ _dl_string_hwcap (const char *str)
static inline int
__attribute__ ((unused))
__attribute__ ((__unused__))
_dl_string_platform (const char *str)
{
int i;

View File

@ -1,10 +1,10 @@
#define weak_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
extern __typeof (name) aliasname __attribute__ ((__weak__, __alias__ (#name)));
#if 0
#define weak_extern(symbol) _weak_extern (symbol)
#define _weak_extern(symbol) asm (".weak " #symbol);
#endif
#define weak_function __attribute__ ((weak))
#define weak_function __attribute__ ((__weak__))

View File

@ -16,7 +16,7 @@ extern "C" {
extern char **environ;
void _EXFUN(_exit, (int __status ) _ATTRIBUTE ((noreturn)));
void _EXFUN(_exit, (int __status ) _ATTRIBUTE ((__noreturn__)));
int _EXFUN(access,(const char *__path, int __amode ));
unsigned _EXFUN(alarm, (unsigned __secs ));