1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #include <stdlib.h>
30 
31 #include "header_checks.h"
32 
stdlib_h()33 static void stdlib_h() {
34   MACRO(EXIT_FAILURE);
35   MACRO_VALUE(EXIT_SUCCESS, 0);
36 
37   MACRO(RAND_MAX);
38 
39   MACRO(MB_CUR_MAX);
40 
41   MACRO(NULL);
42 
43   TYPE(div_t);
44   TYPE(ldiv_t);
45   TYPE(lldiv_t);
46   TYPE(size_t);
47   TYPE(wchar_t);
48 
49 #if !defined(WEXITSTATUS)
50 #error WEXITSTATUS
51 #endif
52 #if !defined(WIFEXITED)
53 #error WIFEXITED
54 #endif
55 #if !defined(WIFSIGNALED)
56 #error WIFSIGNALED
57 #endif
58 #if !defined(WIFSTOPPED)
59 #error WIFSTOPPED
60 #endif
61   MACRO(WNOHANG);
62 #if !defined(WSTOPSIG)
63 #error WSTOPSIG
64 #endif
65 #if !defined(WTERMSIG)
66 #error WTERMSIG
67 #endif
68   MACRO(WUNTRACED);
69 
70   FUNCTION(_Exit, void (*f)(int));
71 #if !defined(__BIONIC__)
72   FUNCTION(a64l, long (*f)(const char*));
73 #endif
74   FUNCTION(abort, void (*f)(void));
75   FUNCTION(abs, int (*f)(int));
76   FUNCTION(atexit, int (*f)(void (*)(void)));
77   FUNCTION(atof, double (*f)(const char*));
78   FUNCTION(atoi, int (*f)(const char*));
79   FUNCTION(atol, long (*f)(const char*));
80   FUNCTION(atoll, long long (*f)(const char*));
81   FUNCTION(bsearch, void* (*f)(const void*, const void*, size_t, size_t, int (*)(const void*, const void*)));
82   FUNCTION(calloc, void* (*f)(size_t, size_t));
83   FUNCTION(div, div_t (*f)(int, int));
84   FUNCTION(drand48, double (*f)(void));
85   FUNCTION(erand48, double (*f)(unsigned short[3]));
86   FUNCTION(exit, void (*f)(int));
87   FUNCTION(free, void (*f)(void*));
88   FUNCTION(getenv, char* (*f)(const char*));
89   FUNCTION(getsubopt, int (*f)(char**, char* const*, char**));
90   FUNCTION(grantpt, int (*f)(int));
91   FUNCTION(initstate, char* (*f)(unsigned, char*, size_t));
92   FUNCTION(jrand48, long (*f)(unsigned short[3]));
93 #if !defined(__BIONIC__)
94   FUNCTION(l64a, char* (*f)(long));
95 #endif
96   FUNCTION(labs, long (*f)(long));
97   FUNCTION(lcong48, void (*f)(unsigned short[7]));
98   FUNCTION(ldiv, ldiv_t (*f)(long, long));
99   FUNCTION(llabs, long long (*f)(long long));
100   FUNCTION(lldiv, lldiv_t (*f)(long long, long long));
101   FUNCTION(lrand48, long (*f)(void));
102   FUNCTION(malloc, void* (*f)(size_t));
103   FUNCTION(mblen, int (*f)(const char*, size_t));
104   FUNCTION(mbstowcs, size_t (*f)(wchar_t*, const char*, size_t));
105   FUNCTION(mbtowc, int (*f)(wchar_t*, const char*, size_t));
106   FUNCTION(mkdtemp, char* (*f)(char*));
107   FUNCTION(mkstemp, int (*f)(char*));
108   FUNCTION(mrand48, long (*f)(void));
109   FUNCTION(nrand48, long (*f)(unsigned short[3]));
110   FUNCTION(posix_memalign, int (*f)(void**, size_t, size_t));
111   FUNCTION(posix_openpt, int (*f)(int));
112   FUNCTION(ptsname, char* (*f)(int));
113   FUNCTION(putenv, int (*f)(char*));
114   FUNCTION(qsort, void (*f)(void*, size_t, size_t, int (*)(const void*, const void*)));
115   FUNCTION(rand, int (*f)(void));
116   FUNCTION(rand_r, int (*f)(unsigned*));
117   FUNCTION(random, long (*f)(void));
118   FUNCTION(realloc, void* (*f)(void*, size_t));
119   FUNCTION(realpath, char* (*f)(const char*, char*));
120   FUNCTION(seed48, unsigned short* (*f)(unsigned short[3]));
121   FUNCTION(setenv, int (*f)(const char*, const char*, int));
122 #if !defined(__BIONIC__)
123   FUNCTION(setkey, void (*f)(const char*));
124 #endif
125   FUNCTION(setstate, char* (*f)(char*));
126   FUNCTION(srand, void (*f)(unsigned));
127   FUNCTION(srand48, void (*f)(long));
128   FUNCTION(srandom, void (*f)(unsigned));
129   FUNCTION(strtod, double (*f)(const char*, char**));
130   FUNCTION(strtof, float (*f)(const char*, char**));
131   FUNCTION(strtol, long (*f)(const char*, char**, int));
132   FUNCTION(strtold, long double (*f)(const char*, char**));
133   FUNCTION(strtoll, long long (*f)(const char*, char**, int));
134   FUNCTION(strtoul, unsigned long (*f)(const char*, char**, int));
135   FUNCTION(strtoull, unsigned long long (*f)(const char*, char**, int));
136   FUNCTION(system, int (*f)(const char*));
137   FUNCTION(unlockpt, int (*f)(int));
138   FUNCTION(unsetenv, int (*f)(const char*));
139   FUNCTION(wcstombs, size_t (*f)(char*, const wchar_t*, size_t));
140   FUNCTION(wctomb, int (*f)(char*, wchar_t));
141 }
142