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 42typedef __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 48typedef signed int signed_size_t __attribute__ ((mode (DI))); 49/* We also use this type to approximate ssize_t. */ 50typedef signed int ssize_t __attribute__ ((mode (DI))); 51#undef unsigned 52#define signed /* Type might or might not have explicit 'signed'. */ 53typedef 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 61typedef __SIZE_TYPE__ signed_size_t; 62/* We also use this type to approximate ssize_t. */ 63typedef __SIZE_TYPE__ ssize_t; 64#undef unsigned 65#define signed /* Type might or might not have explicit 'signed'. */ 66typedef 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. */ 74typedef llong quad_t; 75typedef 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*/ 87typedef struct _FILE FILE; 88extern FILE *stdin; 89extern FILE *stdout; 90 91extern int fprintf (FILE *restrict, const char *restrict, ...); 92extern int printf (const char *restrict, ...); 93extern int fprintf_unlocked (FILE *restrict, const char *restrict, ...); 94extern int printf_unlocked (const char *restrict, ...); 95extern int sprintf (char *restrict, const char *restrict, ...); 96extern int vfprintf (FILE *restrict, const char *restrict, va_list); 97extern int vprintf (const char *restrict, va_list); 98extern int vsprintf (char *restrict, const char *restrict, va_list); 99extern int snprintf (char *restrict, size_t, const char *restrict, ...); 100extern int vsnprintf (char *restrict, size_t, const char *restrict, va_list); 101 102extern int fscanf (FILE *restrict, const char *restrict, ...); 103extern int scanf (const char *restrict, ...); 104extern int sscanf (const char *restrict, const char *restrict, ...); 105extern int vfscanf (FILE *restrict, const char *restrict, va_list); 106extern int vscanf (const char *restrict, va_list); 107extern int vsscanf (const char *restrict, const char *restrict, va_list); 108 109extern char *gettext (const char *); 110extern char *dgettext (const char *, const char *); 111extern char *dcgettext (const char *, const char *, int); 112 113struct tm; 114 115extern size_t strftime (char *restrict, size_t, const char *restrict, 116 const struct tm *restrict); 117 118extern 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 123extern USE_PRINTF(2,3) int fprintf_gnu (FILE *restrict, const char *restrict, ...); 124#undef fprintf 125#define fprintf fprintf_gnu 126 127extern USE_PRINTF(1,2) int printf_gnu (const char *restrict, ...); 128#undef printf 129#define printf printf_gnu 130 131extern 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 135extern USE_PRINTF(1,2)int printf_unlocked_gnu (const char *restrict, ...); 136#undef printf_unlocked 137#define printf_unlocked printf_unlocked_gnu 138 139extern USE_PRINTF(2,3) int sprintf_gnu (char *restrict, const char *restrict, ...); 140#undef sprintf 141#define sprintf sprintf_gnu 142 143extern USE_PRINTF(2,0) int vfprintf_gnu (FILE *restrict, const char *restrict, va_list); 144#undef vsprintf 145#define vsprintf vsprintf_gnu 146 147extern USE_PRINTF(1,0) int vprintf_gnu (const char *restrict, va_list); 148#undef vprintf 149#define vprintf vprintf_gnu 150 151extern USE_PRINTF(2,0) int vsprintf_gnu (char *restrict, const char *restrict, va_list); 152#undef vsprintf 153#define vsprintf vsprintf_gnu 154 155extern USE_PRINTF(3,4) int snprintf_gnu (char *restrict, size_t, const char *restrict, ...); 156#undef snprintf 157#define snprintf snprintf_gnu 158 159extern 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 163extern USE_SCANF(2,3) int fscanf_gnu (FILE *restrict, const char *restrict, ...); 164#undef fscanf 165#define fscanf fscanf_gnu 166 167extern USE_SCANF(1,2) int scanf_gnu (const char *restrict, ...); 168#undef scanf 169#define scanf scanf_gnu 170 171extern USE_SCANF(2,3) int sscanf_gnu (const char *restrict, const char *restrict, ...); 172#undef sscanf 173#define sscanf sscanf_gnu 174 175extern USE_SCANF(2,0) int vfscanf_gnu (FILE *restrict, const char *restrict, va_list); 176#undef vfscanf 177#define vfscanf vfscanf_gnu 178 179extern USE_SCANF(1,0) int vscanf_gnu (const char *restrict, va_list); 180#undef vscanf 181#define vscanf vscanf_gnu 182 183extern USE_SCANF(2,0) int vsscanf_gnu (const char *restrict, const char *restrict, va_list); 184#undef vsscanf 185#define vsscanf vsscanf_gnu 186 187extern 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