1 /* Format checking tests: common header. */ 2 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */ 3 4 #include <stdarg.h> 5 #include <stddef.h> 6 7 #ifndef _WINT_T 8 #ifndef __WINT_TYPE__ 9 #define __WINT_TYPE__ unsigned int 10 #endif 11 typedef __WINT_TYPE__ wint_t; 12 #endif 13 14 /* Kludges to get types corresponding to size_t and ptrdiff_t. */ 15 #define unsigned signed 16 typedef __SIZE_TYPE__ signed_size_t; 17 /* We also use this type to approximate ssize_t. */ 18 typedef __SIZE_TYPE__ ssize_t; 19 #undef unsigned 20 #define signed /* Type might or might not have explicit 'signed'. */ 21 typedef unsigned __PTRDIFF_TYPE__ unsigned_ptrdiff_t; 22 #undef signed 23 24 __extension__ typedef long long int llong; 25 __extension__ typedef unsigned long long int ullong; 26 27 /* %q formats want a "quad"; GCC considers this to be a long long. */ 28 typedef llong quad_t; 29 typedef ullong u_quad_t; 30 31 /* This next definition is a kludge. When GCC has a <stdint.h> it 32 should be used. 33 */ 34 /* (T *) if E is zero, (void *) otherwise. */ 35 #define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E)) 36 37 /* (T *) if E is nonzero, (void *) otherwise. */ 38 #define type_if(T, E) type_if_not(T, !(E)) 39 40 /* Combine pointer types, all but one (void *). */ 41 #define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0) 42 #define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3)) 43 44 #define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong)) 45 #define maybe_uint_ptr type_if(unsigned int, sizeof(unsigned int) == sizeof(ullong)) 46 #define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int)) 47 #define maybe_ulong_ptr type_if(unsigned long, sizeof(unsigned long) == sizeof(ullong) && sizeof(unsigned long) > sizeof(unsigned int)) 48 #define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long)) 49 #define maybe_ulong_long_ptr type_if(ullong, sizeof(ullong) > sizeof(unsigned long)) 50 51 #define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr) 52 #define uintmax_type_ptr type_comb3(maybe_uint_ptr, maybe_ulong_ptr, maybe_ulong_long_ptr) 53 54 typedef __typeof__(*((intmax_type_ptr)0)) intmax_t; 55 typedef __typeof__(*((uintmax_type_ptr)0)) uintmax_t; 56 57 #if __STDC_VERSION__ < 199901L 58 #define restrict /* "restrict" not in old C standard. */ 59 #endif 60 61 /* This may not be correct in the particular case, but allows the 62 prototypes to be declared, and we don't try to link. 63 */ 64 typedef struct _FILE FILE; 65 extern FILE *stdin; 66 extern FILE *stdout; 67 68 extern int fprintf (FILE *restrict, const char *restrict, ...); 69 extern int printf (const char *restrict, ...); 70 extern int fprintf_unlocked (FILE *restrict, const char *restrict, ...); 71 extern int printf_unlocked (const char *restrict, ...); 72 extern int sprintf (char *restrict, const char *restrict, ...); 73 extern int vfprintf (FILE *restrict, const char *restrict, va_list); 74 extern int vprintf (const char *restrict, va_list); 75 extern int vsprintf (char *restrict, const char *restrict, va_list); 76 extern int snprintf (char *restrict, size_t, const char *restrict, ...); 77 extern int vsnprintf (char *restrict, size_t, const char *restrict, va_list); 78 79 extern int fscanf (FILE *restrict, const char *restrict, ...); 80 extern int scanf (const char *restrict, ...); 81 extern int sscanf (const char *restrict, const char *restrict, ...); 82 extern int vfscanf (FILE *restrict, const char *restrict, va_list); 83 extern int vscanf (const char *restrict, va_list); 84 extern int vsscanf (const char *restrict, const char *restrict, va_list); 85 86 extern char *gettext (const char *); 87 extern char *dgettext (const char *, const char *); 88 extern char *dcgettext (const char *, const char *, int); 89 90 struct tm; 91 92 extern size_t strftime (char *restrict, size_t, const char *restrict, 93 const struct tm *restrict); 94 95 extern ssize_t strfmon (char *restrict, size_t, const char *restrict, ...); 96