summaryrefslogtreecommitdiff
path: root/libc/string
diff options
context:
space:
mode:
Diffstat (limited to 'libc/string')
-rw-r--r--libc/string/_collate.c11
-rw-r--r--libc/string/ffs.c11
-rw-r--r--libc/string/ffsll.c36
-rw-r--r--libc/string/frv/memset.S1
-rw-r--r--libc/string/generic/memmem.c1
-rw-r--r--libc/string/generic/strcpy.c3
-rw-r--r--libc/string/memmem.c1
-rw-r--r--libc/string/stpncpy.c4
-rw-r--r--libc/string/strcasecmp.c4
-rw-r--r--libc/string/strchr.c7
-rw-r--r--libc/string/strchrnul.c2
-rw-r--r--libc/string/strcpy.c4
-rw-r--r--libc/string/strlcpy.c22
-rw-r--r--libc/string/strncasecmp.c4
-rw-r--r--libc/string/x86_64/memcpy.S4
-rw-r--r--libc/string/x86_64/memset.S6
16 files changed, 70 insertions, 51 deletions
diff --git a/libc/string/_collate.c b/libc/string/_collate.c
index 77d9eb62c..def56d260 100644
--- a/libc/string/_collate.c
+++ b/libc/string/_collate.c
@@ -62,7 +62,6 @@ size_t wcsxfrm(Wchar *__restrict ws1, const Wchar *__restrict ws2, size_t n)
{
return wcsxfrm_l(ws1, ws2, n, __UCLIBC_CURLOCALE );
}
-libc_hidden_def(wcsxfrm)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -500,7 +499,6 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM )
} while (1);
}
-libc_hidden_proto(__XL_NPP(wcscoll))
int __XL_NPP(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCALE_PARAM )
{
col_state_t ws[2];
@@ -538,10 +536,6 @@ libc_hidden_def(__XL_NPP(wcscoll))
#ifdef WANT_WIDE
-extern size_t __wcslcpy(wchar_t *__restrict dst,
- const wchar_t *__restrict src, size_t n);
-
-libc_hidden_proto(__XL_NPP(wcsxfrm))
size_t __XL_NPP(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *__restrict ws2,
size_t n __LOCALE_PARAM )
{
@@ -579,7 +573,9 @@ size_t __XL_NPP(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *__restrict ws2,
}
return count-1;
}
+#if defined L_strxfrm_l || defined L_wcsxfrm_l
libc_hidden_def(__XL_NPP(wcsxfrm))
+#endif
#else /* WANT_WIDE */
@@ -623,7 +619,6 @@ static size_t store(unsigned char *s, size_t count, size_t n, __uwchar_t weight)
return r;
}
-libc_hidden_proto(__XL_NPP(strxfrm))
size_t __XL_NPP(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_t n
__LOCALE_PARAM )
{
@@ -661,7 +656,9 @@ size_t __XL_NPP(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_
}
return count-1;
}
+#ifdef L_strxfrm_l
libc_hidden_def(__XL_NPP(strxfrm))
+#endif
#endif /* WANT_WIDE */
diff --git a/libc/string/ffs.c b/libc/string/ffs.c
index 22efe4a1e..f39d304b7 100644
--- a/libc/string/ffs.c
+++ b/libc/string/ffs.c
@@ -5,11 +5,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* ffsl,ffsll */
-
-#include "_string.h"
-
-
+#include <limits.h>
+#include <string.h>
+
int ffs(int i)
{
#if 1
@@ -52,3 +50,6 @@ int ffs(int i)
#endif
}
libc_hidden_def(ffs)
+#if ULONG_MAX == UINT_MAX
+strong_alias_untyped(ffs, ffsl)
+#endif
diff --git a/libc/string/ffsll.c b/libc/string/ffsll.c
new file mode 100644
index 000000000..a7662900b
--- /dev/null
+++ b/libc/string/ffsll.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1992, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <limits.h>
+#include <string.h>
+
+/* Find the first bit set in I. */
+int ffsll (long long int i)
+{
+ unsigned long long int x = i & -i;
+
+ if (x <= 0xffffffff)
+ return ffs (i);
+ else
+ return 32 + ffs (i >> 32);
+}
+
+#if ULONG_MAX != UINT_MAX
+strong_alias_untyped(ffsll, ffsl)
+#endif
diff --git a/libc/string/frv/memset.S b/libc/string/frv/memset.S
index a3e76c491..bc0f80db0 100644
--- a/libc/string/frv/memset.S
+++ b/libc/string/frv/memset.S
@@ -155,3 +155,4 @@ memset:
bralr
.size memset, .-memset
+libc_hidden_def(memset)
diff --git a/libc/string/generic/memmem.c b/libc/string/generic/memmem.c
index 0fccac77f..97384978b 100644
--- a/libc/string/generic/memmem.c
+++ b/libc/string/generic/memmem.c
@@ -48,5 +48,4 @@ void *memmem (const void *haystack, size_t haystack_len,
return NULL;
}
-libc_hidden_def(memmem)
#endif
diff --git a/libc/string/generic/strcpy.c b/libc/string/generic/strcpy.c
index 4d070531f..ace6dea58 100644
--- a/libc/string/generic/strcpy.c
+++ b/libc/string/generic/strcpy.c
@@ -17,9 +17,6 @@
02111-1307 USA. */
#include <string.h>
-#include <stddef.h>
-
-#include "memcopy.h"
/* Copy SRC to DEST. */
char *strcpy(char *dest, const char *src)
diff --git a/libc/string/memmem.c b/libc/string/memmem.c
index f568a4261..1b3a0bab6 100644
--- a/libc/string/memmem.c
+++ b/libc/string/memmem.c
@@ -37,5 +37,4 @@ void *memmem(const void *haystack, size_t haystacklen,
return NULL;
}
-libc_hidden_def(memmem)
#endif
diff --git a/libc/string/stpncpy.c b/libc/string/stpncpy.c
index 088145dea..50d83a131 100644
--- a/libc/string/stpncpy.c
+++ b/libc/string/stpncpy.c
@@ -27,7 +27,3 @@ Wchar *Wstpncpy(register Wchar * __restrict s1,
}
return s1 + (s2 - p);
}
-
-#ifndef WANT_WIDE
-libc_hidden_def(stpncpy)
-#endif
diff --git a/libc/string/strcasecmp.c b/libc/string/strcasecmp.c
index 33e48fa22..f894e426e 100644
--- a/libc/string/strcasecmp.c
+++ b/libc/string/strcasecmp.c
@@ -31,7 +31,9 @@ int strcasecmp(register const Wchar *s1, register const Wchar *s2)
{
return strcasecmp_l(s1, s2, __UCLIBC_CURLOCALE);
}
+#ifndef WANT_WIDE
libc_hidden_def(strcasecmp)
+#endif
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -59,6 +61,8 @@ int __XL_NPP(strcasecmp)(register const Wchar *s1, register const Wchar *s2
return r;
#endif
}
+#if !defined WANT_WIDE || (defined WANT_WIDE && defined __UCLIBC_DO_XLOCALE)
libc_hidden_def(__XL_NPP(strcasecmp))
+#endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/string/strchr.c b/libc/string/strchr.c
index 462b7b1f1..7ea477362 100644
--- a/libc/string/strchr.c
+++ b/libc/string/strchr.c
@@ -23,8 +23,9 @@ Wchar *Wstrchr(register const Wchar *s, Wint c)
return NULL;
}
-libc_hidden_def(Wstrchr)
-
-#if !defined WANT_WIDE && defined __UCLIBC_SUSV3_LEGACY__
+#ifndef WANT_WIDE
+libc_hidden_def(strchr)
+# ifdef __UCLIBC_SUSV3_LEGACY__
weak_alias(strchr,index)
+# endif
#endif
diff --git a/libc/string/strchrnul.c b/libc/string/strchrnul.c
index d2d7df307..4751971bc 100644
--- a/libc/string/strchrnul.c
+++ b/libc/string/strchrnul.c
@@ -21,5 +21,7 @@ Wchar *Wstrchrnul(register const Wchar *s, Wint c)
while (*++s && (*s != ((Wchar)c)));
return (Wchar *) s;
}
+# ifndef WANT_WIDE
libc_hidden_def(Wstrchrnul)
+# endif
#endif
diff --git a/libc/string/strcpy.c b/libc/string/strcpy.c
index bb5a16872..549360c22 100644
--- a/libc/string/strcpy.c
+++ b/libc/string/strcpy.c
@@ -22,8 +22,6 @@ Wchar *Wstrcpy(Wchar * __restrict s1, const Wchar * __restrict s2)
return s1;
}
-#ifdef WANT_WIDE
-/* wcscpy does not need libc_hidden_def */
-#else
+#ifndef WANT_WIDE
libc_hidden_def(strcpy)
#endif
diff --git a/libc/string/strlcpy.c b/libc/string/strlcpy.c
index 0ccfc0e8a..83787049a 100644
--- a/libc/string/strlcpy.c
+++ b/libc/string/strlcpy.c
@@ -9,19 +9,16 @@
#ifdef WANT_WIDE
# define Wstrlcpy __wcslcpy
+# define Wstrxfrm wcsxfrm
#else
# define Wstrlcpy strlcpy
+# define Wstrxfrm strxfrm
#endif
/* OpenBSD function:
* Copy at most n-1 chars from src to dst and nul-terminate dst.
* Returns strlen(src), so truncation occurred if the return value is >= n. */
-#ifdef WANT_WIDE
-size_t Wstrlcpy(register Wchar *__restrict dst,
- register const Wchar *__restrict src,
- size_t n) attribute_hidden;
-#endif
size_t Wstrlcpy(register Wchar *__restrict dst,
register const Wchar *__restrict src,
size_t n)
@@ -45,19 +42,10 @@ size_t Wstrlcpy(register Wchar *__restrict dst,
return src - src0;
}
-#ifdef WANT_WIDE
-
-#ifndef __UCLIBC_HAS_LOCALE__
-strong_alias(__wcslcpy,wcsxfrm)
-libc_hidden_def(wcsxfrm)
-#endif
-
-#else
-
+#ifndef WANT_WIDE
libc_hidden_def(strlcpy)
-#ifndef __UCLIBC_HAS_LOCALE__
-strong_alias(strlcpy,strxfrm)
-libc_hidden_def(strxfrm)
#endif
+#ifndef __UCLIBC_HAS_LOCALE__
+strong_alias(Wstrlcpy,Wstrxfrm)
#endif
diff --git a/libc/string/strncasecmp.c b/libc/string/strncasecmp.c
index 2af305e16..2eac47dd4 100644
--- a/libc/string/strncasecmp.c
+++ b/libc/string/strncasecmp.c
@@ -31,7 +31,9 @@ int strncasecmp(register const Wchar *s1, register const Wchar *s2, size_t n)
{
return strncasecmp_l(s1, s2, n, __UCLIBC_CURLOCALE);
}
+#ifndef WANT_WIDE
libc_hidden_def(strncasecmp)
+#endif
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -62,6 +64,8 @@ int __XL_NPP(strncasecmp)(register const Wchar *s1, register const Wchar *s2,
return r;
#endif
}
+#if !defined WANT_WIDE || (defined WANT_WIDE && defined __UCLIBC_DO_XLOCALE)
libc_hidden_def(__XL_NPP(strncasecmp))
+#endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/string/x86_64/memcpy.S b/libc/string/x86_64/memcpy.S
index 6d941e0f2..9c8169b42 100644
--- a/libc/string/x86_64/memcpy.S
+++ b/libc/string/x86_64/memcpy.S
@@ -26,12 +26,10 @@
#define MEMPCPY_P (defined memcpy)
.text
-#if defined __PIC__ && !defined NOT_IN_libc
+#if defined __PIC__ && !defined NOT_IN_libc && defined __UCLIBC_HAS_FORTIFY__
ENTRY (__memcpy_chk)
cmpq %rdx, %rcx
-#if defined __UCLIBC_HAS_SSP__
jb HIDDEN_JUMPTARGET (__chk_fail)
-#endif
END (__memcpy_chk)
#endif
ENTRY (BP_SYM (memcpy))
diff --git a/libc/string/x86_64/memset.S b/libc/string/x86_64/memset.S
index df265f394..6b758ce3a 100644
--- a/libc/string/x86_64/memset.S
+++ b/libc/string/x86_64/memset.S
@@ -29,12 +29,10 @@
#define LARGE $120000
.text
-#if defined __PIC__ && !defined NOT_IN_libc
+#if defined __PIC__ && !defined NOT_IN_libc && defined __UCLIBC_HAS_FORTIFY__
ENTRY (__memset_chk)
cmpq %rdx, %rcx
-#if defined __UCLIBC_HAS_SSP__
jb HIDDEN_JUMPTARGET (__chk_fail)
-#endif
END (__memset_chk)
#endif
ENTRY (memset)
@@ -144,6 +142,6 @@ END (memset)
libc_hidden_def(memset)
#endif
-#if !BZERO_P && defined __PIC__ && !defined NOT_IN_libc
+#if !BZERO_P && defined __PIC__ && !defined NOT_IN_libc && defined __UCLIBC_HAS_FORTIFY__
strong_alias (__memset_chk, __memset_zero_constant_len_parameter)
#endif