summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-08-28 08:01:11 +0000
committerUlrich Drepper <drepper@redhat.com>2002-08-28 08:01:11 +0000
commit7a5affebe810c786bfc9ef17cdc4d0bc20a1302e (patch)
treed461b7135c42ab5555bddfe4a5fa4b46a1c4ca94
parenta3f9038c879c11344430169d6daa8fad30d4f379 (diff)
downloadglibc-7a5affebe810c786bfc9ef17cdc4d0bc20a1302e.tar.gz
glibc-7a5affebe810c786bfc9ef17cdc4d0bc20a1302e.tar.xz
glibc-7a5affebe810c786bfc9ef17cdc4d0bc20a1302e.zip
Prepare headers for use in ISO C++ compliant implementations.
-rw-r--r--ctype/ctype.h19
-rw-r--r--libio/stdio.h101
-rw-r--r--locale/locale.h5
-rw-r--r--math/bits/mathcalls.h69
-rw-r--r--math/math.h14
-rw-r--r--setjmp/setjmp.h26
-rw-r--r--signal/signal.h6
-rw-r--r--stdlib/stdlib.h56
-rw-r--r--string/string.h25
-rw-r--r--time/time.h29
-rw-r--r--wcsmbs/wchar.h89
-rw-r--r--wctype/wctype.h22
12 files changed, 364 insertions, 97 deletions
diff --git a/ctype/ctype.h b/ctype/ctype.h
index 4a8ce30d04..47fba836ca 100644
--- a/ctype/ctype.h
+++ b/ctype/ctype.h
@@ -85,6 +85,8 @@ extern __const __int32_t *__ctype_toupper; /* Case conversions.  */
 
 #define	__exctype(name)	extern int name (int) __THROW
 
+
+__BEGIN_NAMESPACE_STD
 /* The following names are all functions:
      int isCHARACTERISTIC(int c);
    which return nonzero iff C has CHARACTERISTIC.
@@ -101,10 +103,6 @@ __exctype (isspace);
 __exctype (isupper);
 __exctype (isxdigit);
 
-#ifdef	__USE_ISOC99
-__exctype (isblank);
-#endif
-
 
 /* Return the lowercase version of C.  */
 extern int tolower (int __c) __THROW;
@@ -112,6 +110,17 @@ extern int tolower (int __c) __THROW;
 /* Return the uppercase version of C.  */
 extern int toupper (int __c) __THROW;
 
+__END_NAMESPACE_STD
+
+
+/* ISO C99 introduced one new function.  */
+#ifdef	__USE_ISOC99
+__BEGIN_NAMESPACE_C99
+
+__exctype (isblank);
+
+__END_NAMESPACE_C99
+#endif
 
 #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
 
@@ -147,7 +156,7 @@ __exctype (_tolower);
 	__res = a[(int) (c)];						      \
       __res; }))
 
-#ifndef	__NO_CTYPE
+#if !defined __NO_CTYPE && !defined __cplusplus
 # define isalnum(c)	__isctype((c), _ISalnum)
 # define isalpha(c)	__isctype((c), _ISalpha)
 # define iscntrl(c)	__isctype((c), _IScntrl)
diff --git a/libio/stdio.h b/libio/stdio.h
index 10bd6e5e88..3acaa8bd97 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -41,8 +41,15 @@ __BEGIN_DECLS
 
 #if !defined __FILE_defined && defined __need_FILE
 
+__BEGIN_NAMESPACE_STD
 /* The opaque type of streams.  This is the definition used elsewhere.  */
 typedef struct _IO_FILE FILE;
+__END_NAMESPACE_STD
+#if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
+    || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
+    || defined __USE_POSIX2
+__USING_NAMESPACE_STD(FILE)
+#endif
 
 # define __FILE_defined	1
 #endif /* FILE not defined.  */
@@ -76,11 +83,13 @@ typedef _G_va_list va_list;
 #endif
 
 /* The type of the second argument to `fgetpos' and `fsetpos'.  */
+__BEGIN_NAMESPACE_STD
 #ifndef __USE_FILE_OFFSET64
 typedef _G_fpos_t fpos_t;
 #else
 typedef _G_fpos64_t fpos_t;
 #endif
+__END_NAMESPACE_STD
 #ifdef __USE_LARGEFILE64
 typedef _G_fpos64_t fpos64_t;
 #endif
@@ -130,20 +139,23 @@ typedef _G_fpos64_t fpos64_t;
 
 
 /* Standard streams.  */
-extern FILE *stdin;		/* Standard input stream.  */
-extern FILE *stdout;		/* Standard output stream.  */
-extern FILE *stderr;		/* Standard error output stream.  */
+extern struct _IO_FILE *stdin;		/* Standard input stream.  */
+extern struct _IO_FILE *stdout;		/* Standard output stream.  */
+extern struct _IO_FILE *stderr;		/* Standard error output stream.  */
 /* C89/C99 say they're macros.  Make them happy.  */
 #define stdin stdin
 #define stdout stdout
 #define stderr stderr
 
+__BEGIN_NAMESPACE_STD
 /* Remove file FILENAME.  */
 extern int remove (__const char *__filename) __THROW;
 /* Rename file OLD to NEW.  */
 extern int rename (__const char *__old, __const char *__new) __THROW;
+__END_NAMESPACE_STD
 
 
+__BEGIN_NAMESPACE_STD
 /* Create a temporary file and open it read/write.  */
 #ifndef __USE_FILE_OFFSET64
 extern FILE *tmpfile (void) __THROW;
@@ -154,11 +166,14 @@ extern FILE *__REDIRECT (tmpfile, (void) __THROW, tmpfile64);
 #  define tmpfile tmpfile64
 # endif
 #endif
+
+/* Generate a temporary filename.  */
+extern char *tmpnam (char *__s) __THROW;
+__END_NAMESPACE_STD
+
 #ifdef __USE_LARGEFILE64
 extern FILE *tmpfile64 (void) __THROW;
 #endif
-/* Generate a temporary filename.  */
-extern char *tmpnam (char *__s) __THROW;
 
 #ifdef __USE_MISC
 /* This is the reentrant variant of `tmpnam'.  The only difference is
@@ -180,10 +195,12 @@ extern char *tempnam (__const char *__dir, __const char *__pfx)
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Close STREAM.  */
 extern int fclose (FILE *__stream) __THROW;
 /* Flush STREAM, or all streams if STREAM is NULL.  */
 extern int fflush (FILE *__stream) __THROW;
+__END_NAMESPACE_STD
 
 #ifdef __USE_MISC
 /* Faster versions when locking is not required.  */
@@ -196,6 +213,7 @@ extern int fcloseall (void) __THROW;
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 #ifndef __USE_FILE_OFFSET64
 /* Open a file and create a new stream for it.  */
 extern FILE *fopen (__const char *__restrict __filename,
@@ -218,6 +236,7 @@ extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
 #  define freopen freopen64
 # endif
 #endif
+__END_NAMESPACE_STD
 #ifdef __USE_LARGEFILE64
 extern FILE *fopen64 (__const char *__restrict __filename,
 		      __const char *__restrict __modes) __THROW;
@@ -249,6 +268,7 @@ extern FILE *open_memstream (char **__restrict __bufloc,
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* If BUF is NULL, make STREAM unbuffered.
    Else make it use buffer BUF, of size BUFSIZ.  */
 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
@@ -257,6 +277,7 @@ extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
    else allocate an internal buffer N bytes long.  */
 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
 		    int __modes, size_t __n) __THROW;
+__END_NAMESPACE_STD
 
 #ifdef	__USE_BSD
 /* If BUF is NULL, make STREAM unbuffered.
@@ -269,6 +290,7 @@ extern void setlinebuf (FILE *__stream) __THROW;
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Write formatted output to STREAM.  */
 extern int fprintf (FILE *__restrict __stream,
 		    __const char *__restrict __format, ...) __THROW;
@@ -287,8 +309,10 @@ extern int vprintf (__const char *__restrict __format, _G_va_list __arg)
 /* Write formatted output to S from argument list ARG.  */
 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
 		     _G_va_list __arg) __THROW;
+__END_NAMESPACE_STD
 
 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
+__BEGIN_NAMESPACE_C99
 /* Maximum chars of output to write in MAXLEN.  */
 extern int snprintf (char *__restrict __s, size_t __maxlen,
 		     __const char *__restrict __format, ...)
@@ -297,6 +321,7 @@ extern int snprintf (char *__restrict __s, size_t __maxlen,
 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
 		      __const char *__restrict __format, _G_va_list __arg)
      __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
+__END_NAMESPACE_C99
 #endif
 
 #ifdef __USE_GNU
@@ -321,6 +346,7 @@ extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Read formatted input from STREAM.  */
 extern int fscanf (FILE *__restrict __stream,
 		   __const char *__restrict __format, ...) __THROW;
@@ -329,8 +355,10 @@ extern int scanf (__const char *__restrict __format, ...) __THROW;
 /* Read formatted input from S.  */
 extern int sscanf (__const char *__restrict __s,
 		   __const char *__restrict __format, ...) __THROW;
+__END_NAMESPACE_STD
 
 #ifdef	__USE_ISOC99
+__BEGIN_NAMESPACE_C99
 /* Read formatted input from S into argument list ARG.  */
 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
 		    _G_va_list __arg)
@@ -344,15 +372,18 @@ extern int vscanf (__const char *__restrict __format, _G_va_list __arg)
 extern int vsscanf (__const char *__restrict __s,
 		    __const char *__restrict __format, _G_va_list __arg)
      __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
+__END_NAMESPACE_C99
 #endif /* Use ISO C9x.  */
 
 
+__BEGIN_NAMESPACE_STD
 /* Read a character from STREAM.  */
 extern int fgetc (FILE *__stream) __THROW;
 extern int getc (FILE *__stream) __THROW;
 
 /* Read a character from stdin.  */
 extern int getchar (void) __THROW;
+__END_NAMESPACE_STD
 
 /* The C standard explicitly says this is a macro, so we always do the
    optimization for it.  */
@@ -370,12 +401,14 @@ extern int fgetc_unlocked (FILE *__stream) __THROW;
 #endif /* Use MISC.  */
 
 
+__BEGIN_NAMESPACE_STD
 /* Write a character to STREAM.  */
 extern int fputc (int __c, FILE *__stream) __THROW;
 extern int putc (int __c, FILE *__stream) __THROW;
 
 /* Write a character to stdout.  */
 extern int putchar (int __c) __THROW;
+__END_NAMESPACE_STD
 
 /* The C standard explicitly says this can be a macro,
    so we always do the optimization for it.  */
@@ -402,20 +435,22 @@ extern int putw (int __w, FILE *__stream) __THROW;
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Get a newline-terminated string of finite length from STREAM.  */
 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
      __THROW;
 
+/* Get a newline-terminated string from stdin, removing the newline.
+   DO NOT USE THIS FUNCTION!!  There is no limit on how much it will read.  */
+extern char *gets (char *__s) __THROW;
+__END_NAMESPACE_STD
+
 #ifdef __USE_GNU
 /* This function does the same as `fgets' but does not lock the stream.  */
 extern char *fgets_unlocked (char *__restrict __s, int __n,
 			     FILE *__restrict __stream) __THROW;
 #endif
 
-/* Get a newline-terminated string from stdin, removing the newline.
-   DO NOT USE THIS FUNCTION!!  There is no limit on how much it will read.  */
-extern char *gets (char *__s) __THROW;
-
 
 #ifdef	__USE_GNU
 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
@@ -437,16 +472,11 @@ extern _IO_ssize_t getline (char **__restrict __lineptr,
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Write a string to STREAM.  */
 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream)
      __THROW;
 
-#ifdef __USE_GNU
-/* This function does the same as `fputs' but does not lock the stream.  */
-extern int fputs_unlocked (__const char *__restrict __s,
-			   FILE *__restrict __stream) __THROW;
-#endif
-
 /* Write a string, followed by a newline, to stdout.  */
 extern int puts (__const char *__s) __THROW;
 
@@ -461,6 +491,13 @@ extern size_t fread (void *__restrict __ptr, size_t __size,
 /* Write chunks of generic data to STREAM.  */
 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
 		      size_t __n, FILE *__restrict __s) __THROW;
+__END_NAMESPACE_STD
+
+#ifdef __USE_GNU
+/* This function does the same as `fputs' but does not lock the stream.  */
+extern int fputs_unlocked (__const char *__restrict __s,
+			   FILE *__restrict __stream) __THROW;
+#endif
 
 #ifdef __USE_MISC
 /* Faster versions when locking is not necessary.  */
@@ -471,26 +508,41 @@ extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Seek to a certain position on STREAM.  */
 extern int fseek (FILE *__stream, long int __off, int __whence) __THROW;
 /* Return the current position of STREAM.  */
 extern long int ftell (FILE *__stream) __THROW;
 /* Rewind to the beginning of STREAM.  */
 extern void rewind (FILE *__stream) __THROW;
+__END_NAMESPACE_STD
 
 /* The Single Unix Specification, Version 2, specifies an alternative,
    more adequate interface for the two functions above which deal with
    file offset.  `long int' is not the right type.  These definitions
    are originally defined in the Large File Support API.  */
 
-#ifndef __USE_FILE_OFFSET64
-# ifdef __USE_LARGEFILE
+#ifdef __USE_LARGEFILE
+# ifndef __USE_FILE_OFFSET64
 /* Seek to a certain position on STREAM.  */
 extern int fseeko (FILE *__stream, __off_t __off, int __whence) __THROW;
 /* Return the current position of STREAM.  */
 extern __off_t ftello (FILE *__stream) __THROW;
+# else
+#  ifdef __REDIRECT
+extern int __REDIRECT (fseeko,
+		       (FILE *__stream, __off64_t __off, int __whence) __THROW,
+		       fseeko64);
+extern __off64_t __REDIRECT (ftello, (FILE *__stream) __THROW, ftello64);
+#  else
+#   define fseeko fseeko64
+#   define ftello ftello64
+#  endif
 # endif
+#endif
 
+__BEGIN_NAMESPACE_STD
+#ifndef __USE_FILE_OFFSET64
 /* Get STREAM's position.  */
 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
      __THROW;
@@ -498,26 +550,17 @@ extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
 extern int fsetpos (FILE *__stream, __const fpos_t *__pos) __THROW;
 #else
 # ifdef __REDIRECT
-#  ifdef __USE_LARGEFILE
-extern int __REDIRECT (fseeko,
-		       (FILE *__stream, __off64_t __off, int __whence) __THROW,
-		       fseeko64);
-extern __off64_t __REDIRECT (ftello, (FILE *__stream) __THROW, ftello64);
-#  endif
 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
 				 fpos_t *__restrict __pos) __THROW, fgetpos64);
 extern int __REDIRECT (fsetpos,
 		       (FILE *__stream, __const fpos_t *__pos) __THROW,
 		       fsetpos64);
 # else
-#  ifdef __USE_LARGEFILE
-#   define fseeko fseeko64
-#   define ftello ftello64
-#  endif
 #  define fgetpos fgetpos64
 #  define fsetpos fsetpos64
 # endif
 #endif
+__END_NAMESPACE_STD
 
 #ifdef __USE_LARGEFILE64
 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence) __THROW;
@@ -527,12 +570,14 @@ extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos)
 extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos) __THROW;
 #endif
 
+__BEGIN_NAMESPACE_STD
 /* Clear the error and EOF indicators for STREAM.  */
 extern void clearerr (FILE *__stream) __THROW;
 /* Return the EOF indicator for STREAM.  */
 extern int feof (FILE *__stream) __THROW;
 /* Return the error indicator for STREAM.  */
 extern int ferror (FILE *__stream) __THROW;
+__END_NAMESPACE_STD
 
 #ifdef __USE_MISC
 /* Faster versions when locking is not required.  */
@@ -542,8 +587,10 @@ extern int ferror_unlocked (FILE *__stream) __THROW;
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Print a message describing the meaning of the value of errno.  */
 extern void perror (__const char *__s) __THROW;
+__END_NAMESPACE_STD
 
 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
    are available on this system.  Even if available, these variables
diff --git a/locale/locale.h b/locale/locale.h
index 57acb62cd0..1b0296ae4a 100644
--- a/locale/locale.h
+++ b/locale/locale.h
@@ -119,12 +119,17 @@ struct lconv
 };
 
 
+__BEGIN_NAMESPACE_STD
+
 /* Set and/or return the current locale.  */
 extern char *setlocale (int __category, __const char *__locale) __THROW;
 
 /* Return the numeric/monetary information for the current locale.  */
 extern struct lconv *localeconv (void) __THROW;
 
+__END_NAMESPACE_STD
+
+
 #ifdef	__USE_GNU
 /* The concept of one static locale per category is not very well
    thought out.  Many applications will need to process its data using
diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h
index 12fcfce022..59d4eb88f7 100644
--- a/math/bits/mathcalls.h
+++ b/math/bits/mathcalls.h
@@ -1,5 +1,5 @@
 /* Prototype declarations for math functions; helper file for <math.h>.
-   Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
+   Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -44,12 +44,13 @@
    NAME, to make token pasting work with -traditional.  */
 
 #ifndef _MATH_H
- #error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
+# error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
 #endif
 
 
 /* Trigonometric functions.  */
 
+_Mdouble_BEGIN_NAMESPACE
 /* Arc cosine of X.  */
 __MATHCALL (acos,, (_Mdouble_ __x));
 /* Arc sine of X.  */
@@ -66,12 +67,6 @@ __MATHCALL (sin,, (_Mdouble_ __x));
 /* Tangent of X.  */
 __MATHCALL (tan,, (_Mdouble_ __x));
 
-#ifdef __USE_GNU
-/* Cosine and sine of X.  */
-__MATHDECL (void,sincos,,
-	    (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
-#endif
-
 /* Hyperbolic functions.  */
 
 /* Hyperbolic cosine of X.  */
@@ -80,28 +75,31 @@ __MATHCALL (cosh,, (_Mdouble_ __x));
 __MATHCALL (sinh,, (_Mdouble_ __x));
 /* Hyperbolic tangent of X.  */
 __MATHCALL (tanh,, (_Mdouble_ __x));
+_Mdouble_END_NAMESPACE
+
+#ifdef __USE_GNU
+/* Cosine and sine of X.  */
+__MATHDECL (void,sincos,,
+	    (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
+#endif
 
 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 /* Hyperbolic arc cosine of X.  */
 __MATHCALL (acosh,, (_Mdouble_ __x));
 /* Hyperbolic arc sine of X.  */
 __MATHCALL (asinh,, (_Mdouble_ __x));
 /* Hyperbolic arc tangent of X.  */
 __MATHCALL (atanh,, (_Mdouble_ __x));
+__END_NAMESPACE_C99
 #endif
 
 /* Exponential and logarithmic functions.  */
 
+_Mdouble_BEGIN_NAMESPACE
 /* Exponential function of X.  */
 __MATHCALL (exp,, (_Mdouble_ __x));
 
-#ifdef __USE_GNU
-/* A function missing in all standards: compute exponent to base ten.  */
-__MATHCALL (exp10,, (_Mdouble_ __x));
-/* Another name occasionally used.  */
-__MATHCALL (pow10,, (_Mdouble_ __x));
-#endif
-
 /* Break VALUE into a normalized fraction and an integral power of 2.  */
 __MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
 
@@ -116,8 +114,17 @@ __MATHCALL (log10,, (_Mdouble_ __x));
 
 /* Break VALUE into integral and fractional parts.  */
 __MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr));
+_Mdouble_END_NAMESPACE
+
+#ifdef __USE_GNU
+/* A function missing in all standards: compute exponent to base ten.  */
+__MATHCALL (exp10,, (_Mdouble_ __x));
+/* Another name occasionally used.  */
+__MATHCALL (pow10,, (_Mdouble_ __x));
+#endif
 
 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 /* Return exp(X) - 1.  */
 __MATHCALL (expm1,, (_Mdouble_ __x));
 
@@ -126,38 +133,48 @@ __MATHCALL (log1p,, (_Mdouble_ __x));
 
 /* Return the base 2 signed integral exponent of X.  */
 __MATHCALL (logb,, (_Mdouble_ __x));
+__END_NAMESPACE_C99
 #endif
 
 #ifdef __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 /* Compute base-2 exponential of X.  */
 __MATHCALL (exp2,, (_Mdouble_ __x));
 
 /* Compute base-2 logarithm of X.  */
 __MATHCALL (log2,, (_Mdouble_ __x));
+__END_NAMESPACE_C99
 #endif
 
 
 /* Power functions.  */
 
+_Mdouble_BEGIN_NAMESPACE
 /* Return X to the Y power.  */
 __MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
 
 /* Return the square root of X.  */
 __MATHCALL (sqrt,, (_Mdouble_ __x));
+_Mdouble_END_NAMESPACE
 
 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 /* Return `sqrt(X*X + Y*Y)'.  */
 __MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
+__END_NAMESPACE_C99
 #endif
 
 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 /* Return the cube root of X.  */
 __MATHCALL (cbrt,, (_Mdouble_ __x));
+__END_NAMESPACE_C99
 #endif
 
 
 /* Nearest integer, absolute value, and remainder functions.  */
 
+_Mdouble_BEGIN_NAMESPACE
 /* Smallest integral value not less than X.  */
 __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
 
@@ -177,6 +194,7 @@ __MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
 
 /* Return nonzero if VALUE is finite and not NaN.  */
 __MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
+_Mdouble_END_NAMESPACE
 
 #ifdef __USE_MISC
 /* Return 0 if VALUE is finite or NaN, +1 if it
@@ -195,13 +213,17 @@ __MATHCALL (significand,, (_Mdouble_ __x));
 #endif /* Use misc.  */
 
 #if defined __USE_MISC || defined __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 /* Return X with its signed changed to Y's.  */
 __MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
+__END_NAMESPACE_C99
 #endif
 
 #ifdef __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 /* Return representation of NaN for double type.  */
 __MATHCALLX (nan,, (__const char *__tagb), (__const__));
+__END_NAMESPACE_C99
 #endif
 
 
@@ -223,14 +245,19 @@ __MATHCALL (yn,, (int, _Mdouble_));
 
 
 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 /* Error and gamma functions.  */
 __MATHCALL (erf,, (_Mdouble_));
 __MATHCALL (erfc,, (_Mdouble_));
 __MATHCALL (lgamma,, (_Mdouble_));
+__END_NAMESPACE_C99
 #endif
 
 #ifdef __USE_ISOC99
+__BEGIN_NAMESPACE_C99
+/* True gamma function.  */
 __MATHCALL (tgamma,, (_Mdouble_));
+__END_NAMESPACE_C99
 #endif
 
 #if defined __USE_MISC || defined __USE_XOPEN
@@ -247,6 +274,7 @@ __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
 
 
 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 /* Return the integer nearest X in the direction of the
    prevailing rounding mode.  */
 __MATHCALL (rint,, (_Mdouble_ __x));
@@ -260,11 +288,6 @@ __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
 /* Return the remainder of integer divison X / Y with infinite precision.  */
 __MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
 
-# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
-/* Return X times (2 to the Nth power).  */
-__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
-# endif
-
 # if defined __USE_MISC || defined __USE_ISOC99
 /* Return X times (2 to the Nth power).  */
 __MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
@@ -330,4 +353,10 @@ __MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
 
 /* Multiply-add function computed as a ternary operation.  */
 __MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
+__END_NAMESPACE_C99
+
+# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
+/* Return X times (2 to the Nth power).  */
+__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
+# endif
 #endif /* Use ISO C99.  */
diff --git a/math/math.h b/math/math.h
index 8a2e86c2f1..28e5937c56 100644
--- a/math/math.h
+++ b/math/math.h
@@ -1,5 +1,5 @@
 /* Declarations for math functions.
-   Copyright (C) 1991,92,93,95,96,97,98,99,2001 Free Software Foundation, Inc.
+   Copyright (C) 1991-1993,1995-1999,2001,2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -60,8 +60,12 @@ __BEGIN_DECLS
 
 #define _Mdouble_ 		double
 #define __MATH_PRECNAME(name,r)	__CONCAT(name,r)
+# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
+# define _Mdouble_END_NAMESPACE   __END_NAMESPACE_STD
 #include <bits/mathcalls.h>
 #undef	_Mdouble_
+#undef _Mdouble_BEGIN_NAMESPACE
+#undef _Mdouble_END_NAMESPACE
 #undef	__MATH_PRECNAME
 
 #if defined __USE_MISC || defined __USE_ISOC99
@@ -79,8 +83,12 @@ __BEGIN_DECLS
 # else
 #  define __MATH_PRECNAME(name,r) name/**/f/**/r
 # endif
+# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
+# define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99
 # include <bits/mathcalls.h>
 # undef	_Mdouble_
+# undef _Mdouble_BEGIN_NAMESPACE
+# undef _Mdouble_END_NAMESPACE
 # undef	__MATH_PRECNAME
 
 # if (__STDC__ - 0 || __GNUC__ - 0) && !defined __NO_LONG_DOUBLE_MATH
@@ -96,8 +104,12 @@ __BEGIN_DECLS
 #  else
 #   define __MATH_PRECNAME(name,r) name/**/l/**/r
 #  endif
+#  define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
+#  define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99
 #  include <bits/mathcalls.h>
 #  undef _Mdouble_
+# undef _Mdouble_BEGIN_NAMESPACE
+# undef _Mdouble_END_NAMESPACE
 #  undef __MATH_PRECNAME
 
 # endif /* __STDC__ || __GNUC__ */
diff --git a/setjmp/setjmp.h b/setjmp/setjmp.h
index 99e3dc8cd0..f0babc047b 100644
--- a/setjmp/setjmp.h
+++ b/setjmp/setjmp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1999, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -30,6 +30,8 @@ __BEGIN_DECLS
 #include <bits/setjmp.h>		/* Get `__jmp_buf'.  */
 #include <bits/sigset.h>		/* Get `__sigset_t'.  */
 
+__BEGIN_NAMESPACE_STD
+
 /* Calling environment, plus possibly a saved signal mask.  */
 typedef struct __jmp_buf_tag	/* C++ doesn't like tagless structs.  */
   {
@@ -47,16 +49,19 @@ typedef struct __jmp_buf_tag	/* C++ doesn't like tagless structs.  */
    Return 0.  */
 extern int setjmp (jmp_buf __env) __THROW;
 
-/* Store the calling environment in ENV, not saving the signal mask.
-   Return 0.  */
-extern int _setjmp (jmp_buf __env) __THROW;
+__END_NAMESPACE_STD
+__USING_NAMESPACE_STD(__jmp_buf_tag)
 
 /* Store the calling environment in ENV, also saving the
    signal mask if SAVEMASK is nonzero.  Return 0.
    This is the internal name for `sigsetjmp'.  */
-extern int __sigsetjmp (jmp_buf __env, int __savemask) __THROW;
+extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROW;
 
 #ifndef	__FAVOR_BSD
+/* Store the calling environment in ENV, not saving the signal mask.
+   Return 0.  */
+extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROW;
+
 /* Do not save the signal mask.  This is equivalent to the `_setjmp'
    BSD function.  */
 # define setjmp(env)	_setjmp (env)
@@ -68,15 +73,20 @@ extern int __sigsetjmp (jmp_buf __env, int __savemask) __THROW;
 #endif /* Favor BSD.  */
 
 
+__BEGIN_NAMESPACE_STD
+
 /* Jump to the environment saved in ENV, making the
    `setjmp' call there return VAL, or 1 if VAL is 0.  */
-extern void longjmp (jmp_buf __env, int __val)
+extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
      __THROW __attribute__ ((__noreturn__));
+
+__END_NAMESPACE_STD
+
 #if defined __USE_BSD || defined __USE_XOPEN
 /* Same.  Usually `_longjmp' is used with `_setjmp', which does not save
    the signal mask.  But it is how ENV was saved that determines whether
    `longjmp' restores the mask; `_longjmp' is just an alias.  */
-extern void _longjmp (jmp_buf __env, int __val)
+extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
      __THROW __attribute__ ((__noreturn__));
 #endif
 
@@ -85,7 +95,7 @@ extern void _longjmp (jmp_buf __env, int __val)
 /* Use the same type for `jmp_buf' and `sigjmp_buf'.
    The `__mask_was_saved' flag determines whether
    or not `longjmp' will restore the signal mask.  */
-typedef jmp_buf sigjmp_buf;
+typedef struct __jmp_buf_tag sigjmp_buf[1];
 
 /* Store the calling environment in ENV, also saving the
    signal mask if SAVEMASK is nonzero.  Return 0.  */
diff --git a/signal/signal.h b/signal/signal.h
index f5d940a858..fffb259f52 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -37,7 +37,9 @@ __BEGIN_DECLS
 #if defined __need_sig_atomic_t || defined _SIGNAL_H
 # ifndef __sig_atomic_t_defined
 #  define __sig_atomic_t_defined
+__BEGIN_NAMESPACE_STD
 typedef __sig_atomic_t sig_atomic_t;
+__END_NAMESPACE_STD
 # endif
 # undef __need_sig_atomic_t
 #endif
@@ -83,6 +85,7 @@ extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler)
 /* Set the handler for the signal SIG to HANDLER, returning the old
    handler, or SIG_ERR on error.
    By default `signal' has the BSD semantic.  */
+__BEGIN_NAMESPACE_STD
 #ifdef __USE_BSD
 extern __sighandler_t signal (int __sig, __sighandler_t __handler) __THROW;
 #else
@@ -96,6 +99,7 @@ extern __sighandler_t __REDIRECT (signal,
 #  define signal __sysv_signal
 # endif
 #endif
+__END_NAMESPACE_STD
 
 #ifdef __USE_XOPEN
 /* The X/Open definition of `signal' conflicts with the BSD version.
@@ -117,8 +121,10 @@ extern int kill (__pid_t __pid, int __sig) __THROW;
 extern int killpg (__pid_t __pgrp, int __sig) __THROW;
 #endif /* Use BSD || X/Open Unix.  */
 
+__BEGIN_NAMESPACE_STD
 /* Raise signal SIG, i.e., send SIG to yourself.  */
 extern int raise (int __sig) __THROW;
+__END_NAMESPACE_STD
 
 #ifdef __USE_SVID
 /* SVID names for the same things.  */
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 232b3812fa..6ab675fc57 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -90,6 +90,7 @@ typedef union
 # define WIFSTOPPED(status)	__WIFSTOPPED(__WAIT_INT(status))
 #endif	/* X/Open and <sys/wait.h> not included.  */
 
+__BEGIN_NAMESPACE_STD
 /* Returned by `div'.  */
 typedef struct
   {
@@ -106,8 +107,10 @@ 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
   {
@@ -115,6 +118,7 @@ __extension__ typedef struct
     long long int rem;		/* Remainder.  */
   } lldiv_t;
 # define __lldiv_t_defined	1
+__END_NAMESPACE_C99
 #endif
 
 
@@ -133,32 +137,41 @@ __extension__ typedef struct
 extern size_t __ctype_get_mb_cur_max (void) __THROW;
 
 
+__BEGIN_NAMESPACE_STD
 /* Convert a string to a floating-point number.  */
 extern double atof (__const char *__nptr) __THROW __attribute_pure__;
 /* Convert a string to an integer.  */
 extern int atoi (__const char *__nptr) __THROW __attribute_pure__;
 /* Convert a string to a long integer.  */
 extern long int atol (__const char *__nptr) __THROW __attribute_pure__;
+__END_NAMESPACE_STD
 
 #if defined __USE_ISOC99 || (defined __GLIBC_HAVE_LONG_LONG && defined __USE_MISC)
+__BEGIN_NAMESPACE_C99
 /* Convert a string to a long long integer.  */
 __extension__ extern long long int atoll (__const char *__nptr)
      __THROW __attribute_pure__;
+__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;
+__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;
 
 extern long double strtold (__const char *__restrict __nptr,
 			    char **__restrict __endptr) __THROW;
+__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) __THROW;
@@ -166,6 +179,7 @@ extern long int strtol (__const char *__restrict __nptr,
 extern unsigned long int strtoul (__const char *__restrict __nptr,
 				  char **__restrict __endptr, int __base)
      __THROW;
+__END_NAMESPACE_C99
 
 #if defined __GLIBC_HAVE_LONG_LONG && defined __USE_BSD
 /* Convert a string to a quadword integer.  */
@@ -180,8 +194,7 @@ extern unsigned long long int strtouq (__const char *__restrict __nptr,
 #endif /* GCC and use BSD.  */
 
 #if defined __USE_ISOC99 || (defined __GLIBC_HAVE_LONG_LONG && defined __USE_MISC)
-/* These functions will part of the standard C library in ISO C99.  */
-
+__BEGIN_NAMESPACE_C99
 /* Convert a string to a quadword integer.  */
 __extension__
 extern long long int strtoll (__const char *__restrict __nptr,
@@ -191,6 +204,7 @@ __extension__
 extern unsigned long long int strtoull (__const char *__restrict __nptr,
 					char **__restrict __endptr, int __base)
      __THROW;
+__END_NAMESPACE_C99
 #endif /* ISO C99 or GCC and use MISC.  */
 
 
@@ -290,6 +304,7 @@ extern unsigned long long int __strtoull_internal (__const char *
 #ifdef __USE_EXTERN_INLINES
 /* Define inline functions which call the internal entry points.  */
 
+__BEGIN_NAMESPACE_STD
 extern __inline double
 strtod (__const char *__restrict __nptr, char **__restrict __endptr) __THROW
 {
@@ -307,8 +322,10 @@ strtoul (__const char *__restrict __nptr, char **__restrict __endptr,
 {
   return __strtoul_internal (__nptr, __endptr, __base, 0);
 }
+__END_NAMESPACE_STD
 
 # ifdef __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 extern __inline float
 strtof (__const char *__restrict __nptr, char **__restrict __endptr) __THROW
 {
@@ -319,6 +336,7 @@ strtold (__const char *__restrict __nptr, char **__restrict __endptr) __THROW
 {
   return __strtold_internal (__nptr, __endptr, 0);
 }
+__END_NAMESPACE_C99
 # endif
 
 # ifdef __USE_BSD
@@ -337,6 +355,7 @@ strtouq (__const char *__restrict __nptr, char **__restrict __endptr,
 # endif
 
 # if defined __USE_MISC || defined __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 __extension__ extern __inline long long int
 strtoll (__const char *__restrict __nptr, char **__restrict __endptr,
 	 int __base) __THROW
@@ -349,8 +368,10 @@ strtoull (__const char * __restrict __nptr, char **__restrict __endptr,
 {
   return __strtoull_internal (__nptr, __endptr, __base, 0);
 }
+__END_NAMESPACE_C99
 # endif
 
+__BEGIN_NAMESPACE_STD
 extern __inline double
 atof (__const char *__nptr) __THROW
 {
@@ -366,13 +387,16 @@ atol (__const char *__nptr) __THROW
 {
   return strtol (__nptr, (char **) NULL, 10);
 }
+__END_NAMESPACE_STD
 
 # if defined __USE_MISC || defined __USE_ISOC99
+__BEGIN_NAMESPACE_C99
 __extension__ extern __inline long long int
 atoll (__const char *__nptr) __THROW
 {
   return strtoll (__nptr, (char **) NULL, 10);
 }
+__END_NAMESPACE_C99
 # endif
 #endif /* Optimizing and Inlining.  */
 
@@ -442,10 +466,12 @@ extern int setstate_r (char *__restrict __statebuf,
 #endif	/* Use SVID || extended X/Open.  */
 
 
+__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_POSIX
 /* Reentrant interface according to POSIX.1.  */
@@ -522,20 +548,24 @@ extern int lcong48_r (unsigned short int __param[7],
 #endif /* don't just need malloc and calloc */
 
 #ifndef __malloc_and_calloc_defined
-#define __malloc_and_calloc_defined
+# define __malloc_and_calloc_defined
+__BEGIN_NAMESPACE_STD
 /* Allocate SIZE bytes of memory.  */
 extern void *malloc (size_t __size) __THROW __attribute_malloc__;
 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
 extern void *calloc (size_t __nmemb, size_t __size)
      __THROW __attribute_malloc__;
+__END_NAMESPACE_STD
 #endif
 
 #ifndef __need_malloc_and_calloc
+__BEGIN_NAMESPACE_STD
 /* Re-allocate the previously allocated block
    in PTR, making the new block SIZE bytes long.  */
 extern void *realloc (void *__ptr, size_t __size) __THROW __attribute_malloc__;
 /* 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).  */
@@ -557,12 +587,14 @@ extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
      __THROW __attribute_malloc__;
 #endif
 
+__BEGIN_NAMESPACE_STD
 /* Abort execution and generate a core-dump.  */
 extern void abort (void) __THROW __attribute__ ((__noreturn__));
 
 
 /* Register a function to be called when `exit' is called.  */
 extern int atexit (void (*__func) (void)) __THROW;
+__END_NAMESPACE_STD
 
 #ifdef	__USE_MISC
 /* Register a function to be called with the status
@@ -571,20 +603,26 @@ extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
      __THROW;
 #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.  */
 extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
+__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;
+__END_NAMESPACE_STD
 
 /* This function is similar to the above but returns NULL if the
    programs is running with SUID or SGID enabled.  */
@@ -651,8 +689,10 @@ extern char *mkdtemp (char *__template) __THROW;
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Execute the given line as a shell command.  */
 extern int system (__const char *__command) __THROW;
+__END_NAMESPACE_STD
 
 
 #ifdef	__USE_GNU
@@ -684,6 +724,7 @@ typedef __compar_fn_t comparison_fn_t;
 # endif
 #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,
@@ -698,12 +739,15 @@ extern void qsort (void *__base, size_t __nmemb, size_t __size,
 /* Return the absolute value of X.  */
 extern int abs (int __x) __THROW __attribute__ ((__const__));
 extern long int labs (long int __x) __THROW __attribute__ ((__const__));
+__END_NAMESPACE_STD
+
 #ifdef __USE_ISOC99
 __extension__ extern long long int llabs (long long int __x)
      __THROW __attribute__ ((__const__));
 #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.  */
@@ -711,10 +755,14 @@ extern div_t div (int __numer, int __denom)
      __THROW __attribute__ ((__const__));
 extern ldiv_t ldiv (long int __numer, long int __denom)
      __THROW __attribute__ ((__const__));
+__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__));
+__END_NAMESPACE_C99
 #endif
 
 
@@ -768,6 +816,7 @@ extern int qfcvt_r (long double __value, int __ndigit,
 #endif	/* use MISC || use X/Open Unix */
 
 
+__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;
@@ -787,6 +836,7 @@ 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_SVID
diff --git a/string/string.h b/string/string.h
index 4a49e457b8..db9bc00e5c 100644
--- a/string/string.h
+++ b/string/string.h
@@ -33,6 +33,7 @@ __BEGIN_DECLS
 #include <stddef.h>
 
 
+__BEGIN_NAMESPACE_STD
 /* Copy N bytes of SRC to DEST.  */
 extern void *memcpy (void *__restrict __dest,
 		     __const void *__restrict __src, size_t __n) __THROW;
@@ -40,6 +41,7 @@ extern void *memcpy (void *__restrict __dest,
    correct behavior for overlapping strings.  */
 extern void *memmove (void *__dest, __const void *__src, size_t __n)
      __THROW;
+__END_NAMESPACE_STD
 
 /* Copy no more than N bytes of SRC to DEST, stopping when C is found.
    Return the position in DEST one byte past where C was copied,
@@ -51,6 +53,7 @@ extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
 #endif /* SVID.  */
 
 
+__BEGIN_NAMESPACE_STD
 /* Set N bytes of S to C.  */
 extern void *memset (void *__s, int __c, size_t __n) __THROW;
 
@@ -61,6 +64,7 @@ extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
 /* Search N bytes of S for C.  */
 extern void *memchr (__const void *__s, int __c, size_t __n)
       __THROW __attribute_pure__;
+__END_NAMESPACE_STD
 
 #ifdef __USE_GNU
 /* Search in S for C.  This is similar to `memchr' but there is no
@@ -73,6 +77,7 @@ extern void *memrchr (__const void *__s, int __c, size_t __n)
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Copy SRC to DEST.  */
 extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
      __THROW;
@@ -100,6 +105,7 @@ extern int strcoll (__const char *__s1, __const char *__s2)
 /* Put a transformation of SRC into no more than N bytes of DEST.  */
 extern size_t strxfrm (char *__restrict __dest,
 		       __const char *__restrict __src, size_t __n) __THROW;
+__END_NAMESPACE_STD
 
 #ifdef __USE_GNU
 /* The following functions are equivalent to the both above but they
@@ -151,10 +157,12 @@ extern char *strndup (__const char *__string, size_t __n)
     }))
 #endif
 
+__BEGIN_NAMESPACE_STD
 /* Find the first occurrence of C in S.  */
 extern char *strchr (__const char *__s, int __c) __THROW __attribute_pure__;
 /* Find the last occurrence of C in S.  */
 extern char *strrchr (__const char *__s, int __c) __THROW __attribute_pure__;
+__END_NAMESPACE_STD
 
 #ifdef __USE_GNU
 /* This function is similar to `strchr'.  But it returns a pointer to
@@ -162,6 +170,7 @@ extern char *strrchr (__const char *__s, int __c) __THROW __attribute_pure__;
 extern char *strchrnul (__const char *__s, int __c) __THROW __attribute_pure__;
 #endif
 
+__BEGIN_NAMESPACE_STD
 /* Return the length of the initial segment of S which
    consists entirely of characters not in REJECT.  */
 extern size_t strcspn (__const char *__s, __const char *__reject)
@@ -177,15 +186,11 @@ extern char *strpbrk (__const char *__s, __const char *__accept)
 extern char *strstr (__const char *__haystack, __const char *__needle)
      __THROW __attribute_pure__;
 
-#ifdef __USE_GNU
-/* Similar to `strstr' but this function ignores the case of both strings.  */
-extern char *strcasestr (__const char *__haystack, __const char *__needle)
-     __THROW __attribute_pure__;
-#endif
 
 /* Divide S into tokens separated by characters in DELIM.  */
 extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
      __THROW;
+__END_NAMESPACE_STD
 
 /* Divide S into tokens separated by characters in DELIM.  Information
    passed between calls are stored in SAVE_PTR.  */
@@ -198,6 +203,12 @@ extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
 #endif
 
 #ifdef __USE_GNU
+/* Similar to `strstr' but this function ignores the case of both strings.  */
+extern char *strcasestr (__const char *__haystack, __const char *__needle)
+     __THROW __attribute_pure__;
+#endif
+
+#ifdef __USE_GNU
 /* Find the first occurrence of NEEDLE in HAYSTACK.
    NEEDLE is NEEDLELEN bytes long;
    HAYSTACK is HAYSTACKLEN bytes long.  */
@@ -214,8 +225,10 @@ extern void *mempcpy (void *__restrict __dest,
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Return the length of S.  */
 extern size_t strlen (__const char *__s) __THROW __attribute_pure__;
+__END_NAMESPACE_STD
 
 #ifdef	__USE_GNU
 /* Find the length of STRING, but scan at most MAXLEN characters.
@@ -225,8 +238,10 @@ extern size_t strnlen (__const char *__string, size_t __maxlen)
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Return a string describing the meaning of the `errno' code in ERRNUM.  */
 extern char *strerror (int __errnum) __THROW;
+__END_NAMESPACE_STD
 #if defined __USE_XOPEN2K || defined __USE_MISC
 /* Reentrant version of `strerror'.  If a temporary buffer is required, at
    most BUFLEN bytes of BUF will be used.  */
diff --git a/time/time.h b/time/time.h
index e71ca7afcc..fa1c284fa5 100644
--- a/time/time.h
+++ b/time/time.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999,2000,01,02 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -55,8 +55,13 @@ __BEGIN_DECLS
 
 # include <bits/types.h>
 
+__BEGIN_NAMESPACE_STD
 /* Returned by `clock'.  */
 typedef __clock_t clock_t;
+__END_NAMESPACE_STD
+#if defined __USE_XOPEN || defined __USE_POSIX || defined __USE_MISC
+__USING_NAMESPACE_STD(clock_t)
+#endif
 
 #endif /* clock_t not defined and <time.h> or need clock_t.  */
 #undef	__need_clock_t
@@ -66,8 +71,13 @@ typedef __clock_t clock_t;
 
 # include <bits/types.h>
 
+__BEGIN_NAMESPACE_STD
 /* Returned by `time'.  */
 typedef __time_t time_t;
+__END_NAMESPACE_STD
+#if defined __USE_POSIX || defined __USE_MISC || defined __USE_SVID
+__USING_NAMESPACE_STD(time_t)
+#endif
 
 #endif /* time_t not defined and <time.h> or need time_t.  */
 #undef	__need_time_t
@@ -114,6 +124,7 @@ struct timespec
 
 
 #ifdef	_TIME_H
+__BEGIN_NAMESPACE_STD
 /* Used by other time functions.  */
 struct tm
 {
@@ -127,14 +138,18 @@ struct tm
   int tm_yday;			/* Days in year.[0-365]	*/
   int tm_isdst;			/* DST.		[-1/0/1]*/
 
-# ifdef	__USE_BSD
+#ifdef	__USE_BSD
   long int tm_gmtoff;		/* Seconds east of UTC.  */
   __const char *tm_zone;	/* Timezone abbreviation.  */
-# else
+#else
   long int __tm_gmtoff;		/* Seconds east of UTC.  */
   __const char *__tm_zone;	/* Timezone abbreviation.  */
-# endif
+#endif
 };
+__END_NAMESPACE_STD
+#if defined __USE_XOPEN || defined __USE_POSIX || defined __USE_MISC
+__USING_NAMESPACE_STD(tm)
+#endif
 
 
 #ifdef __USE_POSIX199309
@@ -158,6 +173,7 @@ typedef __pid_t pid_t;
 #endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Time used by the program so far (user time + system time).
    The result / CLOCKS_PER_SECOND is program time in seconds.  */
 extern clock_t clock (void) __THROW;
@@ -179,6 +195,7 @@ extern time_t mktime (struct tm *__tp) __THROW;
 extern size_t strftime (char *__restrict __s, size_t __maxsize,
 			__const char *__restrict __format,
 			__const struct tm *__restrict __tp) __THROW;
+__END_NAMESPACE_STD
 
 # ifdef __USE_XOPEN
 /* Parse S according to FORMAT and store binary time information in TP.
@@ -204,6 +221,7 @@ extern char *strptime_l (__const char *__restrict __s,
 # endif
 
 
+__BEGIN_NAMESPACE_STD
 /* Return the `struct tm' representation of *TIMER
    in Universal Coordinated Time (aka Greenwich Mean Time).  */
 extern struct tm *gmtime (__const time_t *__timer) __THROW;
@@ -211,6 +229,7 @@ extern struct tm *gmtime (__const time_t *__timer) __THROW;
 /* Return the `struct tm' representation
    of *TIMER in the local timezone.  */
 extern struct tm *localtime (__const time_t *__timer) __THROW;
+__END_NAMESPACE_STD
 
 # if defined __USE_POSIX || defined __USE_MISC
 /* Return the `struct tm' representation of *TIMER in UTC,
@@ -224,12 +243,14 @@ extern struct tm *localtime_r (__const time_t *__restrict __timer,
 			       struct tm *__restrict __tp) __THROW;
 # endif	/* POSIX or misc */
 
+__BEGIN_NAMESPACE_STD
 /* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
    that is the representation of TP in this format.  */
 extern char *asctime (__const struct tm *__tp) __THROW;
 
 /* Equivalent to `asctime (localtime (timer))'.  */
 extern char *ctime (__const time_t *__timer) __THROW;
+__END_NAMESPACE_STD
 
 # if defined __USE_POSIX || defined __USE_MISC
 /* Reentrant versions of the above functions.  */
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index 5a1f341041..9b2f721076 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -58,6 +58,10 @@
    member of the extended character set.  */
 # define _WINT_T
 typedef unsigned int wint_t;
+#else
+# ifdef __USE_GNU
+__USING_NAMESPACE_STD(wint_t)
+# endif
 #endif
 
 
@@ -81,8 +85,13 @@ typedef struct
    defined.  */
 #ifdef _WCHAR_H
 
+__BEGIN_NAMESPACE_C99
 /* Public type.  */
 typedef __mbstate_t mbstate_t;
+__END_NAMESPACE_C99
+#ifdef __USE_GNU
+__USING_NAMESPACE_C99(mbstate_t)
+#endif
 
 #ifndef WCHAR_MIN
 /* These constants might also be defined in <inttypes.h>.  */
@@ -100,13 +109,21 @@ typedef __mbstate_t mbstate_t;
 # include <wctype.h>
 #endif
 
+
+__BEGIN_DECLS
+
+__BEGIN_NAMESPACE_STD
 /* This incomplete type is defined in <time.h> but needed here because
    of `wcsftime'.  */
 struct tm;
+/* XXX We have to clean this up at some point.  Since tm is in the std
+   namespace but wcsftime is in __c99 the type wouldn't be found
+   without inserting it in the global namespace.  */
+__USING_NAMESPACE_STD(tm)
+__END_NAMESPACE_STD
 
 
-__BEGIN_DECLS
-
+__BEGIN_NAMESPACE_C99
 /* Copy SRC to DEST.  */
 extern wchar_t *wcscpy (wchar_t *__restrict __dest,
 			__const wchar_t *__restrict __src) __THROW;
@@ -129,6 +146,7 @@ extern int wcscmp (__const wchar_t *__s1, __const wchar_t *__s2)
 /* Compare N wide-characters of S1 and S2.  */
 extern int wcsncmp (__const wchar_t *__s1, __const wchar_t *__s2, size_t __n)
      __THROW __attribute_pure__;
+__END_NAMESPACE_C99
 
 #ifdef __USE_GNU
 /* Compare S1 and S2, ignoring case.  */
@@ -149,6 +167,7 @@ extern int wcsncasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
 			  size_t __n, __locale_t __loc) __THROW;
 #endif
 
+__BEGIN_NAMESPACE_C99
 /* Compare S1 and S2, both interpreted as appropriate to the
    LC_COLLATE category of the current locale.  */
 extern int wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
@@ -157,6 +176,7 @@ extern int wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
    `wcscoll' to the original strings.  */
 extern size_t wcsxfrm (wchar_t *__restrict __s1,
 		       __const wchar_t *__restrict __s2, size_t __n) __THROW;
+__END_NAMESPACE_C99
 
 #ifdef __USE_GNU
 /* Similar to the two functions above but take the information from
@@ -177,12 +197,14 @@ extern size_t wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2,
 extern wchar_t *wcsdup (__const wchar_t *__s) __THROW __attribute_malloc__;
 #endif
 
+__BEGIN_NAMESPACE_C99
 /* Find the first occurrence of WC in WCS.  */
 extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
      __THROW __attribute_pure__;
 /* Find the last occurrence of WC in WCS.  */
 extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
      __THROW __attribute_pure__;
+__END_NAMESPACE_C99
 
 #ifdef __USE_GNU
 /* This function is similar to `wcschr'.  But it returns a pointer to
@@ -191,6 +213,7 @@ extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc)
      __THROW __attribute_pure__;
 #endif
 
+__BEGIN_NAMESPACE_C99
 /* Return the length of the initial segmet of WCS which
    consists entirely of wide characters not in REJECT.  */
 extern size_t wcscspn (__const wchar_t *__wcs, __const wchar_t *__reject)
@@ -206,12 +229,6 @@ extern wchar_t *wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept)
 extern wchar_t *wcsstr (__const wchar_t *__haystack, __const wchar_t *__needle)
      __THROW __attribute_pure__;
 
-#ifdef __USE_XOPEN
-/* Another name for `wcsstr' from XPG4.  */
-extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle)
-     __THROW __attribute_pure__;
-#endif
-
 /* Divide WCS into tokens separated by characters in DELIM.  */
 extern wchar_t *wcstok (wchar_t *__restrict __s,
 			__const wchar_t *__restrict __delim,
@@ -219,6 +236,13 @@ extern wchar_t *wcstok (wchar_t *__restrict __s,
 
 /* Return the number of wide characters in S.  */
 extern size_t wcslen (__const wchar_t *__s) __THROW __attribute_pure__;
+__END_NAMESPACE_C99
+
+#ifdef __USE_XOPEN
+/* Another name for `wcsstr' from XPG4.  */
+extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle)
+     __THROW __attribute_pure__;
+#endif
 
 #ifdef __USE_GNU
 /* Return the number of wide characters in S, but at most MAXLEN.  */
@@ -227,6 +251,7 @@ extern size_t wcsnlen (__const wchar_t *__s, size_t __maxlen)
 #endif
 
 
+__BEGIN_NAMESPACE_C99
 /* Search N wide characters of S for C.  */
 extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n)
      __THROW __attribute_pure__;
@@ -247,6 +272,7 @@ extern wchar_t *wmemmove (wchar_t *__s1, __const wchar_t *__s2, size_t __n)
 
 /* Set N wide characters of S to C.  */
 extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
+__END_NAMESPACE_C99
 
 #ifdef __USE_GNU
 /* Copy N wide characters of SRC to DEST and return pointer to following
@@ -257,6 +283,7 @@ extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
 #endif
 
 
+__BEGIN_NAMESPACE_C99
 /* Determine whether C constitutes a valid (one-byte) multibyte
    character.  */
 extern wint_t btowc (int __c) __THROW;
@@ -284,6 +311,7 @@ extern size_t __mbrlen (__const char *__restrict __s, size_t __n,
 			mbstate_t *__restrict __ps) __THROW;
 extern size_t mbrlen (__const char *__restrict __s, size_t __n,
 		      mbstate_t *__restrict __ps) __THROW;
+__END_NAMESPACE_C99
 
 #ifdef __USE_EXTERN_INLINES
 /* Define inline function as optimization.  */
@@ -293,6 +321,7 @@ extern __inline size_t mbrlen (__const char *__restrict __s, size_t __n,
 	  ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); }
 #endif
 
+__BEGIN_NAMESPACE_C99
 /* Write wide character representation of multibyte character string
    SRC to DST.  */
 extern size_t mbsrtowcs (wchar_t *__restrict __dst,
@@ -304,6 +333,7 @@ extern size_t mbsrtowcs (wchar_t *__restrict __dst,
 extern size_t wcsrtombs (char *__restrict __dst,
 			 __const wchar_t **__restrict __src, size_t __len,
 			 mbstate_t *__restrict __ps) __THROW;
+__END_NAMESPACE_C99
 
 
 #ifdef	__USE_GNU
@@ -333,6 +363,7 @@ extern int wcswidth (__const wchar_t *__s, size_t __n) __THROW;
 #endif	/* Use X/Open.  */
 
 
+__BEGIN_NAMESPACE_C99
 /* Convert initial portion of the wide string NPTR to `double'
    representation.  */
 extern double wcstod (__const wchar_t *__restrict __nptr,
@@ -358,37 +389,38 @@ extern unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
 				  wchar_t **__restrict __endptr, int __base)
      __THROW;
 
-#if defined __GNUC__ && defined __USE_GNU
+#if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_GNU)
 /* Convert initial portion of wide string NPTR to `long int'
    representation.  */
 __extension__
-extern long long int wcstoq (__const wchar_t *__restrict __nptr,
-			     wchar_t **__restrict __endptr, int __base)
+extern long long int wcstoll (__const wchar_t *__restrict __nptr,
+			      wchar_t **__restrict __endptr, int __base)
      __THROW;
 
 /* Convert initial portion of wide string NPTR to `unsigned long long int'
    representation.  */
 __extension__
-extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr,
-				       wchar_t **__restrict __endptr,
-				       int __base) __THROW;
-#endif /* GCC and use GNU.  */
+extern unsigned long long int wcstoull (__const wchar_t *__restrict __nptr,
+					wchar_t **__restrict __endptr,
+					int __base) __THROW;
+#endif /* ISO C99 or GCC and GNU.  */
+__END_NAMESPACE_C99
 
-#if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_GNU)
+#if defined __GNUC__ && defined __USE_GNU
 /* Convert initial portion of wide string NPTR to `long int'
    representation.  */
 __extension__
-extern long long int wcstoll (__const wchar_t *__restrict __nptr,
-			      wchar_t **__restrict __endptr, int __base)
+extern long long int wcstoq (__const wchar_t *__restrict __nptr,
+			     wchar_t **__restrict __endptr, int __base)
      __THROW;
 
 /* Convert initial portion of wide string NPTR to `unsigned long long int'
    representation.  */
 __extension__
-extern unsigned long long int wcstoull (__const wchar_t *__restrict __nptr,
-					wchar_t **__restrict __endptr,
-					int __base) __THROW;
-#endif /* ISO C99 or GCC and GNU.  */
+extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr,
+				       wchar_t **__restrict __endptr,
+				       int __base) __THROW;
+#endif /* GCC and use GNU.  */
 
 #ifdef __USE_GNU
 /* The concept of one static locale per category is not very well
@@ -486,6 +518,7 @@ extern unsigned long long int __wcstoull_internal (__const wchar_t *
 
 #if defined __OPTIMIZE__ && __GNUC__ >= 2
 /* Define inline functions which call the internal entry points.  */
+__BEGIN_NAMESPACE_C99
 
 extern __inline double wcstod (__const wchar_t *__restrict __nptr,
 			       wchar_t **__restrict __endptr) __THROW
@@ -498,6 +531,7 @@ extern __inline unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
                                            wchar_t **__restrict __endptr,
 					   int __base) __THROW
 { return __wcstoul_internal (__nptr, __endptr, __base, 0); }
+__END_NAMESPACE_C99
 
 # ifdef __USE_GNU
 extern __inline float wcstof (__const wchar_t *__restrict __nptr,
@@ -537,6 +571,7 @@ extern wchar_t *wcpncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n)
 
 /* Wide character I/O functions.  */
 #if defined __USE_ISOC99 || defined __USE_UNIX98
+__BEGIN_NAMESPACE_C99
 
 /* Select orientation for stream.  */
 extern int fwide (__FILE *__fp, int __mode) __THROW;
@@ -582,9 +617,13 @@ extern int wscanf (__const wchar_t *__restrict __format, ...)
 extern int swscanf (__const wchar_t *__restrict __s,
 		    __const wchar_t *__restrict __format, ...)
      __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
+
+__END_NAMESPACE_C99
 #endif /* Use ISO C99 and Unix98. */
 
 #ifdef __USE_ISOC99
+__BEGIN_NAMESPACE_C99
+
 /* Read formatted input from S into argument list ARG.  */
 extern int vfwscanf (__FILE *__restrict __s,
 		     __const wchar_t *__restrict __format,
@@ -599,9 +638,12 @@ extern int vswscanf (__const wchar_t *__restrict __s,
 		     __const wchar_t *__restrict __format,
 		     __gnuc_va_list __arg)
      __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
+
+__END_NAMESPACE_C99
 #endif /* Use ISO C99. */
 
 
+__BEGIN_NAMESPACE_C99
 /* Read a character from STREAM.  */
 extern wint_t fgetwc (__FILE *__stream) __THROW;
 extern wint_t getwc (__FILE *__stream) __THROW;
@@ -630,6 +672,7 @@ extern int fputws (__const wchar_t *__restrict __ws,
 
 /* Push a character back onto the input buffer of STREAM.  */
 extern wint_t ungetwc (wint_t __wc, __FILE *__stream) __THROW;
+__END_NAMESPACE_C99
 
 
 #ifdef __USE_GNU
@@ -660,12 +703,14 @@ extern int fputws_unlocked (__const wchar_t *__restrict __ws,
 #endif
 
 
+__BEGIN_NAMESPACE_C99
 /* Format TP into S according to FORMAT.
    Write no more than MAXSIZE wide characters and return the number
    of wide characters written, or 0 if it would exceed MAXSIZE.  */
 extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
 			__const wchar_t *__restrict __format,
 			__const struct tm *__restrict __tp) __THROW;
+__END_NAMESPACE_C99
 
 # ifdef __USE_GNU
 # include <xlocale.h>
diff --git a/wctype/wctype.h b/wctype/wctype.h
index cd7f0b89d2..0cd1603c3f 100644
--- a/wctype/wctype.h
+++ b/wctype/wctype.h
@@ -40,6 +40,11 @@
    member of the extended character set.  */
 #  define _WINT_T
 typedef unsigned int wint_t;
+# else
+#  ifdef __USE_ISOC99
+__USING_NAMESPACE_C99(wint_t)
+#  endif
+__END_NAMESPACE_C99
 # endif
 
 /* Constant expression of type `wint_t' whose value does not correspond
@@ -56,9 +61,11 @@ typedef unsigned int wint_t;
 #ifndef __iswxxx_defined
 # define __iswxxx_defined	1
 
+__BEGIN_NAMESPACE_C99
 /* Scalar type that can hold values which represent locale-specific
    character classifications.  */
 typedef unsigned long int wctype_t;
+__END_NAMESPACE_C99
 
 # ifndef _ISwbit
 /* The characteristics are stored always in network byte order (big
@@ -109,6 +116,7 @@ enum
 
 __BEGIN_DECLS
 
+__BEGIN_NAMESPACE_C99
 /*
  * Wide-character classification functions: 7.15.2.1.
  */
@@ -180,8 +188,9 @@ extern wctype_t wctype (__const char *__property) __THROW;
 /* Determine whether the wide-character WC has the property described by
    DESC.  */
 extern int iswctype (wint_t __wc, wctype_t __desc) __THROW;
+__END_NAMESPACE_C99
 
-#if __GNUC__ >= 2 && defined __OPTIMIZE__
+#if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
 /* The tables are always organized in a way which allows direct access
    for single byte characters.  */
 extern unsigned int *__ctype32_b;
@@ -244,17 +253,24 @@ extern unsigned int *__ctype32_b;
  * Wide-character case-mapping functions: 7.15.3.1.
  */
 
+__BEGIN_NAMESPACE_C99
 /* Scalar type that can hold values which represent locale-specific
    character mappings.  */
 typedef __const __int32_t *wctrans_t;
+__END_NAMESPACE_C99
+#ifdef __USE_GNU
+__USING_NAMESPACE_C99(wctrans_t)
+#endif
 
+__BEGIN_NAMESPACE_C99
 /* Converts an uppercase letter to the corresponding lowercase letter.  */
 extern wint_t towlower (wint_t __wc) __THROW;
 
 /* Converts an lowercase letter to the corresponding uppercase letter.  */
 extern wint_t towupper (wint_t __wc) __THROW;
+__END_NAMESPACE_C99
 
-#if __GNUC__ >= 2 && defined __OPTIMIZE__
+#if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
 /* The tables are always organized in a way which allows direct access
    for single byte characters.  */
 extern const wint_t *__ctype32_tolower;
@@ -287,12 +303,14 @@ __END_DECLS
 
 __BEGIN_DECLS
 
+__BEGIN_NAMESPACE_C99
 /* Construct value that describes a mapping between wide characters
    identified by the string argument PROPERTY.  */
 extern wctrans_t wctrans (__const char *__property) __THROW;
 
 /* Map the wide character WC using the mapping described by DESC.  */
 extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW;
+__END_NAMESPACE_C99
 
 # ifdef __USE_GNU
 /* Declare the interface to extended locale model.  */