1 /* Format checking tests: common header. */ 2 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */ 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 #if __STDC_VERSION__ < 199901L && !defined(restrict) 81 #define restrict /* "restrict" not in old C standard. */ 82 #endif 83 84 /* This may not be correct in the particular case, but allows the 85 prototypes to be declared, and we don't try to link. 86 */ 87 typedef struct _FILE FILE; 88 extern FILE *stdin; 89 extern FILE *stdout; 90 91 extern int fprintf (FILE *restrict, const char *restrict, ...); 92 extern int printf (const char *restrict, ...); 93 extern int fprintf_unlocked (FILE *restrict, const char *restrict, ...); 94 extern int printf_unlocked (const char *restrict, ...); 95 extern int sprintf (char *restrict, const char *restrict, ...); 96 extern int vfprintf (FILE *restrict, const char *restrict, va_list); 97 extern int vprintf (const char *restrict, va_list); 98 extern int vsprintf (char *restrict, const char *restrict, va_list); 99 extern int snprintf (char *restrict, size_t, const char *restrict, ...); 100 extern int vsnprintf (char *restrict, size_t, const char *restrict, va_list); 101 102 extern int fscanf (FILE *restrict, const char *restrict, ...); 103 extern int scanf (const char *restrict, ...); 104 extern int sscanf (const char *restrict, const char *restrict, ...); 105 extern int vfscanf (FILE *restrict, const char *restrict, va_list); 106 extern int vscanf (const char *restrict, va_list); 107 extern int vsscanf (const char *restrict, const char *restrict, va_list); 108 109 extern char *gettext (const char *); 110 extern char *dgettext (const char *, const char *); 111 extern char *dcgettext (const char *, const char *, int); 112 113 struct tm; 114 115 extern size_t strftime (char *restrict, size_t, const char *restrict, 116 const struct tm *restrict); 117 118 extern ssize_t strfmon (char *restrict, size_t, const char *restrict, ...); 119 120 /* Mingw specific part. */ 121 #if !defined (USE_SYSTEM_FORMATS) && defined(_WIN32) && !defined(DONT_GNU_PROTOTYPE) 122 123 extern USE_PRINTF(2,3) int fprintf_gnu (FILE *restrict, const char *restrict, ...); 124 #undef fprintf 125 #define fprintf fprintf_gnu 126 127 extern USE_PRINTF(1,2) int printf_gnu (const char *restrict, ...); 128 #undef printf 129 #define printf printf_gnu 130 131 extern USE_PRINTF(2,3) int fprintf_unlocked_gnu (FILE *restrict, const char *restrict, ...); 132 #undef fprintf_unlocked 133 #define fprintf_unlocked fprintf_unlocked_gnu 134 135 extern USE_PRINTF(1,2)int printf_unlocked_gnu (const char *restrict, ...); 136 #undef printf_unlocked 137 #define printf_unlocked printf_unlocked_gnu 138 139 extern USE_PRINTF(2,3) int sprintf_gnu (char *restrict, const char *restrict, ...); 140 #undef sprintf 141 #define sprintf sprintf_gnu 142 143 extern USE_PRINTF(2,0) int vfprintf_gnu (FILE *restrict, const char *restrict, va_list); 144 #undef vsprintf 145 #define vsprintf vsprintf_gnu 146 147 extern USE_PRINTF(1,0) int vprintf_gnu (const char *restrict, va_list); 148 #undef vprintf 149 #define vprintf vprintf_gnu 150 151 extern USE_PRINTF(2,0) int vsprintf_gnu (char *restrict, const char *restrict, va_list); 152 #undef vsprintf 153 #define vsprintf vsprintf_gnu 154 155 extern USE_PRINTF(3,4) int snprintf_gnu (char *restrict, size_t, const char *restrict, ...); 156 #undef snprintf 157 #define snprintf snprintf_gnu 158 159 extern USE_PRINTF(3,0) int vsnprintf_gnu (char *restrict, size_t, const char *restrict, va_list); 160 #undef vsnprintf 161 #define vsnprintf vsnprintf_gnu 162 163 extern USE_SCANF(2,3) int fscanf_gnu (FILE *restrict, const char *restrict, ...); 164 #undef fscanf 165 #define fscanf fscanf_gnu 166 167 extern USE_SCANF(1,2) int scanf_gnu (const char *restrict, ...); 168 #undef scanf 169 #define scanf scanf_gnu 170 171 extern USE_SCANF(2,3) int sscanf_gnu (const char *restrict, const char *restrict, ...); 172 #undef sscanf 173 #define sscanf sscanf_gnu 174 175 extern USE_SCANF(2,0) int vfscanf_gnu (FILE *restrict, const char *restrict, va_list); 176 #undef vfscanf 177 #define vfscanf vfscanf_gnu 178 179 extern USE_SCANF(1,0) int vscanf_gnu (const char *restrict, va_list); 180 #undef vscanf 181 #define vscanf vscanf_gnu 182 183 extern USE_SCANF(2,0) int vsscanf_gnu (const char *restrict, const char *restrict, va_list); 184 #undef vsscanf 185 #define vsscanf vsscanf_gnu 186 187 extern USE_STRFTIME(3) size_t strftime_gnu (char *restrict, size_t, const char *restrict, 188 const struct tm *restrict); 189 #undef strftime 190 #define strftime strftime_gnu 191 192 #endif 193