xref: /third_party/musl/libc-test/src/api/stdlib.c (revision 570af302)
1#include <stdlib.h>
2#define T(t) (t*)0;
3#define F(t,n) {t *y = &x.n;}
4#define C(n) switch(n){case n:;}
5#define I(t,e) {t x[sizeof(t)==sizeof(e)] = {e};}
6static void f()
7{
8C(EXIT_FAILURE)
9C(EXIT_SUCCESS)
10C(RAND_MAX)
11I(size_t,MB_CUR_MAX)
12{void *x=NULL;}
13T(div_t)
14T(ldiv_t)
15T(lldiv_t)
16T(size_t)
17T(wchar_t)
18#ifdef _POSIX_C_SOURCE
19C(WEXITSTATUS(0))
20C(WIFEXITED(0))
21C(WIFSIGNALED(0))
22C(WIFSTOPPED(0))
23C(WNOHANG)
24C(WSTOPSIG(0))
25C(WTERMSIG(0))
26C(WUNTRACED)
27#endif
28{void(*p)(int) = _Exit;}
29{void(*p)(void) = abort;}
30{int(*p)(int) = abs;}
31{int(*p)(void(*)(void)) = atexit;}
32{double(*p)(const char*) = atof;}
33{int(*p)(const char*) = atoi;}
34{long(*p)(const char*) = atol;}
35{long long(*p)(const char*) = atoll;}
36{void*(*p)(const void*,const void*,size_t,size_t,int(*)(const void*,const void*)) = bsearch;}
37{void*(*p)(size_t,size_t) = calloc;}
38{div_t(*p)(int,int) = div;}
39{void(*p)(int) = exit;}
40{void(*p)(void*) = free;}
41{char*(*p)(const char*) = getenv;}
42{int(*p)(char**,char*const*,char**) = getsubopt;}
43{long(*p)(long) = labs;}
44{ldiv_t(*p)(long,long) = ldiv;}
45{long long(*p)(long long) = llabs;}
46{lldiv_t(*p)(long long,long long) = lldiv;}
47{void*(*p)(size_t) = malloc;}
48{int(*p)(const char*,size_t) = mblen;}
49{size_t(*p)(wchar_t*restrict,const char*restrict,size_t) = mbstowcs;}
50{int(*p)(wchar_t*restrict,const char*restrict,size_t) = mbtowc;}
51{int(*p)(void**,size_t,size_t) = posix_memalign;}
52{void(*p)(void*,size_t,size_t,int(*)(const void*,const void*)) = qsort;}
53{int(*p)(void) = rand;}
54{void*(*p)(void*,size_t) = realloc;}
55{void(*p)(unsigned) = srand;}
56{double(*p)(const char*restrict,char**restrict) = strtod;}
57{float(*p)(const char*restrict,char**restrict) = strtof;}
58{long(*p)(const char*restrict,char**restrict,int) = strtol;}
59{long double(*p)(const char*restrict,char**restrict) = strtold;}
60{long long(*p)(const char*restrict,char**restrict,int) = strtoll;}
61{unsigned long(*p)(const char*restrict,char**restrict,int) = strtoul;}
62{unsigned long long(*p)(const char*restrict,char**restrict,int) = strtoull;}
63{int(*p)(const char*) = system;}
64{size_t(*p)(char*restrict,const wchar_t*restrict,size_t) = wcstombs;}
65{int(*p)(char*,wchar_t) = wctomb;}
66#ifdef _POSIX_C_SOURCE
67{char*(*p)(char*) = mkdtemp;}
68{int(*p)(char*) = mkstemp;}
69{int(*p)(const char*,const char*,int) = setenv;}
70{int(*p)(const char*) = unsetenv;}
71#endif
72#ifdef _XOPEN_SOURCE
73{long(*p)(const char*) = a64l;}
74{double(*p)(void) = drand48;}
75{double(*p)(unsigned short[]) = erand48;}
76{int(*p)(int) = grantpt;}
77{char*(*p)(unsigned,char*,size_t) = initstate;}
78{long(*p)(unsigned short[]) = jrand48;}
79{char*(*p)(long) = l64a;}
80{void(*p)(unsigned short[]) = lcong48;}
81{long(*p)(void) = lrand48;}
82{long(*p)(void) = mrand48;}
83{long(*p)(unsigned short[]) = nrand48;}
84{char*(*p)(int) = ptsname;}
85{int(*p)(char*) = putenv;}
86{long(*p)(void) = random;}
87{char*(*p)(const char*restrict,char*restrict) = realpath;}
88{unsigned short*(*p)(unsigned short[]) = seed48;}
89{void(*p)(const char*) = setkey;}
90{char*(*p)(char*) = setstate;}
91{void(*p)(long) = srand48;}
92{void(*p)(unsigned) = srandom;}
93{int(*p)(int) = unlockpt;}
94#endif
95}
96
97#ifdef _XOPEN_SOURCE
98#include <fcntl.h>
99static void g()
100{
101{int(*p)(int) = posix_openpt;}
102}
103#endif
104
105