Browse Source

Mark some functions as GNU, provide missing hidden memmem, remove _ISOC99/XOPEN_SOURCE

Peter S. Mazinger 18 years ago
parent
commit
55b24e4e95

+ 3 - 1
libc/inet/if_index.c

@@ -35,11 +35,13 @@
 
 #include "netlinkaccess.h"
 
-libc_hidden_proto(strndup)
 libc_hidden_proto(strncpy)
 libc_hidden_proto(strdup)
 libc_hidden_proto(ioctl)
 libc_hidden_proto(close)
+#if __ASSUME_NETLINK_SUPPORT
+libc_hidden_proto(strndup)
+#endif
 
 extern int __opensock(void) attribute_hidden;
 

+ 0 - 1
libc/inet/rpc/rcmd.c

@@ -94,7 +94,6 @@ libc_hidden_proto(strcmp)
 libc_hidden_proto(strcpy)
 libc_hidden_proto(strlen)
 libc_hidden_proto(strncmp)
-libc_hidden_proto(strnlen)
 libc_hidden_proto(memmove)
 libc_hidden_proto(getpid)
 libc_hidden_proto(socket)

+ 0 - 1
libc/misc/assert/__assert.c

@@ -27,7 +27,6 @@
  * and is useful in debugging the stdio code.
  */
 
-#define _ISOC99_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>

+ 0 - 1
libc/misc/ftw/ftw.c

@@ -22,7 +22,6 @@
 # include <config.h>
 #endif
 
-#define _XOPEN_SOURCE 500
 #include <features.h>
 #ifdef __UCLIBC__
 #undef _LIBC

+ 2 - 1
libc/misc/locale/locale.c

@@ -60,7 +60,6 @@
 
 libc_hidden_proto(memcpy)
 libc_hidden_proto(memset)
-libc_hidden_proto(stpcpy)
 libc_hidden_proto(strtok_r)
 libc_hidden_proto(strlen)
 libc_hidden_proto(strcmp)
@@ -192,6 +191,7 @@ static const char utf8[] = "UTF-8";
  */
 static char hr_locale[(MAX_LOCALE_CATEGORY_STR * LC_ALL) + MAX_LOCALE_STR];
 
+libc_hidden_proto(stpcpy)
 libc_hidden_proto(newlocale)
 
 static void update_hr_locale(const unsigned char *spec)
@@ -1082,6 +1082,7 @@ libc_hidden_def(__XL_NPP(nl_langinfo))
 /**********************************************************************/
 #ifdef L_newlocale
 
+libc_hidden_proto(stpcpy)
 libc_hidden_proto(newlocale)
 
 #ifdef __UCLIBC_MJN3_ONLY__

+ 1 - 1
libc/misc/regex/regcomp.c

@@ -532,7 +532,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
     {
       if (BE (msg_size > errbuf_size, 0))
 	{
-#if defined HAVE_MEMPCPY || defined _LIBC
+#if (defined HAVE_MEMPCPY || defined _LIBC) && defined __USE_GNU
 	  *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
 #else
 	  memcpy (errbuf, msg, errbuf_size - 1);

+ 6 - 2
libc/misc/regex/regex.c

@@ -28,7 +28,9 @@
 #ifdef __UCLIBC__
 #undef _LIBC
 #define _REGEX_RE_COMP
-#define HAVE_MEMPCPY
+#ifdef __USE_GNU
+# define HAVE_MEMPCPY
+#endif
 #define HAVE_LANGINFO
 #define HAVE_LANGINFO_CODESET
 #include <stdbool.h>
@@ -83,8 +85,10 @@ libc_hidden_proto(strlen)
 libc_hidden_proto(strncpy)
 libc_hidden_proto(getenv)
 libc_hidden_proto(strcasecmp)
-libc_hidden_proto(mempcpy)
 libc_hidden_proto(abort)
+#ifdef __USE_GNU
+libc_hidden_proto(mempcpy)
+#endif
 
 #endif
 

+ 7 - 3
libc/misc/regex/regex_old.c

@@ -26,7 +26,9 @@
 #ifdef __UCLIBC__
 # undef _LIBC
 # define _REGEX_RE_COMP
-# define HAVE_MEMPCPY
+# ifdef __USE_GNU
+#  define HAVE_MEMPCPY
+# endif
 # define STDC_HEADERS
 # define RE_TRANSLATE_TYPE char *
 #endif
@@ -41,8 +43,10 @@ libc_hidden_proto(memcpy)
 libc_hidden_proto(strcmp)
 libc_hidden_proto(strlen)
 libc_hidden_proto(printf)
-libc_hidden_proto(mempcpy)
 libc_hidden_proto(abort)
+#ifdef __USE_GNU
+libc_hidden_proto(mempcpy)
+#endif
 
 /* AIX requires this to be the first thing in the file. */
 #if defined _AIX && !defined REGEX_MALLOC
@@ -8281,7 +8285,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
     {
       if (msg_size > errbuf_size)
         {
-#if defined HAVE_MEMPCPY || defined _LIBC
+#if (defined HAVE_MEMPCPY || defined _LIBC) && defined __USE_GNU
 	  *((char *) mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
 #else
           memcpy (errbuf, msg, errbuf_size - 1);

+ 1 - 1
libc/misc/regex/regexec.c

@@ -385,7 +385,7 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
 
 	if (BE (s == NULL, 0))
 	  return -2;
-#if defined _LIBC || defined __UCLIBC__
+#if (defined _LIBC || defined __UCLIBC__) && defined __USE_GNU
 	memcpy (__mempcpy (s, string1, length1), string2, length2);
 #else
 	memcpy (s, string1, length1);

+ 2 - 1
libc/misc/time/time.c

@@ -164,7 +164,6 @@ libc_hidden_proto(strcmp)
 libc_hidden_proto(strcpy)
 libc_hidden_proto(strlen)
 libc_hidden_proto(strncpy)
-libc_hidden_proto(strnlen)
 /* libc_hidden_proto(sprintf) */
 libc_hidden_proto(open)
 libc_hidden_proto(read)
@@ -606,6 +605,8 @@ libc_hidden_def(localtime_r)
 
 #ifdef __UCLIBC_HAS_TM_EXTENSIONS__
 
+libc_hidden_proto(strnlen)
+
 struct ll_tzname_item;
 
 typedef struct ll_tzname_item {

+ 0 - 1
libc/misc/wchar/wchar.c

@@ -98,7 +98,6 @@
  * Manuel
  */
 
-#define _ISOC99_SOURCE
 #include <errno.h>
 #include <stddef.h>
 #include <limits.h>

+ 0 - 1
libc/stdlib/ptsname.c

@@ -17,7 +17,6 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#define _ISOC99_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <paths.h>

+ 2 - 0
libc/string/basename.c

@@ -7,6 +7,7 @@
 
 #include "_string.h"
 
+#ifdef __USE_GNU
 libc_hidden_proto(basename)
 
 char *basename(const char *path)
@@ -25,3 +26,4 @@ char *basename(const char *path)
 	return (char *) p;
 }
 libc_hidden_def(basename)
+#endif

+ 2 - 0
libc/string/generic/memmem.c

@@ -19,6 +19,7 @@
 #include <string.h>
 #include <stddef.h>
 
+#ifdef __USE_GNU
 libc_hidden_proto(memmem)
 libc_hidden_proto(memcmp)
 
@@ -50,3 +51,4 @@ void *memmem (const void *haystack, size_t haystack_len,
   return NULL;
 }
 libc_hidden_def(memmem)
+#endif

+ 2 - 0
libc/string/generic/mempcpy.c

@@ -7,6 +7,7 @@
 
 #include <string.h>
 
+#ifdef __USE_GNU
 libc_hidden_proto(mempcpy)
 libc_hidden_proto(memcpy)
 
@@ -16,3 +17,4 @@ void *mempcpy (void *dstpp, const void *srcpp, size_t len)
   return (void *)(((char *)dstpp) + len);
 }
 libc_hidden_def(mempcpy)
+#endif

+ 2 - 0
libc/string/generic/memrchr.c

@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <limits.h>
 
+#ifdef __USE_GNU
 libc_hidden_proto(memrchr)
 libc_hidden_proto(abort)
 
@@ -174,3 +175,4 @@ void *memrchr (const void * s, int c_in, size_t n)
   return 0;
 }
 libc_hidden_def(memrchr)
+#endif

+ 2 - 0
libc/string/generic/rawmemchr.c

@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <limits.h>
 
+#ifdef __USE_GNU
 libc_hidden_proto(rawmemchr)
 libc_hidden_proto(abort)
 
@@ -160,3 +161,4 @@ void *rawmemchr (const void * s, int c_in)
     }
 }
 libc_hidden_def(rawmemchr)
+#endif

+ 2 - 0
libc/string/generic/strchrnul.c

@@ -24,6 +24,7 @@
 #include <string.h>
 #include <stdlib.h>
 
+#ifdef __USE_GNU
 libc_hidden_proto(strchrnul)
 libc_hidden_proto(abort)
 
@@ -165,3 +166,4 @@ char *strchrnul (const char *s, int c_in)
   return NULL;
 }
 libc_hidden_def(strchrnul)
+#endif

+ 2 - 0
libc/string/generic/strnlen.c

@@ -24,6 +24,7 @@
 #include <string.h>
 #include <stdlib.h>
 
+#ifdef __USE_GNU
 libc_hidden_proto(strnlen)
 libc_hidden_proto(abort)
 
@@ -160,3 +161,4 @@ size_t strnlen (const char *str, size_t maxlen)
   return char_ptr - str;
 }
 libc_hidden_def(strnlen)
+#endif

+ 7 - 1
libc/string/generic/strtok_r.c

@@ -22,7 +22,13 @@
 libc_hidden_proto(strtok_r)
 libc_hidden_proto(strspn)
 libc_hidden_proto(strpbrk)
+#ifdef __USE_GNU
+# define __rawmemchr rawmemchr
 libc_hidden_proto(rawmemchr)
+#else
+# define __rawmemchr strchr
+libc_hidden_proto(strchr)
+#endif
 
 /* Parse S into tokens separated by characters in DELIM.
    If S is NULL, the saved pointer in SAVE_PTR is used as
@@ -54,7 +60,7 @@ char *strtok_r (char *s, const char *delim, char **save_ptr)
   s = strpbrk (token, delim);
   if (s == NULL)
     /* This token finishes the string.  */
-    *save_ptr = rawmemchr (token, '\0');
+    *save_ptr = __rawmemchr (token, '\0');
   else
     {
       /* Terminate the token and make *SAVE_PTR point past it.  */

+ 2 - 0
libc/string/i386/strnlen.c

@@ -32,6 +32,7 @@
 
 #include <string.h>
 
+#ifdef __USE_GNU
 libc_hidden_proto(strnlen)
 size_t strnlen(const char *s, size_t count)
 {
@@ -52,3 +53,4 @@ size_t strnlen(const char *s, size_t count)
     return __res;
 }
 libc_hidden_def(strnlen)
+#endif

+ 4 - 0
libc/string/memmem.c

@@ -7,6 +7,8 @@
 
 #include "_string.h"
 
+#ifdef __USE_GNU
+libc_hidden_proto(memmem)
 void *memmem(const void *haystack, size_t haystacklen,
 		     const void *needle, size_t needlelen)
 {
@@ -36,3 +38,5 @@ void *memmem(const void *haystack, size_t haystacklen,
 
 	return NULL;
 }
+libc_hidden_def(memmem)
+#endif

+ 3 - 0
libc/string/mempcpy.c

@@ -7,6 +7,8 @@
 
 #include "_string.h"
 
+#ifdef __USE_GNU
+
 #ifdef WANT_WIDE
 # define Wmempcpy wmempcpy
 #else
@@ -35,3 +37,4 @@ Wvoid *Wmempcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n)
 }
 
 libc_hidden_def(Wmempcpy)
+#endif

+ 3 - 0
libc/string/memrchr.c

@@ -7,6 +7,8 @@
 
 #include "_string.h"
 
+#ifdef __USE_GNU
+
 libc_hidden_proto(memrchr)
 
 void *memrchr(const void *s, int c, size_t n)
@@ -33,3 +35,4 @@ void *memrchr(const void *s, int c, size_t n)
 #undef np
 
 libc_hidden_def(memrchr)
+#endif

+ 2 - 1
libc/string/rawmemchr.c

@@ -7,8 +7,8 @@
 
 #include "_string.h"
 
+#ifdef __USE_GNU
 libc_hidden_proto(rawmemchr)
-
 void *rawmemchr(const void *s, int c)
 {
 	register const unsigned char *r = s;
@@ -18,3 +18,4 @@ void *rawmemchr(const void *s, int c)
 	return (void *) r;	/* silence the warning */
 }
 libc_hidden_def(rawmemchr)
+#endif

+ 3 - 0
libc/string/strchrnul.c

@@ -7,6 +7,8 @@
 
 #include "_string.h"
 
+#ifdef __USE_GNU
+
 #ifdef WANT_WIDE
 # define Wstrchrnul wcschrnul
 #else
@@ -22,3 +24,4 @@ Wchar *Wstrchrnul(register const Wchar *s, Wint c)
 	return (Wchar *) s;
 }
 libc_hidden_def(Wstrchrnul)
+#endif

+ 3 - 0
libc/string/strnlen.c

@@ -7,6 +7,8 @@
 
 #include "_string.h"
 
+#ifdef __USE_GNU
+
 #ifdef WANT_WIDE
 # define Wstrnlen wcsnlen
 #else
@@ -35,3 +37,4 @@ size_t Wstrnlen(const Wchar *s, size_t max)
 #undef maxp
 
 libc_hidden_def(Wstrnlen)
+#endif

+ 2 - 2
libc/sysdeps/linux/common/setegid.c

@@ -11,7 +11,7 @@
 #include <sys/types.h>
 #include <sys/syscall.h>
 
-#if defined __NR_setresgid || defined __NR_setresgid32
+#if (defined __NR_setresgid || defined __NR_setresgid32) && defined __USE_GNU
 libc_hidden_proto(setresgid)
 #endif
 libc_hidden_proto(setregid)
@@ -26,7 +26,7 @@ int setegid(gid_t gid)
 	return -1;
     }
 
-#if defined __NR_setresgid || defined __NR_setresgid32
+#if (defined __NR_setresgid || defined __NR_setresgid32) && defined __USE_GNU
     result = setresgid(-1, gid, -1);
     if (result == -1 && errno == ENOSYS)
 	/* Will also set the saved group ID if egid != gid,

+ 2 - 2
libc/sysdeps/linux/common/seteuid.c

@@ -13,7 +13,7 @@
 
 libc_hidden_proto(seteuid)
 
-#if defined __NR_setresuid || defined __NR_setresuid32
+#if (defined __NR_setresuid || defined __NR_setresuid32) && defined __USE_GNU
 libc_hidden_proto(setresuid)
 #endif
 libc_hidden_proto(setreuid)
@@ -28,7 +28,7 @@ int seteuid(uid_t uid)
 	return -1;
     }
 
-#if defined __NR_setresuid || defined __NR_setresuid32
+#if (defined __NR_setresuid || defined __NR_setresuid32) && defined __USE_GNU
     result = setresuid(-1, uid, -1);
     if (result == -1 && errno == ENOSYS)
 	/* Will also set the saved user ID if euid != uid,

+ 2 - 1
libc/unistd/exec.c

@@ -45,7 +45,6 @@ libc_hidden_proto(execvp)
 libc_hidden_proto(memcpy)
 libc_hidden_proto(strchr)
 libc_hidden_proto(strlen)
-libc_hidden_proto(strchrnul)
 libc_hidden_proto(execve)
 libc_hidden_proto(mmap)
 libc_hidden_proto(munmap)
@@ -220,6 +219,8 @@ int execlp(const char *file, const char *arg, ...)
 /**********************************************************************/
 #ifdef L_execvp
 
+libc_hidden_proto(strchrnul)
+
 /* Use a default path that matches glibc behavior, since SUSv3 says
  * this is implementation-defined.  The default is current working dir,
  * /bin, and then /usr/bin. */