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
11typedef __WINT_TYPE__ wint_t;
12#endif
13
14/* Kludges to get types corresponding to size_t and ptrdiff_t.  */
15#define unsigned signed
16typedef __SIZE_TYPE__ signed_size_t;
17/* We also use this type to approximate ssize_t.  */
18typedef __SIZE_TYPE__ ssize_t;
19#undef unsigned
20#define signed /* Type might or might not have explicit 'signed'.  */
21typedef 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.  */
28typedef llong quad_t;
29typedef 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
54typedef __typeof__(*((intmax_type_ptr)0)) intmax_t;
55typedef __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*/
64typedef struct _FILE FILE;
65extern FILE *stdin;
66extern FILE *stdout;
67
68extern int fprintf (FILE *restrict, const char *restrict, ...);
69extern int printf (const char *restrict, ...);
70extern int fprintf_unlocked (FILE *restrict, const char *restrict, ...);
71extern int printf_unlocked (const char *restrict, ...);
72extern int sprintf (char *restrict, const char *restrict, ...);
73extern int vfprintf (FILE *restrict, const char *restrict, va_list);
74extern int vprintf (const char *restrict, va_list);
75extern int vsprintf (char *restrict, const char *restrict, va_list);
76extern int snprintf (char *restrict, size_t, const char *restrict, ...);
77extern int vsnprintf (char *restrict, size_t, const char *restrict, va_list);
78
79extern int fscanf (FILE *restrict, const char *restrict, ...);
80extern int scanf (const char *restrict, ...);
81extern int sscanf (const char *restrict, const char *restrict, ...);
82extern int vfscanf (FILE *restrict, const char *restrict, va_list);
83extern int vscanf (const char *restrict, va_list);
84extern int vsscanf (const char *restrict, const char *restrict, va_list);
85
86extern char *gettext (const char *);
87extern char *dgettext (const char *, const char *);
88extern char *dcgettext (const char *, const char *, int);
89
90struct tm;
91
92extern size_t strftime (char *restrict, size_t, const char *restrict,
93			const struct tm *restrict);
94
95extern ssize_t strfmon (char *restrict, size_t, const char *restrict, ...);
96