File: gcc-function-attributes.h

package info (click to toggle)
findutils 4.9.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,424 kB
  • sloc: ansic: 109,201; sh: 10,207; yacc: 1,851; exp: 839; makefile: 830; python: 66; sed: 16
file content (233 lines) | stat: -rw-r--r-- 6,984 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/* gcc-function-attribtues.h -- GCC-specific function attributes

   Copyright (C) 2016-2022 Free Software Foundation, Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU 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 General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/

/*
 Be aware that some function attributes do not work with function
 pointers.  See
 https://lists.gnu.org/r/bug-gnulib/2011-04/msg00007.html
 for details.
*/
#ifndef _GCC_FUNCTION_ATTRIBUTES_H
# define _GCC_FUNCTION_ATTRIBUTES_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

/*
The following attributes are currently (GCC-4.4.5) defined for
functions on all targets.  Where this file provides a macro
for using it, the macro name is given in the second column.

Attribute                 Macro (if implemented in this file)
-------------------------------------------------------------------------------
alias
aligned
alloc_size		  _GL_ATTRIBUTE_ALLOC_SIZE(arg_num)
always_inline
artificial
cold
const
constructor
deprecated		  _GL_ATTRIBUTE_DEPRECATED
destructor
error
externally_visible
flatten
format			  _GL_ATTRIBUTE_FORMAT(spec)
                          _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(fmt,firstarg)
                          _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(fmt,firstarg)
                          _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(fmt,firstarg)
                          _GL_ATTRIBUTE_FORMAT_SCANF(fmt,firstarg)
format_arg
gnu_inline
hot
malloc			  _GL_ATTRIBUTE_MALLOC
no_instrument_function
noinline
nonnull			  _GL_ATTRIBUTE_NONNULL(args)
                          _GL_ARG_NONNULL(args)
noreturn		  _GL_ATTRIBUTE_NORETURN
nothrow
pure			  _GL_ATTRIBUTE_PURE
returns_twice
section
sentinel		  _GL_ATTRIBUTE_SENTINEL
unused
used
warn_unused_result        _GL_ATTRIBUTE_WUR
warning
weak
*/

/*
Attributes used in gnulib, but which appear to be platform-specific
regparm
stdcall
*/

/*
Attributes used in gnulib with special arguments
Macro         Args
visibility    "default"
*/

/*
   The __attribute__ feature is available in gcc versions 2.5 and later.
   The underscored __format__ spelling of the attribute names requires 2.6.4 (we check for 2.7).
*/


# ifndef _GL_ATTRIBUTE_ALLOC_SIZE
#  if __GNUC_PREREQ(4,3)
#   define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
#  else
#   define _GL_ATTRIBUTE_ALLOC_SIZE(args) /* unsupported */
#  endif
# endif

# ifndef _GL_ATTRIBUTE_DEPRECATED
#  if __GNUC_PREREQ(3,1)
#   define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
#  else
#   define _GL_ATTRIBUTE_DEPRECATED /* empty */
#  endif
# endif

# ifndef _GL_ATTRIBUTE_FORMAT
#  if __GNUC_PREREQ(2,7)
#   define _GL_ATTRIBUTE_FORMAT(spec)  __attribute__ ((__format__ spec))
#  else
#   define _GL_ATTRIBUTE_FORMAT(spec) /* unsupported */
#  endif
# endif

# ifndef _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM
#  if __GNUC_PREREQ(2,7)
#   define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
    _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
#  else
#   define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(spec) /* unsupported */
#  endif
# endif

# ifndef _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD
#  if __GNUC_PREREQ(2,7)
#   if __GNUC_PREREQ(4,4)
#    define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
     _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
#   else
#    define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
     _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
#   endif
#  else
#   define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(spec) /* unsupported */
#  endif
# endif

# ifndef _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM
#  if __GNUC_PREREQ(2,7)
#   define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
    _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
#  else
#   define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(spec) /* unsupported */
#  endif
# endif

# ifndef _GL_ATTRIBUTE_FORMAT_SCANF
#  if __GNUC_PREREQ(2,7)
#   if __GNUC_PREREQ(4,4)
#    define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
     _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
#   else
#    define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
     _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
#   endif
#  else
#   define _GL_ATTRIBUTE_FORMAT_SCANF(spec) /* unsupported */
#  endif
# endif

# ifndef _GL_ATTRIBUTE_MALLOC
#  if __GNUC_PREREQ(3,0)
#   define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
#  else
#   define _GL_ATTRIBUTE_MALLOC /* unsupported */
#  endif
# endif


# ifndef _GL_ATTRIBUTE_NONNULL
#  if __GNUC_PREREQ(3,3)
#   define _GL_ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
#  else
#   define _GL_ATTRIBUTE_NONNULL(m) /* unsupported */
#  endif
# endif
# ifndef _GL_ARG_NONNULL
/* alternative spelling used in gnulib's stdio.h */
#  define _GL_ARG_NONNULL(m) _GL_ATTRIBUTE_NONNULL(m)
# endif


# ifndef _GL_ATTRIBUTE_NORETURN
#  if __GNUC_PREREQ(2,8)
#   define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
#  else
#   define _GL_ATTRIBUTE_NORETURN /* unsupported */
#  endif
# endif

# ifndef _GL_ATTRIBUTE_PURE
#  if __GNUC_PREREQ(2,96)
#   define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
#  else
#   define _GL_ATTRIBUTE_PURE /* unsupported */
#  endif
# endif

# ifndef _GL_ATTRIBUTE_SENTINEL
#  if __GNUC_PREREQ(4,0)
  /* gnulib uses the __attribute__((__sentinel__)) variant, for which the
    argument number 0 is assumed.  Arguments are counted backwards, the last
    being 0.
  */
#   define _GL_ATTRIBUTE_SENTINEL(backward_arg_num) __attribute__ ((__sentinel__(backward_arg_num)))
#  else
#   define _GL_ATTRIBUTE_SENTINEL(backward_arg_num) /* unsupported */
#  endif
# endif

# ifndef _GL_ATTRIBUTE_WUR
#  if __GNUC_PREREQ(3,4)
#   define _GL_ATTRIBUTE_WUR __attribute__ ((__warn__unused_result__))
#  else
#   define _GL_ATTRIBUTE_WUR /* unsupported */
#  endif
# endif
# ifndef _GL_ATTRIBUTE_RETURN_CHECK
/* gnulib is inconsistent in which macro it uses; support both for now. */
#  define _GL_ATTRIBUTE_RETURN_CHECK _GL_ATTRIBUTE_WUR
# endif

#endif /* _GCC_FUNCTION_ATTRIBUTES_H */