summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2023-12-07 11:58:47 +0100
committerjvoisin2023-12-07 12:07:29 +0100
commit9064a508d5f1ed3514d3e5b4734576e80f7048ae (patch)
tree488a7315c7362ab1ab1691be54f0b7f6cc9a3c58
parent5494a3f9dce8d3cb1a4f4359084a1ef0ee15333e (diff)
Add a global test to ensure that all headers are compiling
-rw-r--r--include/stdlib.h11
-rw-r--r--tests/Makefile1
-rw-r--r--tests/test_compile.c18
3 files changed, 27 insertions, 3 deletions
diff --git a/include/stdlib.h b/include/stdlib.h
index d3cd863..5d89c9c 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -23,6 +23,7 @@ __extension__
23#include_next <stdlib.h> 23#include_next <stdlib.h>
24 24
25#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 25#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
26
26#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 27#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
27#if !defined(__cplusplus) && !defined(__clang__) 28#if !defined(__cplusplus) && !defined(__clang__)
28__extension__ 29__extension__
@@ -36,6 +37,9 @@ __extension__
36extern "C" { 37extern "C" {
37#endif 38#endif
38 39
40
41/* FIXME clang */
42#if !defined(__clang__)
39#undef malloc 43#undef malloc
40#undef realloc 44#undef realloc
41#undef calloc 45#undef calloc
@@ -84,8 +88,7 @@ _FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s)
84} 88}
85#endif 89#endif
86 90
87/* FIXME clang */ 91#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE))
88#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__)
89#undef realpath 92#undef realpath
90__warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?") 93__warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?")
91#if __has_builtin(__builtin_realpath) 94#if __has_builtin(__builtin_realpath)
@@ -118,6 +121,8 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
118} 121}
119#endif 122#endif
120 123
121#endif 124#endif // clang
125
126#endif // _FORTIFY_SOURCE
122 127
123#endif 128#endif
diff --git a/tests/Makefile b/tests/Makefile
index 4889dc7..f91bff0 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -18,6 +18,7 @@ RUNTIME_TARGETS= \
18 test_bcopy_static_write \ 18 test_bcopy_static_write \
19 test_bzero_dynamic_write \ 19 test_bzero_dynamic_write \
20 test_bzero_static_write \ 20 test_bzero_static_write \
21 test_compile \
21 test_confstr_dynamic \ 22 test_confstr_dynamic \
22 test_confstr_static \ 23 test_confstr_static \
23 test_fgets_dynamic \ 24 test_fgets_dynamic \
diff --git a/tests/test_compile.c b/tests/test_compile.c
new file mode 100644
index 0000000..edbbb27
--- /dev/null
+++ b/tests/test_compile.c
@@ -0,0 +1,18 @@
1#include "common.h"
2
3#include <poll.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <strings.h>
8#include <unistd.h>
9#include <wchar.h>
10
11#include <sys/select.h>
12#include <sys/socket.h>
13#include <sys/stat.h>
14
15// Check that all headers are compiling.
16int main(int argc, char** argv) {
17 return 0;
18}