P99
p99_c99_default.h
Go to the documentation of this file.
1 /* This may look like nonsense, but it really is -*- mode: C; coding: utf-8 -*- */
2 /* */
3 /* Except for parts copied from previous work and as explicitly stated below, */
4 /* the authors and copyright holders for this work are as follows: */
5 /* (C) copyright 2010-2012 Jens Gustedt, INRIA, France */
6 /* (C) copyright 2012 William Morris */
7 /* */
8 /* This file is free software; it is part of the P99 project. */
9 /* */
10 /* Licensed under the Apache License, Version 2.0 (the "License"); */
11 /* you may not use this file except in compliance with the License. */
12 /* You may obtain a copy of the License at */
13 /* */
14 /* http://www.apache.org/licenses/LICENSE-2.0 */
15 /* */
16 /* Unless required by applicable law or agreed to in writing, software */
17 /* distributed under the License is distributed on an "AS IS" BASIS, */
18 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
19 /* See the License for the specific language governing permissions and */
20 /* limitations under the License. */
21 /* */
22 #ifndef P99_C99_DEFAULT_H_
23 # define P99_C99_DEFAULT_H_
24 
25 #include "p99_defarg.h"
26 
27 #define P00_C99_DEFARG_DOCU(NAME, RET, ...) \
28  \
29  \
30 
31 P99_MACRO_END(C99_DEFARG_DOCU);
32 
33 P00_C99_DEFARG_DOCU(strerror, char*, int errnum)
35 #define strerror(...) P99_CALL_DEFARG(strerror, 1, __VA_ARGS__)
36 #define strerror_defarg_0() 0
37 
38 P00_C99_DEFARG_DOCU(calloc, void*, size_t rec_num, size_t rec_size)
44 #define calloc(...) P99_CALL_DEFARG(calloc, 2, __VA_ARGS__)
45 #define calloc_defarg_1() 1u
46 
47 P00_C99_DEFARG_DOCU(longjmp, void, jmp_buf env, int val)
51 #ifdef longjmp
52 # pragma message "warning longjmp defined as a macro, overwriting"
53 # undef longjmp
54 #endif
55 # define longjmp(...) P99_CALL_DEFARG(longjmp, 2, __VA_ARGS__)
56 # define longjmp_defarg_1() 1
57 
58 
101 P00_C99_DEFARG_DOCU(wcstol, long, wchar_t const *p00_nptr, wchar_t **p00_eptr, int p00_base)
105 #define wcstol(...) P99_CALL_DEFARG(wcstol, 3, __VA_ARGS__)
106 #define wcstol_defarg_1() 0
107 #define wcstol_defarg_2() 0
108 
109 P00_C99_DEFARG_DOCU(wcstoll, long long, wchar_t const *p00_nptr, wchar_t **p00_eptr, int p00_base)
110 
111 
114 #define wcstoll(...) P99_CALL_DEFARG(wcstoll, 3, __VA_ARGS__)
115 #define wcstoll_defarg_1() 0
116 #define wcstoll_defarg_2() 0
117 
118 P00_C99_DEFARG_DOCU(wcstoimax, intmax_t, wchar_t const *p00_nptr, wchar_t **p00_eptr, int p00_base)
122 #define wcstoimax(...) P99_CALL_DEFARG(wcstoimax, 3, __VA_ARGS__)
123 #define wcstoimax_defarg_1() 0
124 #define wcstoimax_defarg_2() 0
125 
126 P00_C99_DEFARG_DOCU(wcstoul, unsigned long, wchar_t const *p00_nptr, wchar_t **p00_eptr, int p00_base)
130 #define wcstoul(...) P99_CALL_DEFARG(wcstoul, 3, __VA_ARGS__)
131 #define wcstoul_defarg_1() 0
132 #define wcstoul_defarg_2() 0
133 
134 P00_C99_DEFARG_DOCU(wcstoull, unsigned long long, wchar_t const *p00_nptr, wchar_t **p00_eptr, int p00_base)
138 #define wcstoull(...) P99_CALL_DEFARG(wcstoull, 3, __VA_ARGS__)
139 #define wcstoull_defarg_1() 0
140 #define wcstoull_defarg_2() 0
141 
142 P00_C99_DEFARG_DOCU(wcstoumax, uintmax_t, wchar_t const *p00_nptr, wchar_t **p00_eptr, int p00_base)
146 #define wcstoumax(...) P99_CALL_DEFARG(wcstoumax, 3, __VA_ARGS__)
147 #define wcstoumax_defarg_1() 0
148 #define wcstoumax_defarg_2() 0
149 
150 P00_C99_DEFARG_DOCU(wcstof, float, wchar_t const *p00_nptr, wchar_t **p00_eptr)
153 #define wcstof(...) P99_CALL_DEFARG(wcstof, 2, __VA_ARGS__)
154 #define wcstof_defarg_1() 0
155 
156 P00_C99_DEFARG_DOCU(wcstod, double, wchar_t const *p00_nptr, wchar_t **p00_eptr)
159 #define wcstod(...) P99_CALL_DEFARG(wcstod, 2, __VA_ARGS__)
160 #define wcstod_defarg_1() 0
161 
162 P00_C99_DEFARG_DOCU(wcstold, long double, wchar_t const *p00_nptr, wchar_t **p00_eptr)
165 #define wcstold(...) P99_CALL_DEFARG(wcstold, 2, __VA_ARGS__)
166 #define wcstold_defarg_1() 0
167 
168 P00_C99_DEFARG_DOCU(strtol, long, char const *p00_nptr, char **p00_eptr, int p00_base)
177 #define strtol(...) P99_CALL_DEFARG(strtol, 3, __VA_ARGS__)
178 #define strtol_defarg_1() 0
179 #define strtol_defarg_2() 0
180 
181 P00_C99_DEFARG_DOCU(strtoll, long long, char const *p00_nptr, char **p00_eptr, int p00_base)
190 #define strtoll(...) P99_CALL_DEFARG(strtoll, 3, __VA_ARGS__)
191 #define strtoll_defarg_1() 0
192 #define strtoll_defarg_2() 0
193 
194 P00_C99_DEFARG_DOCU(strtoimax, intmax_t, char const *p00_nptr, char **p00_eptr, int p00_base)
198 #define strtoimax(...) P99_CALL_DEFARG(strtoimax, 3, __VA_ARGS__)
199 #define strtoimax_defarg_1() 0
200 #define strtoimax_defarg_2() 0
201 
202 P00_C99_DEFARG_DOCU(strtoul, unsigned long, char const *p00_nptr, char **p00_eptr, int p00_base)
206 #define strtoul(...) P99_CALL_DEFARG(strtoul, 3, __VA_ARGS__)
207 #define strtoul_defarg_1() 0
208 #define strtoul_defarg_2() 0
209 
210 P00_C99_DEFARG_DOCU(strtoull, unsigned long long, char const *p00_nptr, char **p00_eptr, int p00_base)
214 #define strtoull(...) P99_CALL_DEFARG(strtoull, 3, __VA_ARGS__)
215 #define strtoull_defarg_1() 0
216 #define strtoull_defarg_2() 0
217 
218 P00_C99_DEFARG_DOCU(strtoumax, uintmax_t, char const *p00_nptr, char **p00_eptr, int p00_base)
222 #define strtoumax(...) P99_CALL_DEFARG(strtoumax, 3, __VA_ARGS__)
223 #define strtoumax_defarg_1() 0
224 #define strtoumax_defarg_2() 0
225 
226 P00_C99_DEFARG_DOCU(strtof, float, char const *p00_nptr, char **p00_eptr)
229 #define strtof(...) P99_CALL_DEFARG(strtof, 2, __VA_ARGS__)
230 #define strtof_defarg_1() 0
231 
232 P00_C99_DEFARG_DOCU(strtod, double, char const *p00_nptr, char **p00_eptr)
235 #define strtod(...) P99_CALL_DEFARG(strtod, 2, __VA_ARGS__)
236 #define strtod_defarg_1() 0
237 
238 P00_C99_DEFARG_DOCU(strtold, long double, char const *p00_nptr, char **p00_eptr)
241 #define strtold(...) P99_CALL_DEFARG(strtold, 2, __VA_ARGS__)
242 #define strtold_defarg_1() 0
243 
244 #define P00_DECLARE_STRTO(SUFF) \
245  \
246  \
247 p99_inline \
248 P99_BUILTIN_TYPE(SUFF) \
249 P99_PASTE2(p99_strto, SUFF)(char const *p00_nptr, char **p00_eptr, int p00_base) { \
250  long long p00_ret = (strtoll)(p00_nptr, p00_eptr, p00_base); \
251  if ((p00_ret > P99_BUILTIN_MAX(SUFF) || p00_ret < P99_BUILTIN_MIN(SUFF)) \
252  && (!errno)) errno = ERANGE; \
253  if (p00_ret > P99_BUILTIN_MAX(SUFF)) p00_ret = P99_BUILTIN_MAX(SUFF); \
254  if (p00_ret < P99_BUILTIN_MIN(SUFF)) p00_ret = P99_BUILTIN_MIN(SUFF); \
255  return p00_ret; \
256 } \
257 P99_MACRO_END(p99_strto, SUFF)
258 
259 
260 #define P00_DECLARE_STRTOU(SUFF) \
261  \
262  \
263 p99_inline \
264 P99_BUILTIN_TYPE(SUFF) \
265 P99_PASTE2(p99_strto, SUFF)(char const *p00_nptr, char **p00_eptr, int p00_base) { \
266  unsigned long long p00_ret = (strtoull)(p00_nptr, p00_eptr, p00_base); \
267  if (p00_ret > P99_BUILTIN_MAX(SUFF)) { \
268  if (!errno) errno = ERANGE; \
269  p00_ret = P99_BUILTIN_MAX(SUFF); \
270  } \
271  return p00_ret; \
272 } \
273 P99_MACRO_END(p99_strto, SUFF)
274 
275 #define P00_I_LIST c, hh, , h, t, j, i8, i16, i32, i64
276 
277 P99_SEP(P00_DECLARE_STRTO, P00_I_LIST);
278 
279 #define P00_U_LIST uhh, u, uh, uz, uj, u8, u16, u32, u64
280 P99_SEP(P00_DECLARE_STRTOU, P00_U_LIST);
281 
287 P00_C99_DEFARG_DOCU(p99_strto, signed, char const *p00_nptr, char **p00_eptr, int p00_base)
291 #define p99_strto(...) P99_CALL_DEFARG(p99_strto, 3, __VA_ARGS__)
292 #define p99_strto_defarg_1() 0
293 #define p99_strto_defarg_2() 0
294 
295 
296 P00_C99_DEFARG_DOCU(p99_strtoc, char, char const *p00_nptr, char **p00_eptr, int p00_base)
300 #define p99_strtoc(...) P99_CALL_DEFARG(p99_strtoc, 3, __VA_ARGS__)
301 #define p99_strtoc_defarg_1() 0
302 #define p99_strtoc_defarg_2() 0
303 
304 P00_C99_DEFARG_DOCU(p99_strtohh, signed char, char const *p00_nptr, char **p00_eptr, int p00_base)
308 #define p99_strtohh(...) P99_CALL_DEFARG(p99_strtohh, 3, __VA_ARGS__)
309 #define p99_strtohh_defarg_1() 0
310 #define p99_strtohh_defarg_2() 0
311 
312 P00_C99_DEFARG_DOCU(p99_strtouhh, unsigned char, char const *p00_nptr, char **p00_eptr, int p00_base)
316 #define p99_strtouhh(...) P99_CALL_DEFARG(p99_strtouhh, 3, __VA_ARGS__)
317 #define p99_strtouhh_defarg_1() 0
318 #define p99_strtouhh_defarg_2() 0
319 
320 
321 P00_C99_DEFARG_DOCU(p99_strtoh, signed short, char const *p00_nptr, char **p00_eptr, int p00_base)
325 #define p99_strtoh(...) P99_CALL_DEFARG(p99_strtoh, 3, __VA_ARGS__)
326 #define p99_strtoh_defarg_1() 0
327 #define p99_strtoh_defarg_2() 0
328 
329 P00_C99_DEFARG_DOCU(p99_strtouh, unsigned short, char const *p00_nptr, char **p00_eptr, int p00_base)
333 #define p99_strtouh(...) P99_CALL_DEFARG(p99_strtouh, 3, __VA_ARGS__)
334 #define p99_strtouh_defarg_1() 0
335 #define p99_strtouh_defarg_2() 0
336 
337 
345 P00_C99_DEFARG_DOCU(p99_strtou, unsinged, char const *p00_nptr, char **p00_eptr, int p00_base)
349 #define p99_strtou(...) P99_CALL_DEFARG(p99_strtou, 3, __VA_ARGS__)
350 #define p99_strtou_defarg_1() 0
351 #define p99_strtou_defarg_2() 0
352 
353 P00_C99_DEFARG_DOCU(p99_strtoi8, int_least8_t, char const *p00_nptr, char **p00_eptr, int p00_base)
357 #define p99_strtoi8(...) P99_CALL_DEFARG(p99_strtoi8, 3, __VA_ARGS__)
358 #define p99_strtoi8_defarg_1() 0
359 #define p99_strtoi8_defarg_2() 0
360 
361 P00_C99_DEFARG_DOCU(p99_strtot, ptrdiff_t, char const *p00_nptr, char **p00_eptr, int p00_base)
365 #define p99_strtot(...) P99_CALL_DEFARG(p99_strtot, 3, __VA_ARGS__)
366 #define p99_strtot_defarg_1() 0
367 #define p99_strtot_defarg_2() 0
368 
369 P00_C99_DEFARG_DOCU(p99_strtouz, size_t, char const *p00_nptr, char **p00_eptr, int p00_base)
373 #define p99_strtouz(...) P99_CALL_DEFARG(p99_strtouz, 3, __VA_ARGS__)
374 #define p99_strtouz_defarg_1() 0
375 #define p99_strtouz_defarg_2() 0
376 
377 
378 P00_C99_DEFARG_DOCU(p99_strtou8, uint_least8_t, char const *p00_nptr, char **p00_eptr, int p00_base)
382 #define p99_strtou8(...) P99_CALL_DEFARG(p99_strtou8, 3, __VA_ARGS__)
383 #define p99_strtou8_defarg_1() 0
384 #define p99_strtou8_defarg_2() 0
385 
386 P00_C99_DEFARG_DOCU(p99_strtoi16, int_least16_t, char const *p00_nptr, char **p00_eptr, int p00_base)
390 #define p99_strtoi16(...) P99_CALL_DEFARG(p99_strtoi16, 3, __VA_ARGS__)
391 #define p99_strtoi16_defarg_1() 0
392 #define p99_strtoi16_defarg_2() 0
393 
394 
395 P00_C99_DEFARG_DOCU(p99_strtou16, uint_least16_t, char const *p00_nptr, char **p00_eptr, int p00_base)
399 #define p99_strtou16(...) P99_CALL_DEFARG(p99_strtou16, 3, __VA_ARGS__)
400 #define p99_strtou16_defarg_1() 0
401 #define p99_strtou16_defarg_2() 0
402 
403 P00_C99_DEFARG_DOCU(p99_strtoi32, int_least32_t, char const *p00_nptr, char **p00_eptr, int p00_base)
407 #define p99_strtoi32(...) P99_CALL_DEFARG(p99_strtoi32, 3, __VA_ARGS__)
408 #define p99_strtoi32_defarg_1() 0
409 #define p99_strtoi32_defarg_2() 0
410 
411 
412 P00_C99_DEFARG_DOCU(p99_strtou32, uint_least32_t, char const *p00_nptr, char **p00_eptr, int p00_base)
416 #define p99_strtou32(...) P99_CALL_DEFARG(p99_strtou32, 3, __VA_ARGS__)
417 #define p99_strtou32_defarg_1() 0
418 #define p99_strtou32_defarg_2() 0
419 
420 
421 P00_C99_DEFARG_DOCU(p99_strtoi64, int_least64_t, char const *p00_nptr, char **p00_eptr, int p00_base)
425 #define p99_strtoi64(...) P99_CALL_DEFARG(p99_strtoi64, 3, __VA_ARGS__)
426 #define p99_strtoi64_defarg_1() 0
427 #define p99_strtoi64_defarg_2() 0
428 
429 
430 P00_C99_DEFARG_DOCU(p99_strtou64, uint_least64_t, char const *p00_nptr, char **p00_eptr, int p00_base)
434 #define p99_strtou64(...) P99_CALL_DEFARG(p99_strtou64, 3, __VA_ARGS__)
435 #define p99_strtou64_defarg_1() 0
436 #define p99_strtou64_defarg_2() 0
437 
438 #ifndef strtoc
439 # define strtoc p99_strtoc
440 #endif
441 
442 #ifndef strtohh
443 # define strtohh p99_strtohh
444 #endif
445 #ifndef strtoh
446 # define strtoh p99_strtoh
447 #endif
448 #ifndef strto
449 # define strto p99_strto
450 #endif
451 #ifndef strtot
452 # define strtot p99_strtot
453 #endif
454 #ifndef strtoj
455 # define strtoj p99_strtoj
456 #endif
457 
458 #ifndef strtouhh
459 # define strtouhh p99_strtouhh
460 #endif
461 #ifndef strtouh
462 # define strtouh p99_strtouh
463 #endif
464 #ifndef strtou
465 # define strtou p99_strtou
466 #endif
467 #ifndef strtouz
468 # define strtouz p99_strtouz
469 #endif
470 #ifndef strtouj
471 # define strtouj p99_strtouj
472 #endif
473 
474 #ifndef strtoi8
475 # define strtoi8 p99_strtoi8
476 #endif
477 #ifndef strtoi16
478 # define strtoi16 p99_strtoi16
479 #endif
480 #ifndef strtoi32
481 # define strtoi32 p99_strtoi32
482 #endif
483 #ifndef strtoi64
484 # define strtoi64 p99_strtoi64
485 #endif
486 
487 #ifndef strtou8
488 # define strtou8 p99_strtou8
489 #endif
490 #ifndef strtou16
491 # define strtou16 p99_strtou16
492 #endif
493 #ifndef strtou32
494 # define strtou32 p99_strtou32
495 #endif
496 #ifndef strtou64
497 # define strtou64 p99_strtou64
498 #endif
499 
500 
505 #endif /* !P99_C99_DEFAULT_H_ */
p99_strtou16
#define p99_strtou16(...)
Default arguments for C99 function p99_strtou16
Definition: p99_c99_default.h:399
p99_defarg.h
Macros for default arguments to functions.
p99_strtou
#define p99_strtou(...)
Default arguments for C99 function p99_strtou
Definition: p99_c99_default.h:349
strerror
#define strerror(...)
Default arguments for C99 function strerror
Definition: p99_c99_default.h:35
wcstoul
#define wcstoul(...)
Default arguments for C99 function wcstoul
Definition: p99_c99_default.h:130
uintmax_t
uintmax_t
Definition: p99_str.h:117
strtoll
#define strtoll(...)
Default arguments for C99 function strtoll
Definition: p99_c99_default.h:190
p99_strtot
#define p99_strtot(...)
Default arguments for C99 function p99_strtot
Definition: p99_c99_default.h:365
strtol
#define strtol(...)
Default arguments for C99 function strtol
Definition: p99_c99_default.h:177
p99_strtoi8
#define p99_strtoi8(...)
Default arguments for C99 function p99_strtoi8
Definition: p99_c99_default.h:357
calloc
#define calloc(...)
Default arguments for C99 function calloc
Definition: p99_c99_default.h:44
P99_SEP
#define P99_SEP(MACRO,...)
Apply the macro MACRO to the rest of the argument list.
Definition: p99_for.h:297
p99_strtohh
#define p99_strtohh(...)
Default arguments for C99 function p99_strtohh
Definition: p99_c99_default.h:308
ptrdiff_t
ptrdiff_t
Definition: p99_str.h:101
wcstol
#define wcstol(...)
Default arguments for C99 function wcstol
Definition: p99_c99_default.h:105
wcstoull
#define wcstoull(...)
Default arguments for C99 function wcstoull
Definition: p99_c99_default.h:138
wcstoll
#define wcstoll(...)
Default arguments for C99 function wcstoll
Definition: p99_c99_default.h:114
strtold
#define strtold(...)
Default arguments for C99 function strtold
Definition: p99_c99_default.h:241
p99_strtouhh
#define p99_strtouhh(...)
Default arguments for C99 function p99_strtouhh
Definition: p99_c99_default.h:316
p99_strtouz
#define p99_strtouz(...)
Default arguments for C99 function p99_strtouz
Definition: p99_c99_default.h:373
p99_strtoh
#define p99_strtoh(...)
Default arguments for C99 function p99_strtoh
Definition: p99_c99_default.h:325
strtoumax
#define strtoumax(...)
Default arguments for C99 function strtoumax
Definition: p99_c99_default.h:222
wcstold
#define wcstold(...)
Default arguments for C99 function wcstold
Definition: p99_c99_default.h:165
strtod
#define strtod(...)
Default arguments for C99 function strtod
Definition: p99_c99_default.h:235
wcstof
#define wcstof(...)
Default arguments for C99 function wcstof
Definition: p99_c99_default.h:153
strtof
#define strtof(...)
Default arguments for C99 function strtof
Definition: p99_c99_default.h:229
strtoull
#define strtoull(...)
Default arguments for C99 function strtoull
Definition: p99_c99_default.h:214
wcstod
#define wcstod(...)
Default arguments for C99 function wcstod
Definition: p99_c99_default.h:159
p99_strtoi32
#define p99_strtoi32(...)
Default arguments for C99 function p99_strtoi32
Definition: p99_c99_default.h:407
p99_strtouh
#define p99_strtouh(...)
Default arguments for C99 function p99_strtouh
Definition: p99_c99_default.h:333
strtoul
#define strtoul(...)
Default arguments for C99 function strtoul
Definition: p99_c99_default.h:206
p99_strtou8
#define p99_strtou8(...)
Default arguments for C99 function p99_strtou8
Definition: p99_c99_default.h:382
longjmp
#define longjmp(...)
Default arguments for C99 function longjmp
Definition: p99_c99_default.h:55
p99_strtou32
#define p99_strtou32(...)
Default arguments for C99 function p99_strtou32
Definition: p99_c99_default.h:416
p99_strtoi16
#define p99_strtoi16(...)
Default arguments for C99 function p99_strtoi16
Definition: p99_c99_default.h:390
p99_strtou64
#define p99_strtou64(...)
Default arguments for C99 function p99_strtou64
Definition: p99_c99_default.h:434
strtoimax
#define strtoimax(...)
Default arguments for C99 function strtoimax
Definition: p99_c99_default.h:198
p99_strtoc
#define p99_strtoc(...)
Default arguments for C99 function p99_strtoc
Definition: p99_c99_default.h:300
p99_strto
#define p99_strto(...)
Default arguments for C99 function p99_strto
Definition: p99_c99_default.h:291
wcstoumax
#define wcstoumax(...)
Default arguments for C99 function wcstoumax
Definition: p99_c99_default.h:146
p99_strtoi64
#define p99_strtoi64(...)
Default arguments for C99 function p99_strtoi64
Definition: p99_c99_default.h:425
wcstoimax
#define wcstoimax(...)
Default arguments for C99 function wcstoimax
Definition: p99_c99_default.h:122