exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / printf-args.h
blob9b80bb39290616a0bc6d3729f6fa51427fbcbe45
1 /* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2024 Free Software
3 Foundation, Inc.
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 #ifndef _PRINTF_ARGS_H
19 #define _PRINTF_ARGS_H
21 /* This file can be parametrized with the following macros:
22 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
23 PRINTF_FETCHARGS Name of the function to be declared.
24 STATIC Set to 'static' to declare the function static. */
26 /* Default parameters. */
27 #ifndef PRINTF_FETCHARGS
28 # define PRINTF_FETCHARGS printf_fetchargs
29 #endif
31 /* Get size_t. */
32 #include <stddef.h>
34 /* Get wchar_t. */
35 #if HAVE_WCHAR_T
36 # include <stddef.h>
37 #endif
39 /* Get wint_t. */
40 #if HAVE_WINT_T
41 # include <wchar.h>
42 #endif
44 /* Get intN_t, uintN_t, intN_fast_t, uintN_fast_t. */
45 #include <stdint.h>
47 /* Get va_list. */
48 #include <stdarg.h>
51 /* Argument types */
52 typedef enum
54 TYPE_NONE,
55 TYPE_SCHAR,
56 TYPE_UCHAR,
57 TYPE_SHORT,
58 TYPE_USHORT,
59 TYPE_INT,
60 TYPE_UINT,
61 TYPE_LONGINT,
62 TYPE_ULONGINT,
63 TYPE_LONGLONGINT,
64 TYPE_ULONGLONGINT,
65 /* According to ISO C 23 ยง 7.23.6.1, "all exact-width integer types",
66 "all minimum-width integer types", and "all fastest minimum-width integer
67 types" defined in <stdint.h> should be supported. But for portability
68 between platforms, we support only those with N = 8, 16, 32, 64. */
69 TYPE_INT8_T,
70 TYPE_UINT8_T,
71 TYPE_INT16_T,
72 TYPE_UINT16_T,
73 TYPE_INT32_T,
74 TYPE_UINT32_T,
75 TYPE_INT64_T,
76 TYPE_UINT64_T,
77 TYPE_INT_FAST8_T,
78 TYPE_UINT_FAST8_T,
79 TYPE_INT_FAST16_T,
80 TYPE_UINT_FAST16_T,
81 TYPE_INT_FAST32_T,
82 TYPE_UINT_FAST32_T,
83 TYPE_INT_FAST64_T,
84 TYPE_UINT_FAST64_T,
85 TYPE_DOUBLE,
86 TYPE_LONGDOUBLE,
87 TYPE_CHAR,
88 #if HAVE_WINT_T
89 TYPE_WIDE_CHAR,
90 #endif
91 TYPE_STRING,
92 #if HAVE_WCHAR_T
93 TYPE_WIDE_STRING,
94 #endif
95 TYPE_POINTER,
96 TYPE_COUNT_SCHAR_POINTER,
97 TYPE_COUNT_SHORT_POINTER,
98 TYPE_COUNT_INT_POINTER,
99 TYPE_COUNT_LONGINT_POINTER,
100 TYPE_COUNT_LONGLONGINT_POINTER,
101 TYPE_COUNT_INT8_T_POINTER,
102 TYPE_COUNT_INT16_T_POINTER,
103 TYPE_COUNT_INT32_T_POINTER,
104 TYPE_COUNT_INT64_T_POINTER,
105 TYPE_COUNT_INT_FAST8_T_POINTER,
106 TYPE_COUNT_INT_FAST16_T_POINTER,
107 TYPE_COUNT_INT_FAST32_T_POINTER,
108 TYPE_COUNT_INT_FAST64_T_POINTER
109 #if ENABLE_UNISTDIO
110 /* The unistdio extensions. */
111 , TYPE_U8_STRING
112 , TYPE_U16_STRING
113 , TYPE_U32_STRING
114 #endif
115 } arg_type;
117 /* Polymorphic argument */
118 typedef struct
120 arg_type type;
121 union
123 signed char a_schar;
124 unsigned char a_uchar;
125 short a_short;
126 unsigned short a_ushort;
127 int a_int;
128 unsigned int a_uint;
129 long int a_longint;
130 unsigned long int a_ulongint;
131 long long int a_longlongint;
132 unsigned long long int a_ulonglongint;
133 int8_t a_int8_t;
134 uint8_t a_uint8_t;
135 int16_t a_int16_t;
136 uint16_t a_uint16_t;
137 int32_t a_int32_t;
138 uint32_t a_uint32_t;
139 int64_t a_int64_t;
140 uint64_t a_uint64_t;
141 int_fast8_t a_int_fast8_t;
142 uint_fast8_t a_uint_fast8_t;
143 int_fast16_t a_int_fast16_t;
144 uint_fast16_t a_uint_fast16_t;
145 int_fast32_t a_int_fast32_t;
146 uint_fast32_t a_uint_fast32_t;
147 int_fast64_t a_int_fast64_t;
148 uint_fast64_t a_uint_fast64_t;
149 float a_float; /* unused */
150 double a_double;
151 long double a_longdouble;
152 int a_char;
153 #if HAVE_WINT_T
154 wint_t a_wide_char;
155 #endif
156 const char* a_string;
157 #if HAVE_WCHAR_T
158 const wchar_t* a_wide_string;
159 #endif
160 void* a_pointer;
161 signed char * a_count_schar_pointer;
162 short * a_count_short_pointer;
163 int * a_count_int_pointer;
164 long int * a_count_longint_pointer;
165 long long int * a_count_longlongint_pointer;
166 int8_t * a_count_int8_t_pointer;
167 int16_t * a_count_int16_t_pointer;
168 int32_t * a_count_int32_t_pointer;
169 int64_t * a_count_int64_t_pointer;
170 int_fast8_t * a_count_int_fast8_t_pointer;
171 int_fast16_t * a_count_int_fast16_t_pointer;
172 int_fast32_t * a_count_int_fast32_t_pointer;
173 int_fast64_t * a_count_int_fast64_t_pointer;
174 #if ENABLE_UNISTDIO
175 /* The unistdio extensions. */
176 const uint8_t * a_u8_string;
177 const uint16_t * a_u16_string;
178 const uint32_t * a_u32_string;
179 #endif
183 argument;
185 /* Number of directly allocated arguments (no malloc() needed). */
186 #define N_DIRECT_ALLOC_ARGUMENTS 7
188 typedef struct
190 size_t count;
191 argument *arg;
192 argument direct_alloc_arg[N_DIRECT_ALLOC_ARGUMENTS];
194 arguments;
197 /* Fetch the arguments, putting them into a. */
198 #ifdef STATIC
199 STATIC
200 #else
201 extern
202 #endif
203 int PRINTF_FETCHARGS (va_list args, arguments *a);
205 #endif /* _PRINTF_ARGS_H */