From 9064a508d5f1ed3514d3e5b4734576e80f7048ae Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 7 Dec 2023 11:58:47 +0100 Subject: Add a global test to ensure that all headers are compiling --- include/stdlib.h | 11 ++++++++--- tests/Makefile | 1 + tests/test_compile.c | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 tests/test_compile.c 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__ #include_next #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 + #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #if !defined(__cplusplus) && !defined(__clang__) __extension__ @@ -36,6 +37,9 @@ __extension__ extern "C" { #endif + +/* FIXME clang */ +#if !defined(__clang__) #undef malloc #undef realloc #undef calloc @@ -84,8 +88,7 @@ _FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s) } #endif -/* FIXME clang */ -#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__) +#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) #undef realpath __warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?") #if __has_builtin(__builtin_realpath) @@ -118,6 +121,8 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) } #endif -#endif +#endif // clang + +#endif // _FORTIFY_SOURCE #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= \ test_bcopy_static_write \ test_bzero_dynamic_write \ test_bzero_static_write \ + test_compile \ test_confstr_dynamic \ test_confstr_static \ 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 @@ +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// Check that all headers are compiling. +int main(int argc, char** argv) { + return 0; +} -- cgit v1.3