Commit | Line | Data |
---|---|---|
0b272666 JH |
1 | ?RCS: $Id: d_attribut.U,v 3.0.1.3 1995/01/30 14:33:45 ram Exp $ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1991-1993, Raphael Manfredi | |
4 | ?RCS: | |
5 | ?RCS: You may redistribute only under the terms of the Artistic Licence, | |
6 | ?RCS: as specified in the README file that comes with the distribution. | |
7 | ?RCS: You may reuse parts of this distribution only within the terms of | |
8 | ?RCS: that same Artistic Licence; a copy of which may be found at the root | |
9 | ?RCS: of the source tree for dist 3.0. | |
10 | ?RCS: | |
11 | ?RCS: Original Author: Andy Dougherty <doughera@lafcol.lafayette.edu> | |
12 | ?RCS: | |
13 | ?RCS: $Log: d_attribut.U,v $ | |
14 | ?RCS: Revision 3.0.1.3 1995/01/30 14:33:45 ram | |
15 | ?RCS: patch49: test C program now includes <stdio.h> (WED) | |
16 | ?RCS: | |
17 | ?RCS: Revision 3.0.1.2 1995/01/11 15:25:47 ram | |
18 | ?RCS: patch45: fixed typo in the d_attribut variable (ADO) | |
19 | ?RCS: | |
20 | ?RCS: Revision 3.0.1.1 1994/10/29 16:08:55 ram | |
21 | ?RCS: patch36: created by ADO | |
22 | ?RCS: | |
c87b5532 RB |
23 | ?MAKE:d_attribute_format d_attribute_malloc d_attribute_nonnull \ |
24 | d_attribute_noreturn d_attribute_pure d_attribute_unused \ | |
25 | d_attribute_warn_unused_result d_printf_format_null: \ | |
26 | Myread Oldconfig cat cc ccflags rm Setvar contains i_stdlib run | |
0b272666 | 27 | ?MAKE: -pick add $@ %< |
7ff25ab7 MB |
28 | ?S:d_attribute_format (d_attribut_format.U): |
29 | ?S: This variable conditionally defines HASATTRIBUTE_FORMAT, which | |
30 | ?S: indicates the C compiler can check for printf-like formats. | |
0b272666 | 31 | ?S:. |
c87b5532 RB |
32 | ?S:d_printf_format_null: |
33 | ?S: This variable conditionally defines PRINTF_FORMAT_NULL_OK, which | |
34 | ?S: indicates the C compiler allows printf-like formats to be null. | |
35 | ?S:. | |
7ff25ab7 MB |
36 | ?S:d_attribute_malloc (d_attribute_malloc.U): |
37 | ?S: This variable conditionally defines HASATTRIBUTE_MALLOC, which | |
38 | ?S: indicates the C compiler can understand functions as having | |
39 | ?S: malloc-like semantics. | |
40 | ?S:. | |
41 | ?S:d_attribute_nonnull (d_attribute_nonnull.U): | |
42 | ?S: This variable conditionally defines HASATTRIBUTE_NONNULL, which | |
43 | ?S: indicates that the C compiler can know that certain arguments | |
44 | ?S: must not be NULL, and will check accordingly at compile time. | |
45 | ?S:. | |
46 | ?S:d_attribute_noreturn (d_attribute_noreturn.U): | |
47 | ?S: This variable conditionally defines HASATTRIBUTE_NORETURN, which | |
48 | ?S: indicates that the C compiler can know that certain functions | |
49 | ?S: are guaranteed never to return. | |
50 | ?S:. | |
51 | ?S:d_attribute_pure (d_attribute_pure.U): | |
52 | ?S: This variable conditionally defines HASATTRIBUTE_PURE, which | |
53 | ?S: indicates that the C compiler can know that certain functions | |
54 | ?S: are "pure" functions, meaning that they have no side effects, and | |
55 | ?S: only rely on function input and/or global data for their results. | |
56 | ?S:. | |
57 | ?S:d_attribute_unused (d_attribute_unused.U): | |
58 | ?S: This variable conditionally defines HASATTRIBUTE_UNUSED, which | |
59 | ?S: indicates that the C compiler can know that certain variables | |
60 | ?S: and arguments may not always be used, and to not throw warnings | |
61 | ?S: if they don't get used. | |
62 | ?S:. | |
63 | ?S:d_attribute_warn_unused_result (d_attribute_warn_unused_result.U): | |
64 | ?S: This variable conditionally defines | |
65 | ?S: HASATTRIBUTE_WARN_UNUSED_RESULT, which indicates that the C | |
66 | ?S: compiler can know that certain functions have a return values | |
67 | ?S: that must not be ignored, such as malloc() or open(). | |
68 | ?S:. | |
69 | ?C:HASATTRIBUTE_FORMAT ~ %< (GNUC_ATTRIBUTE_CHECK): | |
70 | ?C: Can we handle GCC attribute for checking printf-style formats | |
71 | ?C:. | |
c87b5532 RB |
72 | ?C:PRINTF_FORMAT_NULL_OK: |
73 | ?C: Allows __printf__ format to be null when checking printf-style | |
74 | ?C:. | |
7ff25ab7 MB |
75 | ?C:HASATTRIBUTE_MALLOC: |
76 | ?C: Can we handle GCC attribute for malloc-style functions. | |
77 | ?C:. | |
78 | ?C:HASATTRIBUTE_NONNULL: | |
79 | ?C: Can we handle GCC attribute for nonnull function parms. | |
80 | ?C:. | |
81 | ?C:HASATTRIBUTE_NORETURN: | |
82 | ?C: Can we handle GCC attribute for functions that do not return | |
0b272666 | 83 | ?C:. |
7ff25ab7 MB |
84 | ?C:HASATTRIBUTE_PURE: |
85 | ?C: Can we handle GCC attribute for pure functions | |
86 | ?C:. | |
87 | ?C:HASATTRIBUTE_UNUSED: | |
88 | ?C: Can we handle GCC attribute for unused variables and arguments | |
89 | ?C:. | |
90 | ?C:HASATTRIBUTE_WARN_UNUSED_RESULT ~ %< (HASATTRIBUTE): | |
91 | ?C: Can we handle GCC attribute for warning on unused results | |
92 | ?C:. | |
93 | ?H:?%<:#$d_attribute_format HASATTRIBUTE_FORMAT /**/ | |
c87b5532 | 94 | ?H:?%<:#$d_printf_format_null PRINTF_FORMAT_NULL_OK /**/ |
7ff25ab7 MB |
95 | ?H:?%<:#$d_attribute_noreturn HASATTRIBUTE_NORETURN /**/ |
96 | ?H:?%<:#$d_attribute_malloc HASATTRIBUTE_MALLOC /**/ | |
97 | ?H:?%<:#$d_attribute_nonnull HASATTRIBUTE_NONNULL /**/ | |
98 | ?H:?%<:#$d_attribute_pure HASATTRIBUTE_PURE /**/ | |
99 | ?H:?%<:#$d_attribute_unused HASATTRIBUTE_UNUSED /**/ | |
100 | ?H:?%<:#$d_attribute_warn_unused_result HASATTRIBUTE_WARN_UNUSED_RESULT /**/ | |
0b272666 | 101 | ?H:. |
7ff25ab7 | 102 | ?LINT:set d_attribute_format |
c87b5532 | 103 | ?LINT:set d_printf_format_null |
7ff25ab7 MB |
104 | ?LINT:set d_attribute_malloc |
105 | ?LINT:set d_attribute_nonnull | |
106 | ?LINT:set d_attribute_noreturn | |
107 | ?LINT:set d_attribute_pure | |
108 | ?LINT:set d_attribute_unused | |
109 | ?LINT:set d_attribute_warn_unused_result | |
110 | : Look for GCC-style attribute format | |
111 | case "$d_attribute_format" in | |
112 | '') | |
113 | echo " " | |
114 | echo "Checking whether your compiler can handle __attribute__((format)) ..." >&4 | |
115 | $cat >attrib.c <<'EOCP' | |
116 | #include <stdio.h> | |
117 | void my_special_printf(char* pat,...) __attribute__((__format__(__printf__,1,2))); | |
118 | EOCP | |
119 | if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then | |
120 | if $contains 'warning' attrib.out >/dev/null 2>&1; then | |
121 | echo "Your C compiler doesn't support __attribute__((format))." | |
122 | val="$undef" | |
123 | else | |
124 | echo "Your C compiler supports __attribute__((format))." | |
125 | val="$define" | |
126 | fi | |
127 | else | |
128 | echo "Your C compiler doesn't seem to understand __attribute__ at all." | |
129 | val="$undef" | |
130 | fi | |
131 | ;; | |
132 | *) val="$d_attribute_format" ;; | |
133 | esac | |
134 | set d_attribute_format | |
135 | eval $setvar | |
136 | $rm -f attrib* | |
137 | ||
c87b5532 RB |
138 | : Look for GCC-style attribute format with null format allowed |
139 | case "$d_printf_format_null" in | |
140 | '') case "$d_attribute_format" in | |
141 | $define) | |
142 | echo " " | |
143 | echo "Checking whether your compiler allows __printf__ format to be null ..." >&4 | |
144 | $cat >attrib.c <<EOCP | |
145 | #include <stdio.h> | |
146 | #$i_stdlib I_STDLIB | |
147 | #ifdef I_STDLIB | |
148 | #include <stdlib.h> | |
149 | #endif | |
150 | int null_printf (char* pat,...) __attribute__((__format__(__printf__,1,2))); | |
151 | int null_printf (char* pat,...) { return (int)pat; } | |
152 | int main () { exit(null_printf(NULL)); } | |
153 | EOCP | |
154 | if $cc $ccflags -o attrib attrib.c >attrib.out 2>&1 ; then | |
155 | : run the executable in case it produces a run-time warning | |
156 | if $run ./attrib >>attrib.out 2>&1; then | |
157 | if $contains 'warning' attrib.out >/dev/null 2>&1; then | |
158 | echo "Your C compiler doesn't allow __printf__ format to be null." | |
159 | val="$undef" | |
160 | else | |
161 | echo "Your C compiler allows __printf__ format to be null." | |
162 | val="$define" | |
163 | fi | |
164 | else | |
165 | echo "Your C compiler executable failed with __printf__ format null." | |
166 | val="$undef" | |
167 | fi | |
168 | else | |
169 | echo "Your C compiler fails with __printf__ format null." | |
170 | val="$undef" | |
171 | fi | |
172 | ;; | |
173 | *) val="$undef" ;; | |
174 | esac | |
175 | ;; | |
176 | *) val="$d_printf_format_null" ;; | |
177 | esac | |
178 | set d_printf_format_null | |
179 | eval $setvar | |
180 | $rm -f attrib* | |
181 | ||
7ff25ab7 MB |
182 | : Look for GCC-style attribute malloc |
183 | case "$d_attribute_malloc" in | |
184 | '') | |
185 | echo " " | |
186 | echo "Checking whether your compiler can handle __attribute__((malloc)) ..." >&4 | |
187 | $cat >attrib.c <<'EOCP' | |
188 | #include <stdio.h> | |
189 | char *go_get_some_memory( int how_many_bytes ) __attribute__((malloc)); | |
190 | EOCP | |
191 | if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then | |
192 | if $contains 'warning' attrib.out >/dev/null 2>&1; then | |
193 | echo "Your C compiler doesn't support __attribute__((malloc))." | |
194 | val="$undef" | |
195 | else | |
196 | echo "Your C compiler supports __attribute__((malloc))." | |
197 | val="$define" | |
198 | fi | |
199 | else | |
200 | echo "Your C compiler doesn't seem to understand __attribute__ at all." | |
201 | val="$undef" | |
202 | fi | |
203 | ;; | |
204 | *) val="$d_attribute_malloc" ;; | |
205 | esac | |
206 | set d_attribute_malloc | |
207 | eval $setvar | |
208 | $rm -f attrib* | |
209 | ||
210 | : Look for GCC-style attribute nonnull | |
211 | case "$d_attribute_nonnull" in | |
212 | '') | |
213 | echo " " | |
214 | echo "Checking whether your compiler can handle __attribute__((nonnull(1))) ..." >&4 | |
215 | $cat >attrib.c <<'EOCP' | |
216 | #include <stdio.h> | |
217 | void do_something (char *some_pointer,...) __attribute__((nonnull(1))); | |
218 | EOCP | |
219 | if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then | |
220 | if $contains 'warning' attrib.out >/dev/null 2>&1; then | |
221 | echo "Your C compiler doesn't support __attribute__((nonnull))." | |
222 | val="$undef" | |
223 | else | |
224 | echo "Your C compiler supports __attribute__((nonnull))." | |
225 | val="$define" | |
226 | fi | |
227 | else | |
228 | echo "Your C compiler doesn't seem to understand __attribute__ at all." | |
229 | val="$undef" | |
230 | fi | |
231 | ;; | |
232 | *) val="$d_attribute_nonnull" ;; | |
233 | esac | |
234 | set d_attribute_nonnull | |
235 | eval $setvar | |
236 | $rm -f attrib* | |
237 | ||
238 | : Look for GCC-style attribute noreturn | |
239 | case "$d_attribute_noreturn" in | |
240 | '') | |
241 | echo " " | |
242 | echo "Checking whether your compiler can handle __attribute__((noreturn)) ..." >&4 | |
243 | $cat >attrib.c <<'EOCP' | |
244 | #include <stdio.h> | |
245 | void fall_over_dead( void ) __attribute__((noreturn)); | |
246 | EOCP | |
247 | if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then | |
248 | if $contains 'warning' attrib.out >/dev/null 2>&1; then | |
249 | echo "Your C compiler doesn't support __attribute__((noreturn))." | |
250 | val="$undef" | |
251 | else | |
252 | echo "Your C compiler supports __attribute__((noreturn))." | |
253 | val="$define" | |
254 | fi | |
255 | else | |
256 | echo "Your C compiler doesn't seem to understand __attribute__ at all." | |
257 | val="$undef" | |
258 | fi | |
259 | ;; | |
260 | *) val="$d_attribute_noreturn" ;; | |
261 | esac | |
262 | set d_attribute_noreturn | |
263 | eval $setvar | |
264 | $rm -f attrib* | |
265 | ||
266 | : Look for GCC-style attribute pure | |
267 | case "$d_attribute_pure" in | |
268 | '') | |
269 | echo " " | |
270 | echo "Checking whether your compiler can handle __attribute__((pure)) ..." >&4 | |
271 | $cat >attrib.c <<'EOCP' | |
272 | #include <stdio.h> | |
273 | int square( int n ) __attribute__((pure)); | |
274 | EOCP | |
275 | if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then | |
276 | if $contains 'warning' attrib.out >/dev/null 2>&1; then | |
277 | echo "Your C compiler doesn't support __attribute__((pure))." | |
278 | val="$undef" | |
279 | else | |
280 | echo "Your C compiler supports __attribute__((pure))." | |
281 | val="$define" | |
282 | fi | |
283 | else | |
284 | echo "Your C compiler doesn't seem to understand __attribute__ at all." | |
285 | val="$undef" | |
286 | fi | |
287 | ;; | |
288 | *) val="$d_attribute_pure" ;; | |
289 | esac | |
290 | set d_attribute_pure | |
291 | eval $setvar | |
292 | $rm -f attrib* | |
293 | ||
294 | : Look for GCC-style attribute unused | |
295 | case "$d_attribute_unused" in | |
296 | '') | |
297 | echo " " | |
298 | echo "Checking whether your compiler can handle __attribute__((unused)) ..." >&4 | |
299 | $cat >attrib.c <<'EOCP' | |
300 | #include <stdio.h> | |
301 | int do_something( int dummy __attribute__((unused)), int n ); | |
302 | EOCP | |
303 | if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then | |
304 | if $contains 'warning' attrib.out >/dev/null 2>&1; then | |
305 | echo "Your C compiler doesn't support __attribute__((unused))." | |
306 | val="$undef" | |
307 | else | |
308 | echo "Your C compiler supports __attribute__((unused))." | |
309 | val="$define" | |
310 | fi | |
311 | else | |
312 | echo "Your C compiler doesn't seem to understand __attribute__ at all." | |
313 | val="$undef" | |
314 | fi | |
315 | ;; | |
316 | *) val="$d_attribute_unused" ;; | |
317 | esac | |
318 | set d_attribute_unused | |
319 | eval $setvar | |
320 | $rm -f attrib* | |
321 | ||
322 | : Look for GCC-style attribute warn_unused_result | |
323 | case "$d_attribute_warn_unused_result" in | |
cdbedeff | 324 | '') |
0b272666 | 325 | echo " " |
7ff25ab7 | 326 | echo "Checking whether your compiler can handle __attribute__((warn_unused_result)) ..." >&4 |
0b272666 JH |
327 | $cat >attrib.c <<'EOCP' |
328 | #include <stdio.h> | |
7ff25ab7 | 329 | int I_will_not_be_ignored(void) __attribute__((warn_unused_result)); |
0b272666 JH |
330 | EOCP |
331 | if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then | |
332 | if $contains 'warning' attrib.out >/dev/null 2>&1; then | |
7ff25ab7 | 333 | echo "Your C compiler doesn't support __attribute__((warn_unused_result))." |
0b272666 JH |
334 | val="$undef" |
335 | else | |
7ff25ab7 | 336 | echo "Your C compiler supports __attribute__((warn_unused_result))." |
0b272666 JH |
337 | val="$define" |
338 | fi | |
339 | else | |
340 | echo "Your C compiler doesn't seem to understand __attribute__ at all." | |
341 | val="$undef" | |
342 | fi | |
cdbedeff | 343 | ;; |
7ff25ab7 | 344 | *) val="$d_attribute_warn_unused_result" ;; |
cdbedeff | 345 | esac |
7ff25ab7 | 346 | set d_attribute_warn_unused_result |
0b272666 JH |
347 | eval $setvar |
348 | $rm -f attrib* | |
349 |