summaryrefslogtreecommitdiff
path: root/include/libc-symbols.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libc-symbols.h')
-rw-r--r--include/libc-symbols.h68
1 files changed, 49 insertions, 19 deletions
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 18f26b2e61..3310e3a678 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -20,26 +20,46 @@
#ifndef _LIBC_SYMBOLS_H
#define _LIBC_SYMBOLS_H 1
-#define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME)
-#define IS_IN(lib) (IN_MODULE == MODULE_##lib)
+/* This file is included implicitly in the compilation of every source file,
+ using -include. It includes config.h. */
-/* Returns true if the current module is a versioned library. Versioned
- library names culled from shlib-versions files are assigned a MODULE_*
- value lower than MODULE_LIBS_BEGIN. */
-#define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN)
-
-#define PASTE_NAME(a,b) PASTE_NAME1 (a,b)
-#define PASTE_NAME1(a,b) a##b
-
-/* This file's macros are included implicitly in the compilation of every
- file in the C library by -imacros.
-
- We include config.h which is generated by configure.
- It should define for us the following symbol:
+/* Enable declarations of GNU extensions, since we are compiling them. */
+#define _GNU_SOURCE 1
+
+#ifdef MODULE_NAME
+
+/* Use `#if IS_IN (module)` to detect what component is being compiled. */
+#define PASTE_NAME1(a,b) a##b
+#define PASTE_NAME(a,b) PASTE_NAME1 (a,b)
+#define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME)
+#define IS_IN(lib) (IN_MODULE == MODULE_##lib)
+
+/* True if the current module is a versioned library. Versioned
+ library names culled from shlib-versions files are assigned a
+ MODULE_* value greater than MODULE_LIBS_BEGIN. */
+#define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN)
+
+/* The testsuite, and some other ancillary code, should be compiled against
+ as close an approximation to the installed headers as possible.
+ Defining this symbol disables most internal-use-only declarations
+ provided by this header, and all those provided by other internal
+ wrapper headers. */
+#if IS_IN (testsuite) || defined IS_IN_build || defined __cplusplus
+# define _ISOMAC 1
+#endif
- * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
+#else
+/* The generation process for a few files created very early in the
+ build (notably libc-modules.h itself) involves preprocessing this
+ header without defining MODULE_NAME. Under these conditions,
+ internal declarations (especially from config.h) must be visible,
+ but IS_IN should always evaluate as false. */
+# define IS_IN(lib) 0
+# define IS_IN_LIB 0
+# define IN_MODULE (-1)
+#endif
- */
+#ifndef _ISOMAC
/* This is defined for the compilation of all C library code. features.h
tests this to avoid inclusion of stubs.h while compiling the library,
@@ -50,8 +70,17 @@
itself is being compiled, or just some generator program. */
#define _LIBC 1
-/* Enable declarations of GNU extensions, since we are compiling them. */
-#define _GNU_SOURCE 1
+/* Some files must be compiled with optimization on. */
+#if !defined __ASSEMBLER__ && !defined __OPTIMIZE__
+# error "glibc cannot be compiled without optimization"
+#endif
+
+/* -ffast-math cannot be applied to the C library, as it alters the ABI.
+ Some test components that use -ffast-math are currently not part of
+ IS_IN (testsuite) for technical reasons, so we have a secondary override. */
+#if defined __FAST_MATH__ && !defined TEST_FAST_MATH
+# error "glibc must not be compiled with -ffast-math"
+#endif
#include <config.h>
@@ -936,4 +965,5 @@ for linking")
# define _GL_ATTRIBUTE_CONST /* empty */
#endif
+#endif /* !_ISOMAC */
#endif /* libc-symbols.h */