Debian Codegraph @

gcc/testsuite/gcc.dg/format/format.h

raw
1 /* Format checking tests: common header. */
2 /* Origin: Joseph Myers <[email protected]> */
3
4 /* DONT_GNU_PROTOTYPE */
5 #if defined (_WIN32) && !defined (__CYGWIN__)
6 #if !defined (USE_SYSTEM_FORMATS)
7 #define gnu_attr_printf gnu_printf
8 #define gnu_attr___printf__ __gnu_printf__
9 #define gnu_attr_scanf gnu_scanf
10 #define gnu_attr___scanf__ __gnu_scanf__
11 #define gnu_attr_strftime gnu_strftime
12 #define gnu_attr___strftime__ __gnu_strftime__
13 #endif
14 #endif
15
16 #ifndef gnu_attr_printf
17 #define gnu_attr_printf printf
18 #define gnu_attr___printf__ __printf__
19 #define gnu_attr_scanf scanf
20 #define gnu_attr___scanf__ __scanf__
21 #define gnu_attr_strftime strftime
22 #define gnu_attr___strftime__ __strftime__
23 #endif
24
25 #if !defined (USE_SYSTEM_FORMATS)
26 #define USE_PRINTF(FMTPOS, WILDARG) __attribute__((format(gnu_printf, FMTPOS, WILDARG))) __attribute__((nonnull (FMTPOS)))
27 #define USE_SCANF(FMTPOS, WILDARG) __attribute__((format(gnu_scanf, FMTPOS, WILDARG))) __attribute__((nonnull (FMTPOS)))
28 #define USE_STRFTIME(FMTPOS) __attribute__((__format__(gnu_strftime, FMTPOS, 0))) __attribute__((nonnull (FMTPOS)))
29 #else
30 #define USE_PRINTF(FMTPOS, WILDARG)
31 #define USE_SCANF(FMTPOS, WILDARG)
32 #define USE_STRFTIME(FMTPOS)
33 #endif
34
35 #include <stdarg.h>
36 #include <stddef.h>
37
38 #ifndef _WINT_T
39 #ifndef __WINT_TYPE__
40 #define __WINT_TYPE__ unsigned int
41 #endif
42 typedef __WINT_TYPE__ wint_t;
43 #endif
44
45 #ifdef _WIN64
46 /* Kludges to get types corresponding to size_t and ptrdiff_t. */
47 #define unsigned signed
48 typedef signed int signed_size_t __attribute__ ((mode (DI)));
49 /* We also use this type to approximate ssize_t. */
50 typedef signed int ssize_t __attribute__ ((mode (DI)));
51 #undef unsigned
52 #define signed /* Type might or might not have explicit 'signed'. */
53 typedef unsigned int unsigned_ptrdiff_t __attribute__ ((mode (DI)));
54 #undef signed
55
56 __extension__ typedef int llong __attribute__ ((mode (DI)));
57 __extension__ typedef unsigned int ullong __attribute__ ((mode (DI)));
58 #else
59 /* Kludges to get types corresponding to size_t and ptrdiff_t. */
60 #define unsigned signed
61 typedef __SIZE_TYPE__ signed_size_t;
62 /* We also use this type to approximate ssize_t. */
63 typedef __SIZE_TYPE__ ssize_t;
64 #undef unsigned
65 #define signed /* Type might or might not have explicit 'signed'. */
66 typedef unsigned __PTRDIFF_TYPE__ unsigned_ptrdiff_t;
67 #undef signed
68
69 __extension__ typedef long long int llong;
70 __extension__ typedef unsigned long long int ullong;
71 #endif
72
73 /* %q formats want a "quad"; GCC considers this to be a long long. */
74 typedef llong quad_t;
75 typedef ullong u_quad_t;
76
77 __extension__ typedef __INTMAX_TYPE__ intmax_t;
78 __extension__ typedef __UINTMAX_TYPE__ uintmax_t;
79
80 __extension__ typedef __INT_LEAST8_TYPE__ int_least8_t;
81 __extension__ typedef __INT_LEAST16_TYPE__ int_least16_t;
82 __extension__ typedef __INT_LEAST32_TYPE__ int_least32_t;
83 __extension__ typedef __INT_LEAST64_TYPE__ int_least64_t;
84 __extension__ typedef __UINT_LEAST8_TYPE__ uint_least8_t;
85 __extension__ typedef __UINT_LEAST16_TYPE__ uint_least16_t;
86 __extension__ typedef __UINT_LEAST32_TYPE__ uint_least32_t;
87 __extension__ typedef __UINT_LEAST64_TYPE__ uint_least64_t;
88
89 __extension__ typedef __INT_FAST8_TYPE__ int_fast8_t;
90 __extension__ typedef __INT_FAST16_TYPE__ int_fast16_t;
91 __extension__ typedef __INT_FAST32_TYPE__ int_fast32_t;
92 __extension__ typedef __INT_FAST64_TYPE__ int_fast64_t;
93 __extension__ typedef __UINT_FAST8_TYPE__ uint_fast8_t;
94 __extension__ typedef __UINT_FAST16_TYPE__ uint_fast16_t;
95 __extension__ typedef __UINT_FAST32_TYPE__ uint_fast32_t;
96 __extension__ typedef __UINT_FAST64_TYPE__ uint_fast64_t;
97
98 #if __STDC_VERSION__ < 199901L && !defined(restrict)
99 #define restrict /* "restrict" not in old C standard. */
100 #endif
101
102 /* This may not be correct in the particular case, but allows the
103 prototypes to be declared, and we don't try to link.
104 */
105 typedef struct _FILE FILE;
106 extern FILE *stdin;
107 extern FILE *stdout;
108
109 extern int fprintf (FILE *restrict, const char *restrict, ...);
110 extern int printf (const char *restrict, ...);
111 extern int fprintf_unlocked (FILE *restrict, const char *restrict, ...);
112 extern int printf_unlocked (const char *restrict, ...);
113 extern int sprintf (char *restrict, const char *restrict, ...);
114 extern int vfprintf (FILE *restrict, const char *restrict, va_list);
115 extern int vprintf (const char *restrict, va_list);
116 extern int vsprintf (char *restrict, const char *restrict, va_list);
117 extern int snprintf (char *restrict, size_t, const char *restrict, ...);
118 extern int vsnprintf (char *restrict, size_t, const char *restrict, va_list);
119
120 extern int fscanf (FILE *restrict, const char *restrict, ...);
121 extern int scanf (const char *restrict, ...);
122 extern int sscanf (const char *restrict, const char *restrict, ...);
123 extern int vfscanf (FILE *restrict, const char *restrict, va_list);
124 extern int vscanf (const char *restrict, va_list);
125 extern int vsscanf (const char *restrict, const char *restrict, va_list);
126
127 extern char *gettext (const char *);
128 extern char *dgettext (const char *, const char *);
129 extern char *dcgettext (const char *, const char *, int);
130
131 struct tm;
132
133 extern size_t strftime (char *restrict, size_t, const char *restrict,
134 const struct tm *restrict);
135
136 extern ssize_t strfmon (char *restrict, size_t, const char *restrict, ...);
137
138 /* Mingw specific part. */
139 #if !defined (USE_SYSTEM_FORMATS) && defined(_WIN32) && !defined(DONT_GNU_PROTOTYPE)
140
141 extern USE_PRINTF(2,3) int fprintf_gnu (FILE *restrict, const char *restrict, ...);
142 #undef fprintf
143 #define fprintf fprintf_gnu
144
145 extern USE_PRINTF(1,2) int printf_gnu (const char *restrict, ...);
146 #undef printf
147 #define printf printf_gnu
148
149 extern USE_PRINTF(2,3) int fprintf_unlocked_gnu (FILE *restrict, const char *restrict, ...);
150 #undef fprintf_unlocked
151 #define fprintf_unlocked fprintf_unlocked_gnu
152
153 extern USE_PRINTF(1,2)int printf_unlocked_gnu (const char *restrict, ...);
154 #undef printf_unlocked
155 #define printf_unlocked printf_unlocked_gnu
156
157 extern USE_PRINTF(2,3) int sprintf_gnu (char *restrict, const char *restrict, ...);
158 #undef sprintf
159 #define sprintf sprintf_gnu
160
161 extern USE_PRINTF(2,0) int vfprintf_gnu (FILE *restrict, const char *restrict, va_list);
162 #undef vsprintf
163 #define vsprintf vsprintf_gnu
164
165 extern USE_PRINTF(1,0) int vprintf_gnu (const char *restrict, va_list);
166 #undef vprintf
167 #define vprintf vprintf_gnu
168
169 extern USE_PRINTF(2,0) int vsprintf_gnu (char *restrict, const char *restrict, va_list);
170 #undef vsprintf
171 #define vsprintf vsprintf_gnu
172
173 extern USE_PRINTF(3,4) int snprintf_gnu (char *restrict, size_t, const char *restrict, ...);
174 #undef snprintf
175 #define snprintf snprintf_gnu
176
177 extern USE_PRINTF(3,0) int vsnprintf_gnu (char *restrict, size_t, const char *restrict, va_list);
178 #undef vsnprintf
179 #define vsnprintf vsnprintf_gnu
180
181 extern USE_SCANF(2,3) int fscanf_gnu (FILE *restrict, const char *restrict, ...);
182 #undef fscanf
183 #define fscanf fscanf_gnu
184
185 extern USE_SCANF(1,2) int scanf_gnu (const char *restrict, ...);
186 #undef scanf
187 #define scanf scanf_gnu
188
189 extern USE_SCANF(2,3) int sscanf_gnu (const char *restrict, const char *restrict, ...);
190 #undef sscanf
191 #define sscanf sscanf_gnu
192
193 extern USE_SCANF(2,0) int vfscanf_gnu (FILE *restrict, const char *restrict, va_list);
194 #undef vfscanf
195 #define vfscanf vfscanf_gnu
196
197 extern USE_SCANF(1,0) int vscanf_gnu (const char *restrict, va_list);
198 #undef vscanf
199 #define vscanf vscanf_gnu
200
201 extern USE_SCANF(2,0) int vsscanf_gnu (const char *restrict, const char *restrict, va_list);
202 #undef vsscanf
203 #define vsscanf vsscanf_gnu
204
205 extern USE_STRFTIME(3) size_t strftime_gnu (char *restrict, size_t, const char *restrict,
206 const struct tm *restrict);
207 #undef strftime
208 #define strftime strftime_gnu
209
210 #endif