about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-03-16 13:31:57 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-03-16 13:31:57 +0000
commit2072f5c34ede81dde9e0d953d57a0690a66b0f12 (patch)
tree0833e169e1c3e9b24ef64e9010f7bb1e862f7da8 /stdlib
parentd6fc3f6516cd20f195758086fbbbe3f17a8a6d95 (diff)
downloadglibc-2072f5c34ede81dde9e0d953d57a0690a66b0f12.tar.gz
glibc-2072f5c34ede81dde9e0d953d57a0690a66b0f12.tar.xz
glibc-2072f5c34ede81dde9e0d953d57a0690a66b0f12.zip
Remove C++ namespace handling from glibc headers.
glibc headers include some code (not particularly consistent or
systematic) to put various declarations in C++ namespaces std and
__c99, if _GLIBCPP_USE_NAMESPACES is defined.

As noted in <https://gcc.gnu.org/ml/libstdc++/2017-03/msg00025.html>,
this macro was removed from libstdc++ in 2000.  I don't expect
compilation with such old versions of libstdc++ to work with current
glibc headers anyway (whereas old *binaries* are expected to stay
working with current glibc); this patch (which should be a no-op with
any libstdc++ version postdating that removal) removes all this code
from the glibc headers.

The begin-end-check.pl test, whose comments say it is about checking
these namespace macro calls, is also removed.  The code in that test
would have covered __BEGIN_DECLS / __END_DECLS as well, but if those
weren't properly matched it would show up with the
check-installed-headers-cxx tests, so I don't think there is an actual
use for keeping begin-end-check.pl with the namespace code removed.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

	* misc/sys/cdefs.h (__BEGIN_NAMESPACE_STD): Remove macro.
	(__END_NAMESPACE_STD): Likewise.
	(__USING_NAMESPACE_STD): Likewise.
	(__BEGIN_NAMESPACE_C99): Likewise.
	(__END_NAMESPACE_C99): Likewise.
	(__USING_NAMESPACE_C99): Likewise.
	* math/math.h (_Mdouble_BEGIN_NAMESPACE): Do not define and
	undefine macro.
	(_Mdouble_END_NAMESPACE): Likewise.
	* ctype/ctype.h: Do not handle C++ namespaces.
	* libio/bits/stdio-ldbl.h: Likewise.
	* libio/stdio.h: Likewise.
	* locale/locale.h: Likewise.
	* math/bits/mathcalls.h: Likewise.
	* setjmp/setjmp.h: Likewise.
	* signal/signal.h: Likewise.
	* stdlib/bits/stdlib-float.h: Likewise.
	* stdlib/bits/stdlib-ldbl.h: Likewise.
	* stdlib/stdlib.h: Likewise.
	* string/string.h: Likewise.
	* sysdeps/x86/fpu/bits/mathinline.h: Likewise.
	* time/bits/types/clock_t.h: Likewise.
	* time/bits/types/struct_tm.h: Likewise.
	* time/bits/types/time_t.h: Likewise.
	* time/time.h: Likewise.
	* wcsmbs/bits/wchar-ldbl.h: Likewise.
	* wcsmbs/uchar.h: Likewise.
	* wcsmbs/wchar.h: Likewise.
	[_GLIBCPP_USE_NAMESPACES] (wint_t): Remove conditional definition.
	* wctype/wctype.h: Do not handle C++ namespaces.
	* scripts/begin-end-check.pl: Remove.
	* Makefile (installed-headers): Likewise.
	(tests-special): Do not add $(objpfx)begin-end-check.out.
	($(objpfx)begin-end-check.out): Remove.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/bits/stdlib-float.h2
-rw-r--r--stdlib/bits/stdlib-ldbl.h2
-rw-r--r--stdlib/stdlib.h44
3 files changed, 0 insertions, 48 deletions
diff --git a/stdlib/bits/stdlib-float.h b/stdlib/bits/stdlib-float.h
index 8052668486..aba8e94596 100644
--- a/stdlib/bits/stdlib-float.h
+++ b/stdlib/bits/stdlib-float.h
@@ -21,11 +21,9 @@
 #endif
 
 #ifdef __USE_EXTERN_INLINES
-__BEGIN_NAMESPACE_STD
 __extern_inline double
 __NTH (atof (const char *__nptr))
 {
   return strtod (__nptr, (char **) NULL);
 }
-__END_NAMESPACE_STD
 #endif /* Optimizing and Inlining.  */
diff --git a/stdlib/bits/stdlib-ldbl.h b/stdlib/bits/stdlib-ldbl.h
index 85d9ee1556..2f568db45a 100644
--- a/stdlib/bits/stdlib-ldbl.h
+++ b/stdlib/bits/stdlib-ldbl.h
@@ -21,9 +21,7 @@
 #endif
 
 #ifdef	__USE_ISOC99
-__BEGIN_NAMESPACE_C99
 __LDBL_REDIR1_DECL (strtold, strtod)
-__END_NAMESPACE_C99
 #endif
 
 #ifdef __USE_GNU
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 7cfbcafe79..c1f389253a 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -51,7 +51,6 @@ __BEGIN_DECLS
 # endif
 #endif	/* X/Open or XPG7 and <sys/wait.h> not included.  */
 
-__BEGIN_NAMESPACE_STD
 /* Returned by `div'.  */
 typedef struct
   {
@@ -68,10 +67,8 @@ typedef struct
   } ldiv_t;
 # define __ldiv_t_defined	1
 #endif
-__END_NAMESPACE_STD
 
 #if defined __USE_ISOC99 && !defined __lldiv_t_defined
-__BEGIN_NAMESPACE_C99
 /* Returned by `lldiv'.  */
 __extension__ typedef struct
   {
@@ -79,7 +76,6 @@ __extension__ typedef struct
     long long int rem;		/* Remainder.  */
   } lldiv_t;
 # define __lldiv_t_defined	1
-__END_NAMESPACE_C99
 #endif
 
 
@@ -98,7 +94,6 @@ __END_NAMESPACE_C99
 extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
 
 
-__BEGIN_NAMESPACE_STD
 /* Convert a string to a floating-point number.  */
 extern double atof (const char *__nptr)
      __THROW __attribute_pure__ __nonnull ((1)) __wur;
@@ -108,25 +103,19 @@ extern int atoi (const char *__nptr)
 /* Convert a string to a long integer.  */
 extern long int atol (const char *__nptr)
      __THROW __attribute_pure__ __nonnull ((1)) __wur;
-__END_NAMESPACE_STD
 
 #ifdef __USE_ISOC99
-__BEGIN_NAMESPACE_C99
 /* Convert a string to a long long integer.  */
 __extension__ extern long long int atoll (const char *__nptr)
      __THROW __attribute_pure__ __nonnull ((1)) __wur;
-__END_NAMESPACE_C99
 #endif
 
-__BEGIN_NAMESPACE_STD
 /* Convert a string to a floating-point number.  */
 extern double strtod (const char *__restrict __nptr,
 		      char **__restrict __endptr)
      __THROW __nonnull ((1));
-__END_NAMESPACE_STD
 
 #ifdef	__USE_ISOC99
-__BEGIN_NAMESPACE_C99
 /* Likewise for `float' and `long double' sizes of floating-point numbers.  */
 extern float strtof (const char *__restrict __nptr,
 		     char **__restrict __endptr) __THROW __nonnull ((1));
@@ -134,10 +123,8 @@ extern float strtof (const char *__restrict __nptr,
 extern long double strtold (const char *__restrict __nptr,
 			    char **__restrict __endptr)
      __THROW __nonnull ((1));
-__END_NAMESPACE_C99
 #endif
 
-__BEGIN_NAMESPACE_STD
 /* Convert a string to a long integer.  */
 extern long int strtol (const char *__restrict __nptr,
 			char **__restrict __endptr, int __base)
@@ -146,7 +133,6 @@ extern long int strtol (const char *__restrict __nptr,
 extern unsigned long int strtoul (const char *__restrict __nptr,
 				  char **__restrict __endptr, int __base)
      __THROW __nonnull ((1));
-__END_NAMESPACE_STD
 
 #ifdef __USE_MISC
 /* Convert a string to a quadword integer.  */
@@ -162,7 +148,6 @@ extern unsigned long long int strtouq (const char *__restrict __nptr,
 #endif /* Use misc.  */
 
 #ifdef __USE_ISOC99
-__BEGIN_NAMESPACE_C99
 /* Convert a string to a quadword integer.  */
 __extension__
 extern long long int strtoll (const char *__restrict __nptr,
@@ -173,7 +158,6 @@ __extension__
 extern unsigned long long int strtoull (const char *__restrict __nptr,
 					char **__restrict __endptr, int __base)
      __THROW __nonnull ((1));
-__END_NAMESPACE_C99
 #endif /* ISO C99 or use MISC.  */
 
 /* Convert a floating-point number to a string.  */
@@ -247,7 +231,6 @@ extern long double strtold_l (const char *__restrict __nptr,
 
 
 #ifdef __USE_EXTERN_INLINES
-__BEGIN_NAMESPACE_STD
 __extern_inline int
 __NTH (atoi (const char *__nptr))
 {
@@ -258,16 +241,13 @@ __NTH (atol (const char *__nptr))
 {
   return strtol (__nptr, (char **) NULL, 10);
 }
-__END_NAMESPACE_STD
 
 # ifdef __USE_ISOC99
-__BEGIN_NAMESPACE_C99
 __extension__ __extern_inline long long int
 __NTH (atoll (const char *__nptr))
 {
   return strtoll (__nptr, (char **) NULL, 10);
 }
-__END_NAMESPACE_C99
 # endif
 #endif /* Optimizing and Inlining.  */
 
@@ -343,12 +323,10 @@ extern int setstate_r (char *__restrict __statebuf,
 #endif	/* Use extended X/Open || misc. */
 
 
-__BEGIN_NAMESPACE_STD
 /* Return a random integer between 0 and RAND_MAX inclusive.  */
 extern int rand (void) __THROW;
 /* Seed the random number generator with the given number.  */
 extern void srand (unsigned int __seed) __THROW;
-__END_NAMESPACE_STD
 
 #ifdef __USE_POSIX199506
 /* Reentrant interface according to POSIX.1.  */
@@ -431,15 +409,12 @@ extern int lcong48_r (unsigned short int __param[7],
 # endif	/* Use misc.  */
 #endif	/* Use misc or X/Open.  */
 
-__BEGIN_NAMESPACE_STD
 /* Allocate SIZE bytes of memory.  */
 extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
 extern void *calloc (size_t __nmemb, size_t __size)
      __THROW __attribute_malloc__ __wur;
-__END_NAMESPACE_STD
 
-__BEGIN_NAMESPACE_STD
 /* Re-allocate the previously allocated block
    in PTR, making the new block SIZE bytes long.  */
 /* __attribute_malloc__ is not used, because if realloc returns
@@ -449,7 +424,6 @@ extern void *realloc (void *__ptr, size_t __size)
      __THROW __attribute_warn_unused_result__;
 /* Free a block allocated by `malloc', `realloc' or `calloc'.  */
 extern void free (void *__ptr) __THROW;
-__END_NAMESPACE_STD
 
 #ifdef	__USE_MISC
 /* Free a block.  An alias for `free'.	(Sun Unices).  */
@@ -478,7 +452,6 @@ extern void *aligned_alloc (size_t __alignment, size_t __size)
      __THROW __attribute_malloc__ __attribute_alloc_size__ ((2)) __wur;
 #endif
 
-__BEGIN_NAMESPACE_STD
 /* Abort execution and generate a core-dump.  */
 extern void abort (void) __THROW __attribute__ ((__noreturn__));
 
@@ -495,7 +468,6 @@ extern "C++" int at_quick_exit (void (*__func) (void))
 extern int at_quick_exit (void (*__func) (void)) __THROW __nonnull ((1));
 # endif
 #endif
-__END_NAMESPACE_STD
 
 #ifdef	__USE_MISC
 /* Register a function to be called with the status
@@ -504,7 +476,6 @@ extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
      __THROW __nonnull ((1));
 #endif
 
-__BEGIN_NAMESPACE_STD
 /* Call all functions registered with `atexit' and `on_exit',
    in the reverse of the order in which they were registered,
    perform stdio cleanup, and terminate program execution with STATUS.  */
@@ -516,21 +487,16 @@ extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
    execution with STATUS.  */
 extern void quick_exit (int __status) __THROW __attribute__ ((__noreturn__));
 #endif
-__END_NAMESPACE_STD
 
 #ifdef __USE_ISOC99
-__BEGIN_NAMESPACE_C99
 /* Terminate the program with STATUS without calling any of the
    functions registered with `atexit' or `on_exit'.  */
 extern void _Exit (int __status) __THROW __attribute__ ((__noreturn__));
-__END_NAMESPACE_C99
 #endif
 
 
-__BEGIN_NAMESPACE_STD
 /* Return the value of envariable NAME, or NULL if it doesn't exist.  */
 extern char *getenv (const char *__name) __THROW __nonnull ((1)) __wur;
-__END_NAMESPACE_STD
 
 #ifdef __USE_GNU
 /* This function is similar to the above but returns NULL if the
@@ -676,13 +642,11 @@ extern int mkostemps64 (char *__template, int __suffixlen, int __flags)
 #endif
 
 
-__BEGIN_NAMESPACE_STD
 /* Execute the given line as a shell command.
 
    This function is a cancellation point and therefore not marked with
    __THROW.  */
 extern int system (const char *__command) __wur;
-__END_NAMESPACE_STD
 
 
 #ifdef	__USE_GNU
@@ -716,7 +680,6 @@ typedef __compar_fn_t comparison_fn_t;
 typedef int (*__compar_d_fn_t) (const void *, const void *, void *);
 #endif
 
-__BEGIN_NAMESPACE_STD
 /* Do a binary search for KEY in BASE, which consists of NMEMB elements
    of SIZE bytes each, using COMPAR to perform the comparisons.  */
 extern void *bsearch (const void *__key, const void *__base,
@@ -741,7 +704,6 @@ extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
 /* Return the absolute value of X.  */
 extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
 extern long int labs (long int __x) __THROW __attribute__ ((__const__)) __wur;
-__END_NAMESPACE_STD
 
 #ifdef __USE_ISOC99
 __extension__ extern long long int llabs (long long int __x)
@@ -749,7 +711,6 @@ __extension__ extern long long int llabs (long long int __x)
 #endif
 
 
-__BEGIN_NAMESPACE_STD
 /* Return the `div_t', `ldiv_t' or `lldiv_t' representation
    of the value of NUMER over DENOM. */
 /* GCC may have built-ins for these someday.  */
@@ -757,14 +718,11 @@ extern div_t div (int __numer, int __denom)
      __THROW __attribute__ ((__const__)) __wur;
 extern ldiv_t ldiv (long int __numer, long int __denom)
      __THROW __attribute__ ((__const__)) __wur;
-__END_NAMESPACE_STD
 
 #ifdef __USE_ISOC99
-__BEGIN_NAMESPACE_C99
 __extension__ extern lldiv_t lldiv (long long int __numer,
 				    long long int __denom)
      __THROW __attribute__ ((__const__)) __wur;
-__END_NAMESPACE_C99
 #endif
 
 
@@ -824,7 +782,6 @@ extern int qfcvt_r (long double __value, int __ndigit,
 #endif	/* misc */
 
 
-__BEGIN_NAMESPACE_STD
 /* Return the length of the multibyte character
    in S, which is no longer than N.  */
 extern int mblen (const char *__s, size_t __n) __THROW;
@@ -844,7 +801,6 @@ extern size_t mbstowcs (wchar_t *__restrict  __pwcs,
 extern size_t wcstombs (char *__restrict __s,
 			const wchar_t *__restrict __pwcs, size_t __n)
      __THROW;
-__END_NAMESPACE_STD
 
 
 #ifdef __USE_MISC