瀏覽代碼

The newly added __glibc_strerror_r function is probably fine, but the
uClibc did not even compile or link without errors. This fixes that
up. Please test more thoroughly next time.

"Steven J. Hill" 20 年之前
父節點
當前提交
7e5c79bcc6
共有 2 個文件被更改,包括 27 次插入38 次删除
  1. 25 36
      include/string.h
  2. 2 2
      libc/string/wstring.c

+ 25 - 36
include/string.h

@@ -122,13 +122,13 @@ __END_NAMESPACE_STD
 extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
 extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
      __THROW __attribute_pure__ __nonnull ((1, 2, 3));
      __THROW __attribute_pure__ __nonnull ((1, 2, 3));
 extern int __strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
 extern int __strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
+     __THROW __attribute_pure__;
 
 
 /* Put a transformation of SRC into no more than N bytes of DEST.  */
 /* Put a transformation of SRC into no more than N bytes of DEST.  */
 extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n,
 extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n,
 			 __locale_t __l) __THROW __nonnull ((2, 4));
 			 __locale_t __l) __THROW __nonnull ((2, 4));
 extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n,
 extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n,
-			 __locale_t __l) __THROW __nonnull ((2, 4));
+			 __locale_t __l) __THROW;
 
 
 #endif
 #endif
 #endif /* __UCLIBC_HAS_XLOCALE__ */
 #endif /* __UCLIBC_HAS_XLOCALE__ */
@@ -263,41 +263,33 @@ __BEGIN_NAMESPACE_STD
 /* Return a string describing the meaning of the `errno' code in ERRNUM.  */
 /* Return a string describing the meaning of the `errno' code in ERRNUM.  */
 extern char *strerror (int __errnum) __THROW;
 extern char *strerror (int __errnum) __THROW;
 __END_NAMESPACE_STD
 __END_NAMESPACE_STD
-
-extern char *__glibc_strerror_r (int __errnum, char *__buf, size_t __buflen)
-     __THROW __nonnull ((2));
-extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
-     __THROW __nonnull ((2));
-
 #if defined __USE_XOPEN2K || defined __USE_MISC
 #if defined __USE_XOPEN2K || defined __USE_MISC
-/* Reentrant version of `strerror'.
+/* Reentrant version of `strerror'.  If a temporary buffer is required, at
-   There are 2 flavors of `strerror_r', GNU which returns the string
+   most BUFLEN bytes of BUF will be used.  */
-   and may or may not use the supplied temporary buffer and POSIX one
+/* extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) __THROW; */
-   which fills the string into the buffer.
+
-   To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
+/* uClibc Note: glibc's strerror_r is different from that specified in SUSv3.
-   without -D_GNU_SOURCE is needed, otherwise the GNU version is
+ * So we try to compensate based on feature macros. */
-   preferred.  */
+extern char *__glibc_strerror_r (int __errnum, char *__buf, size_t __buflen) __THROW;
-# if defined __USE_XOPEN2K && !defined __USE_GNU
+extern int _susv3_strerror_r (int __errnum, char *__buf, size_t buflen) __THROW;
-/* Fill BUF with a string describing the meaning of the `errno' code in
+
-   ERRNUM.  */
+# if defined(__USE_XOPEN2K) && !defined(__USE_GNU)
-#  ifdef __REDIRECT_NTH
+#  ifdef __REDIRECT
-extern int __REDIRECT_NTH (strerror_r,
+extern int __REDIRECT (strerror_r,
-			   (int __errnum, char *__buf, size_t __buflen),
+			   (int __errnum, char *__buf, size_t buflen) __THROW,
-			   __xpg_strerror_r) __nonnull ((2));
+			   _susv3_strerror_r);
 #  else
 #  else
 #   define strerror_r __xpg_strerror_r
 #   define strerror_r __xpg_strerror_r
 #  endif
 #  endif
 # else
 # else
-/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be
+#  ifdef __REDIRECT
-   used.  */
+extern char *__REDIRECT (strerror_r,
-#  ifdef __REDIRECT_NTH
+			   (int __errnum, char *__buf, size_t buflen) __THROW,
-extern char * __REDIRECT_NTH (strerror_r,
+			   __glibc_strerror_r);
-			   (int __errnum, char *__buf, size_t __buflen),
-			   __glibc_strerror_r) __nonnull ((2));
 #  else
 #  else
 #   define strerror_r __glibc_strerror_r
 #   define strerror_r __glibc_strerror_r
 #  endif
 #  endif
-# endif
+# endif /* defined(__USE_XOPEN2K) && !defined(__USE_GNU) */
 #endif
 #endif
 
 
 /* We define this function always since `bzero' is sometimes needed when
 /* We define this function always since `bzero' is sometimes needed when
@@ -355,15 +347,14 @@ extern int strcasecmp_l (__const char *__s1, __const char *__s2,
 			 __locale_t __loc)
 			 __locale_t __loc)
      __THROW __attribute_pure__ __nonnull ((1, 2, 3));
      __THROW __attribute_pure__ __nonnull ((1, 2, 3));
 extern int __strcasecmp_l (__const char *__s1, __const char *__s2,
 extern int __strcasecmp_l (__const char *__s1, __const char *__s2,
-			 __locale_t __loc)
+			 __locale_t __loc) __THROW __attribute_pure__;
-     __THROW __attribute_pure__ __nonnull ((1, 2, 3));
 
 
 extern int strncasecmp_l (__const char *__s1, __const char *__s2,
 extern int strncasecmp_l (__const char *__s1, __const char *__s2,
 			  size_t __n, __locale_t __loc)
 			  size_t __n, __locale_t __loc)
      __THROW __attribute_pure__ __nonnull ((1, 2, 4));
      __THROW __attribute_pure__ __nonnull ((1, 2, 4));
 extern int __strncasecmp_l (__const char *__s1, __const char *__s2,
 extern int __strncasecmp_l (__const char *__s1, __const char *__s2,
 			  size_t __n, __locale_t __loc)
 			  size_t __n, __locale_t __loc)
-     __THROW __attribute_pure__ __nonnull ((1, 2, 4));
+     __THROW __attribute_pure__;
 #endif
 #endif
 #endif /* __UCLIBC_HAS_XLOCALE__ */
 #endif /* __UCLIBC_HAS_XLOCALE__ */
 
 
@@ -398,13 +389,11 @@ extern char *stpncpy (char *__restrict __dest,
 		      __const char *__restrict __src, size_t __n)
 		      __const char *__restrict __src, size_t __n)
      __THROW __nonnull ((1, 2));
      __THROW __nonnull ((1, 2));
 
 
-#if 0							/* uClibc does not support strfry or memfrob. */
 /* Sautee STRING briskly.  */
 /* Sautee STRING briskly.  */
 extern char *strfry (char *__string) __THROW __nonnull ((1));
 extern char *strfry (char *__string) __THROW __nonnull ((1));
 
 
 /* Frobnicate N bytes of S.  */
 /* Frobnicate N bytes of S.  */
 extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1));
 extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1));
-#endif
 
 
 # ifndef basename
 # ifndef basename
 /* Return the file name within directory of FILENAME.  We don't
 /* Return the file name within directory of FILENAME.  We don't
@@ -419,9 +408,9 @@ extern char *basename (__const char *__filename) __THROW __nonnull ((1));
 #ifdef	__USE_BSD
 #ifdef	__USE_BSD
 /* Two OpenBSD extension functions. */
 /* Two OpenBSD extension functions. */
 extern size_t strlcat(char *__restrict dst, const char *__restrict src,
 extern size_t strlcat(char *__restrict dst, const char *__restrict src,
-                      size_t n) __THROW __nonnull ((1, 2));
+                      size_t n) __THROW;
 extern size_t strlcpy(char *__restrict dst, const char *__restrict src,
 extern size_t strlcpy(char *__restrict dst, const char *__restrict src,
-                      size_t n) __THROW __nonnull ((1, 2));
+                      size_t n) __THROW;
 #endif
 #endif
 
 
 __END_DECLS
 __END_DECLS

+ 2 - 2
libc/string/wstring.c

@@ -1571,8 +1571,6 @@ int __xpg_strerror_r(int errnum, char *strerrbuf, size_t buflen)
 /**********************************************************************/
 /**********************************************************************/
 #ifdef L___glibc_strerror_r
 #ifdef L___glibc_strerror_r
 
 
-weak_alias(__glibc_strerror_r,__strerror_r);
-
 char *__glibc_strerror_r(int errnum, char *strerrbuf, size_t buflen)
 char *__glibc_strerror_r(int errnum, char *strerrbuf, size_t buflen)
 {
 {
     __xpg_strerror_r(errnum, strerrbuf, buflen);
     __xpg_strerror_r(errnum, strerrbuf, buflen);
@@ -1580,6 +1578,8 @@ char *__glibc_strerror_r(int errnum, char *strerrbuf, size_t buflen)
     return strerrbuf;
     return strerrbuf;
 }
 }
 
 
+weak_alias(__glibc_strerror_r,__strerror_r);
+
 #endif
 #endif
 /**********************************************************************/
 /**********************************************************************/
 #ifdef L_memmem
 #ifdef L_memmem