[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r7826 - in /fsf/trunk/libc: ./ nptl/ nptl/sysdeps/pthread/ string/ sysdeps/i386/ wcsmbs/



Author: eglibc
Date: Fri Jan 30 00:04:24 2009
New Revision: 7826

Log:
Import glibc-mainline for 2009-01-30

Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/nptl/ChangeLog
    fsf/trunk/libc/nptl/allocatestack.c
    fsf/trunk/libc/nptl/init.c
    fsf/trunk/libc/nptl/pthreadP.h
    fsf/trunk/libc/nptl/sysdeps/pthread/unwind-forcedunwind.c
    fsf/trunk/libc/string/string.h
    fsf/trunk/libc/sysdeps/i386/stackinfo.h
    fsf/trunk/libc/wcsmbs/wchar.h

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Fri Jan 30 00:04:24 2009
@@ -1,3 +1,14 @@
+2009-01-29  Ulrich Drepper  <drepper@xxxxxxxxxx>
+	    Jakub Jelinek  <jakub@xxxxxxxxxx>
+
+	* string/string.h: Define correct C++ prototypes for gcc 4.4.
+	* wcsmbs/wchar.h: Likewise.
+
+2009-01-29  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* sysdeps/i386/stackinfo.h (stackinfo_get_sp): Define.
+	(stackinfo_sub_sp): Define.
+
 2009-01-28  Ulrich Drepper  <drepper@xxxxxxxxxx>
 
 	[BZ #9750]

Modified: fsf/trunk/libc/nptl/ChangeLog
==============================================================================
--- fsf/trunk/libc/nptl/ChangeLog (original)
+++ fsf/trunk/libc/nptl/ChangeLog Fri Jan 30 00:04:24 2009
@@ -1,3 +1,22 @@
+2009-01-29  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* sysdeps/pthread/unwind-forcedunwind.c: Encrypt all function
+	pointer variables.
+
+	* allocatestack.c (__free_stacks): Renamed from free_stacks.
+	(__free_stack_cache): Removed.  Change callers to call __free_stacks.
+	* init.c (nptl_freeres): New function.
+	(pthread_functions): Initialize ptr_freeres to nptl_freeres.
+	* pthreadP.h: Don't declare __free_stack_cache.  Declare __free_stacks.
+	* sysdeps/pthread/unwind-forcedunwind.c (libgcc_s_handle): New
+	variable.
+	(pthread_cancel_init): Depend in libgcc_s_handle for decision to
+	load DSO.  Assign last.
+	(__unwind_freeres): New function.
+
+	* allocatestack.c (__reclaim_stacks): Reset in_flight_stack later
+	for better debugging.  No need to use stack_list_add here.
+
 2009-01-14  Kaz Kojima  <kkojima@xxxxxxxxxxxxxx>
 
 	* sysdeps/unix/sysv/linux/sh/lowlevellock.S

Modified: fsf/trunk/libc/nptl/allocatestack.c
==============================================================================
--- fsf/trunk/libc/nptl/allocatestack.c (original)
+++ fsf/trunk/libc/nptl/allocatestack.c Fri Jan 30 00:04:24 2009
@@ -248,8 +248,8 @@
 
 
 /* Free stacks until cache size is lower than LIMIT.  */
-static void
-free_stacks (size_t limit)
+void
+__free_stacks (size_t limit)
 {
   /* We reduce the size of the cache.  Remove the last entries until
      the size is below the limit.  */
@@ -299,15 +299,7 @@
 
   stack_cache_actsize += stack->stackblock_size;
   if (__builtin_expect (stack_cache_actsize > stack_cache_maxsize, 0))
-    free_stacks (stack_cache_maxsize);
-}
-
-
-/* This function is called indirectly from the freeres code in libc.  */
-void
-__free_stack_cache (void)
-{
-  free_stacks (0);
+    __free_stacks (stack_cache_maxsize);
 }
 
 
@@ -849,8 +841,6 @@
 	  elem->next->prev = elem->prev;
 	  elem->prev->next = elem->next;
 	}
-
-      in_flight_stack = 0;
     }
 
   /* Mark all stacks except the still running one as free.  */
@@ -913,10 +903,12 @@
   if (__builtin_expect (THREAD_GETMEM (self, user_stack), 0))
     list_add (&self->list, &__stack_user);
   else
-    stack_list_add (&self->list, &stack_used);
+    list_add (&self->list, &stack_used);
 
   /* There is one thread running.  */
   __nptl_nthreads = 1;
+
+  in_flight_stack = 0;
 
   /* Initialize the lock.  */
   stack_cache_lock = LLL_LOCK_INITIALIZER;

Modified: fsf/trunk/libc/nptl/init.c
==============================================================================
--- fsf/trunk/libc/nptl/init.c (original)
+++ fsf/trunk/libc/nptl/init.c Fri Jan 30 00:04:24 2009
@@ -66,6 +66,8 @@
 #ifndef SHARED
 extern void __libc_setup_tls (size_t tcbsize, size_t tcbalign);
 #endif
+
+static void nptl_freeres (void);
 
 
 #ifdef SHARED
@@ -128,12 +130,24 @@
     .ptr__nptl_deallocate_tsd = __nptl_deallocate_tsd,
     .ptr__nptl_setxid = __nptl_setxid,
     /* For now only the stack cache needs to be freed.  */
-    .ptr_freeres = __free_stack_cache
+    .ptr_freeres = nptl_freeres
   };
 # define ptr_pthread_functions &pthread_functions
 #else
 # define ptr_pthread_functions NULL
 #endif
+
+
+/* This function is called indirectly from the freeres code in libc.  */
+static void
+__libc_freeres_fn_section
+nptl_freeres (void)
+{
+#ifdef SHARED
+  __unwind_freeres ();
+#endif
+  __free_stacks (0);
+}
 
 
 /* For asynchronous cancellation we use a signal.  This is the handler.  */

Modified: fsf/trunk/libc/nptl/pthreadP.h
==============================================================================
--- fsf/trunk/libc/nptl/pthreadP.h (original)
+++ fsf/trunk/libc/nptl/pthreadP.h Fri Jan 30 00:04:24 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2002.
 
@@ -247,6 +247,7 @@
 hidden_proto (__pthread_unregister_cancel)
 # ifdef SHARED
 extern void attribute_hidden pthread_cancel_init (void);
+extern void __unwind_freeres (void);
 # endif
 #endif
 
@@ -564,7 +565,7 @@
 
 extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden;
 
-extern void __free_stack_cache (void) attribute_hidden;
+extern void __free_stacks (size_t limit) attribute_hidden;
 
 extern void __wait_lookup_done (void) attribute_hidden;
 

Modified: fsf/trunk/libc/nptl/sysdeps/pthread/unwind-forcedunwind.c
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/pthread/unwind-forcedunwind.c (original)
+++ fsf/trunk/libc/nptl/sysdeps/pthread/unwind-forcedunwind.c Fri Jan 30 00:04:24 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2005, 2006, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@xxxxxxxxxx>.
 
@@ -21,7 +21,9 @@
 #include <stdio.h>
 #include <unwind.h>
 #include <pthreadP.h>
+#include <sysdep.h>
 
+static void *libgcc_s_handle;
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
 static _Unwind_Reason_Code (*libgcc_s_personality)
   (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
@@ -34,10 +36,13 @@
 __attribute_noinline__
 pthread_cancel_init (void)
 {
-  void *resume, *personality, *forcedunwind, *getcfa;
+  void *resume;
+  void *personality;
+  void *forcedunwind;
+  void *getcfa;
   void *handle;
 
-  if (__builtin_expect (libgcc_s_getcfa != NULL, 1))
+  if (__builtin_expect (libgcc_s_handle != NULL, 1))
     {
       /* Force gcc to reload all values.  */
       asm volatile ("" ::: "memory");
@@ -58,23 +63,42 @@
       )
     __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
 
+  PTR_MANGLE (resume);
   libgcc_s_resume = resume;
+  PTR_MANGLE (personality);
   libgcc_s_personality = personality;
+  PTR_MANGLE (forcedunwind);
   libgcc_s_forcedunwind = forcedunwind;
-  /* Make sure libgcc_s_getcfa is written last.  Otherwise,
+  PTR_MANGLE (getcfa);
+  libgcc_s_getcfa = getcfa;
+  /* Make sure libgcc_s_handle is written last.  Otherwise,
      pthread_cancel_init might return early even when the pointer the
      caller is interested in is not initialized yet.  */
   atomic_write_barrier ();
-  libgcc_s_getcfa = getcfa;
+  libgcc_s_handle = handle;
+}
+
+void
+__libc_freeres_fn_section
+__unwind_freeres (void)
+{
+  void *handle = libgcc_s_handle;
+  if (handle != NULL)
+    {
+      libgcc_s_handle = NULL;
+      __libc_dlclose (handle);
+    }
 }
 
 void
 _Unwind_Resume (struct _Unwind_Exception *exc)
 {
-  if (__builtin_expect (libgcc_s_resume == NULL, 0))
+  if (__builtin_expect (libgcc_s_handle == NULL, 0))
     pthread_cancel_init ();
 
-  libgcc_s_resume (exc);
+  void (*resume) (struct _Unwind_Exception *exc) = libgcc_s_resume;
+  PTR_DEMANGLE (resume);
+  resume (exc);
 }
 
 _Unwind_Reason_Code
@@ -83,28 +107,37 @@
                       struct _Unwind_Exception *ue_header,
                       struct _Unwind_Context *context)
 {
-  if (__builtin_expect (libgcc_s_personality == NULL, 0))
+  if (__builtin_expect (libgcc_s_handle == NULL, 0))
     pthread_cancel_init ();
 
-  return libgcc_s_personality (version, actions, exception_class,
-			       ue_header, context);
+  _Unwind_Reason_Code (*personality)
+    (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
+     struct _Unwind_Context *) = libgcc_s_personality;
+  PTR_DEMANGLE (personality);
+  return personality (version, actions, exception_class, ue_header, context);
 }
 
 _Unwind_Reason_Code
 _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop,
 		      void *stop_argument)
 {
-  if (__builtin_expect (libgcc_s_forcedunwind == NULL, 0))
+  if (__builtin_expect (libgcc_s_handle == NULL, 0))
     pthread_cancel_init ();
 
-  return libgcc_s_forcedunwind (exc, stop, stop_argument);
+  _Unwind_Reason_Code (*forcedunwind)
+    (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *)
+    = libgcc_s_forcedunwind;
+  PTR_DEMANGLE (forcedunwind);
+  return forcedunwind (exc, stop, stop_argument);
 }
 
 _Unwind_Word
 _Unwind_GetCFA (struct _Unwind_Context *context)
 {
-  if (__builtin_expect (libgcc_s_getcfa == NULL, 0))
+  if (__builtin_expect (libgcc_s_handle == NULL, 0))
     pthread_cancel_init ();
 
-  return libgcc_s_getcfa (context);
+  _Unwind_Word (*getcfa) (struct _Unwind_Context *) = libgcc_s_getcfa;
+  PTR_DEMANGLE (getcfa);
+  return getcfa (context);
 }

Modified: fsf/trunk/libc/string/string.h
==============================================================================
--- fsf/trunk/libc/string/string.h (original)
+++ fsf/trunk/libc/string/string.h Fri Jan 30 00:04:24 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1993, 1995-2004, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993,1995-2004,2007,2009 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
@@ -31,6 +31,11 @@
 #define	__need_size_t
 #define	__need_NULL
 #include <stddef.h>
+
+/* Tell the caller that we provide correct C++ prototypes.  */
+#if defined __cplusplus && __GNUC_PREREQ (4, 4)
+# define __CORRECT_ISO_CPP_STRING_H_PROTO
+#endif
 
 
 __BEGIN_NAMESPACE_STD
@@ -63,19 +68,40 @@
      __THROW __attribute_pure__ __nonnull ((1, 2));
 
 /* Search N bytes of S for C.  */
+#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" void *memchr (void *__s, int __c, size_t __n)
+      __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
+extern "C++" __const void *memchr (__const void *__s, int __c, size_t __n)
+      __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
+#else
 extern void *memchr (__const void *__s, int __c, size_t __n)
       __THROW __attribute_pure__ __nonnull ((1));
+#endif
 __END_NAMESPACE_STD
 
 #ifdef __USE_GNU
 /* Search in S for C.  This is similar to `memchr' but there is no
    length limit.  */
+# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" void *rawmemchr (void *__s, int __c)
+     __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
+extern "C++" __const void *rawmemchr (__const void *__s, int __c)
+     __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1));
+# else
 extern void *rawmemchr (__const void *__s, int __c)
      __THROW __attribute_pure__ __nonnull ((1));
+# endif
 
 /* Search N bytes of S for the final occurrence of C.  */
+# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" void *memrchr (void *__s, int __c, size_t __n)
+      __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
+extern "C++" __const void *memrchr (__const void *__s, int __c, size_t __n)
+      __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1));
+# else
 extern void *memrchr (__const void *__s, int __c, size_t __n)
       __THROW __attribute_pure__ __nonnull ((1));
+# endif
 #endif
 
 
@@ -164,18 +190,39 @@
 
 __BEGIN_NAMESPACE_STD
 /* Find the first occurrence of C in S.  */
+#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" char *strchr (char *__s, int __c)
+     __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
+extern "C++" __const char *strchr (__const char *__s, int __c)
+     __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1));
+#else
 extern char *strchr (__const char *__s, int __c)
      __THROW __attribute_pure__ __nonnull ((1));
+#endif
 /* Find the last occurrence of C in S.  */
+#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" char *strrchr (char *__s, int __c)
+     __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
+extern "C++" __const char *strrchr (__const char *__s, int __c)
+     __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
+#else
 extern char *strrchr (__const char *__s, int __c)
      __THROW __attribute_pure__ __nonnull ((1));
+#endif
 __END_NAMESPACE_STD
 
 #ifdef __USE_GNU
 /* This function is similar to `strchr'.  But it returns a pointer to
    the closing NUL byte in case C is not found in S.  */
+# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" char *strchrnul (char *__s, int __c)
+     __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
+extern "C++" __const char *strchrnul (__const char *__s, int __c)
+     __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1));
+# else
 extern char *strchrnul (__const char *__s, int __c)
      __THROW __attribute_pure__ __nonnull ((1));
+# endif
 #endif
 
 __BEGIN_NAMESPACE_STD
@@ -188,11 +235,26 @@
 extern size_t strspn (__const char *__s, __const char *__accept)
      __THROW __attribute_pure__ __nonnull ((1, 2));
 /* Find the first occurrence in S of any character in ACCEPT.  */
+#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" char *strpbrk (char *__s, __const char *__accept)
+     __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
+extern "C++" __const char *strpbrk (__const char *__s, __const char *__accept)
+     __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2));
+#else
 extern char *strpbrk (__const char *__s, __const char *__accept)
      __THROW __attribute_pure__ __nonnull ((1, 2));
+#endif
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
+#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" char *strstr (char *__haystack, __const char *__needle)
+     __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
+extern "C++" __const char *strstr (__const char *__haystack,
+				   __const char *__needle)
+     __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2));
+#else
 extern char *strstr (__const char *__haystack, __const char *__needle)
      __THROW __attribute_pure__ __nonnull ((1, 2));
+#endif
 
 
 /* Divide S into tokens separated by characters in DELIM.  */
@@ -214,8 +276,16 @@
 
 #ifdef __USE_GNU
 /* Similar to `strstr' but this function ignores the case of both strings.  */
+# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" char *strcasestr (char *__haystack, __const char *__needle)
+     __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
+extern "C++" __const char *strcasestr (__const char *__haystack,
+				       __const char *__needle)
+     __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2));
+# else
 extern char *strcasestr (__const char *__haystack, __const char *__needle)
      __THROW __attribute_pure__ __nonnull ((1, 2));
+# endif
 #endif
 
 #ifdef __USE_GNU
@@ -306,12 +376,26 @@
      __THROW __attribute_pure__ __nonnull ((1, 2));
 
 /* Find the first occurrence of C in S (same as strchr).  */
+# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" char *index (char *__s, int __c)
+     __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
+extern "C++" __const char *index (__const char *__s, int __c)
+     __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
+# else
 extern char *index (__const char *__s, int __c)
      __THROW __attribute_pure__ __nonnull ((1));
+# endif
 
 /* Find the last occurrence of C in S (same as strrchr).  */
+# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" char *rindex (char *__s, int __c)
+     __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
+extern "C++" __const char *rindex (__const char *__s, int __c)
+     __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
+# else
 extern char *rindex (__const char *__s, int __c)
      __THROW __attribute_pure__ __nonnull ((1));
+# endif
 
 /* Return the position of the first bit set in I, or 0 if none are set.
    The least-significant bit is position 1, the most-significant 32.  */
@@ -390,7 +474,14 @@
    declare the function if the `basename' macro is available (defined
    in <libgen.h>) which makes the XPG version of this function
    available.  */
+#  ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
+extern "C++" char *basename (char *__filename)
+     __THROW __asm ("basename") __nonnull ((1));
+extern "C++" __const char *basename (__const char *__filename)
+     __THROW __asm ("basename") __nonnull ((1));
+#  else
 extern char *basename (__const char *__filename) __THROW __nonnull ((1));
+#  endif
 # endif
 #endif
 

Modified: fsf/trunk/libc/sysdeps/i386/stackinfo.h
==============================================================================
--- fsf/trunk/libc/sysdeps/i386/stackinfo.h (original)
+++ fsf/trunk/libc/sysdeps/i386/stackinfo.h Fri Jan 30 00:04:24 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2009 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
@@ -25,4 +25,14 @@
 /* On x86 the stack grows down.  */
 #define _STACK_GROWS_DOWN	1
 
+/* Access to the stack pointer.  The macros are used in alloca_account
+   for which they need to act as barriers as well, hence the additional
+   (unnecessary) parameters.  */
+#define stackinfo_get_sp() \
+  ({ void *p__; asm volatile ("mov %%esp, %0" : "=r" (p__)); p__; })
+#define stackinfo_sub_sp(ptr) \
+  ({ ptrdiff_t d__;                                             \
+     asm volatile ("sub %%esp, %0" : "=r" (d__) : "0" (ptr));   \
+     d__; })
+
 #endif	/* stackinfo.h */

Modified: fsf/trunk/libc/wcsmbs/wchar.h
==============================================================================
--- fsf/trunk/libc/wcsmbs/wchar.h (original)
+++ fsf/trunk/libc/wcsmbs/wchar.h Fri Jan 30 00:04:24 2009
@@ -50,6 +50,11 @@
 # undef __need_wint_t
 # define __need_wint_t
 # include <stddef.h>
+
+/* Tell the caller that we provide correct C++ prototypes.  */
+#if defined __cplusplus && __GNUC_PREREQ (4, 4)
+# define __CORRECT_ISO_CPP_WCHAR_H_PROTO
+#endif
 
 /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
    there.  So define it ourselves if it remains undefined.  */
@@ -210,11 +215,25 @@
 
 __BEGIN_NAMESPACE_STD
 /* Find the first occurrence of WC in WCS.  */
+#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc)
+     __THROW __asm ("wcschr") __attribute_pure__;
+extern "C++" __const wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
+     __THROW __asm ("wcschr")  __attribute_pure__;
+#else
 extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
      __THROW __attribute_pure__;
+#endif
 /* Find the last occurrence of WC in WCS.  */
+#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc)
+     __THROW __asm ("wcsrchr") __attribute_pure__;
+extern "C++" __const wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
+     __THROW __asm ("wcsrchr") __attribute_pure__;
+#else
 extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
      __THROW __attribute_pure__;
+#endif
 __END_NAMESPACE_STD
 
 #ifdef __USE_GNU
@@ -234,11 +253,27 @@
 extern size_t wcsspn (__const wchar_t *__wcs, __const wchar_t *__accept)
      __THROW __attribute_pure__;
 /* Find the first occurrence in WCS of any character in ACCEPT.  */
+#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, __const wchar_t *__accept)
+     __THROW __asm ("wcspbrk") __attribute_pure__;
+extern "C++" __const wchar_t *wcspbrk (__const wchar_t *__wcs,
+				       __const wchar_t *__accept)
+     __THROW __asm ("wcspbrk") __attribute_pure__;
+#else
 extern wchar_t *wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept)
      __THROW __attribute_pure__;
+#endif
 /* Find the first occurrence of NEEDLE in HAYSTACK.  */
+#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wcsstr (wchar_t *__haystack, __const wchar_t *__needle)
+     __THROW __asm ("wcsstr") __attribute_pure__;
+extern "C++" __const wchar_t *wcsstr (__const wchar_t *__haystack,
+				      __const wchar_t *__needle)
+     __THROW __asm ("wcsstr") __attribute_pure__;
+#else
 extern wchar_t *wcsstr (__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,
@@ -251,8 +286,16 @@
 
 #ifdef __USE_XOPEN
 /* Another name for `wcsstr' from XPG4.  */
+# ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wcswcs (wchar_t *__haystack, __const wchar_t *__needle)
+     __THROW __asm ("wcswcs") __attribute_pure__;
+extern "C++" __const wchar_t *wcswcs (__const wchar_t *__haystack,
+				      __const wchar_t *__needle)
+     __THROW __asm ("wcswcs") __attribute_pure__;
+# else
 extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle)
      __THROW __attribute_pure__;
+# endif
 #endif
 
 #ifdef __USE_GNU
@@ -264,8 +307,16 @@
 
 __BEGIN_NAMESPACE_STD
 /* Search N wide characters of S for C.  */
+#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
+     __THROW __asm ("wmemchr") __attribute_pure__;
+extern "C++" __const wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c,
+				       size_t __n)
+     __THROW __asm ("wmemchr") __attribute_pure__;
+#else
 extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n)
      __THROW __attribute_pure__;
+#endif
 
 /* Compare N wide characters of S1 and S2.  */
 extern int wmemcmp (__const wchar_t *__restrict __s1,