summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/errno.h2
-rw-r--r--include/libc-symbols.h68
-rw-r--r--include/math.h5
-rw-r--r--include/stdio.h7
-rw-r--r--include/stdlib.h4
-rw-r--r--include/string.h10
-rw-r--r--include/time.h4
-rw-r--r--include/unistd.h3
-rw-r--r--include/wchar.h2
9 files changed, 61 insertions, 44 deletions
diff --git a/include/errno.h b/include/errno.h
index 7df41dfc31..73fc32e5e0 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -2,7 +2,7 @@
#include <stdlib/errno.h>
-#if defined _ERRNO_H && !defined _ISOMAC && !defined __cplusplus
+#if defined _ERRNO_H && !defined _ISOMAC
# if IS_IN (rtld)
# include <dl-sysdep.h>
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 */
diff --git a/include/math.h b/include/math.h
index a4f556263a..6ff67830f8 100644
--- a/include/math.h
+++ b/include/math.h
@@ -1,5 +1,10 @@
#ifndef _MATH_H
+#ifdef _ISOMAC
+# undef NO_LONG_DOUBLE
+# undef _Mlong_double_
+#endif
+
#include <math/math.h>
#ifndef _ISOMAC
diff --git a/include/stdio.h b/include/stdio.h
index 4e7cfa1be5..ed6593ba50 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -1,11 +1,10 @@
#ifndef _STDIO_H
-# if defined __need_FILE || defined __need___FILE || defined _ISOMAC
+# if defined _ISOMAC || defined __need_FILE || defined __need___FILE
# include <libio/stdio.h>
# else
# include <libio/stdio.h>
/* Now define the internal interfaces. */
-__BEGIN_DECLS
extern int __fcloseall (void);
extern int __snprintf (char *__restrict __s, size_t __maxlen,
@@ -30,7 +29,6 @@ extern int __vsscanf (const char *__restrict __s,
_G_va_list __arg)
__attribute__ ((__format__ (__scanf__, 2, 0)));
-# ifndef __cplusplus
extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW;
extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...)
__THROW;
@@ -52,7 +50,6 @@ extern int __obstack_printf_chk (struct obstack *, int, const char *, ...)
__THROW;
extern int __obstack_vprintf_chk (struct obstack *, int, const char *,
_G_va_list) __THROW;
-# endif
extern int __isoc99_fscanf (FILE *__restrict __stream,
const char *__restrict __format, ...) __wur;
@@ -186,7 +183,5 @@ libc_hidden_proto (__obstack_vprintf_chk)
extern FILE * __fmemopen (void *buf, size_t len, const char *mode);
libc_hidden_proto (__fmemopen)
-__END_DECLS
# endif
-
#endif
diff --git a/include/stdlib.h b/include/stdlib.h
index 929cead59a..c3ee680bd6 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -9,8 +9,6 @@
#if !defined _ISOMAC
# include <sys/stat.h>
-__BEGIN_DECLS
-
extern __typeof (strtol_l) __strtol_l;
extern __typeof (strtoul_l) __strtoul_l;
extern __typeof (strtoll_l) __strtoll_l;
@@ -261,8 +259,6 @@ extern __typeof (unsetenv) unsetenv attribute_hidden;
extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden;
# endif
-__END_DECLS
-
#endif
#endif /* include/stdlib.h */
diff --git a/include/string.h b/include/string.h
index f166de9c43..ce71674086 100644
--- a/include/string.h
+++ b/include/string.h
@@ -1,6 +1,8 @@
#ifndef _STRING_H
-#if !defined _ISOMAC && !defined __cplusplus
+#ifndef _ISOMAC
+/* Some of these are defined as macros in the real string.h, so we must
+ prototype them before including it. */
#include <sys/types.h>
extern void *__memccpy (void *__dest, const void *__src,
@@ -46,16 +48,14 @@ extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
extern int __ffs (int __i) __attribute__ ((const));
extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen);
-#endif
/* Get _STRING_ARCH_unaligned. */
#include <string_private.h>
+#endif
-/* Now the real definitions. We do this here since some of the functions
- above are defined as macros in the headers. */
#include <string/string.h>
-#if !defined _ISOMAC && !defined __cplusplus
+#ifndef _ISOMAC
extern __typeof (strcoll_l) __strcoll_l;
extern __typeof (strxfrm_l) __strxfrm_l;
extern __typeof (strcasecmp_l) __strcasecmp_l;
diff --git a/include/time.h b/include/time.h
index 6badf0e557..3a828e0420 100644
--- a/include/time.h
+++ b/include/time.h
@@ -4,8 +4,6 @@
#ifndef _ISOMAC
# include <xlocale.h>
-__BEGIN_DECLS
-
extern __typeof (strftime_l) __strftime_l;
libc_hidden_proto (__strftime_l)
extern __typeof (strptime_l) __strptime_l;
@@ -104,7 +102,5 @@ extern double __difftime (time_t time1, time_t time0);
actual clock ID. */
#define CLOCK_IDFIELD_SIZE 3
-__END_DECLS
-
#endif
#endif
diff --git a/include/unistd.h b/include/unistd.h
index f36759b24d..c40f41c0f2 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -2,7 +2,6 @@
# include <posix/unistd.h>
# ifndef _ISOMAC
-__BEGIN_DECLS
libc_hidden_proto (_exit, __noreturn__)
rtld_hidden_proto (_exit, __noreturn__)
@@ -188,7 +187,5 @@ extern int __getlogin_r_loginuid (char *name, size_t namesize)
extern __typeof (__access) __access_noerrno attribute_hidden;
# endif
-__END_DECLS
# endif
-
#endif
diff --git a/include/wchar.h b/include/wchar.h
index 6272130e24..e2579a176a 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -172,7 +172,6 @@ extern int __vfwprintf (__FILE *__restrict __s,
const wchar_t *__restrict __format,
__gnuc_va_list __arg)
/* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
-#ifndef __cplusplus
extern int __vfwprintf_chk (FILE *__restrict __s, int __flag,
const wchar_t *__restrict __format,
__gnuc_va_list __arg)
@@ -184,7 +183,6 @@ extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
/* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
libc_hidden_proto (__vfwprintf_chk)
libc_hidden_proto (__vswprintf_chk)
-#endif
extern int __isoc99_fwscanf (__FILE *__restrict __stream,
const wchar_t *__restrict __format, ...);