diff options
Diffstat (limited to 'libc/string')
185 files changed, 3786 insertions, 1022 deletions
diff --git a/libc/string/Makefile.in b/libc/string/Makefile.in index 4f96b8354..376316b7e 100644 --- a/libc/string/Makefile.in +++ b/libc/string/Makefile.in @@ -1,79 +1,113 @@ # Makefile for uClibc # -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> # # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -# order is relevant --include $(top_srcdir)libc/string/$(TARGET_ARCH)/Makefile.arch -include $(top_srcdir)libc/string/generic/Makefile.in +# +# Arch specific fun +# +STRING_ARCH_DIR := $(top_srcdir)libc/string/$(TARGET_ARCH) +STRING_ARCH_OUT := $(top_builddir)libc/string/$(TARGET_ARCH) + +STRING_ARCH_SRC := $(wildcard $(STRING_ARCH_DIR)/*.c) +STRING_ARCH_OBJ := $(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SRC)) + +STRING_ARCH_SSRC := $(wildcard $(STRING_ARCH_DIR)/*.S) +STRING_ARCH_SOBJ := $(patsubst $(STRING_ARCH_DIR)/%.S,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SSRC)) + +STRING_ARCH_OBJS := $(STRING_ARCH_OBJ) $(STRING_ARCH_SOBJ) + +libc-$(UCLIBC_HAS_STRING_ARCH_OPT) += $(STRING_ARCH_OBJS) + +libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT) += $(STRING_ARCH_SOBJ) + +# +# Generic stuff +# +STRING_GENERIC_DIR := $(top_srcdir)libc/string/generic +STRING_GENERIC_OUT := $(top_builddir)libc/string/generic -STRING_DIR:=$(top_srcdir)libc/string -STRING_OUT:=$(top_builddir)libc/string +STRING_GENERIC_SRC := $(wildcard $(STRING_GENERIC_DIR)/*.c) + +ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y) +ifneq ($(strip $(STRING_ARCH_OBJS)),) +STRING_GENERIC_SRC := $(filter-out $(patsubst %.o,$(STRING_GENERIC_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_GENERIC_SRC)) +endif +endif + +STRING_GENERIC_OBJS := $(patsubst $(STRING_GENERIC_DIR)/%.c,$(STRING_GENERIC_OUT)/%.o,$(STRING_GENERIC_SRC)) + +libc-$(UCLIBC_HAS_STRING_GENERIC_OPT) += $(STRING_GENERIC_OBJS) + +# +# Top level string +# +STRING_DIR := $(top_srcdir)libc/string +STRING_OUT := $(top_builddir)libc/string -STRING_ALL_WXSRC:=$(wildcard $(STRING_DIR)/w*_l.c) +STRING_ALL_WXSRC := $(wildcard $(STRING_DIR)/w*_l.c) ifeq ($(UCLIBC_HAS_LOCALE),y) -STRING_WXSRC:=$(STRING_ALL_WXSRC) +STRING_WXSRC := $(STRING_ALL_WXSRC) else # wcscoll_l -STRING_WXSRC:=$(filter-out $(STRING_DIR)/wcsxfrm_l.c,$(STRING_ALL_WXSRC)) +STRING_WXSRC := $(filter-out $(STRING_DIR)/wcsxfrm_l.c,$(STRING_ALL_WXSRC)) endif -STRING_ALL_XLSRC:=$(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/*_l.c)) +STRING_ALL_XLSRC := $(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/*_l.c)) ifeq ($(UCLIBC_HAS_LOCALE),y) -STRING_XLSRC:=$(STRING_ALL_XLSRC) +STRING_XLSRC := $(STRING_ALL_XLSRC) else # strcoll_l -STRING_XLSRC:=$(filter-out $(STRING_DIR)/strxfrm_l.c,$(STRING_ALL_XLSRC)) +STRING_XLSRC := $(filter-out $(STRING_DIR)/strxfrm_l.c,$(STRING_ALL_XLSRC)) endif -STRING_ALL_WSRC:=$(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/w*.c)) +STRING_ALL_WSRC := $(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/w*.c)) ifeq ($(UCLIBC_HAS_LOCALE),y) -STRING_WSRC:=$(STRING_ALL_WSRC) +STRING_WSRC := $(STRING_ALL_WSRC) else # wcscoll -STRING_WSRC:=$(filter-out $(STRING_DIR)/wcsxfrm.c,$(STRING_ALL_WSRC)) +STRING_WSRC := $(filter-out $(STRING_DIR)/wcsxfrm.c,$(STRING_ALL_WSRC)) endif -STRING_ALL_CSRC:=$(filter-out $(STRING_ALL_WXSRC) $(STRING_ALL_XLSRC) $(STRING_ALL_WSRC) $(STRING_DIR)/_collate.c,$(wildcard $(STRING_DIR)/*.c)) +STRING_ALL_CSRC := $(filter-out $(STRING_ALL_WXSRC) $(STRING_ALL_XLSRC) $(STRING_ALL_WSRC) $(STRING_DIR)/_collate.c,$(wildcard $(STRING_DIR)/*.c)) ifeq ($(UCLIBC_HAS_LOCALE),y) -STRING_CSRC:=$(STRING_ALL_CSRC) +STRING_CSRC := $(STRING_ALL_CSRC) else # strcoll -STRING_CSRC:=$(filter-out $(STRING_DIR)/strxfrm.c,$(STRING_ALL_CSRC)) +STRING_CSRC := $(filter-out $(STRING_DIR)/strxfrm.c,$(STRING_ALL_CSRC)) endif ifeq ($(UCLIBC_HAS_WCHAR),y) -STRING_CSRC+=$(STRING_WSRC) +STRING_CSRC += $(STRING_WSRC) endif ifeq ($(UCLIBC_HAS_XLOCALE),y) -STRING_CSRC+=$(STRING_XLSRC) +STRING_CSRC += $(STRING_XLSRC) ifeq ($(UCLIBC_HAS_WCHAR),y) -STRING_CSRC+=$(STRING_WXSRC) +STRING_CSRC += $(STRING_WXSRC) endif endif ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y) ifneq ($(strip $(STRING_ARCH_OBJS)),) -STRING_CSRC:=$(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_CSRC)) +STRING_CSRC := $(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_CSRC)) endif endif ifeq ($(UCLIBC_HAS_STRING_GENERIC_OPT),y) ifneq ($(strip $(STRING_GENERIC_OBJS)),) -STRING_CSRC:=$(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_GENERIC_OBJS))),$(STRING_CSRC)) +STRING_CSRC := $(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_GENERIC_OBJS))),$(STRING_CSRC)) endif endif -STRING_COBJ:=$(patsubst $(STRING_DIR)/%.c,$(STRING_OUT)/%.o,$(STRING_CSRC)) +STRING_COBJ := $(patsubst $(STRING_DIR)/%.c,$(STRING_OUT)/%.o,$(STRING_CSRC)) -libc-a-y+=$(STRING_COBJ) -libc-so-y+=$(STRING_COBJ:.o=.os) +libc-y += $(STRING_COBJ) -libc-multi-y+=$(STRING_CSRC) +libc-nomulti-$(UCLIBC_HAS_XLOCALE) += $(STRING_OUT)/wcsxfrm_l.o -objclean-y+=string_objclean +objclean-y += string_objclean string_objclean: $(RM) $(STRING_OUT)/{,*/}*.{o,os} diff --git a/libc/string/__glibc_strerror_r.c b/libc/string/__glibc_strerror_r.c index 54955ec25..0f9cd16a9 100644 --- a/libc/string/__glibc_strerror_r.c +++ b/libc/string/__glibc_strerror_r.c @@ -8,12 +8,13 @@ #include <features.h> #include <string.h> -char attribute_hidden *__glibc_strerror_r_internal(int errnum, char *strerrbuf, size_t buflen) +libc_hidden_proto(__glibc_strerror_r) +libc_hidden_proto(__xpg_strerror_r) + +char *__glibc_strerror_r(int errnum, char *strerrbuf, size_t buflen) { - __xpg_strerror_r_internal(errnum, strerrbuf, buflen); + __xpg_strerror_r(errnum, strerrbuf, buflen); return strerrbuf; } - -strong_alias(__glibc_strerror_r_internal,__glibc_strerror_r) -/*hidden_weak_alias(__glibc_strerror_r_internal,__strerror_r)*/ +libc_hidden_def(__glibc_strerror_r) diff --git a/libc/string/__xpg_basename.c b/libc/string/__xpg_basename.c index 6281f015c..2449d1d42 100644 --- a/libc/string/__xpg_basename.c +++ b/libc/string/__xpg_basename.c @@ -6,6 +6,7 @@ */ #include "_string.h" +#include <libgen.h> char *__xpg_basename(register char *path) { diff --git a/libc/string/__xpg_strerror_r.c b/libc/string/__xpg_strerror_r.c index 93dffc732..d146d35ac 100644 --- a/libc/string/__xpg_strerror_r.c +++ b/libc/string/__xpg_strerror_r.c @@ -1,19 +1,23 @@ /* * Copyright (C) 2002 Manuel Novoa III - * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> * * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ -#define _GNU_SOURCE #include <features.h> #include <errno.h> +#include <string.h> #include <bits/uClibc_uintmaxtostr.h> #include "_syserrmsg.h" +libc_hidden_proto(__xpg_strerror_r) +libc_hidden_proto(memcpy) +libc_hidden_proto(strlen) + #ifdef __UCLIBC_HAS_ERRNO_MESSAGES__ -extern const char _string_syserrmsgs[]; +extern const char _string_syserrmsgs[] attribute_hidden; #if defined(__alpha__) || defined(__mips__) || defined(__sparc__) @@ -140,22 +144,21 @@ static const unsigned char estridx[] = { ENAVAIL, EISNAM, EREMOTEIO, -#ifdef __mips__ - 0, /* mips has an outrageous value for this... */ +#if EDQUOT > 200 /* mips has an outrageous value for this... */ + 0, #else EDQUOT, #endif ENOMEDIUM, EMEDIUMTYPE, -#if defined(__mips__) || defined(__sparc__) +#if EDEADLOCK != EDEADLK EDEADLOCK, #endif }; #endif -/* __xpg_strerror_r is used in header */ -int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size_t buflen) +int __xpg_strerror_r(int errnum, char *strerrbuf, size_t buflen) { register char *s; int i, retval; @@ -177,11 +180,10 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size } } i = INT_MAX; /* Failed, but may need to check mips special case. */ -#ifdef __mips__ - if (errnum == EDQUOT) { /* Deal with large EDQUOT value on mips */ +#if EDQUOT > 200 /* Deal with large EDQUOT value on mips */ + if (errnum == EDQUOT) i = 122; - } -#endif /* __mips__ */ +#endif GOT_ESTRIDX: #else /* No errno to string index translation needed. */ @@ -207,20 +209,20 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size #endif /* __UCLIBC_HAS_ERRNO_MESSAGES__ */ s = _int10tostr(buf+sizeof(buf)-1, errnum) - sizeof(unknown); - __memcpy(s, unknown, sizeof(unknown)); + memcpy(s, unknown, sizeof(unknown)); GOT_MESG: if (!strerrbuf) { /* SUSv3 */ buflen = 0; } - i = __strlen(s) + 1; + i = strlen(s) + 1; if (i > buflen) { i = buflen; retval = ERANGE; } if (i) { - __memcpy(strerrbuf, s, i); + memcpy(strerrbuf, s, i); strerrbuf[i-1] = 0; /* In case buf was too small. */ } @@ -233,7 +235,7 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size #else /* __UCLIBC_HAS_ERRNO_MESSAGES__ */ -int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size_t buflen) +int __xpg_strerror_r(int errnum, char *strerrbuf, size_t buflen) { register char *s; int i, retval; @@ -243,7 +245,7 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size }; s = _int10tostr(buf+sizeof(buf)-1, errnum) - sizeof(unknown); - __memcpy(s, unknown, sizeof(unknown)); + memcpy(s, unknown, sizeof(unknown)); if (!strerrbuf) { /* SUSv3 */ buflen = 0; @@ -259,7 +261,7 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size } if (i) { - __memcpy(strerrbuf, s, i); + memcpy(strerrbuf, s, i); strerrbuf[i-1] = 0; /* In case buf was too small. */ } @@ -269,5 +271,4 @@ int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size } #endif /* __UCLIBC_HAS_ERRNO_MESSAGES__ */ - -strong_alias(__xpg_strerror_r_internal,__xpg_strerror_r) +libc_hidden_def(__xpg_strerror_r) diff --git a/libc/string/_collate.c b/libc/string/_collate.c index 35fe7dc1b..42216e9e4 100644 --- a/libc/string/_collate.c +++ b/libc/string/_collate.c @@ -19,19 +19,13 @@ #include <errno.h> #include <assert.h> -extern size_t __strlcpy(char *__restrict dst, const char *__restrict src, - size_t n) attribute_hidden; - +libc_hidden_proto(memset) +libc_hidden_proto(memcpy) +libc_hidden_proto(strlcpy) +libc_hidden_proto(strcmp) #ifdef WANT_WIDE -extern int __wcscmp (__const wchar_t *__s1, __const wchar_t *__s2) attribute_hidden; -extern size_t __wcsxfrm (wchar_t *__restrict __s1, - __const wchar_t *__restrict __s2, size_t __n) attribute_hidden; -#endif -#ifdef __UCLIBC_HAS_XLOCALE__ -extern int __strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l) attribute_hidden; -extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n, __locale_t __l) attribute_hidden; -extern int __wcscoll_l (__const wchar_t *__s1, __const wchar_t *__s2, __locale_t __loc) attribute_hidden; -extern size_t __wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2, size_t __n, __locale_t __loc) attribute_hidden; +libc_hidden_proto(wcsxfrm) +libc_hidden_proto(wcscmp) #endif #ifdef __UCLIBC_HAS_LOCALE__ @@ -49,13 +43,9 @@ extern size_t __wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2, size_t __n, __l #if defined(L_strxfrm) || defined(L_strxfrm_l) #define wcscoll strcoll -#define __wcscoll __strcoll #define wcscoll_l strcoll_l -#define __wcscoll_l __strcoll_l #define wcsxfrm strxfrm -#define __wcsxfrm __strxfrm #define wcsxfrm_l strxfrm_l -#define __wcsxfrm_l __strxfrm_l #undef WANT_WIDE #undef Wvoid @@ -67,19 +57,27 @@ extern size_t __wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2, size_t __n, __l #endif /* defined(L_strxfrm) || defined(L_strxfrm_l) */ +libc_hidden_proto(__global_locale) + #if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) -int attribute_hidden __wcscoll (const Wchar *s0, const Wchar *s1) +libc_hidden_proto(wcscoll_l) + +libc_hidden_proto(wcscoll) +int wcscoll (const Wchar *s0, const Wchar *s1) { - return __wcscoll_l(s0, s1, __UCLIBC_CURLOCALE ); + return wcscoll_l(s0, s1, __UCLIBC_CURLOCALE ); } -strong_alias(__wcscoll,wcscoll) +libc_hidden_def(wcscoll) -size_t attribute_hidden __wcsxfrm(Wchar *__restrict ws1, const Wchar *__restrict ws2, size_t n) +libc_hidden_proto(wcsxfrm_l) + +libc_hidden_proto(wcsxfrm) +size_t wcsxfrm(Wchar *__restrict ws1, const Wchar *__restrict ws2, size_t n) { - return __wcsxfrm_l(ws1, ws2, n, __UCLIBC_CURLOCALE ); + return wcsxfrm_l(ws1, ws2, n, __UCLIBC_CURLOCALE ); } -strong_alias(__wcsxfrm,wcsxfrm) +libc_hidden_def(wcsxfrm) #else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */ @@ -160,7 +158,7 @@ static int lookup(wchar_t wc __LOCALE_PARAM ) static void init_col_state(col_state_t *cs, const Wchar *wcs) { - __memset(cs, 0, sizeof(col_state_t)); + memset(cs, 0, sizeof(col_state_t)); cs->s = wcs; cs->bp = cs->back_buf = cs->ibb; cs->bb_size = 128; @@ -392,7 +390,7 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM ) cs->weight = 0; return; } - __memcpy(cs->bp, cs->back_buf, cs->bb_size); + memcpy(cs->bp, cs->back_buf, cs->bb_size); } else { cs->bp = realloc(cs->back_buf, cs->bb_size + 128); @@ -517,16 +515,17 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM ) } while (1); } -int attribute_hidden __UCXL(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCALE_PARAM ) +libc_hidden_proto(__XL_NPP(wcscoll)) +int __XL_NPP(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCALE_PARAM ) { col_state_t ws[2]; int pass; if (!CUR_COLLATE->num_weights) { /* C locale */ #ifdef WANT_WIDE - return __wcscmp(s0, s1); + return wcscmp(s0, s1); #else /* WANT_WIDE */ - return __strcmp(s0, s1); + return strcmp(s0, s1); #endif /* WANT_WIDE */ } @@ -550,11 +549,15 @@ int attribute_hidden __UCXL(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCAL return 0; } -__UCXL_ALIAS(wcscoll) +libc_hidden_def(__XL_NPP(wcscoll)) #ifdef WANT_WIDE -size_t attribute_hidden __UCXL(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *__restrict ws2, +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 ) { col_state_t cs; @@ -562,7 +565,7 @@ size_t attribute_hidden __UCXL(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t * int pass; if (!CUR_COLLATE->num_weights) { /* C locale */ - return __wcsxfrm(ws1, ws2, n); + return __wcslcpy(ws1, ws2, n); } #ifdef __UCLIBC_MJN3_ONLY__ @@ -591,8 +594,7 @@ size_t attribute_hidden __UCXL(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t * } return count-1; } - -__UCXL_ALIAS(wcsxfrm) +libc_hidden_def(__XL_NPP(wcsxfrm)) #else /* WANT_WIDE */ @@ -636,7 +638,8 @@ static size_t store(unsigned char *s, size_t count, size_t n, __uwchar_t weight) return r; } -size_t attribute_hidden __UCXL(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_t n +libc_hidden_proto(__XL_NPP(strxfrm)) +size_t __XL_NPP(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_t n __LOCALE_PARAM ) { col_state_t cs; @@ -644,7 +647,7 @@ size_t attribute_hidden __UCXL(strxfrm)(char *__restrict ws1, const char *__rest int pass; if (!CUR_COLLATE->num_weights) { /* C locale */ - return __strlcpy(ws1, ws2, n); + return strlcpy(ws1, ws2, n); } #ifdef __UCLIBC_MJN3_ONLY__ @@ -673,8 +676,7 @@ size_t attribute_hidden __UCXL(strxfrm)(char *__restrict ws1, const char *__rest } return count-1; } - -__UCXL_ALIAS(strxfrm) +libc_hidden_def(__XL_NPP(strxfrm)) #endif /* WANT_WIDE */ diff --git a/libc/string/_string.h b/libc/string/_string.h index 4ecde30a7..67f17b1ff 100644 --- a/libc/string/_string.h +++ b/libc/string/_string.h @@ -8,7 +8,6 @@ #ifndef __STRING_H #define __STRING_H -#define _GNU_SOURCE #include <features.h> #include <string.h> #include <limits.h> diff --git a/libc/string/_string_syserrmsgs.c b/libc/string/_string_syserrmsgs.c index a76c0e3af..893af5cc6 100644 --- a/libc/string/_string_syserrmsgs.c +++ b/libc/string/_string_syserrmsgs.c @@ -9,6 +9,7 @@ #ifdef __UCLIBC_HAS_ERRNO_MESSAGES__ +attribute_hidden const char _string_syserrmsgs[] = { /* 0: 0, 8 */ "Success\0" /* 1: 8, 24 */ "Operation not permitted\0" diff --git a/libc/string/_string_syssigmsgs.c b/libc/string/_string_syssigmsgs.c index 4a94ddf4f..26c0948f4 100644 --- a/libc/string/_string_syssigmsgs.c +++ b/libc/string/_string_syssigmsgs.c @@ -9,6 +9,7 @@ #ifdef __UCLIBC_HAS_SIGNUM_MESSAGES__ +attribute_hidden const char _string_syssigmsgs[] = { /* 0: 0, 1 */ "\0" /* 1: 1, 7 */ "Hangup\0" @@ -42,7 +43,7 @@ const char _string_syssigmsgs[] = { /* 29: 445, 13 */ "I/O possible\0" /* 30: 458, 14 */ "Power failure\0" /* 31: 472, 16 */ "Bad system call" -#if defined(__alpha__) || defined(__mips__) || defined(__hppa__) || defined(__sparc__) +#if defined SIGEMT /* 32: 488, 9 */ "\0EMT trap" #endif }; diff --git a/libc/string/arm/Makefile b/libc/string/arm/Makefile index ac0063770..0a95346fd 100644 --- a/libc/string/arm/Makefile +++ b/libc/string/arm/Makefile @@ -5,9 +5,9 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -top_srcdir=../../../ -top_builddir=../../../ +top_srcdir:=../../../ +top_builddir:=../../../ all: objs include $(top_builddir)Rules.mak -include Makefile.arch +include ../Makefile.in include $(top_srcdir)Makerules diff --git a/libc/string/arm/Makefile.arch b/libc/string/arm/Makefile.arch deleted file mode 100644 index 4b2550ee2..000000000 --- a/libc/string/arm/Makefile.arch +++ /dev/null @@ -1,27 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -SSRC:= _memcpy.S bcopy.S bzero.S memcmp.S memcpy.S memmove.S memset.S \ - strcmp.S strlen.S strncmp.S - -STRING_ARCH_DIR:=$(top_srcdir)libc/string/arm -STRING_ARCH_OUT:=$(top_builddir)libc/string/arm - -STRING_ARCH_SRC:=$(patsubst %.S,$(STRING_ARCH_DIR)/%.S,$(SSRC)) -STRING_ARCH_OBJ:=$(patsubst %.S,$(STRING_ARCH_OUT)/%.o,$(SSRC)) - -STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ) - -libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) -libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os) - -libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) - -objclean-y+=string_arch_objclean - -string_arch_objclean: - $(RM) $(STRING_ARCH_OUT)/*.{o,os} diff --git a/libc/string/arm/_memcpy.S b/libc/string/arm/_memcpy.S index e8d78af23..3704f96b5 100644 --- a/libc/string/arm/_memcpy.S +++ b/libc/string/arm/_memcpy.S @@ -37,7 +37,7 @@ * by Erik Andersen <andersen@codepoet.org> */ - +#include <features.h> #include <endian.h> /* @@ -83,8 +83,11 @@ _memcpy: bcc .Lmemcpy_backwards moveq r0, #0 /* Quick abort for len=0 */ - moveq pc, lr - +#if defined(__USE_BX__) + bxeq lr +#else + moveq pc, lr +#endif stmdb sp!, {r0, lr} /* memcpy() returns dest addr */ subs r2, r2, #4 blt .Lmemcpy_fl4 /* less than 4 bytes */ @@ -389,8 +392,11 @@ _memcpy: .Lmemcpy_bl4: /* less than 4 bytes to go */ adds r2, r2, #4 +#if defined(__USE_BX__) + bxeq lr +#else moveq pc, lr /* done */ - +#endif /* copy the crud byte at a time */ cmp r2, #2 ldrb r3, [r1, #-1]! @@ -399,8 +405,11 @@ _memcpy: strgeb r3, [r0, #-1]! ldrgtb r3, [r1, #-1]! strgtb r3, [r0, #-1]! +#if defined(__USE_BX__) + bx lr +#else mov pc, lr - +#endif /* erg - unaligned destination */ .Lmemcpy_bdestul: cmp r12, #2 diff --git a/libc/string/arm/bcopy.S b/libc/string/arm/bcopy.S index 2914b8972..0e559225f 100644 --- a/libc/string/arm/bcopy.S +++ b/libc/string/arm/bcopy.S @@ -42,18 +42,15 @@ #include <features.h> .text -.global __bcopy -.hidden __bcopy -.type __bcopy,%function +.global bcopy +.type bcopy,%function .align 4 -__bcopy: +bcopy: /* switch the source and destination registers */ eor r0, r1, r0 eor r1, r0, r1 eor r0, r1, r0 - b _memcpy (PLT) + b _memcpy /* (PLT) */ -.size __bcopy,.-__bcopy - -strong_alias(__bcopy,bcopy) +.size bcopy,.-bcopy diff --git a/libc/string/arm/bzero.S b/libc/string/arm/bzero.S index 2cb67097e..c1eb93323 100644 --- a/libc/string/arm/bzero.S +++ b/libc/string/arm/bzero.S @@ -40,16 +40,13 @@ #include <features.h> .text -.global __bzero -.hidden __bzero -.type __bzero,%function +.global bzero +.type bzero,%function .align 4 -__bzero: +bzero: mov r2, r1 mov r1, #0 - b __memset + b HIDDEN_JUMPTARGET(memset) -.size __bzero,.-__bzero - -strong_alias(__bzero,bzero) +.size bzero,.-bzero diff --git a/libc/string/arm/memcmp.S b/libc/string/arm/memcmp.S index a97e02742..af1b876ed 100644 --- a/libc/string/arm/memcmp.S +++ b/libc/string/arm/memcmp.S @@ -32,17 +32,19 @@ #include <features.h> .text -.global __memcmp -.hidden __memcmp -.type __memcmp,%function +.global memcmp +.type memcmp,%function .align 4 -__memcmp: +memcmp: /* if ((len - 1) < 0) return 0 */ subs r2, r2, #1 movmi r0, #0 +#if defined(__USE_BX__) + bxmi lr +#else movmi pc, lr - +#endif /* ip == last src address to compare */ add ip, r0, r2 1: @@ -52,9 +54,13 @@ __memcmp: cmpcs r2, r3 beq 1b sub r0, r2, r3 - mov pc, lr +#if defined(__USE_BX__) + bx lr +#else + mov pc, lr +#endif -.size __memcmp,.-__memcmp +.size memcmp,.-memcmp -strong_alias(__memcmp,memcmp) -strong_alias(__memcmp,bcmp) +libc_hidden_def(memcmp) +strong_alias(memcmp,bcmp) diff --git a/libc/string/arm/memcpy.S b/libc/string/arm/memcpy.S index 8f81a15e5..7a5b6ab76 100644 --- a/libc/string/arm/memcpy.S +++ b/libc/string/arm/memcpy.S @@ -40,16 +40,15 @@ #include <features.h> .text -.global __memcpy -.hidden __memcpy -.type __memcpy,%function +.global memcpy +.type memcpy,%function .align 4 -__memcpy: +memcpy: stmfd sp!, {r0, lr} bl _memcpy ldmfd sp!, {r0, pc} -.size __memcpy,.-__memcpy +.size memcpy,.-memcpy -strong_alias(__memcpy,memcpy) +libc_hidden_def(memcpy) diff --git a/libc/string/arm/memmove.S b/libc/string/arm/memmove.S index a26cf731e..45cd9b4d4 100644 --- a/libc/string/arm/memmove.S +++ b/libc/string/arm/memmove.S @@ -40,16 +40,15 @@ #include <features.h> .text -.global __memmove -.hidden __memmove -.type __memmove,%function +.global memmove +.type memmove,%function .align 4 -__memmove: +memmove: stmfd sp!, {r0, lr} bl _memcpy ldmfd sp!, {r0, pc} -.size __memmove,.-__memmove +.size memmove,.-memmove -strong_alias(__memmove,memmove) +libc_hidden_def(memmove) diff --git a/libc/string/arm/memset.S b/libc/string/arm/memset.S index dea05a6b0..16bfe0dc5 100644 --- a/libc/string/arm/memset.S +++ b/libc/string/arm/memset.S @@ -21,12 +21,11 @@ #include <sys/syscall.h> .text -.global __memset -.hidden __memset -.type __memset,%function +.global memset +.type memset,%function .align 4 -__memset: +memset: mov a4, a1 cmp a3, $8 @ at least 8 bytes to do? blt 2f @@ -57,7 +56,11 @@ __memset: bge 1b 2: movs a3, a3 @ anything left? - moveq pc, lr @ nope +#if defined(__USE_BX__) + bxeq lr +#else + moveq pc, lr @ nope +#endif rsb a3, a3, $7 add pc, pc, a3, lsl $2 mov r0, r0 @@ -68,8 +71,12 @@ __memset: strb a2, [a4], $1 strb a2, [a4], $1 strb a2, [a4], $1 - mov pc, lr +#if defined(__USE_BX__) + bx lr +#else + mov pc, lr +#endif -.size __memset,.-__memset +.size memset,.-memset -strong_alias(__memset,memset) +libc_hidden_def(memset) diff --git a/libc/string/arm/strcmp.S b/libc/string/arm/strcmp.S index 3f462dec0..89aa38874 100644 --- a/libc/string/arm/strcmp.S +++ b/libc/string/arm/strcmp.S @@ -32,12 +32,11 @@ #include <features.h> .text -.global __strcmp -.hidden __strcmp -.type __strcmp,%function +.global strcmp +.type strcmp,%function .align 4 -__strcmp: +strcmp: 1: ldrb r2, [r0], #1 ldrb r3, [r1], #1 @@ -45,12 +44,16 @@ __strcmp: cmpcs r2, r3 beq 1b sub r0, r2, r3 - mov pc, lr +#if defined(__USE_BX__) + bx lr +#else + mov pc, lr +#endif -.size __strcmp,.-__strcmp +.size strcmp,.-strcmp -strong_alias(__strcmp,strcmp) +libc_hidden_def(strcmp) #ifndef __UCLIBC_HAS_LOCALE__ -hidden_strong_alias(__strcmp,__strcoll) -strong_alias(__strcmp,strcoll) +strong_alias(strcmp,strcoll) +libc_hidden_def(strcoll) #endif diff --git a/libc/string/arm/strlen.S b/libc/string/arm/strlen.S index f623cbe20..5b4b02e17 100644 --- a/libc/string/arm/strlen.S +++ b/libc/string/arm/strlen.S @@ -27,12 +27,11 @@ */ .text -.global __strlen -.hidden __strlen -.type __strlen,%function +.global strlen +.type strlen,%function .align 4 -__strlen: +strlen: bic r1, r0, $3 @ addr of word containing first byte ldr r2, [r1], $4 @ get the first word ands r3, r0, $3 @ how many bytes are duff? @@ -76,8 +75,12 @@ Llastword: @ drop through to here once we find a tstne r2, $0x00ff0000 @ (if first three all non-zero, 4th addne r0, r0, $1 @ must be zero) #endif - mov pc,lr +#if defined(__USE_BX__) + bx lr +#else + mov pc,lr +#endif -.size __strlen,.-__strlen +.size strlen,.-strlen -strong_alias(__strlen,strlen) +libc_hidden_def(strlen) diff --git a/libc/string/arm/strncmp.S b/libc/string/arm/strncmp.S index a3278727e..d6b36312a 100644 --- a/libc/string/arm/strncmp.S +++ b/libc/string/arm/strncmp.S @@ -32,16 +32,19 @@ #include <features.h> .text -.global __strncmp -.hidden __strncmp -.type __strncmp,%function +.global strncmp +.type strncmp,%function .align 4 -__strncmp: +strncmp: /* if (len == 0) return 0 */ cmp r2, #0 moveq r0, #0 +#if defined(__USE_BX__) + bxeq lr +#else moveq pc, lr +#endif subs r2, r2, #1 /* ip == last src address to compare */ @@ -54,8 +57,12 @@ __strncmp: cmpcs r2, r3 beq 1b sub r0, r2, r3 - mov pc, lr +#if defined(__USE_BX__) + bx lr +#else + mov pc, lr +#endif -.size __strncmp,.-__strncmp +.size strncmp,.-strncmp -strong_alias(__strncmp,strncmp) +libc_hidden_def(strncmp) diff --git a/libc/string/basename.c b/libc/string/basename.c index 403cd770b..2c4937fca 100644 --- a/libc/string/basename.c +++ b/libc/string/basename.c @@ -7,7 +7,9 @@ #include "_string.h" -char attribute_hidden *__basename(const char *path) +libc_hidden_proto(basename) + +char *basename(const char *path) { register const char *s; register const char *p; @@ -22,5 +24,4 @@ char attribute_hidden *__basename(const char *path) return (char *) p; } - -strong_alias(__basename,basename) +libc_hidden_def(basename) diff --git a/libc/string/bcopy.c b/libc/string/bcopy.c index 59e586b34..11c3e8015 100644 --- a/libc/string/bcopy.c +++ b/libc/string/bcopy.c @@ -7,10 +7,12 @@ #include "_string.h" -void attribute_hidden __bcopy(const void *s2, void *s1, size_t n) +libc_hidden_proto(memmove) + +void bcopy(const void *s2, void *s1, size_t n) { #if 1 - __memmove(s1, s2, n); + memmove(s1, s2, n); #else #ifdef __BCC__ register char *s; @@ -49,5 +51,3 @@ void attribute_hidden __bcopy(const void *s2, void *s1, size_t n) #endif #endif } - -strong_alias(__bcopy,bcopy) diff --git a/libc/string/bzero.c b/libc/string/bzero.c index 0439e39a1..30bdf5674 100644 --- a/libc/string/bzero.c +++ b/libc/string/bzero.c @@ -7,10 +7,12 @@ #include "_string.h" -void attribute_hidden __bzero(void *s, size_t n) +libc_hidden_proto(memset) + +void bzero(void *s, size_t n) { #if 1 - (void)__memset(s, 0, n); + (void)memset(s, 0, n); #else register unsigned char *p = s; #ifdef __BCC__ @@ -27,5 +29,3 @@ void attribute_hidden __bzero(void *s, size_t n) #endif } #undef np - -strong_alias(__bzero,bzero) diff --git a/libc/string/dirname.c b/libc/string/dirname.c index a6242e238..6265e562e 100644 --- a/libc/string/dirname.c +++ b/libc/string/dirname.c @@ -6,6 +6,7 @@ */ #include "_string.h" +#include <libgen.h> char *dirname(char *path) { diff --git a/libc/string/ffs.c b/libc/string/ffs.c index fc76e6c70..d98383d4e 100644 --- a/libc/string/ffs.c +++ b/libc/string/ffs.c @@ -9,7 +9,9 @@ #include "_string.h" -int attribute_hidden __ffs(int i) +libc_hidden_proto(ffs) + +int ffs(int i) { #if 1 /* inlined binary search method */ @@ -50,5 +52,4 @@ int attribute_hidden __ffs(int i) return n; #endif } - -strong_alias(__ffs,ffs) +libc_hidden_def(ffs) diff --git a/libc/string/frv/Makefile b/libc/string/frv/Makefile index ac0063770..0a95346fd 100644 --- a/libc/string/frv/Makefile +++ b/libc/string/frv/Makefile @@ -5,9 +5,9 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -top_srcdir=../../../ -top_builddir=../../../ +top_srcdir:=../../../ +top_builddir:=../../../ all: objs include $(top_builddir)Rules.mak -include Makefile.arch +include ../Makefile.in include $(top_srcdir)Makerules diff --git a/libc/string/frv/Makefile.arch b/libc/string/frv/Makefile.arch deleted file mode 100644 index a864e8d1a..000000000 --- a/libc/string/frv/Makefile.arch +++ /dev/null @@ -1,27 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2004 Alexandre Oliva <aoliva@redhat.com> -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -SSRC:=memcpy.S memset.S - -STRING_ARCH_DIR:=$(top_srcdir)libc/string/frv -STRING_ARCH_OUT:=$(top_builddir)libc/string/frv - -STRING_ARCH_SRC:=$(patsubst %.S,$(STRING_ARCH_DIR)/%.S,$(SSRC)) -STRING_ARCH_OBJ:=$(patsubst %.S,$(STRING_ARCH_OUT)/%.o,$(SSRC)) - -STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ) - -libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) -libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os) - -libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) - -objclean-y+=string_arch_objclean - -string_arch_objclean: - $(RM) $(STRING_ARCH_OUT)/*.{o,os} diff --git a/libc/string/frv/memcpy.S b/libc/string/frv/memcpy.S index abd8a28db..ae843797d 100644 --- a/libc/string/frv/memcpy.S +++ b/libc/string/frv/memcpy.S @@ -31,10 +31,9 @@ # to caller's fixup routine, aborting the remainder of the copy # ############################################################################### - .globl __memcpy - .hidden __memcpy - .type __memcpy,@function -__memcpy: + .globl memcpy + .type memcpy,@function +memcpy: or.p gr8,gr9,gr4 orcc gr10,gr0,gr0,icc3 or.p gr10,gr4,gr4 @@ -123,6 +122,6 @@ memcpy_32: bne icc0,#2,0b bralr - .size __memcpy, .-__memcpy + .size memcpy, .-memcpy -strong_alias(__memcpy,memcpy) +libc_hidden_def(memcpy) diff --git a/libc/string/frv/memset.S b/libc/string/frv/memset.S index a548b3779..4e64550e4 100644 --- a/libc/string/frv/memset.S +++ b/libc/string/frv/memset.S @@ -32,10 +32,9 @@ # GR4, GR7, GR8, and GR11 must be managed # ############################################################################### - .globl __memset - .hidden __memset - .type __memset,@function -__memset: + .globl memset + .type memset,@function +memset: orcc.p gr10,gr0,gr5,icc3 ; GR5 = count andi gr9,#0xff,gr9 or.p gr8,gr0,gr4 ; GR4 = address @@ -154,6 +153,6 @@ __memset: cknc icc0,cc7 cstb.p gr12,@(gr4,gr0) ,cc7,#1 bralr - .size __memset, .-__memset + .size memset, .-memset -strong_alias(__memset,memset) +libc_hidden_proto(memset) diff --git a/libc/string/generic/Makefile b/libc/string/generic/Makefile index 4a8f4a072..0a95346fd 100644 --- a/libc/string/generic/Makefile +++ b/libc/string/generic/Makefile @@ -5,9 +5,9 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -top_srcdir=../../../ -top_builddir=../../../ +top_srcdir:=../../../ +top_builddir:=../../../ all: objs include $(top_builddir)Rules.mak -include Makefile.in +include ../Makefile.in include $(top_srcdir)Makerules diff --git a/libc/string/generic/Makefile.in b/libc/string/generic/Makefile.in deleted file mode 100644 index 82910172a..000000000 --- a/libc/string/generic/Makefile.in +++ /dev/null @@ -1,29 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -STRING_GENERIC_DIR:=$(top_srcdir)libc/string/generic -STRING_GENERIC_OUT:=$(top_builddir)libc/string/generic - -STRING_GENERIC_SRC:=$(wildcard $(STRING_GENERIC_DIR)/*.c) - -ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y) -ifneq ($(strip $(STRING_ARCH_OBJS)),) -STRING_GENERIC_SRC:=$(filter-out $(patsubst %.o,$(STRING_GENERIC_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_GENERIC_SRC)) -endif -endif - -STRING_GENERIC_OBJS:=$(patsubst $(STRING_GENERIC_DIR)/%.c,$(STRING_GENERIC_OUT)/%.o,$(STRING_GENERIC_SRC)) - -libc-a-$(UCLIBC_HAS_STRING_GENERIC_OPT)+=$(STRING_GENERIC_OBJS) -libc-so-$(UCLIBC_HAS_STRING_GENERIC_OPT)+=$(STRING_GENERIC_OBJS:.o=.os) - -libc-multi-$(UCLIBC_HAS_STRING_GENERIC_OPT)+=$(STRING_GENERIC_SRC) - -objclean-y+=string_generic_objclean - -string_generic_objclean: - $(RM) $(STRING_GENERIC_OUT)/*.{o,os} diff --git a/libc/string/generic/memchr.c b/libc/string/generic/memchr.c index 68c820814..4bda5d758 100644 --- a/libc/string/generic/memchr.c +++ b/libc/string/generic/memchr.c @@ -25,12 +25,15 @@ #include <stdlib.h> #include <limits.h> +libc_hidden_proto(memchr) +libc_hidden_proto(abort) + #include "memcopy.h" #define LONG_MAX_32_BITS 2147483647 /* Search no more than N bytes of S for C. */ -void attribute_hidden *__memchr (const void * s, int c_in, size_t n) +void *memchr (const void * s, int c_in, size_t n) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -171,5 +174,4 @@ void attribute_hidden *__memchr (const void * s, int c_in, size_t n) return 0; } - -strong_alias(__memchr,memchr) +libc_hidden_def(memchr) diff --git a/libc/string/generic/memcmp.c b/libc/string/generic/memcmp.c index 13e11692a..41f15369d 100644 --- a/libc/string/generic/memcmp.c +++ b/libc/string/generic/memcmp.c @@ -19,9 +19,10 @@ 02111-1307 USA. */ #include <string.h> - #include "memcopy.h" +libc_hidden_proto(memcmp) + #include <endian.h> #if __BYTE_ORDER == __BIG_ENDIAN @@ -273,7 +274,7 @@ memcmp_not_common_alignment (srcp1, srcp2, len) } int -attribute_hidden __memcmp (const __ptr_t s1, const __ptr_t s2, size_t len) +memcmp (const __ptr_t s1, const __ptr_t s2, size_t len) { op_t a0; op_t b0; @@ -329,7 +330,5 @@ attribute_hidden __memcmp (const __ptr_t s1, const __ptr_t s2, size_t len) return 0; } - -strong_alias(__memcmp,memcmp) - -strong_alias(__memcmp,bcmp) +libc_hidden_def(memcmp) +strong_alias(memcmp,bcmp) diff --git a/libc/string/generic/memcpy.c b/libc/string/generic/memcpy.c index 6db4d0d44..42e97a063 100644 --- a/libc/string/generic/memcpy.c +++ b/libc/string/generic/memcpy.c @@ -23,6 +23,8 @@ #include "memcopy.h" #include "pagecopy.h" +libc_hidden_proto(memcpy) + /* _wordcopy_fwd_aligned -- Copy block beginning at SRCP to block beginning at DSTP with LEN `op_t' words (not LEN bytes!). Both SRCP and DSTP should be aligned for memory operations on `op_t's. */ @@ -209,7 +211,7 @@ static void _wordcopy_fwd_dest_aligned (long int dstp, long int srcp, size_t len ((op_t *) dstp)[0] = MERGE (a2, sh_1, a3, sh_2); } -void attribute_hidden *__memcpy (void *dstpp, const void *srcpp, size_t len) +void *memcpy (void *dstpp, const void *srcpp, size_t len) { unsigned long int dstp = (long int) dstpp; unsigned long int srcp = (long int) srcpp; @@ -242,5 +244,4 @@ void attribute_hidden *__memcpy (void *dstpp, const void *srcpp, size_t len) return dstpp; } - -strong_alias(__memcpy,memcpy) +libc_hidden_def(memcpy) diff --git a/libc/string/generic/memmem.c b/libc/string/generic/memmem.c index 0353759e3..c2e8547be 100644 --- a/libc/string/generic/memmem.c +++ b/libc/string/generic/memmem.c @@ -19,8 +19,11 @@ #include <string.h> #include <stddef.h> +libc_hidden_proto(memmem) +libc_hidden_proto(memcmp) + /* Return the first occurrence of NEEDLE in HAYSTACK. */ -void attribute_hidden *__memmem (const void *haystack, size_t haystack_len, +void *memmem (const void *haystack, size_t haystack_len, const void *needle, size_t needle_len) { const char *begin; @@ -39,12 +42,11 @@ void attribute_hidden *__memmem (const void *haystack, size_t haystack_len, for (begin = (const char *) haystack; begin <= last_possible; ++begin) if (begin[0] == ((const char *) needle)[0] && - !__memcmp ((const void *) &begin[1], + !memcmp ((const void *) &begin[1], (const void *) ((const char *) needle + 1), needle_len - 1)) return (void *) begin; return NULL; } - -strong_alias(__memmem,memmem) +libc_hidden_def(memmem) diff --git a/libc/string/generic/memmove.c b/libc/string/generic/memmove.c index e34b0005d..68caacd78 100644 --- a/libc/string/generic/memmove.c +++ b/libc/string/generic/memmove.c @@ -24,6 +24,9 @@ #include "memcopy.h" #include "pagecopy.h" +libc_hidden_proto(memmove) +libc_hidden_proto(memcpy) + static void _wordcopy_bwd_aligned (long int dstp, long int srcp, size_t len) { op_t a0, a1; @@ -206,7 +209,7 @@ static void _wordcopy_bwd_dest_aligned (long int dstp, long int srcp, size_t len ((op_t *) dstp)[3] = MERGE (a0, sh_1, a1, sh_2); } -void attribute_hidden *__memmove (void *dest, const void *src, size_t len) +void *memmove (void *dest, const void *src, size_t len) { unsigned long int dstp = (long int) dest; unsigned long int srcp = (long int) src; @@ -217,7 +220,7 @@ void attribute_hidden *__memmove (void *dest, const void *src, size_t len) { #if 1 #warning REMINDER: generic-opt memmove assumes memcpy does forward copying! - __memcpy(dest, src, len); + memcpy(dest, src, len); #else /* Copy from the beginning to the end. */ @@ -276,5 +279,4 @@ void attribute_hidden *__memmove (void *dest, const void *src, size_t len) return (dest); } - -strong_alias(__memmove,memmove) +libc_hidden_def(memmove) diff --git a/libc/string/generic/mempcpy.c b/libc/string/generic/mempcpy.c index d121967cd..7c251914d 100644 --- a/libc/string/generic/mempcpy.c +++ b/libc/string/generic/mempcpy.c @@ -7,10 +7,12 @@ #include <string.h> -void attribute_hidden *__mempcpy (void *dstpp, const void *srcpp, size_t len) +libc_hidden_proto(mempcpy) +libc_hidden_proto(memcpy) + +void *mempcpy (void *dstpp, const void *srcpp, size_t len) { - __memcpy(dstpp, srcpp, len); + memcpy(dstpp, srcpp, len); return (void *)(((char *)dstpp) + len); } - -strong_alias(__mempcpy,mempcpy) +libc_hidden_def(mempcpy) diff --git a/libc/string/generic/memrchr.c b/libc/string/generic/memrchr.c index d27ae03ef..f63efa46b 100644 --- a/libc/string/generic/memrchr.c +++ b/libc/string/generic/memrchr.c @@ -26,12 +26,15 @@ #include <stdlib.h> #include <limits.h> +libc_hidden_proto(memrchr) +libc_hidden_proto(abort) + #include "memcopy.h" #define LONG_MAX_32_BITS 2147483647 /* Search no more than N bytes of S for C. */ -void attribute_hidden *__memrchr (const void * s, int c_in, size_t n) +void *memrchr (const void * s, int c_in, size_t n) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -170,5 +173,4 @@ void attribute_hidden *__memrchr (const void * s, int c_in, size_t n) return 0; } - -strong_alias(__memrchr,memrchr) +libc_hidden_def(memrchr) diff --git a/libc/string/generic/memset.c b/libc/string/generic/memset.c index 91401d7ee..1df1a450f 100644 --- a/libc/string/generic/memset.c +++ b/libc/string/generic/memset.c @@ -19,7 +19,8 @@ #include <string.h> #include "memcopy.h" -void attribute_hidden *__memset (void *dstpp, int c, size_t len) +libc_hidden_proto(memset) +void *memset (void *dstpp, int c, size_t len) { long int dstp = (long int) dstpp; @@ -82,5 +83,4 @@ void attribute_hidden *__memset (void *dstpp, int c, size_t len) return dstpp; } - -strong_alias(__memset,memset) +libc_hidden_def(memset) diff --git a/libc/string/generic/rawmemchr.c b/libc/string/generic/rawmemchr.c index d1be620eb..85fc09836 100644 --- a/libc/string/generic/rawmemchr.c +++ b/libc/string/generic/rawmemchr.c @@ -25,12 +25,15 @@ #include <stdlib.h> #include <limits.h> +libc_hidden_proto(rawmemchr) +libc_hidden_proto(abort) + #include "memcopy.h" #define LONG_MAX_32_BITS 2147483647 /* Find the first occurrence of C in S. */ -void attribute_hidden *__rawmemchr (const void * s, int c_in) +void *rawmemchr (const void * s, int c_in) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -156,5 +159,4 @@ void attribute_hidden *__rawmemchr (const void * s, int c_in) } } } - -strong_alias(__rawmemchr,rawmemchr) +libc_hidden_def(rawmemchr) diff --git a/libc/string/generic/strcat.c b/libc/string/generic/strcat.c index 96412acc5..53c4d0d9e 100644 --- a/libc/string/generic/strcat.c +++ b/libc/string/generic/strcat.c @@ -19,8 +19,9 @@ #include <string.h> #include "memcopy.h" +libc_hidden_proto(strcat) /* Append SRC on the end of DEST. */ -char attribute_hidden *__strcat (char *dest, const char *src) +char *strcat (char *dest, const char *src) { char *s1 = dest; const char *s2 = src; @@ -44,5 +45,4 @@ char attribute_hidden *__strcat (char *dest, const char *src) return dest; } - -strong_alias(__strcat,strcat) +libc_hidden_def(strcat) diff --git a/libc/string/generic/strchr.c b/libc/string/generic/strchr.c index dcb30ad7b..b1ffc7538 100644 --- a/libc/string/generic/strchr.c +++ b/libc/string/generic/strchr.c @@ -24,10 +24,13 @@ #include <string.h> #include <stdlib.h> +libc_hidden_proto(strchr) +libc_hidden_proto(abort) + #include "memcopy.h" /* Find the first occurrence of C in S. */ -char attribute_hidden *__strchr (const char *s, int c_in) +char *strchr (const char *s, int c_in) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -178,7 +181,5 @@ char attribute_hidden *__strchr (const char *s, int c_in) return NULL; } - -strong_alias(__strchr,strchr) - -strong_alias(__strchr,index) +libc_hidden_def(strchr) +strong_alias(strchr,index) diff --git a/libc/string/generic/strchrnul.c b/libc/string/generic/strchrnul.c index a2aafbfb0..e699a6dfa 100644 --- a/libc/string/generic/strchrnul.c +++ b/libc/string/generic/strchrnul.c @@ -24,10 +24,13 @@ #include <string.h> #include <stdlib.h> +libc_hidden_proto(strchrnul) +libc_hidden_proto(abort) + #include "memcopy.h" /* Find the first occurrence of C in S or the final NUL byte. */ -char attribute_hidden *__strchrnul (const char *s, int c_in) +char *strchrnul (const char *s, int c_in) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -161,5 +164,4 @@ char attribute_hidden *__strchrnul (const char *s, int c_in) /* This should never happen. */ return NULL; } - -strong_alias(__strchrnul,strchrnul) +libc_hidden_def(strchrnul) diff --git a/libc/string/generic/strcmp.c b/libc/string/generic/strcmp.c index 209aeed15..acfefb6dc 100644 --- a/libc/string/generic/strcmp.c +++ b/libc/string/generic/strcmp.c @@ -20,10 +20,11 @@ #include "memcopy.h" +libc_hidden_proto(strcmp) /* Compare S1 and S2, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. */ -int attribute_hidden __strcmp (const char *p1, const char *p2) +int strcmp (const char *p1, const char *p2) { register const unsigned char *s1 = (const unsigned char *) p1; register const unsigned char *s2 = (const unsigned char *) p2; @@ -40,10 +41,10 @@ int attribute_hidden __strcmp (const char *p1, const char *p2) return c1 - c2; } - -strong_alias(__strcmp,strcmp) +libc_hidden_def(strcmp) #ifndef __UCLIBC_HAS_LOCALE__ -hidden_strong_alias(__strcmp,__strcoll) -strong_alias(__strcmp,strcoll) +libc_hidden_proto(strcoll) +strong_alias(strcmp,strcoll) +libc_hidden_def(strcoll) #endif diff --git a/libc/string/generic/strcpy.c b/libc/string/generic/strcpy.c index 9280d3561..7e558ead1 100644 --- a/libc/string/generic/strcpy.c +++ b/libc/string/generic/strcpy.c @@ -22,8 +22,9 @@ #include "memcopy.h" #include "bp-checks.h" +libc_hidden_proto(strcpy) /* Copy SRC to DEST. */ -char attribute_hidden *__strcpy (char *dest, const char *src) +char *strcpy (char *dest, const char *src) { reg_char c; char *__unbounded s = (char *__unbounded) CHECK_BOUNDS_LOW (src); @@ -43,5 +44,4 @@ char attribute_hidden *__strcpy (char *dest, const char *src) return dest; } - -strong_alias(__strcpy,strcpy) +libc_hidden_def(strcpy) diff --git a/libc/string/generic/strcspn.c b/libc/string/generic/strcspn.c index a06577bca..1b5e465ea 100644 --- a/libc/string/generic/strcspn.c +++ b/libc/string/generic/strcspn.c @@ -18,19 +18,21 @@ #include <string.h> +libc_hidden_proto(strcspn) +libc_hidden_proto(strchr) + /* Return the length of the maximum initial segment of S which contains no characters from REJECT. */ -size_t attribute_hidden __strcspn (const char *s, const char *reject) +size_t strcspn (const char *s, const char *reject) { size_t count = 0; while (*s != '\0') - if (__strchr (reject, *s++) == NULL) + if (strchr (reject, *s++) == NULL) ++count; else return count; return count; } - -strong_alias(__strcspn,strcspn) +libc_hidden_def(strcspn) diff --git a/libc/string/generic/strlen.c b/libc/string/generic/strlen.c index 6c1b5eae3..3528829af 100644 --- a/libc/string/generic/strlen.c +++ b/libc/string/generic/strlen.c @@ -22,9 +22,12 @@ #include <string.h> #include <stdlib.h> +libc_hidden_proto(strlen) +libc_hidden_proto(abort) + /* Return the length of the null-terminated string STR. Scan for the null terminator quickly by testing four bytes at a time. */ -size_t attribute_hidden __strlen (const char *str) +size_t strlen (const char *str) { const char *char_ptr; const unsigned long int *longword_ptr; @@ -146,5 +149,4 @@ size_t attribute_hidden __strlen (const char *str) } } } - -strong_alias(__strlen,strlen) +libc_hidden_def(strlen) diff --git a/libc/string/generic/strncat.c b/libc/string/generic/strncat.c index 5ece4d248..9e0dfcd78 100644 --- a/libc/string/generic/strncat.c +++ b/libc/string/generic/strncat.c @@ -20,7 +20,8 @@ #include "memcopy.h" -char attribute_hidden *__strncat (char *s1, const char *s2, size_t n) +libc_hidden_proto(strncat) +char *strncat (char *s1, const char *s2, size_t n) { reg_char c; char *s = s1; @@ -73,5 +74,4 @@ char attribute_hidden *__strncat (char *s1, const char *s2, size_t n) return s; } - -strong_alias(__strncat,strncat) +libc_hidden_def(strncat) diff --git a/libc/string/generic/strncmp.c b/libc/string/generic/strncmp.c index 849726f6b..4c1978439 100644 --- a/libc/string/generic/strncmp.c +++ b/libc/string/generic/strncmp.c @@ -19,11 +19,12 @@ #include <string.h> #include "memcopy.h" +libc_hidden_proto(strncmp) /* Compare no more than N characters of S1 and S2, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. */ -int attribute_hidden __strncmp (const char *s1, const char *s2, size_t n) +int strncmp (const char *s1, const char *s2, size_t n) { unsigned reg_char c1 = '\0'; unsigned reg_char c2 = '\0'; @@ -64,5 +65,4 @@ int attribute_hidden __strncmp (const char *s1, const char *s2, size_t n) return c1 - c2; } - -strong_alias(__strncmp,strncmp) +libc_hidden_def(strncmp) diff --git a/libc/string/generic/strncpy.c b/libc/string/generic/strncpy.c index ca4f59e52..4b0b0894e 100644 --- a/libc/string/generic/strncpy.c +++ b/libc/string/generic/strncpy.c @@ -19,7 +19,8 @@ #include <string.h> #include "memcopy.h" -char attribute_hidden *__strncpy (char *s1, const char *s2, size_t n) +libc_hidden_proto(strncpy) +char *strncpy (char *s1, const char *s2, size_t n) { reg_char c; char *s = s1; @@ -78,5 +79,4 @@ char attribute_hidden *__strncpy (char *s1, const char *s2, size_t n) return s; } - -strong_alias(__strncpy,strncpy) +libc_hidden_def(strncpy) diff --git a/libc/string/generic/strnlen.c b/libc/string/generic/strnlen.c index 4b96dde31..31b5ba8e0 100644 --- a/libc/string/generic/strnlen.c +++ b/libc/string/generic/strnlen.c @@ -24,9 +24,12 @@ #include <string.h> #include <stdlib.h> +libc_hidden_proto(strnlen) +libc_hidden_proto(abort) + /* Find the length of S, but scan at most MAXLEN characters. If no '\0' terminator is found in that many characters, return MAXLEN. */ -size_t attribute_hidden __strnlen (const char *str, size_t maxlen) +size_t strnlen (const char *str, size_t maxlen) { const char *char_ptr, *end_ptr = str + maxlen; const unsigned long int *longword_ptr; @@ -156,5 +159,4 @@ size_t attribute_hidden __strnlen (const char *str, size_t maxlen) char_ptr = end_ptr; return char_ptr - str; } - -strong_alias(__strnlen,strnlen) +libc_hidden_def(strnlen) diff --git a/libc/string/generic/strrchr.c b/libc/string/generic/strrchr.c index 529016ede..b67e369fd 100644 --- a/libc/string/generic/strrchr.c +++ b/libc/string/generic/strrchr.c @@ -18,8 +18,11 @@ #include <string.h> +libc_hidden_proto(strrchr) +libc_hidden_proto(strchr) + /* Find the last occurrence of C in S. */ -char attribute_hidden *__strrchr (const char *s, int c) +char *strrchr (const char *s, int c) { register const char *found, *p; @@ -28,10 +31,10 @@ char attribute_hidden *__strrchr (const char *s, int c) /* Since strchr is fast, we use it rather than the obvious loop. */ if (c == '\0') - return __strchr (s, '\0'); + return strchr (s, '\0'); found = NULL; - while ((p = __strchr (s, c)) != NULL) + while ((p = strchr (s, c)) != NULL) { found = p; s = p + 1; @@ -39,7 +42,5 @@ char attribute_hidden *__strrchr (const char *s, int c) return (char *) found; } - -strong_alias(__strrchr,strrchr) - -strong_alias (__strrchr,rindex) +libc_hidden_def(strrchr) +strong_alias(strrchr,rindex) diff --git a/libc/string/generic/strsep.c b/libc/string/generic/strsep.c index 762b07ff9..7b34e2c16 100644 --- a/libc/string/generic/strsep.c +++ b/libc/string/generic/strsep.c @@ -16,11 +16,13 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define strpbrk __strpbrk - #include <string.h> -char attribute_hidden *__strsep (char **stringp, const char *delim) +libc_hidden_proto(strsep) +libc_hidden_proto(strchr) +libc_hidden_proto(strpbrk) + +char *strsep (char **stringp, const char *delim) { char *begin, *end; @@ -44,7 +46,7 @@ char attribute_hidden *__strsep (char **stringp, const char *delim) else if (*begin == '\0') end = NULL; else - end = __strchr (begin + 1, ch); + end = strchr (begin + 1, ch); } } else @@ -63,5 +65,4 @@ char attribute_hidden *__strsep (char **stringp, const char *delim) return begin; } - -strong_alias(__strsep,strsep) +libc_hidden_def(strsep) diff --git a/libc/string/generic/strspn.c b/libc/string/generic/strspn.c index 129c58742..a194fdc7d 100644 --- a/libc/string/generic/strspn.c +++ b/libc/string/generic/strspn.c @@ -18,9 +18,10 @@ #include <string.h> +libc_hidden_proto(strspn) /* Return the length of the maximum initial segment of S which contains only characters in ACCEPT. */ -size_t attribute_hidden __strspn (const char *s, const char *accept) +size_t strspn (const char *s, const char *accept) { const char *p; const char *a; @@ -39,5 +40,4 @@ size_t attribute_hidden __strspn (const char *s, const char *accept) return count; } - -strong_alias(__strspn,strspn) +libc_hidden_def(strspn) diff --git a/libc/string/generic/strstr.c b/libc/string/generic/strstr.c index 12e384014..f151a820a 100644 --- a/libc/string/generic/strstr.c +++ b/libc/string/generic/strstr.c @@ -28,9 +28,11 @@ #include <string.h> +libc_hidden_proto(strstr) + typedef unsigned chartype; -char attribute_hidden *__strstr (const char *phaystack, const char *pneedle) +char *strstr (const char *phaystack, const char *pneedle) { const unsigned char *haystack, *needle; chartype b; @@ -109,5 +111,4 @@ foundneedle: ret0: return 0; } - -strong_alias(__strstr,strstr) +libc_hidden_def(strstr) diff --git a/libc/string/generic/strtok_r.c b/libc/string/generic/strtok_r.c index 1a11166dd..0ab18b35e 100644 --- a/libc/string/generic/strtok_r.c +++ b/libc/string/generic/strtok_r.c @@ -17,9 +17,13 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define _GNU_SOURCE #include <string.h> +libc_hidden_proto(strtok_r) +libc_hidden_proto(strspn) +libc_hidden_proto(strpbrk) +libc_hidden_proto(rawmemchr) + /* Parse S into tokens separated by characters in DELIM. If S is NULL, the saved pointer in SAVE_PTR is used as the next starting point. For example: @@ -30,7 +34,7 @@ x = strtok_r(NULL, "=", &sp); // x = NULL // s = "abc\0-def\0" */ -char attribute_hidden *__strtok_r (char *s, const char *delim, char **save_ptr) +char *strtok_r (char *s, const char *delim, char **save_ptr) { char *token; @@ -38,7 +42,7 @@ char attribute_hidden *__strtok_r (char *s, const char *delim, char **save_ptr) s = *save_ptr; /* Scan leading delimiters. */ - s += __strspn (s, delim); + s += strspn (s, delim); if (*s == '\0') { *save_ptr = s; @@ -47,10 +51,10 @@ char attribute_hidden *__strtok_r (char *s, const char *delim, char **save_ptr) /* Find the end of the token. */ token = s; - s = __strpbrk (token, delim); + 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. */ @@ -59,5 +63,4 @@ char attribute_hidden *__strtok_r (char *s, const char *delim, char **save_ptr) } return token; } - -strong_alias(__strtok_r,strtok_r) +libc_hidden_def(strtok_r) diff --git a/libc/string/i386/Makefile b/libc/string/i386/Makefile index ac0063770..0a95346fd 100644 --- a/libc/string/i386/Makefile +++ b/libc/string/i386/Makefile @@ -5,9 +5,9 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -top_srcdir=../../../ -top_builddir=../../../ +top_srcdir:=../../../ +top_builddir:=../../../ all: objs include $(top_builddir)Rules.mak -include Makefile.arch +include ../Makefile.in include $(top_srcdir)Makerules diff --git a/libc/string/i386/Makefile.arch b/libc/string/i386/Makefile.arch deleted file mode 100644 index 27a29dd16..000000000 --- a/libc/string/i386/Makefile.arch +++ /dev/null @@ -1,24 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -STRING_ARCH_DIR:=$(top_srcdir)libc/string/i386 -STRING_ARCH_OUT:=$(top_builddir)libc/string/i386 - -STRING_ARCH_CSRC:=$(wildcard $(STRING_ARCH_DIR)/*.c) -STRING_ARCH_COBJ:=$(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_CSRC)) - -STRING_ARCH_OBJS:=$(STRING_ARCH_COBJ) - -libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) -libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os) - -libc-multi-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_CSRC) - -objclean-y+=string_arch_objclean - -string_arch_objclean: - $(RM) $(STRING_ARCH_OUT)/*.{o,os} diff --git a/libc/string/i386/memchr.c b/libc/string/i386/memchr.c index c7cd33758..229d42919 100644 --- a/libc/string/i386/memchr.c +++ b/libc/string/i386/memchr.c @@ -32,7 +32,8 @@ #include <string.h> -void attribute_hidden *__memchr(const void *cs, int c, size_t count) +libc_hidden_proto(memchr) +void *memchr(const void *cs, int c, size_t count) { int d0; register void * __res; @@ -47,5 +48,4 @@ void attribute_hidden *__memchr(const void *cs, int c, size_t count) :"=D" (__res), "=&c" (d0) : "a" (c),"0" (cs),"1" (count)); return __res; } - -strong_alias(__memchr,memchr) +libc_hidden_def(memchr) diff --git a/libc/string/i386/memcpy.c b/libc/string/i386/memcpy.c index 12ba8d7de..a2b8d3d8c 100644 --- a/libc/string/i386/memcpy.c +++ b/libc/string/i386/memcpy.c @@ -32,7 +32,8 @@ #include <string.h> -void attribute_hidden *__memcpy(void * to, const void * from, size_t n) +libc_hidden_proto(memcpy) +void *memcpy(void * to, const void * from, size_t n) { int d0, d1, d2; __asm__ __volatile__( @@ -49,5 +50,4 @@ void attribute_hidden *__memcpy(void * to, const void * from, size_t n) : "memory"); return (to); } - -strong_alias(__memcpy,memcpy) +libc_hidden_def(memcpy) diff --git a/libc/string/i386/memmove.c b/libc/string/i386/memmove.c index d6e29e553..a26fe2be1 100644 --- a/libc/string/i386/memmove.c +++ b/libc/string/i386/memmove.c @@ -32,7 +32,8 @@ #include <string.h> -void attribute_hidden *__memmove(void *dest, const void *src, size_t n) +libc_hidden_proto(memmove) +void *memmove(void *dest, const void *src, size_t n) { int d0, d1, d2; if (dest<src) @@ -55,5 +56,4 @@ void attribute_hidden *__memmove(void *dest, const void *src, size_t n) :"memory"); return dest; } - -strong_alias(__memmove,memmove) +libc_hidden_def(memmove) diff --git a/libc/string/i386/memset.c b/libc/string/i386/memset.c index eadbf9feb..eea48040a 100644 --- a/libc/string/i386/memset.c +++ b/libc/string/i386/memset.c @@ -32,7 +32,8 @@ #include <string.h> -void attribute_hidden *__memset(void *s, int c, size_t count) +libc_hidden_proto(memset) +void *memset(void *s, int c, size_t count) { int d0, d1; __asm__ __volatile__( @@ -43,5 +44,4 @@ void attribute_hidden *__memset(void *s, int c, size_t count) :"memory"); return s; } - -strong_alias(__memset,memset) +libc_hidden_def(memset) diff --git a/libc/string/i386/strcat.c b/libc/string/i386/strcat.c index 02b2a3c5b..e0b1f3b51 100644 --- a/libc/string/i386/strcat.c +++ b/libc/string/i386/strcat.c @@ -32,7 +32,8 @@ #include <string.h> -char attribute_hidden *__strcat(char * dest, const char * src) +libc_hidden_proto(strcat) +char *strcat(char * dest, const char * src) { int d0, d1, d2, d3; __asm__ __volatile__( @@ -47,5 +48,4 @@ char attribute_hidden *__strcat(char * dest, const char * src) : "0" (src), "1" (dest), "2" (0), "3" (0xffffffff):"memory"); return dest; } - -strong_alias(__strcat,strcat) +libc_hidden_def(strcat) diff --git a/libc/string/i386/strchr.c b/libc/string/i386/strchr.c index a8343fa00..5ed87e816 100644 --- a/libc/string/i386/strchr.c +++ b/libc/string/i386/strchr.c @@ -32,7 +32,8 @@ #include <string.h> -char attribute_hidden *__strchr(const char *s, int c) +libc_hidden_proto(strchr) +char *strchr(const char *s, int c) { int d0; register char * __res; @@ -49,7 +50,5 @@ char attribute_hidden *__strchr(const char *s, int c) :"=a" (__res), "=&S" (d0) : "1" (s),"0" (c)); return __res; } - -strong_alias(__strchr,strchr) - -strong_alias(__strchr,index) +libc_hidden_def(strchr) +strong_alias(strchr,index) diff --git a/libc/string/i386/strcmp.c b/libc/string/i386/strcmp.c index f335da646..47635d817 100644 --- a/libc/string/i386/strcmp.c +++ b/libc/string/i386/strcmp.c @@ -32,7 +32,8 @@ #include <string.h> -int attribute_hidden __strcmp(const char *cs, const char *ct) +libc_hidden_proto(strcmp) +int strcmp(const char *cs, const char *ct) { int d0, d1; register int __res; @@ -51,10 +52,10 @@ int attribute_hidden __strcmp(const char *cs, const char *ct) :"1" (cs),"2" (ct)); return __res; } - -strong_alias(__strcmp,strcmp) +libc_hidden_def(strcmp) #ifndef __UCLIBC_HAS_LOCALE__ -hidden_strong_alias(__strcmp,__strcoll) -strong_alias(__strcmp,strcoll) +libc_hidden_proto(strcoll) +strong_alias(strcmp,strcoll) +libc_hidden_def(strcoll) #endif diff --git a/libc/string/i386/strcpy.c b/libc/string/i386/strcpy.c index 59effd45e..9e2b81009 100644 --- a/libc/string/i386/strcpy.c +++ b/libc/string/i386/strcpy.c @@ -32,7 +32,8 @@ #include <string.h> -char attribute_hidden *__strcpy(char * dest, const char * src) +libc_hidden_proto(strcpy) +char *strcpy(char * dest, const char * src) { int d0, d1, d2; __asm__ __volatile__( @@ -44,5 +45,4 @@ char attribute_hidden *__strcpy(char * dest, const char * src) :"0" (src),"1" (dest) : "memory"); return dest; } - -strong_alias(__strcpy,strcpy) +libc_hidden_def(strcpy) diff --git a/libc/string/i386/strlen.c b/libc/string/i386/strlen.c index 01cc46f9e..f0767b600 100644 --- a/libc/string/i386/strlen.c +++ b/libc/string/i386/strlen.c @@ -32,7 +32,8 @@ #include <string.h> -size_t attribute_hidden __strlen(const char *s) +libc_hidden_proto(strlen) +size_t strlen(const char *s) { int d0; register int __res; @@ -44,5 +45,4 @@ size_t attribute_hidden __strlen(const char *s) :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff)); return __res; } - -strong_alias(__strlen,strlen) +libc_hidden_def(strlen) diff --git a/libc/string/i386/strncat.c b/libc/string/i386/strncat.c index b55b87b59..c1061421e 100644 --- a/libc/string/i386/strncat.c +++ b/libc/string/i386/strncat.c @@ -32,7 +32,8 @@ #include <string.h> -char attribute_hidden *__strncat(char * dest, +libc_hidden_proto(strncat) +char *strncat(char * dest, const char * src, size_t count) { int d0, d1, d2, d3; @@ -57,5 +58,4 @@ char attribute_hidden *__strncat(char * dest, : "memory"); return dest; } - -strong_alias(__strncat,strncat) +libc_hidden_def(strncat) diff --git a/libc/string/i386/strncmp.c b/libc/string/i386/strncmp.c index 2e22bf642..0c42134e1 100644 --- a/libc/string/i386/strncmp.c +++ b/libc/string/i386/strncmp.c @@ -32,7 +32,8 @@ #include <string.h> -int attribute_hidden __strncmp(const char *cs, const char *ct, size_t count) +libc_hidden_proto(strncmp) +int strncmp(const char *cs, const char *ct, size_t count) { register int __res; int d0, d1, d2; @@ -54,5 +55,4 @@ int attribute_hidden __strncmp(const char *cs, const char *ct, size_t count) :"1" (cs),"2" (ct),"3" (count)); return __res; } - -strong_alias(__strncmp,strncmp) +libc_hidden_def(strncmp) diff --git a/libc/string/i386/strncpy.c b/libc/string/i386/strncpy.c index 272c60ee4..c061fe37e 100644 --- a/libc/string/i386/strncpy.c +++ b/libc/string/i386/strncpy.c @@ -32,7 +32,8 @@ #include <string.h> -char attribute_hidden *__strncpy(char * dest, const char * src, size_t count) +libc_hidden_proto(strncpy) +char *strncpy(char * dest, const char * src, size_t count) { int d0, d1, d2, d3; __asm__ __volatile__( @@ -52,5 +53,4 @@ char attribute_hidden *__strncpy(char * dest, const char * src, size_t count) :"0" (src),"1" (dest),"2" (count) : "memory"); return dest; } - -strong_alias(__strncpy,strncpy) +libc_hidden_def(strncpy) diff --git a/libc/string/i386/strnlen.c b/libc/string/i386/strnlen.c index ef5c83a9a..af512f10a 100644 --- a/libc/string/i386/strnlen.c +++ b/libc/string/i386/strnlen.c @@ -30,10 +30,10 @@ * -Erik */ -#define _GNU_SOURCE #include <string.h> -size_t attribute_hidden __strnlen(const char *s, size_t count) +libc_hidden_proto(strnlen) +size_t strnlen(const char *s, size_t count) { int d0; register int __res; @@ -51,5 +51,4 @@ size_t attribute_hidden __strnlen(const char *s, size_t count) :"c" (s),"1" (count)); return __res; } - -strong_alias(__strnlen,strnlen) +libc_hidden_def(strnlen) diff --git a/libc/string/i386/strrchr.c b/libc/string/i386/strrchr.c index 9f0f65a36..7af990bd7 100644 --- a/libc/string/i386/strrchr.c +++ b/libc/string/i386/strrchr.c @@ -32,7 +32,8 @@ #include <string.h> -char attribute_hidden *__strrchr(const char *s, int c) +libc_hidden_proto(strrchr) +char *strrchr(const char *s, int c) { int d0, d1; register char * __res; @@ -47,7 +48,5 @@ char attribute_hidden *__strrchr(const char *s, int c) :"=g" (__res), "=&S" (d0), "=&a" (d1) :"0" (0),"1" (s),"2" (c)); return __res; } - -strong_alias(__strrchr,strrchr) - -strong_alias(__strrchr,rindex) +libc_hidden_def(strrchr) +strong_alias(strrchr,rindex) diff --git a/libc/string/ia64/Makefile b/libc/string/ia64/Makefile new file mode 100644 index 000000000..0a95346fd --- /dev/null +++ b/libc/string/ia64/Makefile @@ -0,0 +1,13 @@ +# Makefile for uClibc +# +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# + +top_srcdir:=../../../ +top_builddir:=../../../ +all: objs +include $(top_builddir)Rules.mak +include ../Makefile.in +include $(top_srcdir)Makerules diff --git a/libc/string/ia64/bcopy.S b/libc/string/ia64/bcopy.S new file mode 100644 index 000000000..c4eb22b1f --- /dev/null +++ b/libc/string/ia64/bcopy.S @@ -0,0 +1,10 @@ +#include "sysdep.h" + +ENTRY(bcopy) + .regstk 3, 0, 0, 0 + mov r8 = in0 + mov in0 = in1 + ;; + mov in1 = r8 + br.cond.sptk.many HIDDEN_JUMPTARGET(memmove) +END(bcopy) diff --git a/libc/string/ia64/bzero.S b/libc/string/ia64/bzero.S new file mode 100644 index 000000000..0e2ff09cc --- /dev/null +++ b/libc/string/ia64/bzero.S @@ -0,0 +1,315 @@ +/* Optimized version of the standard bzero() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. + Contributed by Dan Pop for Itanium <Dan.Pop@cern.ch>. + Rewritten for McKinley by Sverre Jarp, HP Labs/CERN <Sverre.Jarp@cern.ch> + + 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. */ + +/* Return: dest + + Inputs: + in0: dest + in1: count + + The algorithm is fairly straightforward: set byte by byte until we + we get to a 16B-aligned address, then loop on 128 B chunks using an + early store as prefetching, then loop on 32B chucks, then clear remaining + words, finally clear remaining bytes. + Since a stf.spill f0 can store 16B in one go, we use this instruction + to get peak speed. */ + +#include "sysdep.h" +#undef ret + +#define dest in0 +#define cnt in1 + +#define tmp r31 +#define save_lc r30 +#define ptr0 r29 +#define ptr1 r28 +#define ptr2 r27 +#define ptr3 r26 +#define ptr9 r24 +#define loopcnt r23 +#define linecnt r22 +#define bytecnt r21 + +// This routine uses only scratch predicate registers (p6 - p15) +#define p_scr p6 // default register for same-cycle branches +#define p_unalgn p9 +#define p_y p11 +#define p_n p12 +#define p_yy p13 +#define p_nn p14 + +#define movi0 mov + +#define MIN1 15 +#define MIN1P1HALF 8 +#define LINE_SIZE 128 +#define LSIZE_SH 7 // shift amount +#define PREF_AHEAD 8 + +#define USE_FLP +#if defined(USE_INT) +#define store st8 +#define myval r0 +#elif defined(USE_FLP) +#define store stf8 +#define myval f0 +#endif + +.align 64 +ENTRY(bzero) +{ .mmi + .prologue + alloc tmp = ar.pfs, 2, 0, 0, 0 + lfetch.nt1 [dest] + .save ar.lc, save_lc + movi0 save_lc = ar.lc +} { .mmi + .body + mov ret0 = dest // return value + nop.m 0 + cmp.eq p_scr, p0 = cnt, r0 +;; } +{ .mmi + and ptr2 = -(MIN1+1), dest // aligned address + and tmp = MIN1, dest // prepare to check for alignment + tbit.nz p_y, p_n = dest, 0 // Do we have an odd address? (M_B_U) +} { .mib + mov ptr1 = dest + nop.i 0 +(p_scr) br.ret.dpnt.many rp // return immediately if count = 0 +;; } +{ .mib + cmp.ne p_unalgn, p0 = tmp, r0 +} { .mib // NB: # of bytes to move is 1 + sub bytecnt = (MIN1+1), tmp // higher than loopcnt + cmp.gt p_scr, p0 = 16, cnt // is it a minimalistic task? +(p_scr) br.cond.dptk.many .move_bytes_unaligned // go move just a few (M_B_U) +;; } +{ .mmi +(p_unalgn) add ptr1 = (MIN1+1), ptr2 // after alignment +(p_unalgn) add ptr2 = MIN1P1HALF, ptr2 // after alignment +(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 3 // should we do a st8 ? +;; } +{ .mib +(p_y) add cnt = -8, cnt +(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 2 // should we do a st4 ? +} { .mib +(p_y) st8 [ptr2] = r0,-4 +(p_n) add ptr2 = 4, ptr2 +;; } +{ .mib +(p_yy) add cnt = -4, cnt +(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 1 // should we do a st2 ? +} { .mib +(p_yy) st4 [ptr2] = r0,-2 +(p_nn) add ptr2 = 2, ptr2 +;; } +{ .mmi + mov tmp = LINE_SIZE+1 // for compare +(p_y) add cnt = -2, cnt +(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 0 // should we do a st1 ? +} { .mmi + nop.m 0 +(p_y) st2 [ptr2] = r0,-1 +(p_n) add ptr2 = 1, ptr2 +;; } + +{ .mmi +(p_yy) st1 [ptr2] = r0 + cmp.gt p_scr, p0 = tmp, cnt // is it a minimalistic task? +} { .mbb +(p_yy) add cnt = -1, cnt +(p_scr) br.cond.dpnt.many .fraction_of_line // go move just a few +;; } +{ .mib + nop.m 0 + shr.u linecnt = cnt, LSIZE_SH + nop.b 0 +;; } + + .align 32 +.l1b: // ------------------// L1B: store ahead into cache lines; fill later +{ .mmi + and tmp = -(LINE_SIZE), cnt // compute end of range + mov ptr9 = ptr1 // used for prefetching + and cnt = (LINE_SIZE-1), cnt // remainder +} { .mmi + mov loopcnt = PREF_AHEAD-1 // default prefetch loop + cmp.gt p_scr, p0 = PREF_AHEAD, linecnt // check against actual value +;; } +{ .mmi +(p_scr) add loopcnt = -1, linecnt + add ptr2 = 16, ptr1 // start of stores (beyond prefetch stores) + add ptr1 = tmp, ptr1 // first address beyond total range +;; } +{ .mmi + add tmp = -1, linecnt // next loop count + movi0 ar.lc = loopcnt +;; } +.pref_l1b: +{ .mib + stf.spill [ptr9] = f0, 128 // Do stores one cache line apart + nop.i 0 + br.cloop.dptk.few .pref_l1b +;; } +{ .mmi + add ptr0 = 16, ptr2 // Two stores in parallel + movi0 ar.lc = tmp +;; } +.l1bx: + { .mmi + stf.spill [ptr2] = f0, 32 + stf.spill [ptr0] = f0, 32 + ;; } + { .mmi + stf.spill [ptr2] = f0, 32 + stf.spill [ptr0] = f0, 32 + ;; } + { .mmi + stf.spill [ptr2] = f0, 32 + stf.spill [ptr0] = f0, 64 + cmp.lt p_scr, p0 = ptr9, ptr1 // do we need more prefetching? + ;; } +{ .mmb + stf.spill [ptr2] = f0, 32 +(p_scr) stf.spill [ptr9] = f0, 128 + br.cloop.dptk.few .l1bx +;; } +{ .mib + cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ? +(p_scr) br.cond.dpnt.many .move_bytes_from_alignment +;; } + +.fraction_of_line: +{ .mib + add ptr2 = 16, ptr1 + shr.u loopcnt = cnt, 5 // loopcnt = cnt / 32 +;; } +{ .mib + cmp.eq p_scr, p0 = loopcnt, r0 + add loopcnt = -1, loopcnt +(p_scr) br.cond.dpnt.many .store_words +;; } +{ .mib + and cnt = 0x1f, cnt // compute the remaining cnt + movi0 ar.lc = loopcnt +;; } + .align 32 +.l2: // -----------------------------// L2A: store 32B in 2 cycles +{ .mmb + store [ptr1] = myval, 8 + store [ptr2] = myval, 8 +;; } { .mmb + store [ptr1] = myval, 24 + store [ptr2] = myval, 24 + br.cloop.dptk.many .l2 +;; } +.store_words: +{ .mib + cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ? +(p_scr) br.cond.dpnt.many .move_bytes_from_alignment // Branch +;; } + +{ .mmi + store [ptr1] = myval, 8 // store + cmp.le p_y, p_n = 16, cnt // + add cnt = -8, cnt // subtract +;; } +{ .mmi +(p_y) store [ptr1] = myval, 8 // store +(p_y) cmp.le.unc p_yy, p_nn = 16, cnt +(p_y) add cnt = -8, cnt // subtract +;; } +{ .mmi // store +(p_yy) store [ptr1] = myval, 8 +(p_yy) add cnt = -8, cnt // subtract +;; } + +.move_bytes_from_alignment: +{ .mib + cmp.eq p_scr, p0 = cnt, r0 + tbit.nz.unc p_y, p0 = cnt, 2 // should we terminate with a st4 ? +(p_scr) br.cond.dpnt.few .restore_and_exit +;; } +{ .mib +(p_y) st4 [ptr1] = r0,4 + tbit.nz.unc p_yy, p0 = cnt, 1 // should we terminate with a st2 ? +;; } +{ .mib +(p_yy) st2 [ptr1] = r0,2 + tbit.nz.unc p_y, p0 = cnt, 0 // should we terminate with a st1 ? +;; } + +{ .mib +(p_y) st1 [ptr1] = r0 +;; } +.restore_and_exit: +{ .mib + nop.m 0 + movi0 ar.lc = save_lc + br.ret.sptk.many rp +;; } + +.move_bytes_unaligned: +{ .mmi + .pred.rel "mutex",p_y, p_n + .pred.rel "mutex",p_yy, p_nn +(p_n) cmp.le p_yy, p_nn = 4, cnt +(p_y) cmp.le p_yy, p_nn = 5, cnt +(p_n) add ptr2 = 2, ptr1 +} { .mmi +(p_y) add ptr2 = 3, ptr1 +(p_y) st1 [ptr1] = r0, 1 // fill 1 (odd-aligned) byte +(p_y) add cnt = -1, cnt // [15, 14 (or less) left] +;; } +{ .mmi +(p_yy) cmp.le.unc p_y, p0 = 8, cnt + add ptr3 = ptr1, cnt // prepare last store + movi0 ar.lc = save_lc +} { .mmi +(p_yy) st2 [ptr1] = r0, 4 // fill 2 (aligned) bytes +(p_yy) st2 [ptr2] = r0, 4 // fill 2 (aligned) bytes +(p_yy) add cnt = -4, cnt // [11, 10 (o less) left] +;; } +{ .mmi +(p_y) cmp.le.unc p_yy, p0 = 8, cnt + add ptr3 = -1, ptr3 // last store + tbit.nz p_scr, p0 = cnt, 1 // will there be a st2 at the end ? +} { .mmi +(p_y) st2 [ptr1] = r0, 4 // fill 2 (aligned) bytes +(p_y) st2 [ptr2] = r0, 4 // fill 2 (aligned) bytes +(p_y) add cnt = -4, cnt // [7, 6 (or less) left] +;; } +{ .mmi +(p_yy) st2 [ptr1] = r0, 4 // fill 2 (aligned) bytes +(p_yy) st2 [ptr2] = r0, 4 // fill 2 (aligned) bytes + // [3, 2 (or less) left] + tbit.nz p_y, p0 = cnt, 0 // will there be a st1 at the end ? +} { .mmi +(p_yy) add cnt = -4, cnt +;; } +{ .mmb +(p_scr) st2 [ptr1] = r0 // fill 2 (aligned) bytes +(p_y) st1 [ptr3] = r0 // fill last byte (using ptr3) + br.ret.sptk.many rp +;; } +END(bzero) diff --git a/libc/string/ia64/memccpy.S b/libc/string/ia64/memccpy.S new file mode 100644 index 000000000..1afba3637 --- /dev/null +++ b/libc/string/ia64/memccpy.S @@ -0,0 +1,213 @@ +/* Optimized version of the memccpy() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + Contributed by Dan Pop <Dan.Pop@cern.ch>. + + 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. */ + +/* Return: a pointer to the next byte after char in dest or NULL + + Inputs: + in0: dest + in1: src + in2: char + in3: byte count + + This implementation assumes little endian mode (UM.be = 0). + + This implementation assumes that it is safe to do read ahead + in the src block, without getting beyond its limit. */ + +#include "sysdep.h" +#undef ret + +#define OP_T_THRES 16 +#define OPSIZ 8 + +#define saved_pr r17 +#define saved_lc r18 +#define dest r19 +#define src r20 +#define len r21 +#define asrc r22 +#define tmp r23 +#define char r24 +#define charx8 r25 +#define saved_ec r26 +#define sh2 r28 +#define sh1 r29 +#define loopcnt r30 +#define value r31 + +#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO +/* Manually force proper loop-alignment. Note: be sure to + double-check the code-layout after making any changes to + this routine! */ +# define ALIGN(n) { nop 0 } +#else +# define ALIGN(n) .align n +#endif + +ENTRY(memccpy) + .prologue + alloc r2 = ar.pfs, 4, 40 - 4, 0, 40 + +#include "softpipe.h" + .rotr r[MEMLAT + 7], tmp1[4], tmp2[4], val[4], tmp3[2], pos0[2] + .rotp p[MEMLAT + 6 + 1] + + mov ret0 = r0 // return NULL if no match + .save pr, saved_pr + mov saved_pr = pr // save the predicate registers + mov dest = in0 // dest + .save ar.lc, saved_lc + mov saved_lc = ar.lc // save the loop counter + mov saved_ec = ar.ec // save the loop counter + .body + mov src = in1 // src + extr.u char = in2, 0, 8 // char + mov len = in3 // len + sub tmp = r0, in0 // tmp = -dest + cmp.ne p7, p0 = r0, r0 // clear p7 + ;; + and loopcnt = 7, tmp // loopcnt = -dest % 8 + cmp.ge p6, p0 = OP_T_THRES, len // is len <= OP_T_THRES + mov ar.ec = 0 // ec not guaranteed zero on entry +(p6) br.cond.spnt .cpyfew // copy byte by byte + ;; + cmp.eq p6, p0 = loopcnt, r0 + mux1 charx8 = char, @brcst +(p6) br.cond.sptk .dest_aligned + sub len = len, loopcnt // len -= -dest % 8 + adds loopcnt = -1, loopcnt // --loopcnt + ;; + mov ar.lc = loopcnt +.l1: // copy -dest % 8 bytes + ld1 value = [src], 1 // value = *src++ + ;; + st1 [dest] = value, 1 // *dest++ = value + cmp.eq p6, p0 = value, char +(p6) br.cond.spnt .foundit + br.cloop.dptk .l1 +.dest_aligned: + and sh1 = 7, src // sh1 = src % 8 + and tmp = -8, len // tmp = len & -OPSIZ + and asrc = -8, src // asrc = src & -OPSIZ -- align src + shr.u loopcnt = len, 3 // loopcnt = len / 8 + and len = 7, len ;; // len = len % 8 + shl sh1 = sh1, 3 // sh1 = 8 * (src % 8) + adds loopcnt = -1, loopcnt // --loopcnt + mov pr.rot = 1 << 16 ;; // set rotating predicates + sub sh2 = 64, sh1 // sh2 = 64 - sh1 + mov ar.lc = loopcnt // set LC + cmp.eq p6, p0 = sh1, r0 // is the src aligned? +(p6) br.cond.sptk .src_aligned ;; + add src = src, tmp // src += len & -OPSIZ + mov ar.ec = MEMLAT + 6 + 1 // six more passes needed + ld8 r[1] = [asrc], 8 // r[1] = w0 + cmp.ne p6, p0 = r0, r0 ;; // clear p6 + ALIGN(32) +.l2: +(p[0]) ld8.s r[0] = [asrc], 8 // r[0] = w1 +(p[MEMLAT]) shr.u tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 >> sh1 +(p[MEMLAT]) shl tmp2[0] = r[0 + MEMLAT], sh2 // tmp2 = w1 << sh2 +(p[MEMLAT+4]) xor tmp3[0] = val[1], charx8 +(p[MEMLAT+5]) czx1.r pos0[0] = tmp3[1] +(p[MEMLAT+6]) chk.s r[6 + MEMLAT], .recovery1 // our data isn't + // valid - rollback! +(p[MEMLAT+6]) cmp.ne p6, p0 = 8, pos0[1] +(p6) br.cond.spnt .gotit +(p[MEMLAT+6]) st8 [dest] = val[3], 8 // store val to dest +(p[MEMLAT+3]) or val[0] = tmp1[3], tmp2[3] // val = tmp1 | tmp2 + br.ctop.sptk .l2 + br.cond.sptk .cpyfew + +.src_aligned: + cmp.ne p6, p0 = r0, r0 // clear p6 + mov ar.ec = MEMLAT + 2 + 1 ;; // set EC +.l3: +(p[0]) ld8.s r[0] = [src], 8 +(p[MEMLAT]) xor tmp3[0] = r[MEMLAT], charx8 +(p[MEMLAT+1]) czx1.r pos0[0] = tmp3[1] +(p[MEMLAT+2]) cmp.ne p7, p0 = 8, pos0[1] +(p[MEMLAT+2]) chk.s r[MEMLAT+2], .recovery2 +(p7) br.cond.spnt .gotit +.back2: +(p[MEMLAT+2]) st8 [dest] = r[MEMLAT+2], 8 + br.ctop.dptk .l3 +.cpyfew: + cmp.eq p6, p0 = len, r0 // is len == 0 ? + adds len = -1, len // --len; +(p6) br.cond.spnt .restore_and_exit ;; + mov ar.lc = len +.l4: + ld1 value = [src], 1 + ;; + st1 [dest] = value, 1 + cmp.eq p6, p0 = value, char +(p6) br.cond.spnt .foundit + br.cloop.dptk .l4 ;; +.foundit: +(p6) mov ret0 = dest +.restore_and_exit: + mov pr = saved_pr, -1 // restore the predicate registers + mov ar.lc = saved_lc // restore the loop counter + mov ar.ec = saved_ec ;; // restore the epilog counter + br.ret.sptk.many b0 +.gotit: + .pred.rel "mutex" p6, p7 +(p6) mov value = val[3] // if coming from l2 +(p7) mov value = r[MEMLAT+2] // if coming from l3 + mov ar.lc = pos0[1] ;; +.l5: + extr.u tmp = value, 0, 8 ;; + st1 [dest] = tmp, 1 + shr.u value = value, 8 + br.cloop.sptk .l5 ;; + mov ret0 = dest + mov pr = saved_pr, -1 + mov ar.lc = saved_lc + br.ret.sptk.many b0 + +.recovery1: + adds src = -(MEMLAT + 6 + 1) * 8, asrc + mov loopcnt = ar.lc + mov tmp = ar.ec ;; + sub sh1 = (MEMLAT + 6 + 1), tmp + shr.u sh2 = sh2, 3 + ;; + shl loopcnt = loopcnt, 3 + sub src = src, sh2 + shl sh1 = sh1, 3 + shl tmp = tmp, 3 + ;; + add len = len, loopcnt + add src = sh1, src ;; + add len = tmp, len +.back1: + br.cond.sptk .cpyfew + +.recovery2: + add tmp = -(MEMLAT + 3) * 8, src +(p7) br.cond.spnt .gotit + ;; + ld8 r[MEMLAT+2] = [tmp] ;; + xor pos0[1] = r[MEMLAT+2], charx8 ;; + czx1.r pos0[1] = pos0[1] ;; + cmp.ne p7, p6 = 8, pos0[1] +(p7) br.cond.spnt .gotit + br.cond.sptk .back2 +END(memccpy) diff --git a/libc/string/ia64/memchr.S b/libc/string/ia64/memchr.S new file mode 100644 index 000000000..2bf078fe6 --- /dev/null +++ b/libc/string/ia64/memchr.S @@ -0,0 +1,133 @@ +/* Optimized version of the standard memchr() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + Contributed by Dan Pop <Dan.Pop@cern.ch>. + + 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. */ + +/* Return: the address of the first occurence of chr in str or NULL + + Inputs: + in0: str + in1: chr + in2: byte count + + This implementation assumes little endian mode. For big endian mode, + the instruction czx1.r should be replaced by czx1.l. + + The algorithm is fairly straightforward: search byte by byte until we + we get to a word aligned address, then search word by word as much as + possible; the remaining few bytes are searched one at a time. + + The word by word search is performed by xor-ing the word with a word + containing chr in every byte. If there is a hit, the result will + contain a zero byte in the corresponding position. The presence and + position of that zero byte is detected with a czx instruction. + + All the loops in this function could have had the internal branch removed + if br.ctop and br.cloop could be predicated :-(. */ + +#include "sysdep.h" +#undef ret + +#define saved_pr r15 +#define saved_lc r16 +#define chr r17 +#define len r18 +#define pos0 r20 +#define val r21 +#define tmp r24 +#define chrx8 r25 +#define loopcnt r30 + +#define str in0 + +ENTRY(__memchr) + .prologue + alloc r2 = ar.pfs, 3, 0, 29, 32 +#include "softpipe.h" + .rotr value[MEMLAT+1], addr[MEMLAT+3], aux[2], poschr[2] + .rotp p[MEMLAT+3] + .save ar.lc, saved_lc + mov saved_lc = ar.lc // save the loop counter + .save pr, saved_pr + mov saved_pr = pr // save the predicates + .body + mov ret0 = str + and tmp = 7, str // tmp = str % 8 + cmp.ne p7, p0 = r0, r0 // clear p7 + extr.u chr = in1, 0, 8 // chr = (unsigned char) in1 + mov len = in2 + cmp.gtu p6, p0 = 16, in2 // use a simple loop for short +(p6) br.cond.spnt .srchfew ;; // searches + sub loopcnt = 8, tmp // loopcnt = 8 - tmp + cmp.eq p6, p0 = tmp, r0 +(p6) br.cond.sptk .str_aligned;; + sub len = len, loopcnt + adds loopcnt = -1, loopcnt;; + mov ar.lc = loopcnt +.l1: + ld1 val = [ret0], 1 + ;; + cmp.eq p6, p0 = val, chr +(p6) br.cond.spnt .foundit + br.cloop.sptk .l1 ;; +.str_aligned: + cmp.ne p6, p0 = r0, r0 // clear p6 + shr.u loopcnt = len, 3 // loopcnt = len / 8 + and len = 7, len ;; // remaining len = len & 7 + adds loopcnt = -1, loopcnt + mov ar.ec = MEMLAT + 3 + mux1 chrx8 = chr, @brcst ;; // get a word full of chr + mov ar.lc = loopcnt + mov pr.rot = 1 << 16 ;; +.l2: +(p[0]) mov addr[0] = ret0 +(p[0]) ld8 value[0] = [ret0], 8 +(p[MEMLAT]) xor aux[0] = value[MEMLAT], chrx8 +(p[MEMLAT+1]) czx1.r poschr[0] = aux[1] +(p[MEMLAT+2]) cmp.ne p7, p0 = 8, poschr[1] +(p7) br.cond.dpnt .foundit + br.ctop.dptk .l2 +.srchfew: + adds loopcnt = -1, len + cmp.eq p6, p0 = len, r0 +(p6) br.cond.spnt .notfound ;; + mov ar.lc = loopcnt +.l3: + ld1 val = [ret0], 1 + ;; + cmp.eq p6, p0 = val, chr +(p6) br.cond.dpnt .foundit + br.cloop.sptk .l3 ;; +.notfound: + cmp.ne p6, p0 = r0, r0 // clear p6 (p7 was already 0 when we got here) + mov ret0 = r0 ;; // return NULL +.foundit: + .pred.rel "mutex" p6, p7 +(p6) adds ret0 = -1, ret0 // if we got here from l1 or l3 +(p7) add ret0 = addr[MEMLAT+2], poschr[1] // if we got here from l2 + mov pr = saved_pr, -1 + mov ar.lc = saved_lc + br.ret.sptk.many b0 + +END(__memchr) + +weak_alias (__memchr, memchr) +#if !__BOUNDED_POINTERS__ +weak_alias (__memchr, __ubp_memchr) +#endif +libc_hidden_def (memchr) diff --git a/libc/string/ia64/memcmp.S b/libc/string/ia64/memcmp.S new file mode 100644 index 000000000..c6ea7529b --- /dev/null +++ b/libc/string/ia64/memcmp.S @@ -0,0 +1,165 @@ +/* Optimized version of the standard memcmp() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc. + Contributed by Dan Pop <Dan.Pop@cern.ch>. + + 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. */ + +/* Return: the result of the comparison + + Inputs: + in0: dest (aka s1) + in1: src (aka s2) + in2: byte count + + In this form, it assumes little endian mode. For big endian mode, the + the two shifts in .l2 must be inverted: + + shl tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 << sh1 + shr.u tmp2[0] = r[0 + MEMLAT], sh2 // tmp2 = w1 >> sh2 + + and all the mux1 instructions should be replaced by plain mov's. */ + +#include "sysdep.h" +#undef ret + +#define OP_T_THRES 16 +#define OPSIZ 8 +#define MEMLAT 2 + +#define start r15 +#define saved_pr r17 +#define saved_lc r18 +#define dest r19 +#define src r20 +#define len r21 +#define asrc r22 +#define tmp r23 +#define value1 r24 +#define value2 r25 +#define sh2 r28 +#define sh1 r29 +#define loopcnt r30 + +ENTRY(memcmp) + .prologue + alloc r2 = ar.pfs, 3, 37, 0, 40 + + .rotr r[MEMLAT + 2], q[MEMLAT + 5], tmp1[4], tmp2[4], val[2] + .rotp p[MEMLAT + 4 + 1] + + mov ret0 = r0 // by default return value = 0 + .save pr, saved_pr + mov saved_pr = pr // save the predicate registers + .save ar.lc, saved_lc + mov saved_lc = ar.lc // save the loop counter + .body + mov dest = in0 // dest + mov src = in1 // src + mov len = in2 // len + sub tmp = r0, in0 // tmp = -dest + ;; + and loopcnt = 7, tmp // loopcnt = -dest % 8 + cmp.ge p6, p0 = OP_T_THRES, len // is len <= OP_T_THRES +(p6) br.cond.spnt .cmpfew // compare byte by byte + ;; + cmp.eq p6, p0 = loopcnt, r0 +(p6) br.cond.sptk .dest_aligned + sub len = len, loopcnt // len -= -dest % 8 + adds loopcnt = -1, loopcnt // --loopcnt + ;; + mov ar.lc = loopcnt +.l1: // copy -dest % 8 bytes + ld1 value1 = [src], 1 // value = *src++ + ld1 value2 = [dest], 1 + ;; + cmp.ne p6, p0 = value1, value2 +(p6) br.cond.spnt .done + br.cloop.dptk .l1 +.dest_aligned: + and sh1 = 7, src // sh1 = src % 8 + and tmp = -8, len // tmp = len & -OPSIZ + and asrc = -8, src // asrc = src & -OPSIZ -- align src + shr.u loopcnt = len, 3 // loopcnt = len / 8 + and len = 7, len ;; // len = len % 8 + shl sh1 = sh1, 3 // sh1 = 8 * (src % 8) + adds loopcnt = -1, loopcnt // --loopcnt + mov pr.rot = 1 << 16 ;; // set rotating predicates + sub sh2 = 64, sh1 // sh2 = 64 - sh1 + mov ar.lc = loopcnt // set LC + cmp.eq p6, p0 = sh1, r0 // is the src aligned? +(p6) br.cond.sptk .src_aligned + add src = src, tmp // src += len & -OPSIZ + mov ar.ec = MEMLAT + 4 + 1 // four more passes needed + ld8 r[1] = [asrc], 8 ;; // r[1] = w0 + .align 32 + +// We enter this loop with p6 cleared by the above comparison + +.l2: +(p[0]) ld8 r[0] = [asrc], 8 // r[0] = w1 +(p[0]) ld8 q[0] = [dest], 8 +(p[MEMLAT]) shr.u tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 >> sh1 +(p[MEMLAT]) shl tmp2[0] = r[0 + MEMLAT], sh2 // tmp2 = w1 << sh2 +(p[MEMLAT+4]) cmp.ne p6, p0 = q[MEMLAT + 4], val[1] +(p[MEMLAT+3]) or val[0] = tmp1[3], tmp2[3] // val = tmp1 | tmp2 +(p6) br.cond.spnt .l2exit + br.ctop.sptk .l2 + br.cond.sptk .cmpfew +.l3exit: + mux1 value1 = r[MEMLAT], @rev + mux1 value2 = q[MEMLAT], @rev + cmp.ne p6, p0 = r0, r0 ;; // clear p6 +.l2exit: +(p6) mux1 value1 = val[1], @rev +(p6) mux1 value2 = q[MEMLAT + 4], @rev ;; + cmp.ltu p6, p7 = value2, value1 ;; +(p6) mov ret0 = -1 +(p7) mov ret0 = 1 + mov pr = saved_pr, -1 // restore the predicate registers + mov ar.lc = saved_lc // restore the loop counter + br.ret.sptk.many b0 +.src_aligned: + cmp.ne p6, p0 = r0, r0 // clear p6 + mov ar.ec = MEMLAT + 1 ;; // set EC +.l3: +(p[0]) ld8 r[0] = [src], 8 +(p[0]) ld8 q[0] = [dest], 8 +(p[MEMLAT]) cmp.ne p6, p0 = r[MEMLAT], q[MEMLAT] +(p6) br.cond.spnt .l3exit + br.ctop.dptk .l3 ;; +.cmpfew: + cmp.eq p6, p0 = len, r0 // is len == 0 ? + adds len = -1, len // --len; +(p6) br.cond.spnt .restore_and_exit ;; + mov ar.lc = len +.l4: + ld1 value1 = [src], 1 + ld1 value2 = [dest], 1 + ;; + cmp.ne p6, p0 = value1, value2 +(p6) br.cond.spnt .done + br.cloop.dptk .l4 ;; +.done: +(p6) sub ret0 = value2, value1 // don't execute it if falling thru +.restore_and_exit: + mov pr = saved_pr, -1 // restore the predicate registers + mov ar.lc = saved_lc // restore the loop counter + br.ret.sptk.many b0 +END(memcmp) + +weak_alias (memcmp, bcmp) +libc_hidden_def (memcmp) diff --git a/libc/string/ia64/memcpy.S b/libc/string/ia64/memcpy.S new file mode 100644 index 000000000..db019f860 --- /dev/null +++ b/libc/string/ia64/memcpy.S @@ -0,0 +1,436 @@ +/* Optimized version of the standard memcpy() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + Contributed by Dan Pop for Itanium <Dan.Pop@cern.ch>. + Rewritten for McKinley by Sverre Jarp, HP Labs/CERN <Sverre.Jarp@cern.ch> + + 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. */ + +/* Return: dest + + Inputs: + in0: dest + in1: src + in2: byte count + + An assembly implementation of the algorithm used by the generic C + version from glibc. The case when source and sest are aligned is + treated separately, for extra performance. + + In this form, memcpy assumes little endian mode. For big endian mode, + sh1 must be computed using an extra instruction: sub sh1 = 64, sh1 + and the order of r[MEMLAT] and r[MEMLAT+1] must be reverted in the + shrp instruction. */ + +#define USE_LFETCH +#define USE_FLP +#include "sysdep.h" +#undef ret + +#define LFETCH_DIST 500 + +#define ALIGN_UNROLL_no 4 // no. of elements +#define ALIGN_UNROLL_sh 2 // (shift amount) + +#define MEMLAT 8 +#define Nrot ((4*(MEMLAT+2) + 7) & ~7) + +#define OP_T_THRES 16 +#define OPSIZ 8 + +#define loopcnt r14 +#define elemcnt r15 +#define saved_pr r16 +#define saved_lc r17 +#define adest r18 +#define dest r19 +#define asrc r20 +#define src r21 +#define len r22 +#define tmp2 r23 +#define tmp3 r24 +#define tmp4 r25 +#define ptable r26 +#define ploop56 r27 +#define loopaddr r28 +#define sh1 r29 +#define ptr1 r30 +#define ptr2 r31 + +#define movi0 mov + +#define p_scr p6 +#define p_xtr p7 +#define p_nxtr p8 +#define p_few p9 + +#if defined(USE_FLP) +#define load ldf8 +#define store stf8 +#define tempreg f6 +#define the_r fr +#define the_s fs +#define the_t ft +#define the_q fq +#define the_w fw +#define the_x fx +#define the_y fy +#define the_z fz +#elif defined(USE_INT) +#define load ld8 +#define store st8 +#define tempreg tmp2 +#define the_r r +#define the_s s +#define the_t t +#define the_q q +#define the_w w +#define the_x x +#define the_y y +#define the_z z +#endif + +#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO +/* Manually force proper loop-alignment. Note: be sure to + double-check the code-layout after making any changes to + this routine! */ +# define ALIGN(n) { nop 0 } +#else +# define ALIGN(n) .align n +#endif + +#if defined(USE_LFETCH) +#define LOOP(shift) \ + ALIGN(32); \ +.loop##shift##: \ +{ .mmb \ +(p[0]) ld8.nt1 r[0] = [asrc], 8 ; \ +(p[0]) lfetch.nt1 [ptr1], 16 ; \ + nop.b 0 ; \ +} { .mib \ +(p[MEMLAT+1]) st8 [dest] = tmp3, 8 ; \ +(p[MEMLAT]) shrp tmp3 = r[MEMLAT], s[MEMLAT+1], shift ; \ + nop.b 0 ;; \ + } { .mmb \ +(p[0]) ld8.nt1 s[0] = [asrc], 8 ; \ +(p[0]) lfetch.nt1 [ptr2], 16 ; \ + nop.b 0 ; \ +} { .mib \ +(p[MEMLAT+1]) st8 [dest] = tmp4, 8 ; \ +(p[MEMLAT]) shrp tmp4 = s[MEMLAT], r[MEMLAT], shift ; \ + br.ctop.sptk.many .loop##shift \ +;; } \ +{ .mib \ + br.cond.sptk.many .copy_bytes ; /* deal with the remaining bytes */ \ +} +#else +#define LOOP(shift) \ + ALIGN(32); \ +.loop##shift##: \ +{ .mmb \ +(p[0]) ld8.nt1 r[0] = [asrc], 8 ; \ + nop.b 0 ; \ +} { .mib \ +(p[MEMLAT+1]) st8 [dest] = tmp3, 8 ; \ +(p[MEMLAT]) shrp tmp3 = r[MEMLAT], s[MEMLAT+1], shift ; \ + nop.b 0 ;; \ + } { .mmb \ +(p[0]) ld8.nt1 s[0] = [asrc], 8 ; \ + nop.b 0 ; \ +} { .mib \ +(p[MEMLAT+1]) st8 [dest] = tmp4, 8 ; \ +(p[MEMLAT]) shrp tmp4 = s[MEMLAT], r[MEMLAT], shift ; \ + br.ctop.sptk.many .loop##shift \ +;; } \ +{ .mib \ + br.cond.sptk.many .copy_bytes ; /* deal with the remaining bytes */ \ +} +#endif + + +ENTRY(memcpy) +{ .mmi + .prologue + alloc r2 = ar.pfs, 3, Nrot - 3, 0, Nrot + .rotr r[MEMLAT+1], s[MEMLAT+2], q[MEMLAT+1], t[MEMLAT+1] + .rotp p[MEMLAT+2] + .rotf fr[MEMLAT+1], fq[MEMLAT+1], fs[MEMLAT+1], ft[MEMLAT+1] + mov ret0 = in0 // return tmp2 = dest + .save pr, saved_pr + movi0 saved_pr = pr // save the predicate registers +} { .mmi + and tmp4 = 7, in0 // check if destination is aligned + mov dest = in0 // dest + mov src = in1 // src +;; } +{ .mii + cmp.eq p_scr, p0 = in2, r0 // if (len == 0) + .save ar.lc, saved_lc + movi0 saved_lc = ar.lc // save the loop counter + .body + cmp.ge p_few, p0 = OP_T_THRES, in2 // is len <= OP_T_THRESH +} { .mbb + mov len = in2 // len +(p_scr) br.cond.dpnt.few .restore_and_exit // Branch no. 1: return dest +(p_few) br.cond.dpnt.many .copy_bytes // Branch no. 2: copy byte by byte +;; } +{ .mmi +#if defined(USE_LFETCH) + lfetch.nt1 [dest] // + lfetch.nt1 [src] // +#endif + shr.u elemcnt = len, 3 // elemcnt = len / 8 +} { .mib + cmp.eq p_scr, p0 = tmp4, r0 // is destination aligned? + sub loopcnt = 7, tmp4 // +(p_scr) br.cond.dptk.many .dest_aligned +;; } +{ .mmi + ld1 tmp2 = [src], 1 // + sub len = len, loopcnt, 1 // reduce len + movi0 ar.lc = loopcnt // +} { .mib + cmp.ne p_scr, p0 = 0, loopcnt // avoid loading beyond end-point +;; } + +.l0: // ---------------------------- // L0: Align src on 8-byte boundary +{ .mmi + st1 [dest] = tmp2, 1 // +(p_scr) ld1 tmp2 = [src], 1 // +} { .mib + cmp.lt p_scr, p0 = 1, loopcnt // avoid load beyond end-point + add loopcnt = -1, loopcnt + br.cloop.dptk.few .l0 // +;; } + +.dest_aligned: +{ .mmi + and tmp4 = 7, src // ready for alignment check + shr.u elemcnt = len, 3 // elemcnt = len / 8 +;; } +{ .mib + cmp.ne p_scr, p0 = tmp4, r0 // is source also aligned + tbit.nz p_xtr, p_nxtr = src, 3 // prepare a separate move if src +} { .mib // is not 16B aligned + add ptr2 = LFETCH_DIST, dest // prefetch address + add ptr1 = LFETCH_DIST, src +(p_scr) br.cond.dptk.many .src_not_aligned +;; } + +// The optimal case, when dest, and src are aligned + +.both_aligned: +{ .mmi + .pred.rel "mutex",p_xtr,p_nxtr +(p_xtr) cmp.gt p_scr, p0 = ALIGN_UNROLL_no+1, elemcnt // Need N + 1 to qualify +(p_nxtr) cmp.gt p_scr, p0 = ALIGN_UNROLL_no, elemcnt // Need only N to qualify + movi0 pr.rot = 1 << 16 // set rotating predicates +} { .mib +(p_scr) br.cond.dpnt.many .copy_full_words +;; } + +{ .mmi +(p_xtr) load tempreg = [src], 8 +(p_xtr) add elemcnt = -1, elemcnt + movi0 ar.ec = MEMLAT + 1 // set the epilog counter +;; } +{ .mmi +(p_xtr) add len = -8, len // + add asrc = 16, src // one bank apart (for USE_INT) + shr.u loopcnt = elemcnt, ALIGN_UNROLL_sh // cater for unrolling +;;} +{ .mmi + add loopcnt = -1, loopcnt +(p_xtr) store [dest] = tempreg, 8 // copy the "extra" word + nop.i 0 +;; } +{ .mib + add adest = 16, dest + movi0 ar.lc = loopcnt // set the loop counter +;; } + +#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO + { nop 0 } +#else + .align 32 +#endif +#if defined(USE_FLP) +.l1: // ------------------------------- // L1: Everything a multiple of 8 +{ .mmi +#if defined(USE_LFETCH) +(p[0]) lfetch.nt1 [ptr2],32 +#endif +(p[0]) ldfp8 the_r[0],the_q[0] = [src], 16 +(p[0]) add len = -32, len +} {.mmb +(p[MEMLAT]) store [dest] = the_r[MEMLAT], 8 +(p[MEMLAT]) store [adest] = the_s[MEMLAT], 8 +;; } +{ .mmi +#if defined(USE_LFETCH) +(p[0]) lfetch.nt1 [ptr1],32 +#endif +(p[0]) ldfp8 the_s[0], the_t[0] = [src], 16 +} {.mmb +(p[MEMLAT]) store [dest] = the_q[MEMLAT], 24 +(p[MEMLAT]) store [adest] = the_t[MEMLAT], 24 + br.ctop.dptk.many .l1 +;; } +#elif defined(USE_INT) +.l1: // ------------------------------- // L1: Everything a multiple of 8 +{ .mmi +(p[0]) load the_r[0] = [src], 8 +(p[0]) load the_q[0] = [asrc], 8 +(p[0]) add len = -32, len +} {.mmb +(p[MEMLAT]) store [dest] = the_r[MEMLAT], 8 +(p[MEMLAT]) store [adest] = the_q[MEMLAT], 8 +;; } +{ .mmi +(p[0]) load the_s[0] = [src], 24 +(p[0]) load the_t[0] = [asrc], 24 +} {.mmb +(p[MEMLAT]) store [dest] = the_s[MEMLAT], 24 +(p[MEMLAT]) store [adest] = the_t[MEMLAT], 24 +#if defined(USE_LFETCH) +;; } +{ .mmb +(p[0]) lfetch.nt1 [ptr2],32 +(p[0]) lfetch.nt1 [ptr1],32 +#endif + br.ctop.dptk.many .l1 +;; } +#endif + +.copy_full_words: +{ .mib + cmp.gt p_scr, p0 = 8, len // + shr.u elemcnt = len, 3 // +(p_scr) br.cond.dpnt.many .copy_bytes +;; } +{ .mii + load tempreg = [src], 8 + add loopcnt = -1, elemcnt // +;; } +{ .mii + cmp.ne p_scr, p0 = 0, loopcnt // + mov ar.lc = loopcnt // +;; } + +.l2: // ------------------------------- // L2: Max 4 words copied separately +{ .mmi + store [dest] = tempreg, 8 +(p_scr) load tempreg = [src], 8 // + add len = -8, len +} { .mib + cmp.lt p_scr, p0 = 1, loopcnt // avoid load beyond end-point + add loopcnt = -1, loopcnt + br.cloop.dptk.few .l2 +;; } + +.copy_bytes: +{ .mib + cmp.eq p_scr, p0 = len, r0 // is len == 0 ? + add loopcnt = -1, len // len--; +(p_scr) br.cond.spnt .restore_and_exit +;; } +{ .mii + ld1 tmp2 = [src], 1 + movi0 ar.lc = loopcnt + cmp.ne p_scr, p0 = 0, loopcnt // avoid load beyond end-point +;; } + +.l3: // ------------------------------- // L3: Final byte move +{ .mmi + st1 [dest] = tmp2, 1 +(p_scr) ld1 tmp2 = [src], 1 +} { .mib + cmp.lt p_scr, p0 = 1, loopcnt // avoid load beyond end-point + add loopcnt = -1, loopcnt + br.cloop.dptk.few .l3 +;; } + +.restore_and_exit: +{ .mmi + movi0 pr = saved_pr, -1 // restore the predicate registers +;; } +{ .mib + movi0 ar.lc = saved_lc // restore the loop counter + br.ret.sptk.many b0 +;; } + + +.src_not_aligned: +{ .mmi + cmp.gt p_scr, p0 = 16, len + and sh1 = 7, src // sh1 = src % 8 + shr.u loopcnt = len, 4 // element-cnt = len / 16 +} { .mib + add tmp4 = @ltoff(.table), gp + add tmp3 = @ltoff(.loop56), gp +(p_scr) br.cond.dpnt.many .copy_bytes // do byte by byte if too few +;; } +{ .mmi + and asrc = -8, src // asrc = (-8) -- align src for loop + add loopcnt = -1, loopcnt // loopcnt-- + shl sh1 = sh1, 3 // sh1 = 8 * (src % 8) +} { .mmi + ld8 ptable = [tmp4] // ptable = &table + ld8 ploop56 = [tmp3] // ploop56 = &loop56 + and tmp2 = -16, len // tmp2 = len & -OPSIZ +;; } +{ .mmi + add tmp3 = ptable, sh1 // tmp3 = &table + sh1 + add src = src, tmp2 // src += len & (-16) + movi0 ar.lc = loopcnt // set LC +;; } +{ .mmi + ld8 tmp4 = [tmp3] // tmp4 = loop offset + sub len = len, tmp2 // len -= len & (-16) + movi0 ar.ec = MEMLAT + 2 // one more pass needed +;; } +{ .mmi + ld8 s[1] = [asrc], 8 // preload + sub loopaddr = ploop56,tmp4 // loopadd = &loop56 - loop offset + movi0 pr.rot = 1 << 16 // set rotating predicates +;; } +{ .mib + nop.m 0 + movi0 b6 = loopaddr + br b6 // jump to the appropriate loop +;; } + + LOOP(8) + LOOP(16) + LOOP(24) + LOOP(32) + LOOP(40) + LOOP(48) + LOOP(56) +END(memcpy) +libc_hidden_def (memcpy) + + .rodata + .align 8 +.table: + data8 0 // dummy entry + data8 .loop56 - .loop8 + data8 .loop56 - .loop16 + data8 .loop56 - .loop24 + data8 .loop56 - .loop32 + data8 .loop56 - .loop40 + data8 .loop56 - .loop48 + data8 .loop56 - .loop56 diff --git a/libc/string/ia64/memmove.S b/libc/string/ia64/memmove.S new file mode 100644 index 000000000..0328f84de --- /dev/null +++ b/libc/string/ia64/memmove.S @@ -0,0 +1,251 @@ +/* Optimized version of the standard memmove() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + Contributed by Dan Pop <Dan.Pop@cern.ch>. + + 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. */ + +/* Return: dest + + Inputs: + in0: dest + in1: src + in2: byte count + + The core of the function is the memcpy implementation used in memcpy.S. + When bytes have to be copied backwards, only the easy case, when + all arguments are multiples of 8, is optimised. + + In this form, it assumes little endian mode. For big endian mode, + sh1 must be computed using an extra instruction: sub sh1 = 64, sh1 + or the UM.be bit should be cleared at the beginning and set at the end. */ + +#include "sysdep.h" +#undef ret + +#define OP_T_THRES 16 +#define OPSIZ 8 + +#define adest r15 +#define saved_pr r17 +#define saved_lc r18 +#define dest r19 +#define src r20 +#define len r21 +#define asrc r22 +#define tmp2 r23 +#define tmp3 r24 +#define tmp4 r25 +#define ptable r26 +#define ploop56 r27 +#define loopaddr r28 +#define sh1 r29 +#define loopcnt r30 +#define value r31 + +#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO +# define ALIGN(n) { nop 0 } +#else +# define ALIGN(n) .align n +#endif + +#define LOOP(shift) \ + ALIGN(32); \ +.loop##shift##: \ +(p[0]) ld8 r[0] = [asrc], 8 ; /* w1 */ \ +(p[MEMLAT+1]) st8 [dest] = value, 8 ; \ +(p[MEMLAT]) shrp value = r[MEMLAT], r[MEMLAT+1], shift ; \ + nop.b 0 ; \ + nop.b 0 ; \ + br.ctop.sptk .loop##shift ; \ + br.cond.sptk .cpyfew ; /* deal with the remaining bytes */ + +#define MEMLAT 21 +#define Nrot (((2*MEMLAT+3) + 7) & ~7) + +ENTRY(memmove) + .prologue + alloc r2 = ar.pfs, 3, Nrot - 3, 0, Nrot + .rotr r[MEMLAT + 2], q[MEMLAT + 1] + .rotp p[MEMLAT + 2] + mov ret0 = in0 // return value = dest + .save pr, saved_pr + mov saved_pr = pr // save the predicate registers + .save ar.lc, saved_lc + mov saved_lc = ar.lc // save the loop counter + .body + or tmp3 = in0, in1 ;; // tmp3 = dest | src + or tmp3 = tmp3, in2 // tmp3 = dest | src | len + mov dest = in0 // dest + mov src = in1 // src + mov len = in2 // len + sub tmp2 = r0, in0 // tmp2 = -dest + cmp.eq p6, p0 = in2, r0 // if (len == 0) +(p6) br.cond.spnt .restore_and_exit;;// return dest; + and tmp4 = 7, tmp3 // tmp4 = (dest | src | len) & 7 + cmp.le p6, p0 = dest, src // if dest <= src it's always safe +(p6) br.cond.spnt .forward // to copy forward + add tmp3 = src, len;; + cmp.lt p6, p0 = dest, tmp3 // if dest > src && dest < src + len +(p6) br.cond.spnt .backward // we have to copy backward + +.forward: + shr.u loopcnt = len, 4 ;; // loopcnt = len / 16 + cmp.ne p6, p0 = tmp4, r0 // if ((dest | src | len) & 7 != 0) +(p6) br.cond.sptk .next // goto next; + +// The optimal case, when dest, src and len are all multiples of 8 + + and tmp3 = 0xf, len + mov pr.rot = 1 << 16 // set rotating predicates + mov ar.ec = MEMLAT + 1 ;; // set the epilog counter + cmp.ne p6, p0 = tmp3, r0 // do we have to copy an extra word? + adds loopcnt = -1, loopcnt;; // --loopcnt +(p6) ld8 value = [src], 8;; +(p6) st8 [dest] = value, 8 // copy the "odd" word + mov ar.lc = loopcnt // set the loop counter + cmp.eq p6, p0 = 8, len +(p6) br.cond.spnt .restore_and_exit;;// the one-word special case + adds adest = 8, dest // set adest one word ahead of dest + adds asrc = 8, src ;; // set asrc one word ahead of src + nop.b 0 // get the "golden" alignment for + nop.b 0 // the next loop +.l0: +(p[0]) ld8 r[0] = [src], 16 +(p[0]) ld8 q[0] = [asrc], 16 +(p[MEMLAT]) st8 [dest] = r[MEMLAT], 16 +(p[MEMLAT]) st8 [adest] = q[MEMLAT], 16 + br.ctop.dptk .l0 ;; + + mov pr = saved_pr, -1 // restore the predicate registers + mov ar.lc = saved_lc // restore the loop counter + br.ret.sptk.many b0 +.next: + cmp.ge p6, p0 = OP_T_THRES, len // is len <= OP_T_THRES + and loopcnt = 7, tmp2 // loopcnt = -dest % 8 +(p6) br.cond.spnt .cpyfew // copy byte by byte + ;; + cmp.eq p6, p0 = loopcnt, r0 +(p6) br.cond.sptk .dest_aligned + sub len = len, loopcnt // len -= -dest % 8 + adds loopcnt = -1, loopcnt // --loopcnt + ;; + mov ar.lc = loopcnt +.l1: // copy -dest % 8 bytes + ld1 value = [src], 1 // value = *src++ + ;; + st1 [dest] = value, 1 // *dest++ = value + br.cloop.dptk .l1 +.dest_aligned: + and sh1 = 7, src // sh1 = src % 8 + and tmp2 = -8, len // tmp2 = len & -OPSIZ + and asrc = -8, src // asrc = src & -OPSIZ -- align src + shr.u loopcnt = len, 3 // loopcnt = len / 8 + and len = 7, len;; // len = len % 8 + adds loopcnt = -1, loopcnt // --loopcnt + addl tmp4 = @ltoff(.table), gp + addl tmp3 = @ltoff(.loop56), gp + mov ar.ec = MEMLAT + 1 // set EC + mov pr.rot = 1 << 16;; // set rotating predicates + mov ar.lc = loopcnt // set LC + cmp.eq p6, p0 = sh1, r0 // is the src aligned? +(p6) br.cond.sptk .src_aligned + add src = src, tmp2 // src += len & -OPSIZ + shl sh1 = sh1, 3 // sh1 = 8 * (src % 8) + ld8 ploop56 = [tmp3] // ploop56 = &loop56 + ld8 ptable = [tmp4];; // ptable = &table + add tmp3 = ptable, sh1;; // tmp3 = &table + sh1 + mov ar.ec = MEMLAT + 1 + 1 // one more pass needed + ld8 tmp4 = [tmp3];; // tmp4 = loop offset + sub loopaddr = ploop56,tmp4 // loopadd = &loop56 - loop offset + ld8 r[1] = [asrc], 8;; // w0 + mov b6 = loopaddr;; + br b6 // jump to the appropriate loop + + LOOP(8) + LOOP(16) + LOOP(24) + LOOP(32) + LOOP(40) + LOOP(48) + LOOP(56) + +.src_aligned: +.l3: +(p[0]) ld8 r[0] = [src], 8 +(p[MEMLAT]) st8 [dest] = r[MEMLAT], 8 + br.ctop.dptk .l3 +.cpyfew: + cmp.eq p6, p0 = len, r0 // is len == 0 ? + adds len = -1, len // --len; +(p6) br.cond.spnt .restore_and_exit ;; + mov ar.lc = len +.l4: + ld1 value = [src], 1 + ;; + st1 [dest] = value, 1 + br.cloop.dptk .l4 ;; +.restore_and_exit: + mov pr = saved_pr, -1 // restore the predicate registers + mov ar.lc = saved_lc // restore the loop counter + br.ret.sptk.many b0 + +// In the case of a backward copy, optimise only the case when everything +// is a multiple of 8, otherwise copy byte by byte. The backward copy is +// used only when the blocks are overlapping and dest > src. + +.backward: + shr.u loopcnt = len, 3 // loopcnt = len / 8 + add src = src, len // src points one byte past the end + add dest = dest, len ;; // dest points one byte past the end + mov ar.ec = MEMLAT + 1 // set the epilog counter + mov pr.rot = 1 << 16 // set rotating predicates + adds loopcnt = -1, loopcnt // --loopcnt + cmp.ne p6, p0 = tmp4, r0 // if ((dest | src | len) & 7 != 0) +(p6) br.cond.sptk .bytecopy ;; // copy byte by byte backward + adds src = -8, src // src points to the last word + adds dest = -8, dest // dest points to the last word + mov ar.lc = loopcnt;; // set the loop counter +.l5: +(p[0]) ld8 r[0] = [src], -8 +(p[MEMLAT]) st8 [dest] = r[MEMLAT], -8 + br.ctop.dptk .l5 + br.cond.sptk .restore_and_exit +.bytecopy: + adds src = -1, src // src points to the last byte + adds dest = -1, dest // dest points to the last byte + adds loopcnt = -1, len;; // loopcnt = len - 1 + mov ar.lc = loopcnt;; // set the loop counter +.l6: +(p[0]) ld1 r[0] = [src], -1 +(p[MEMLAT]) st1 [dest] = r[MEMLAT], -1 + br.ctop.dptk .l6 + br.cond.sptk .restore_and_exit +END(memmove) + + .rodata + .align 8 +.table: + data8 0 // dummy entry + data8 .loop56 - .loop8 + data8 .loop56 - .loop16 + data8 .loop56 - .loop24 + data8 .loop56 - .loop32 + data8 .loop56 - .loop40 + data8 .loop56 - .loop48 + data8 .loop56 - .loop56 + +libc_hidden_def (memmove) diff --git a/libc/string/ia64/memset.S b/libc/string/ia64/memset.S new file mode 100644 index 000000000..ed27f3f31 --- /dev/null +++ b/libc/string/ia64/memset.S @@ -0,0 +1,400 @@ +/* Optimized version of the standard memset() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Contributed by Dan Pop for Itanium <Dan.Pop@cern.ch>. + Rewritten for McKinley by Sverre Jarp, HP Labs/CERN <Sverre.Jarp@cern.ch> + + 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. */ + +/* Return: dest + + Inputs: + in0: dest + in1: value + in2: count + + The algorithm is fairly straightforward: set byte by byte until we + we get to a 16B-aligned address, then loop on 128 B chunks using an + early store as prefetching, then loop on 32B chucks, then clear remaining + words, finally clear remaining bytes. + Since a stf.spill f0 can store 16B in one go, we use this instruction + to get peak speed when value = 0. */ + +#include "sysdep.h" +#undef ret + +#define dest in0 +#define value in1 +#define cnt in2 + +#define tmp r31 +#define save_lc r30 +#define ptr0 r29 +#define ptr1 r28 +#define ptr2 r27 +#define ptr3 r26 +#define ptr9 r24 +#define loopcnt r23 +#define linecnt r22 +#define bytecnt r21 + +#define fvalue f6 + +// This routine uses only scratch predicate registers (p6 - p15) +#define p_scr p6 // default register for same-cycle branches +#define p_nz p7 +#define p_zr p8 +#define p_unalgn p9 +#define p_y p11 +#define p_n p12 +#define p_yy p13 +#define p_nn p14 + +#define movi0 mov + +#define MIN1 15 +#define MIN1P1HALF 8 +#define LINE_SIZE 128 +#define LSIZE_SH 7 // shift amount +#define PREF_AHEAD 8 + +#define USE_FLP +#if defined(USE_INT) +#define store st8 +#define myval value +#elif defined(USE_FLP) +#define store stf8 +#define myval fvalue +#endif + +.align 64 +ENTRY(memset) +{ .mmi + .prologue + alloc tmp = ar.pfs, 3, 0, 0, 0 + lfetch.nt1 [dest] + .save ar.lc, save_lc + movi0 save_lc = ar.lc +} { .mmi + .body + mov ret0 = dest // return value + cmp.ne p_nz, p_zr = value, r0 // use stf.spill if value is zero + cmp.eq p_scr, p0 = cnt, r0 +;; } +{ .mmi + and ptr2 = -(MIN1+1), dest // aligned address + and tmp = MIN1, dest // prepare to check for alignment + tbit.nz p_y, p_n = dest, 0 // Do we have an odd address? (M_B_U) +} { .mib + mov ptr1 = dest + mux1 value = value, @brcst // create 8 identical bytes in word +(p_scr) br.ret.dpnt.many rp // return immediately if count = 0 +;; } +{ .mib + cmp.ne p_unalgn, p0 = tmp, r0 +} { .mib // NB: # of bytes to move is 1 higher + sub bytecnt = (MIN1+1), tmp // than loopcnt + cmp.gt p_scr, p0 = 16, cnt // is it a minimalistic task? +(p_scr) br.cond.dptk.many .move_bytes_unaligned // go move just a few (M_B_U) +;; } +{ .mmi +(p_unalgn) add ptr1 = (MIN1+1), ptr2 // after alignment +(p_unalgn) add ptr2 = MIN1P1HALF, ptr2 // after alignment +(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 3 // should we do a st8 ? +;; } +{ .mib +(p_y) add cnt = -8, cnt +(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 2 // should we do a st4 ? +} { .mib +(p_y) st8 [ptr2] = value, -4 +(p_n) add ptr2 = 4, ptr2 +;; } +{ .mib +(p_yy) add cnt = -4, cnt +(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 1 // should we do a st2 ? +} { .mib +(p_yy) st4 [ptr2] = value, -2 +(p_nn) add ptr2 = 2, ptr2 +;; } +{ .mmi + mov tmp = LINE_SIZE+1 // for compare +(p_y) add cnt = -2, cnt +(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 0 // should we do a st1 ? +} { .mmi + setf.sig fvalue=value // transfer value to FLP side +(p_y) st2 [ptr2] = value, -1 +(p_n) add ptr2 = 1, ptr2 +;; } + +{ .mmi +(p_yy) st1 [ptr2] = value + cmp.gt p_scr, p0 = tmp, cnt // is it a minimalistic task? +} { .mbb +(p_yy) add cnt = -1, cnt +(p_scr) br.cond.dpnt.many .fraction_of_line // go move just a few +;; } + +{ .mib + nop.m 0 + shr.u linecnt = cnt, LSIZE_SH +(p_zr) br.cond.dptk.many .l1b // Jump to use stf.spill +;; } + +#ifndef GAS_ALIGN_BREAKS_UNWIND_INFO + .align 32 // -------- // L1A: store ahead into cache lines; fill later +#endif +{ .mmi + and tmp = -(LINE_SIZE), cnt // compute end of range + mov ptr9 = ptr1 // used for prefetching + and cnt = (LINE_SIZE-1), cnt // remainder +} { .mmi + mov loopcnt = PREF_AHEAD-1 // default prefetch loop + cmp.gt p_scr, p0 = PREF_AHEAD, linecnt // check against actual value +;; } +{ .mmi +(p_scr) add loopcnt = -1, linecnt // start of stores + add ptr2 = 8, ptr1 // (beyond prefetch stores) + add ptr1 = tmp, ptr1 // first address beyond total +;; } // range +{ .mmi + add tmp = -1, linecnt // next loop count + movi0 ar.lc = loopcnt +;; } +.pref_l1a: +{ .mib + store [ptr9] = myval, 128 // Do stores one cache line apart + nop.i 0 + br.cloop.dptk.few .pref_l1a +;; } +{ .mmi + add ptr0 = 16, ptr2 // Two stores in parallel + movi0 ar.lc = tmp +;; } +.l1ax: + { .mmi + store [ptr2] = myval, 8 + store [ptr0] = myval, 8 + ;; } + { .mmi + store [ptr2] = myval, 24 + store [ptr0] = myval, 24 + ;; } + { .mmi + store [ptr2] = myval, 8 + store [ptr0] = myval, 8 + ;; } + { .mmi + store [ptr2] = myval, 24 + store [ptr0] = myval, 24 + ;; } + { .mmi + store [ptr2] = myval, 8 + store [ptr0] = myval, 8 + ;; } + { .mmi + store [ptr2] = myval, 24 + store [ptr0] = myval, 24 + ;; } + { .mmi + store [ptr2] = myval, 8 + store [ptr0] = myval, 32 + cmp.lt p_scr, p0 = ptr9, ptr1 // do we need more prefetching? + ;; } +{ .mmb + store [ptr2] = myval, 24 +(p_scr) store [ptr9] = myval, 128 + br.cloop.dptk.few .l1ax +;; } +{ .mbb + cmp.le p_scr, p0 = 8, cnt // just a few bytes left ? +(p_scr) br.cond.dpnt.many .fraction_of_line // Branch no. 2 + br.cond.dpnt.many .move_bytes_from_alignment // Branch no. 3 +;; } + +#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO + { nop 0 } +#else + .align 32 +#endif +.l1b: // ------------------ // L1B: store ahead into cache lines; fill later +{ .mmi + and tmp = -(LINE_SIZE), cnt // compute end of range + mov ptr9 = ptr1 // used for prefetching + and cnt = (LINE_SIZE-1), cnt // remainder +} { .mmi + mov loopcnt = PREF_AHEAD-1 // default prefetch loop + cmp.gt p_scr, p0 = PREF_AHEAD, linecnt // check against actual value +;; } +{ .mmi +(p_scr) add loopcnt = -1, linecnt + add ptr2 = 16, ptr1 // start of stores (beyond prefetch stores) + add ptr1 = tmp, ptr1 // first address beyond total range +;; } +{ .mmi + add tmp = -1, linecnt // next loop count + movi0 ar.lc = loopcnt +;; } +.pref_l1b: +{ .mib + stf.spill [ptr9] = f0, 128 // Do stores one cache line apart + nop.i 0 + br.cloop.dptk.few .pref_l1b +;; } +{ .mmi + add ptr0 = 16, ptr2 // Two stores in parallel + movi0 ar.lc = tmp +;; } +.l1bx: + { .mmi + stf.spill [ptr2] = f0, 32 + stf.spill [ptr0] = f0, 32 + ;; } + { .mmi + stf.spill [ptr2] = f0, 32 + stf.spill [ptr0] = f0, 32 + ;; } + { .mmi + stf.spill [ptr2] = f0, 32 + stf.spill [ptr0] = f0, 64 + cmp.lt p_scr, p0 = ptr9, ptr1 // do we need more prefetching? + ;; } +{ .mmb + stf.spill [ptr2] = f0, 32 +(p_scr) stf.spill [ptr9] = f0, 128 + br.cloop.dptk.few .l1bx +;; } +{ .mib + cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ? +(p_scr) br.cond.dpnt.many .move_bytes_from_alignment +;; } + +.fraction_of_line: +{ .mib + add ptr2 = 16, ptr1 + shr.u loopcnt = cnt, 5 // loopcnt = cnt / 32 +;; } +{ .mib + cmp.eq p_scr, p0 = loopcnt, r0 + add loopcnt = -1, loopcnt +(p_scr) br.cond.dpnt.many store_words +;; } +{ .mib + and cnt = 0x1f, cnt // compute the remaining cnt + movi0 ar.lc = loopcnt +;; } +#ifndef GAS_ALIGN_BREAKS_UNWIND_INFO + .align 32 +#endif +.l2: // ---------------------------- // L2A: store 32B in 2 cycles +{ .mmb + store [ptr1] = myval, 8 + store [ptr2] = myval, 8 +;; } { .mmb + store [ptr1] = myval, 24 + store [ptr2] = myval, 24 + br.cloop.dptk.many .l2 +;; } +store_words: +{ .mib + cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ? +(p_scr) br.cond.dpnt.many .move_bytes_from_alignment // Branch +;; } + +{ .mmi + store [ptr1] = myval, 8 // store + cmp.le p_y, p_n = 16, cnt // + add cnt = -8, cnt // subtract +;; } +{ .mmi +(p_y) store [ptr1] = myval, 8 // store +(p_y) cmp.le.unc p_yy, p_nn = 16, cnt // +(p_y) add cnt = -8, cnt // subtract +;; } +{ .mmi // store +(p_yy) store [ptr1] = myval, 8 // +(p_yy) add cnt = -8, cnt // subtract +;; } + +.move_bytes_from_alignment: +{ .mib + cmp.eq p_scr, p0 = cnt, r0 + tbit.nz.unc p_y, p0 = cnt, 2 // should we terminate with a st4 ? +(p_scr) br.cond.dpnt.few .restore_and_exit +;; } +{ .mib +(p_y) st4 [ptr1] = value, 4 + tbit.nz.unc p_yy, p0 = cnt, 1 // should we terminate with a st2 ? +;; } +{ .mib +(p_yy) st2 [ptr1] = value, 2 + tbit.nz.unc p_y, p0 = cnt, 0 +;; } + +{ .mib +(p_y) st1 [ptr1] = value +;; } +.restore_and_exit: +{ .mib + nop.m 0 + movi0 ar.lc = save_lc + br.ret.sptk.many rp +;; } + +.move_bytes_unaligned: +{ .mmi + .pred.rel "mutex",p_y, p_n + .pred.rel "mutex",p_yy, p_nn +(p_n) cmp.le p_yy, p_nn = 4, cnt +(p_y) cmp.le p_yy, p_nn = 5, cnt +(p_n) add ptr2 = 2, ptr1 +} { .mmi +(p_y) add ptr2 = 3, ptr1 +(p_y) st1 [ptr1] = value, 1 // fill 1 (odd-aligned) byte +(p_y) add cnt = -1, cnt // [15, 14 (or less) left] +;; } +{ .mmi +(p_yy) cmp.le.unc p_y, p0 = 8, cnt + add ptr3 = ptr1, cnt // prepare last store + movi0 ar.lc = save_lc +} { .mmi +(p_yy) st2 [ptr1] = value, 4 // fill 2 (aligned) bytes +(p_yy) st2 [ptr2] = value, 4 // fill 2 (aligned) bytes +(p_yy) add cnt = -4, cnt // [11, 10 (o less) left] +;; } +{ .mmi +(p_y) cmp.le.unc p_yy, p0 = 8, cnt + add ptr3 = -1, ptr3 // last store + tbit.nz p_scr, p0 = cnt, 1 // will there be a st2 at the end ? +} { .mmi +(p_y) st2 [ptr1] = value, 4 // fill 2 (aligned) bytes +(p_y) st2 [ptr2] = value, 4 // fill 2 (aligned) bytes +(p_y) add cnt = -4, cnt // [7, 6 (or less) left] +;; } +{ .mmi +(p_yy) st2 [ptr1] = value, 4 // fill 2 (aligned) bytes +(p_yy) st2 [ptr2] = value, 4 // fill 2 (aligned) bytes + // [3, 2 (or less) left] + tbit.nz p_y, p0 = cnt, 0 // will there be a st1 at the end ? +} { .mmi +(p_yy) add cnt = -4, cnt +;; } +{ .mmb +(p_scr) st2 [ptr1] = value // fill 2 (aligned) bytes +(p_y) st1 [ptr3] = value // fill last byte (using ptr3) + br.ret.sptk.many rp +;; } +END(memset) +libc_hidden_def (memset) diff --git a/libc/string/ia64/softpipe.h b/libc/string/ia64/softpipe.h new file mode 100644 index 000000000..cf0eb5355 --- /dev/null +++ b/libc/string/ia64/softpipe.h @@ -0,0 +1,29 @@ +/* This file is part of the GNU C Library. + Copyright (C) 2000 Free Software Foundation, Inc. + + 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. */ + +/* The latency of a memory load assumed by the assembly implementation + of the mem and str functions. Since we don't have any clue about + where the data might be, let's assume it's in the L2 cache. + Assuming L3 would be too pessimistic :-) + + Some functions define MEMLAT as 2, because they expect their data + to be in the L1D cache. */ + +#ifndef MEMLAT +# define MEMLAT 6 +#endif diff --git a/libc/string/ia64/strchr.S b/libc/string/ia64/strchr.S new file mode 100644 index 000000000..7d1a0834e --- /dev/null +++ b/libc/string/ia64/strchr.S @@ -0,0 +1,112 @@ +/* Optimized version of the standard strchr() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + Contributed by Dan Pop <Dan.Pop@cern.ch>. + + 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. */ + +/* Return: the address of the first occurence of chr in str or NULL + + Inputs: + in0: str + in1: chr + + A modified version of memchr.S, the search ends when the character is + found or the terminating null character is encountered. + + This implementation assumes little endian mode. For big endian mode, + the instruction czx1.r should be replaced by czx1.l. */ + +#include "sysdep.h" +#undef ret + +#define saved_lc r18 +#define poschr r19 +#define pos0 r20 +#define val1 r21 +#define val2 r22 +#define tmp r24 +#define chrx8 r25 +#define loopcnt r30 + +#define str in0 +#define chr in1 + +ENTRY(strchr) + .prologue + alloc r2 = ar.pfs, 2, 0, 0, 0 + .save ar.lc, saved_lc + mov saved_lc = ar.lc // save the loop counter + .body + mov ret0 = str + and tmp = 7, str // tmp = str % 8 + mux1 chrx8 = chr, @brcst + extr.u chr = chr, 0, 8 // retain only the last byte + cmp.ne p8, p0 = r0, r0 // clear p8 + ;; + sub loopcnt = 8, tmp // loopcnt = 8 - tmp + cmp.eq p6, p0 = tmp, r0 +(p6) br.cond.sptk .str_aligned;; + adds loopcnt = -1, loopcnt;; + mov ar.lc = loopcnt +.l1: + ld1 val2 = [ret0], 1 + ;; + cmp.eq p6, p0 = val2, chr + cmp.eq p7, p0 = val2, r0 +(p6) br.cond.spnt .restore_and_exit +(p7) br.cond.spnt .notfound + br.cloop.sptk .l1 +.str_aligned: + ld8 val1 = [ret0], 8;; + nop.b 0 + nop.b 0 +.l2: + ld8.s val2 = [ret0], 8 // don't bomb out here + czx1.r pos0 = val1 + xor tmp = val1, chrx8 // if val1 contains chr, tmp will + ;; // contain a zero in its position + czx1.r poschr = tmp + cmp.ne p6, p0 = 8, pos0 + ;; + cmp.ne p7, p0 = 8, poschr +(p7) br.cond.spnt .foundit +(p6) br.cond.spnt .notfound + chk.s val2, .recovery +.back: + mov val1 = val2 + br.cond.dptk .l2 +.foundit: +(p6) cmp.lt p8, p0 = pos0, poschr // we found chr and null in the word +(p8) br.cond.spnt .notfound // null was found before chr + add ret0 = ret0, poschr ;; + adds ret0 = -15, ret0 ;; // should be -16, but we decrement +.restore_and_exit: // ret0 in the next instruction + adds ret0 = -1, ret0 // ret0 was pointing 1 char too far + mov ar.lc = saved_lc // restore the loop counter + br.ret.sptk.many b0 +.notfound: + mov ret0 = r0 // return NULL if null was found + mov ar.lc = saved_lc + br.ret.sptk.many b0 +.recovery: + adds ret0 = -8, ret0;; + ld8 val2 = [ret0], 8 // bomb out here + br.cond.sptk .back +END(strchr) + +weak_alias (strchr, index) +libc_hidden_def (strchr) diff --git a/libc/string/ia64/strcmp.S b/libc/string/ia64/strcmp.S new file mode 100644 index 000000000..d3b41e642 --- /dev/null +++ b/libc/string/ia64/strcmp.S @@ -0,0 +1,59 @@ +/* Optimized version of the standard strcmp() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + Contributed by Dan Pop <Dan.Pop@cern.ch>. + + 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. */ + +/* Return: the result of the comparison + + Inputs: + in0: s1 + in1: s2 + + Unlike memcmp(), this function is optimized for mismatches within the + first few characters. */ + +#include "sysdep.h" +#undef ret + +#define s1 in0 +#define s2 in1 + +#define val1 r15 +#define val2 r16 + + +ENTRY(strcmp) + alloc r2 = ar.pfs, 2, 0, 0, 0 +.loop: + ld1 val1 = [s1], 1 + ld1 val2 = [s2], 1 + cmp.eq p6, p0 = r0, r0 // set p6 + ;; + cmp.ne.and p6, p0 = val1, r0 + cmp.ne.and p6, p0 = val2, r0 + cmp.eq.and p6, p0 = val1, val2 +(p6) br.cond.sptk .loop + sub ret0 = val1, val2 + br.ret.sptk.many b0 +END(strcmp) +libc_hidden_def (strcmp) + +#ifndef __UCLIBC_HAS_LOCALE__ +strong_alias(strcmp,strcoll) +libc_hidden_def(strcoll) +#endif diff --git a/libc/string/ia64/strcpy.S b/libc/string/ia64/strcpy.S new file mode 100644 index 000000000..e4a9915ca --- /dev/null +++ b/libc/string/ia64/strcpy.S @@ -0,0 +1,145 @@ +/* Optimized version of the standard strcpy() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + Contributed by Dan Pop <Dan.Pop@cern.ch>. + + 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. */ + +/* Return: dest + + Inputs: + in0: dest + in1: src + + In this form, it assumes little endian mode. For big endian mode, the + the two shifts in .l2 must be inverted: + + shl value = r[1], sh1 // value = w0 << sh1 + shr.u tmp = r[0], sh2 // tmp = w1 >> sh2 + */ + +#include "sysdep.h" +#undef ret + +#define saved_lc r15 +#define saved_pr r16 +#define thresh r17 +#define dest r19 +#define src r20 +#define len r21 +#define asrc r22 +#define tmp r23 +#define pos r24 +#define w0 r25 +#define w1 r26 +#define c r27 +#define sh2 r28 +#define sh1 r29 +#define loopcnt r30 +#define value r31 + +ENTRY(strcpy) + .prologue + alloc r2 = ar.pfs, 2, 0, 30, 32 + +#define MEMLAT 2 + .rotr r[MEMLAT + 2] + .rotp p[MEMLAT + 1] + + mov ret0 = in0 // return value = dest + .save pr, saved_pr + mov saved_pr = pr // save the predicate registers + .save ar.lc, saved_lc + mov saved_lc = ar.lc // save the loop counter + .body + sub tmp = r0, in0 ;; // tmp = -dest + mov dest = in0 // dest + mov src = in1 // src + and loopcnt = 7, tmp ;; // loopcnt = -dest % 8 + cmp.eq p6, p0 = loopcnt, r0 + adds loopcnt = -1, loopcnt // --loopcnt +(p6) br.cond.sptk .dest_aligned ;; + mov ar.lc = loopcnt +.l1: // copy -dest % 8 bytes + ld1 c = [src], 1 // c = *src++ + ;; + st1 [dest] = c, 1 // *dest++ = c + cmp.eq p6, p0 = c, r0 +(p6) br.cond.dpnt .restore_and_exit + br.cloop.dptk .l1 ;; +.dest_aligned: + and sh1 = 7, src // sh1 = src % 8 + mov ar.lc = -1 // "infinite" loop + and asrc = -8, src ;; // asrc = src & -OPSIZ -- align src + sub thresh = 8, sh1 + mov pr.rot = 1 << 16 // set rotating predicates + cmp.ne p7, p0 = r0, r0 // clear p7 + shl sh1 = sh1, 3 ;; // sh1 = 8 * (src % 8) + sub sh2 = 64, sh1 // sh2 = 64 - sh1 + cmp.eq p6, p0 = sh1, r0 // is the src aligned? +(p6) br.cond.sptk .src_aligned ;; + ld8 r[1] = [asrc],8 ;; + + .align 32 +.l2: + ld8.s r[0] = [asrc], 8 + shr.u value = r[1], sh1 ;; // value = w0 >> sh1 + czx1.r pos = value ;; // do we have an "early" zero + cmp.lt p7, p0 = pos, thresh // in w0 >> sh1? +(p7) br.cond.dpnt .found0 + chk.s r[0], .recovery2 // it is safe to do that only +.back2: // after the previous test + shl tmp = r[0], sh2 // tmp = w1 << sh2 + ;; + or value = value, tmp ;; // value |= tmp + czx1.r pos = value ;; + cmp.ne p7, p0 = 8, pos +(p7) br.cond.dpnt .found0 + st8 [dest] = value, 8 // store val to dest + br.ctop.dptk .l2 ;; +.src_aligned: +.l3: +(p[0]) ld8.s r[0] = [src], 8 +(p[MEMLAT]) chk.s r[MEMLAT], .recovery3 +.back3: +(p[MEMLAT]) mov value = r[MEMLAT] +(p[MEMLAT]) czx1.r pos = r[MEMLAT] ;; +(p[MEMLAT]) cmp.ne p7, p0 = 8, pos +(p7) br.cond.dpnt .found0 +(p[MEMLAT]) st8 [dest] = r[MEMLAT], 8 + br.ctop.dptk .l3 ;; +.found0: + mov ar.lc = pos +.l4: + extr.u c = value, 0, 8 // c = value & 0xff + shr.u value = value, 8 + ;; + st1 [dest] = c, 1 + br.cloop.dptk .l4 ;; +.restore_and_exit: + mov ar.lc = saved_lc // restore the loop counter + mov pr = saved_pr, -1 // restore the predicate registers + br.ret.sptk.many b0 +.recovery2: + add tmp = -8, asrc ;; + ld8 r[0] = [tmp] + br.cond.sptk .back2 +.recovery3: + add tmp = -(MEMLAT + 1) * 8, src ;; + ld8 r[MEMLAT] = [tmp] + br.cond.sptk .back3 +END(strcpy) +libc_hidden_def (strcpy) diff --git a/libc/string/ia64/strlen.S b/libc/string/ia64/strlen.S new file mode 100644 index 000000000..9b27a2d1b --- /dev/null +++ b/libc/string/ia64/strlen.S @@ -0,0 +1,98 @@ +/* Optimized version of the standard strlen() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc. + Contributed by Dan Pop <Dan.Pop@cern.ch>. + + 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. */ + +/* Return: the length of the input string + + Input: + in0: str + + Look for the null character byte by byte, until we reach a word aligned + address, then search word by word, using the czx instruction. We're + also doing one word of read ahead, which could cause problems if the + null character is on the last word of a page and the next page is not + mapped in the process address space. Hence the use of the speculative + load. + + This implementation assumes little endian mode. For big endian mode, + the instruction czx1.r should be replaced by czx1.l. */ + +#include "sysdep.h" +#undef ret + +#define saved_lc r18 +#define str r19 +#define pos0 r20 +#define val1 r21 +#define val2 r22 +#define origadd r23 +#define tmp r24 +#define loopcnt r30 +#define len ret0 + +ENTRY(strlen) + .prologue + alloc r2 = ar.pfs, 1, 0, 0, 0 + .save ar.lc, saved_lc + mov saved_lc = ar.lc // save the loop counter + .body + mov str = in0 + mov len = r0 // len = 0 + and tmp = 7, in0 // tmp = str % 8 + ;; + sub loopcnt = 8, tmp // loopcnt = 8 - tmp + cmp.eq p6, p0 = tmp, r0 +(p6) br.cond.sptk .str_aligned;; + adds loopcnt = -1, loopcnt;; + mov ar.lc = loopcnt +.l1: + ld1 val2 = [str], 1 + ;; + cmp.eq p6, p0 = val2, r0 +(p6) br.cond.spnt .restore_and_exit + adds len = 1, len + br.cloop.dptk .l1 +.str_aligned: + mov origadd = str // origadd = orig + ld8 val1 = [str], 8;; + nop.b 0 + nop.b 0 +.l2: ld8.s val2 = [str], 8 // don't bomb out here + czx1.r pos0 = val1 + ;; + cmp.ne p6, p0 = 8, pos0 +(p6) br.cond.spnt .foundit + chk.s val2, .recovery +.back: + mov val1 = val2 + br.cond.dptk .l2 +.foundit: + sub tmp = str, origadd // tmp = crt address - orig + add len = len, pos0;; + add len = len, tmp;; + adds len = -16, len +.restore_and_exit: + mov ar.lc = saved_lc // restore the loop counter + br.ret.sptk.many b0 +.recovery: + adds str = -8, str;; + ld8 val2 = [str], 8 // bomb out here + br.cond.sptk .back +END(strlen) +libc_hidden_def (strlen) diff --git a/libc/string/ia64/strncmp.S b/libc/string/ia64/strncmp.S new file mode 100644 index 000000000..74011650c --- /dev/null +++ b/libc/string/ia64/strncmp.S @@ -0,0 +1,62 @@ +/* Optimized version of the standard strncmp() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + Contributed by Dan Pop <Dan.Pop@cern.ch>. + + 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. */ + +/* Return: the result of the comparison + + Inputs: + in0: s1 + in1: s2 + in2: n + + Unlike memcmp(), this function is optimized for mismatches within the + first few characters. */ + +#include "sysdep.h" +#undef ret + +#define s1 in0 +#define s2 in1 +#define n in2 + +#define val1 r15 +#define val2 r16 + + +ENTRY(strncmp) + alloc r2 = ar.pfs, 3, 0, 0, 0 + mov ret0 = r0 + cmp.eq p6, p0 = r0, r0 // set p6 + cmp.eq p7, p0 = n, r0 // return immediately if n == 0 +(p7) br.cond.spnt .restore_and_exit ;; +.loop: + ld1 val1 = [s1], 1 + ld1 val2 = [s2], 1 + adds n = -1, n // n-- + ;; + cmp.ne.and p6, p0 = val1, r0 + cmp.ne.and p6, p0 = val2, r0 + cmp.ne.and p6, p0 = n, r0 + cmp.eq.and p6, p0 = val1, val2 +(p6) br.cond.sptk .loop + sub ret0 = val1, val2 +.restore_and_exit: + br.ret.sptk.many b0 +END(strncmp) +libc_hidden_def (strncmp) diff --git a/libc/string/ia64/strncpy.S b/libc/string/ia64/strncpy.S new file mode 100644 index 000000000..4f1129350 --- /dev/null +++ b/libc/string/ia64/strncpy.S @@ -0,0 +1,232 @@ +/* Optimized version of the standard strncpy() function. + This file is part of the GNU C Library. + Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Contributed by Dan Pop <Dan.Pop@cern.ch> + and Jakub Jelinek <jakub@redhat.com>. + + 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. */ + +/* Return: dest + + Inputs: + in0: dest + in1: src + in2: len + + In this form, it assumes little endian mode. + */ + +#include "sysdep.h" +#undef ret + +#define saved_lc r15 +#define saved_pr r16 +#define thresh r17 +#define dest r18 +#define dest2 r19 +#define src r20 +#define len r21 +#define asrc r22 +#define tmp r23 +#define pos r24 +#define w0 r25 +#define w1 r26 +#define c r27 +#define sh2 r28 +#define sh1 r29 +#define loopcnt r30 +#define value r31 + +ENTRY(strncpy) + .prologue + alloc r2 = ar.pfs, 3, 0, 29, 32 + +#define MEMLAT 2 + .rotr r[MEMLAT + 2] + .rotp p[MEMLAT + 1] + + mov ret0 = in0 // return value = dest + .save pr, saved_pr + mov saved_pr = pr // save the predicate registers + .save ar.lc, saved_lc + mov saved_lc = ar.lc // save the loop counter + mov ar.ec = 0 // ec is not guaranteed to + // be zero upon function entry + .body + cmp.geu p6, p5 = 24, in2 +(p6) br.cond.spnt .short_len + sub tmp = r0, in0 ;; // tmp = -dest + mov len = in2 // len + mov dest = in0 // dest + mov src = in1 // src + and tmp = 7, tmp ;; // loopcnt = -dest % 8 + cmp.eq p6, p7 = tmp, r0 + adds loopcnt = -1, tmp // --loopcnt +(p6) br.cond.sptk .dest_aligned ;; + sub len = len, tmp // len -= -dest % 8 + mov ar.lc = loopcnt +.l1: // copy -dest % 8 bytes +(p5) ld1 c = [src], 1 // c = *src++ + ;; + st1 [dest] = c, 1 // *dest++ = c + cmp.ne p5, p7 = c, r0 + br.cloop.dptk .l1 ;; +(p7) br.cond.dpnt .found0_align + +.dest_aligned: // p7 should be cleared here + shr.u c = len, 3 // c = len / 8 + and sh1 = 7, src // sh1 = src % 8 + and asrc = -8, src ;; // asrc = src & -OPSIZ -- align src + adds c = (MEMLAT-1), c // c = (len / 8) + MEMLAT - 1 + sub thresh = 8, sh1 + mov pr.rot = 1 << 16 // set rotating predicates + shl sh1 = sh1, 3 ;; // sh1 = 8 * (src % 8) + mov ar.lc = c // "infinite" loop + sub sh2 = 64, sh1 // sh2 = 64 - sh1 + cmp.eq p6, p0 = sh1, r0 // is the src aligned? +(p6) br.cond.sptk .src_aligned + adds c = -(MEMLAT-1), c ;; // c = (len / 8) + ld8 r[1] = [asrc],8 + mov ar.lc = c ;; + + .align 32 +.l2: +(p6) st8 [dest] = value, 8 // store val to dest + ld8.s r[0] = [asrc], 8 + shr.u value = r[1], sh1 ;; // value = w0 >> sh1 + czx1.r pos = value ;; // do we have an "early" zero + cmp.lt p7, p0 = pos, thresh // in w0 >> sh1? + adds len = -8, len // len -= 8 +(p7) br.cond.dpnt .nonalign_found0 + chk.s r[0], .recovery2 // it is safe to do that only +.back2: // after the previous test + shl tmp = r[0], sh2 // tmp = w1 << sh2 + ;; + or value = value, tmp ;; // value |= tmp + czx1.r pos = value ;; + cmp.ne p7, p6 = 8, pos +(p7) br.cond.dpnt .nonalign_found0 + br.ctop.dptk .l2 ;; + adds len = 8, len + br.cond.sptk .not_found0 ;; +.nonalign_found0: + cmp.gtu p6, p0 = -8, len +(p6) br.cond.dptk .found0 + adds len = 8, len + br.cond.sptk .not_found0 ;; + + .align 32 +.src_aligned: +.l3: +(p[0]) ld8.s r[0] = [src], 8 +(p[MEMLAT]) chk.s r[MEMLAT], .recovery3 +.back3: +(p[MEMLAT]) mov value = r[MEMLAT] +(p[MEMLAT]) czx1.r pos = r[MEMLAT] ;; +(p[MEMLAT]) cmp.ne p7, p0 = 8, pos +(p[MEMLAT]) adds len = -8, len // len -= 8 +(p7) br.cond.dpnt .found0 +(p[MEMLAT]) st8 [dest] = r[MEMLAT], 8 + br.ctop.dptk .l3 ;; + + chk.s r[MEMLAT-1], .recovery4 +.back4: + mov value = r[MEMLAT-1] + +.not_found0: + cmp.eq p5, p6 = len, r0 + adds len = -1, len +(p5) br.cond.dptk .restore_and_exit ;; + mov ar.lc = len +.l4: +(p6) extr.u c = value, 0, 8 // c = value & 0xff +(p6) shr.u value = value, 8 ;; + st1 [dest] = c, 1 + cmp.ne p6, p0 = c, r0 + br.cloop.dptk .l4 + br.cond.sptk .restore_and_exit + +.found0_align: + mov pos = 0 + adds len = -8, len + mov value = 0 ;; +.found0: + shl tmp = pos, 3 + shr.u loopcnt = len, 4 // loopcnt = len / 16 + mov c = -1 ;; + cmp.eq p6, p0 = loopcnt, r0 + adds loopcnt = -1, loopcnt + shl c = c, tmp ;; + and len = 0xf, len + andcm value = value, c + mov ar.lc = loopcnt ;; + cmp.le p7, p0 = 8, len + adds dest2 = 16, dest + st8 [dest] = value, 8 + and len = 0x7, len +(p6) br.cond.dpnt .l6 ;; +.l5: + st8 [dest] = r0, 16 + st8 [dest2] = r0, 16 + br.cloop.dptk .l5 ;; +.l6: +(p7) st8 [dest] = r0, 8 + cmp.eq p5, p0 = len, r0 + adds len = -1, len +(p5) br.cond.dptk .restore_and_exit ;; + mov ar.lc = len ;; +.l7: + st1 [dest] = r0, 1 + br.cloop.dptk .l7 ;; +.restore_and_exit: + mov ar.lc = saved_lc // restore the loop counter + mov pr = saved_pr, -1 // restore the predicate registers + br.ret.sptk.many b0 + +.short_len: + cmp.eq p5, p0 = in2, r0 + adds loopcnt = -1, in2 +(p5) br.cond.spnt .restore_and_exit ;; + mov ar.lc = loopcnt // p6 should be set when we get here +.l8: +(p6) ld1 c = [in1], 1 // c = *src++ + ;; + st1 [in0] = c, 1 // *dest++ = c +(p6) cmp.ne p6, p0 = c, r0 + br.cloop.dptk .l8 + ;; + mov ar.lc = saved_lc // restore the loop counter + mov pr = saved_pr, -1 // restore the predicate registers + br.ret.sptk.many b0 +.recovery2: + add c = 8, len + add tmp = -8, asrc ;; + cmp.gtu p8, p5 = c, thresh ;; +(p8) ld8 r[0] = [tmp] +(p5) mov r[0] = r0 + br.cond.sptk .back2 +.recovery3: + add tmp = -(MEMLAT + 1) * 8, src ;; + ld8 r[MEMLAT] = [tmp] + br.cond.sptk .back3 +.recovery4: + cmp.eq p5, p6 = len, r0 + add tmp = -MEMLAT * 8, src ;; +(p6) ld8 r[MEMLAT - 1] = [tmp] +(p5) mov r[MEMLAT - 1] = r0 + br.cond.sptk .back4 +END(strncpy) +libc_hidden_def (strncpy) diff --git a/libc/string/ia64/sysdep.h b/libc/string/ia64/sysdep.h new file mode 100644 index 000000000..03e74360d --- /dev/null +++ b/libc/string/ia64/sysdep.h @@ -0,0 +1,168 @@ +/* Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999. + Based on code originally written by David Mosberger-Tang + + 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. */ + +#ifndef _LINUX_IA64_SYSDEP_H +#define _LINUX_IA64_SYSDEP_H 1 + +#include <features.h> +#include <asm/unistd.h> + +#ifdef __ASSEMBLER__ + +/* Macros to help writing .prologue directives in assembly code. */ +#define ASM_UNW_PRLG_RP 0x8 +#define ASM_UNW_PRLG_PFS 0x4 +#define ASM_UNW_PRLG_PSP 0x2 +#define ASM_UNW_PRLG_PR 0x1 +#define ASM_UNW_PRLG_GRSAVE(ninputs) (32+(ninputs)) + +#ifdef __STDC__ +#define C_LABEL(name) name##: +#else +#define C_LABEL(name) name/**/: +#endif + +#define CALL_MCOUNT + +#define ENTRY(name) \ + .text; \ + .align 32; \ + .proc C_SYMBOL_NAME(name); \ + .global C_SYMBOL_NAME(name); \ + C_LABEL(name) \ + CALL_MCOUNT + +#define LEAF(name) \ + .text; \ + .align 32; \ + .proc C_SYMBOL_NAME(name); \ + .global name; \ + C_LABEL(name) + +/* Mark the end of function SYM. */ +#undef END +#define END(sym) .endp C_SYMBOL_NAME(sym) + +/* For Linux we can use the system call table in the header file + /usr/include/asm/unistd.h + of the kernel. But these symbols do not follow the SYS_* syntax + so we have to redefine the `SYS_ify' macro here. */ +#undef SYS_ify +#ifdef __STDC__ +# define SYS_ify(syscall_name) __NR_##syscall_name +#else +# define SYS_ify(syscall_name) __NR_/**/syscall_name +#endif + +/* Linux uses a negative return value to indicate syscall errors, unlike + most Unices, which use the condition codes' carry flag. + + Since version 2.1 the return value of a system call might be negative + even if the call succeeded. E.g., the `lseek' system call might return + a large offset. Therefore we must not anymore test for < 0, but test + for a real error by making sure the value in %d0 is a real error + number. Linus said he will make sure the no syscall returns a value + in -1 .. -4095 as a valid result so we can savely test with -4095. */ + +/* We don't want the label for the error handler to be visible in the symbol + table when we define it here. */ +#define SYSCALL_ERROR_LABEL __syscall_error + +#undef PSEUDO +#define PSEUDO(name, syscall_name, args) \ + ENTRY(name) \ + DO_CALL (SYS_ify(syscall_name)); \ + cmp.eq p6,p0=-1,r10; \ +(p6) br.cond.spnt.few __syscall_error; + +#define DO_CALL_VIA_BREAK(num) \ + mov r15=num; \ + break __BREAK_SYSCALL + +#ifdef IA64_USE_NEW_STUB +# ifdef SHARED +# define DO_CALL(num) \ + .prologue; \ + adds r2 = SYSINFO_OFFSET, r13;; \ + ld8 r2 = [r2]; \ + .save ar.pfs, r11; \ + mov r11 = ar.pfs;; \ + .body; \ + mov r15 = num; \ + mov b7 = r2; \ + br.call.sptk.many b6 = b7;; \ + .restore sp; \ + mov ar.pfs = r11; \ + .prologue; \ + .body +# else /* !SHARED */ +# define DO_CALL(num) \ + .prologue; \ + mov r15 = num; \ + movl r2 = _dl_sysinfo;; \ + ld8 r2 = [r2]; \ + .save ar.pfs, r11; \ + mov r11 = ar.pfs;; \ + .body; \ + mov b7 = r2; \ + br.call.sptk.many b6 = b7;; \ + .restore sp; \ + mov ar.pfs = r11; \ + .prologue; \ + .body +# endif +#else +# define DO_CALL(num) DO_CALL_VIA_BREAK(num) +#endif + +#undef PSEUDO_END +#define PSEUDO_END(name) .endp C_SYMBOL_NAME(name); + +#undef PSEUDO_NOERRNO +#define PSEUDO_NOERRNO(name, syscall_name, args) \ + ENTRY(name) \ + DO_CALL (SYS_ify(syscall_name)); + +#undef PSEUDO_END_NOERRNO +#define PSEUDO_END_NOERRNO(name) .endp C_SYMBOL_NAME(name); + +#undef PSEUDO_ERRVAL +#define PSEUDO_ERRVAL(name, syscall_name, args) \ + ENTRY(name) \ + DO_CALL (SYS_ify(syscall_name)); \ + cmp.eq p6,p0=-1,r10; \ +(p6) mov r10=r8; + + +#undef PSEUDO_END_ERRVAL +#define PSEUDO_END_ERRVAL(name) .endp C_SYMBOL_NAME(name); + +#undef END +#define END(name) \ + .size C_SYMBOL_NAME(name), . - C_SYMBOL_NAME(name) ; \ + .endp C_SYMBOL_NAME(name) + +#define ret br.ret.sptk.few b0 +#define ret_NOERRNO ret +#define ret_ERRVAL ret + +#endif /* not __ASSEMBLER__ */ + +#endif /* linux/ia64/sysdep.h */ diff --git a/libc/string/memccpy.c b/libc/string/memccpy.c index 81d20b19c..fe5a76a4d 100644 --- a/libc/string/memccpy.c +++ b/libc/string/memccpy.c @@ -9,7 +9,7 @@ #include "_string.h" -void attribute_hidden *__memccpy(void * __restrict s1, const void * __restrict s2, int c, size_t n) +void *memccpy(void * __restrict s1, const void * __restrict s2, int c, size_t n) { register char *r1 = s1; register const char *r2 = s2; @@ -18,5 +18,3 @@ void attribute_hidden *__memccpy(void * __restrict s1, const void * __restrict s return (n == (size_t) -1) ? NULL : r1; } - -strong_alias(__memccpy,memccpy) diff --git a/libc/string/memchr.c b/libc/string/memchr.c index 288bd9748..413999722 100644 --- a/libc/string/memchr.c +++ b/libc/string/memchr.c @@ -8,14 +8,14 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wmemchr __wmemchr # define Wmemchr wmemchr #else -# define __Wmemchr __memchr # define Wmemchr memchr #endif -Wvoid attribute_hidden *__Wmemchr(const Wvoid *s, Wint c, size_t n) +libc_hidden_proto(Wmemchr) + +Wvoid *Wmemchr(const Wvoid *s, Wint c, size_t n) { register const Wuchar *r = (const Wuchar *) s; #ifdef __BCC__ @@ -37,4 +37,4 @@ Wvoid attribute_hidden *__Wmemchr(const Wvoid *s, Wint c, size_t n) } #undef np -strong_alias(__Wmemchr,Wmemchr) +libc_hidden_def(Wmemchr) diff --git a/libc/string/memcmp.c b/libc/string/memcmp.c index 9808b3785..9de28c234 100644 --- a/libc/string/memcmp.c +++ b/libc/string/memcmp.c @@ -8,14 +8,13 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wmemcmp __wmemcmp # define Wmemcmp wmemcmp #else -# define __Wmemcmp __memcmp +libc_hidden_proto(memcmp) # define Wmemcmp memcmp #endif -int attribute_hidden __Wmemcmp(const Wvoid *s1, const Wvoid *s2, size_t n) +int Wmemcmp(const Wvoid *s1, const Wvoid *s2, size_t n) { register const Wuchar *r1 = (const Wuchar *) s1; register const Wuchar *r2 = (const Wuchar *) s2; @@ -37,7 +36,7 @@ int attribute_hidden __Wmemcmp(const Wvoid *s1, const Wvoid *s2, size_t n) #endif } -strong_alias(__Wmemcmp,Wmemcmp) #ifndef WANT_WIDE -strong_alias(__memcmp,bcmp) +libc_hidden_def(memcmp) +strong_alias(memcmp,bcmp) #endif diff --git a/libc/string/memcpy.c b/libc/string/memcpy.c index abfe1b4ef..dc2986778 100644 --- a/libc/string/memcpy.c +++ b/libc/string/memcpy.c @@ -8,14 +8,14 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wmemcpy __wmemcpy # define Wmemcpy wmemcpy #else -# define __Wmemcpy __memcpy # define Wmemcpy memcpy #endif -Wvoid attribute_hidden *__Wmemcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n) +libc_hidden_proto(Wmemcpy) + +Wvoid *Wmemcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n) { register Wchar *r1 = s1; register const Wchar *r2 = s2; @@ -33,5 +33,4 @@ Wvoid attribute_hidden *__Wmemcpy(Wvoid * __restrict s1, const Wvoid * __restric return s1; } - -strong_alias(__Wmemcpy,Wmemcpy) +libc_hidden_def(Wmemcpy) diff --git a/libc/string/memmem.c b/libc/string/memmem.c index a42176181..f57733c4a 100644 --- a/libc/string/memmem.c +++ b/libc/string/memmem.c @@ -7,7 +7,7 @@ #include "_string.h" -void attribute_hidden *__memmem(const void *haystack, size_t haystacklen, +void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) { register const char *ph; @@ -36,5 +36,3 @@ void attribute_hidden *__memmem(const void *haystack, size_t haystacklen, return NULL; } - -strong_alias(__memmem,memmem) diff --git a/libc/string/memmove.c b/libc/string/memmove.c index 9e50cf5a9..3cdcca116 100644 --- a/libc/string/memmove.c +++ b/libc/string/memmove.c @@ -8,14 +8,13 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wmemmove __wmemmove # define Wmemmove wmemmove #else -# define __Wmemmove __memmove +libc_hidden_proto(memmove) # define Wmemmove memmove #endif -Wvoid attribute_hidden *__Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n) +Wvoid *Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n) { #ifdef __BCC__ register Wchar *s = (Wchar *) s1; @@ -54,4 +53,6 @@ Wvoid attribute_hidden *__Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n) #endif } -strong_alias(__Wmemmove,Wmemmove) +#ifndef WANT_WIDE +libc_hidden_def(Wmemmove) +#endif diff --git a/libc/string/mempcpy.c b/libc/string/mempcpy.c index aed37d03a..70626f24a 100644 --- a/libc/string/mempcpy.c +++ b/libc/string/mempcpy.c @@ -8,14 +8,14 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wmempcpy __wmempcpy # define Wmempcpy wmempcpy #else -# define __Wmempcpy __mempcpy # define Wmempcpy mempcpy #endif -Wvoid attribute_hidden *__Wmempcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n) +libc_hidden_proto(Wmempcpy) + +Wvoid *Wmempcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n) { register Wchar *r1 = s1; register const Wchar *r2 = s2; @@ -34,4 +34,4 @@ Wvoid attribute_hidden *__Wmempcpy(Wvoid * __restrict s1, const Wvoid * __restri return r1; } -strong_alias(__Wmempcpy,Wmempcpy) +libc_hidden_def(Wmempcpy) diff --git a/libc/string/memrchr.c b/libc/string/memrchr.c index fb696bc6d..0bb67b2e5 100644 --- a/libc/string/memrchr.c +++ b/libc/string/memrchr.c @@ -7,7 +7,9 @@ #include "_string.h" -void attribute_hidden *__memrchr(const void *s, int c, size_t n) +libc_hidden_proto(memrchr) + +void *memrchr(const void *s, int c, size_t n) { register const unsigned char *r; #ifdef __BCC__ @@ -30,4 +32,4 @@ void attribute_hidden *__memrchr(const void *s, int c, size_t n) } #undef np -strong_alias(__memrchr,memrchr) +libc_hidden_def(memrchr) diff --git a/libc/string/memset.c b/libc/string/memset.c index cb97dbce8..2f3fc271d 100644 --- a/libc/string/memset.c +++ b/libc/string/memset.c @@ -8,14 +8,13 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wmemset __wmemset # define Wmemset wmemset #else -# define __Wmemset __memset +libc_hidden_proto(memset) # define Wmemset memset #endif -Wvoid attribute_hidden *__Wmemset(Wvoid *s, Wint c, size_t n) +Wvoid *Wmemset(Wvoid *s, Wint c, size_t n) { register Wuchar *p = (Wuchar *) s; #ifdef __BCC__ @@ -34,4 +33,6 @@ Wvoid attribute_hidden *__Wmemset(Wvoid *s, Wint c, size_t n) } #undef np -strong_alias(__Wmemset,Wmemset) +#ifndef WANT_WIDE +libc_hidden_def(memset) +#endif diff --git a/libc/string/mips/Makefile b/libc/string/mips/Makefile index ac0063770..0a95346fd 100644 --- a/libc/string/mips/Makefile +++ b/libc/string/mips/Makefile @@ -5,9 +5,9 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -top_srcdir=../../../ -top_builddir=../../../ +top_srcdir:=../../../ +top_builddir:=../../../ all: objs include $(top_builddir)Rules.mak -include Makefile.arch +include ../Makefile.in include $(top_srcdir)Makerules diff --git a/libc/string/mips/Makefile.arch b/libc/string/mips/Makefile.arch deleted file mode 100644 index a110c291e..000000000 --- a/libc/string/mips/Makefile.arch +++ /dev/null @@ -1,26 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -SSRC:=memcpy.S memset.S - -STRING_ARCH_DIR:=$(top_srcdir)libc/string/mips -STRING_ARCH_OUT:=$(top_builddir)libc/string/mips - -STRING_ARCH_SRC:=$(patsubst %.S,$(STRING_ARCH_DIR)/%.S,$(SSRC)) -STRING_ARCH_OBJ:=$(patsubst %.S,$(STRING_ARCH_OUT)/%.o,$(SSRC)) - -STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ) - -libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) -libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os) - -libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) - -objclean-y+=string_arch_objclean - -string_arch_objclean: - $(RM) $(STRING_ARCH_OUT)/*.{o,os} diff --git a/libc/string/mips/memcpy.S b/libc/string/mips/memcpy.S index 991b44eb4..155bc1128 100644 --- a/libc/string/mips/memcpy.S +++ b/libc/string/mips/memcpy.S @@ -17,8 +17,10 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <sysdep.h> +#include <features.h> +/*#include <sysdep.h>*/ #include <endian.h> +#include "sysdep.h" #ifdef __mips64 #error mips32 code being compiled for mips64! @@ -38,7 +40,7 @@ # define SWLO swl /* low part is left in little-endian */ #endif -ENTRY (__memcpy) +ENTRY (memcpy) .set noreorder slti t0, a2, 8 # Less than 8? @@ -135,6 +137,6 @@ L(shfth): move a2, t0 .set reorder -END (__memcpy) +END (memcpy) -strong_alias(__memcpy,memcpy) +libc_hidden_def(memcpy) diff --git a/libc/string/mips/memset.S b/libc/string/mips/memset.S index 8e814a49b..9169ad58a 100644 --- a/libc/string/mips/memset.S +++ b/libc/string/mips/memset.S @@ -17,8 +17,10 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <sysdep.h> +#include <features.h> +/*#include <sysdep.h>*/ #include <endian.h> +#include "sysdep.h" #ifdef __mips64 #error mips32 code being compiled for mips64! @@ -32,7 +34,7 @@ # define SWHI swr /* high part is right in little-endian */ #endif -ENTRY (__memset) +ENTRY (memset) .set noreorder slti t1, a2, 8 # Less than 8? @@ -85,6 +87,6 @@ L(exit): nop .set reorder -END (__memset) +END (memset) -strong_alias(__memset,memset) +libc_hidden_def(memset) diff --git a/libc/string/mips/sysdep.h b/libc/string/mips/sysdep.h new file mode 100644 index 000000000..96f088c94 --- /dev/null +++ b/libc/string/mips/sysdep.h @@ -0,0 +1,45 @@ +/* Adapted from glibc's sysdeps/unix/mips/sysdep.h */ + +/* Copyright (C) 1992, 1995, 1997, 1999, 2000, 2002, 2003 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Brendan Kehoe (brendan@zen.org). + + 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. */ + +#ifdef __ASSEMBLER__ + +#include <sgidefs.h> +#include <sys/regdef.h> + +#define ENTRY(name) \ + .globl name; \ + .align 2; \ + .ent name,0; \ + name##: + +#undef END +#define END(function) \ + .end function; \ + .size function,.-function + +#if _MIPS_SIM == _MIPS_SIM_ABI32 || _MIPS_SIM == _MIPS_SIM_ABIO64 +# define L(label) $L ## label +#else +# define L(label) .L ## label +#endif + +#endif diff --git a/libc/string/powerpc/Makefile b/libc/string/powerpc/Makefile index ac0063770..0a95346fd 100644 --- a/libc/string/powerpc/Makefile +++ b/libc/string/powerpc/Makefile @@ -5,9 +5,9 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -top_srcdir=../../../ -top_builddir=../../../ +top_srcdir:=../../../ +top_builddir:=../../../ all: objs include $(top_builddir)Rules.mak -include Makefile.arch +include ../Makefile.in include $(top_srcdir)Makerules diff --git a/libc/string/powerpc/Makefile.arch b/libc/string/powerpc/Makefile.arch deleted file mode 100644 index 47a8dac1d..000000000 --- a/libc/string/powerpc/Makefile.arch +++ /dev/null @@ -1,24 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -STRING_ARCH_DIR:=$(top_srcdir)libc/string/powerpc -STRING_ARCH_OUT:=$(top_builddir)libc/string/powerpc - -STRING_ARCH_CSRC:=$(wildcard $(STRING_ARCH_DIR)/*.c) -STRING_ARCH_COBJ:=$(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_CSRC)) - -STRING_ARCH_OBJS:=$(STRING_ARCH_COBJ) - -libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) -libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os) - -libc-multi-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_CSRC) - -objclean-y+=string_arch_objclean - -string_arch_objclean: - $(RM) $(STRING_ARCH_OUT)/*.{o,os} diff --git a/libc/string/powerpc/memcpy.c b/libc/string/powerpc/memcpy.c index 5af96869b..ed8022313 100644 --- a/libc/string/powerpc/memcpy.c +++ b/libc/string/powerpc/memcpy.c @@ -21,7 +21,8 @@ #include <string.h> -void attribute_hidden *__memcpy(void *to, const void *from, size_t n) +libc_hidden_proto(memcpy) +void *memcpy(void *to, const void *from, size_t n) /* PPC can do pre increment and load/store, but not post increment and load/store. Therefore use *++ptr instead of *ptr++. */ { @@ -76,5 +77,4 @@ void attribute_hidden *__memcpy(void *to, const void *from, size_t n) goto copy_chunks; goto lessthan8; } - -strong_alias(__memcpy,memcpy) +libc_hidden_def(memcpy) diff --git a/libc/string/powerpc/memmove.c b/libc/string/powerpc/memmove.c index 1d513a966..327161116 100644 --- a/libc/string/powerpc/memmove.c +++ b/libc/string/powerpc/memmove.c @@ -21,14 +21,17 @@ #include <string.h> -void attribute_hidden *__memmove(void *to, const void *from, size_t n) +libc_hidden_proto(memcpy) + +libc_hidden_proto(memmove) +void *memmove(void *to, const void *from, size_t n) { unsigned long rem, chunks, tmp1, tmp2; unsigned char *tmp_to; unsigned char *tmp_from = (unsigned char *)from; if (tmp_from >= (unsigned char *)to) - return __memcpy(to, from, n); + return memcpy(to, from, n); chunks = n / 8; tmp_from += n; tmp_to = to + n; @@ -72,5 +75,4 @@ void attribute_hidden *__memmove(void *to, const void *from, size_t n) goto copy_chunks; goto lessthan8; } - -strong_alias(__memmove,memmove) +libc_hidden_def(memmove) diff --git a/libc/string/powerpc/memset.c b/libc/string/powerpc/memset.c index f6cda9579..891e0b8aa 100644 --- a/libc/string/powerpc/memset.c +++ b/libc/string/powerpc/memset.c @@ -21,6 +21,8 @@ #include <string.h> +libc_hidden_proto(memset) + static inline int expand_byte_word(int c){ /* this does: c = c << 8 | c; @@ -32,7 +34,7 @@ static inline int expand_byte_word(int c){ return c; } -void attribute_hidden *__memset(void *to, int c, size_t n) +void *memset(void *to, int c, size_t n) { unsigned long rem, chunks; unsigned char *tmp_to; @@ -78,5 +80,4 @@ void attribute_hidden *__memset(void *to, int c, size_t n) goto copy_chunks; goto lessthan8; } - -strong_alias(__memset,memset) +libc_hidden_def(memset) diff --git a/libc/string/psignal.c b/libc/string/psignal.c index b6d6a30c0..a852e6047 100644 --- a/libc/string/psignal.c +++ b/libc/string/psignal.c @@ -8,8 +8,11 @@ #include <features.h> #include <stdio.h> #include <string.h> +#include <signal.h> -extern char *__strsignal (int __sig) __THROW attribute_hidden; +libc_hidden_proto(fprintf) +libc_hidden_proto(strsignal) +libc_hidden_proto(stderr) /* TODO: make this threadsafe with a reentrant version of strsignal? */ @@ -26,5 +29,5 @@ void psignal(int signum, register const char *message) message = (sep += 2); /* or passed an empty string. */ } - fprintf(stderr, "%s%s%s\n", message, sep, __strsignal(signum)); + fprintf(stderr, "%s%s%s\n", message, sep, strsignal(signum)); } diff --git a/libc/string/rawmemchr.c b/libc/string/rawmemchr.c index 81d578a0f..754a34e18 100644 --- a/libc/string/rawmemchr.c +++ b/libc/string/rawmemchr.c @@ -7,7 +7,9 @@ #include "_string.h" -void attribute_hidden *__rawmemchr(const void *s, int c) +libc_hidden_proto(rawmemchr) + +void *rawmemchr(const void *s, int c) { register const unsigned char *r = s; @@ -15,5 +17,4 @@ void attribute_hidden *__rawmemchr(const void *s, int c) return (void *) r; /* silence the warning */ } - -strong_alias(__rawmemchr,rawmemchr) +libc_hidden_def(rawmemchr) diff --git a/libc/string/sh64/Makefile b/libc/string/sh64/Makefile index ac0063770..0a95346fd 100644 --- a/libc/string/sh64/Makefile +++ b/libc/string/sh64/Makefile @@ -5,9 +5,9 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -top_srcdir=../../../ -top_builddir=../../../ +top_srcdir:=../../../ +top_builddir:=../../../ all: objs include $(top_builddir)Rules.mak -include Makefile.arch +include ../Makefile.in include $(top_srcdir)Makerules diff --git a/libc/string/sh64/Makefile.arch b/libc/string/sh64/Makefile.arch deleted file mode 100644 index f246864f6..000000000 --- a/libc/string/sh64/Makefile.arch +++ /dev/null @@ -1,27 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org> -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -SSRC:=memcpy.S memset.S strcpy.S strlen.S - -STRING_ARCH_DIR:=$(top_srcdir)libc/string/sh64 -STRING_ARCH_OUT:=$(top_builddir)libc/string/sh64 - -STRING_ARCH_SRC:=$(patsubst %.S,$(STRING_ARCH_DIR)/%.S,$(SSRC)) -STRING_ARCH_OBJ:=$(patsubst %.S,$(STRING_ARCH_OUT)/%.o,$(SSRC)) - -STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ) - -libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) -libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os) - -libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) - -objclean-y+=string_arch_objclean - -string_arch_objclean: - $(RM) $(STRING_ARCH_OUT)/*.{o,os} diff --git a/libc/string/sh64/memcpy.S b/libc/string/sh64/memcpy.S index d74980613..3c0ea0c0d 100644 --- a/libc/string/sh64/memcpy.S +++ b/libc/string/sh64/memcpy.S @@ -39,12 +39,11 @@ #include <features.h> .section .text..SHmedia32,"ax" - .globl __memcpy - .hidden __memcpy - .type __memcpy, @function + .globl memcpy + .type memcpy, @function .align 5 -__memcpy: +memcpy: #define LDUAQ(P,O,D0,D1) ldlo.q P,O,D0; ldhi.q P,O+7,D1 #define STUAQ(P,O,D0,D1) stlo.q P,O,D0; sthi.q P,O+7,D1 @@ -201,6 +200,6 @@ Loop_ua: stlo.q r5, 8, r1 blink tr1, r63 - .size __memcpy,.-__memcpy + .size memcpy,.-memcpy -strong_alias(__memcpy,memcpy) +libc_hidden_def(memcpy) diff --git a/libc/string/sh64/memset.S b/libc/string/sh64/memset.S index cd2ad7998..f588323f0 100644 --- a/libc/string/sh64/memset.S +++ b/libc/string/sh64/memset.S @@ -21,13 +21,12 @@ #endif .section .text..SHmedia32,"ax" - .globl __memset - .hidden __memset - .type __memset, @function + .globl memset + .type memset, @function .align 5 -__memset: +memset: pta/l multiquad, tr0 andi r2, 7, r22 ptabs r18, tr2 @@ -92,6 +91,6 @@ loop: sthi.q r5, -1, r3 blink tr2,r63 - .size __memset,.-__memset + .size memset,.-memset -strong_alias(__memset,memset) +libc_hidden_def(memset) diff --git a/libc/string/sh64/strcpy.S b/libc/string/sh64/strcpy.S index 2ce998257..da79d5143 100644 --- a/libc/string/sh64/strcpy.S +++ b/libc/string/sh64/strcpy.S @@ -18,12 +18,11 @@ #endif .section .text..SHmedia32,"ax" - .globl __strcpy - .hidden __strcpy - .type __strcpy, @function + .globl strcpy + .type strcpy, @function .align 5 -__strcpy: +strcpy: pta/l shortstring,tr1 ldlo.q r3,0,r4 @@ -98,6 +97,6 @@ loop: addi r0, 8, r0 blink tr1, r63 // shortstring - .size __strcpy,.-__strcpy + .size strcpy,.-strcpy -strong_alias(__strcpy,strcpy) +libc_hidden_def(strcpy) diff --git a/libc/string/sh64/strlen.S b/libc/string/sh64/strlen.S index 673a34dbd..18f4164ff 100644 --- a/libc/string/sh64/strlen.S +++ b/libc/string/sh64/strlen.S @@ -33,12 +33,11 @@ #include <features.h> .section .text..SHmedia32,"ax" - .globl __strlen - .hidden __strlen - .type __strlen,@function + .globl strlen + .type strlen,@function .balign 16 -__strlen: +strlen: ptabs r18, tr4 /* @@ -59,6 +58,6 @@ loop: or r0, r63, r2 blink tr4, r63 - .size __strlen,.-__strlen + .size strlen,.-strlen -strong_alias(__strlen,strlen) +libc_hidden_def(strlen) diff --git a/libc/string/sparc/Makefile b/libc/string/sparc/Makefile index ac0063770..0a95346fd 100644 --- a/libc/string/sparc/Makefile +++ b/libc/string/sparc/Makefile @@ -5,9 +5,9 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -top_srcdir=../../../ -top_builddir=../../../ +top_srcdir:=../../../ +top_builddir:=../../../ all: objs include $(top_builddir)Rules.mak -include Makefile.arch +include ../Makefile.in include $(top_srcdir)Makerules diff --git a/libc/string/sparc/Makefile.arch b/libc/string/sparc/Makefile.arch deleted file mode 100644 index 1acd93ad9..000000000 --- a/libc/string/sparc/Makefile.arch +++ /dev/null @@ -1,28 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -STRING_ARCH_DIR:=$(top_srcdir)libc/string/sparc -STRING_ARCH_OUT:=$(top_builddir)libc/string/sparc - -STRING_ARCH_SRC:=$(wildcard $(STRING_ARCH_DIR)/*.c) -STRING_ARCH_OBJ:=$(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SRC)) - -STRING_ARCH_SSRC:=$(wildcard $(STRING_ARCH_DIR)/*.S) -STRING_ARCH_SOBJ:=$(patsubst $(STRING_ARCH_DIR)/%.S,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SSRC)) - -STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ) $(STRING_ARCH_SOBJ) - -libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) -libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os) - -libc-multi-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_SRC) -libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_SOBJ) - -objclean-y+=string_arch_objclean - -string_arch_objclean: - $(RM) $(STRING_ARCH_OUT)/*.{o,os} diff --git a/libc/string/sparc/_glibc_inc.h b/libc/string/sparc/_glibc_inc.h index 6ef1dbde6..4eb4d755c 100644 --- a/libc/string/sparc/_glibc_inc.h +++ b/libc/string/sparc/_glibc_inc.h @@ -14,7 +14,6 @@ #define ENTRY(sym) \ .global sym; \ - .hidden sym; \ .align ENTRY_ALIGN; \ .type sym,%function; \ sym: diff --git a/libc/string/sparc/sparc32/memchr.S b/libc/string/sparc/sparc32/memchr.S index e012844ba..4d57a553b 100644 --- a/libc/string/sparc/sparc32/memchr.S +++ b/libc/string/sparc/sparc32/memchr.S @@ -63,7 +63,7 @@ 1: retl sub %o0, 1, %o0 -ENTRY(__memchr) +ENTRY(memchr) andcc %o1, 0xff, %o1 sll %o1, 8, %g6 andcc %o0, 3, %g0 @@ -136,9 +136,9 @@ ENTRY(__memchr) sub %o0, 3, %o0 4: retl sub %o0, 4, %o0 -END(__memchr) -strong_alias(__memchr,memchr) +END(memchr) +libc_hidden_def(memchr) #if !__BOUNDED_POINTERS__ -weak_alias(__memchr,__ubp_memchr) +weak_alias(memchr,__ubp_memchr) #endif diff --git a/libc/string/sparc/sparc32/memcpy.S b/libc/string/sparc/sparc32/memcpy.S index a1dd246e6..fb79a601a 100644 --- a/libc/string/sparc/sparc32/memcpy.S +++ b/libc/string/sparc/sparc32/memcpy.S @@ -161,14 +161,13 @@ b 3f sub %o0, 2, %o0 -ENTRY(__bcopy) +ENTRY(bcopy) mov %o0, %o3 mov %o1, %o0 mov %o3, %o1 -END(__bcopy) -strong_alias(__bcopy,bcopy) +END(bcopy) -ENTRY(__memmove) +ENTRY(memmove) cmp %o0, %o1 st %o0, [%sp + 64] bleu 9f @@ -448,10 +447,10 @@ ENTRY(__memmove) sub %o2, 2, %o2 b 3f add %o0, 2, %o0 -END(__memmove) -strong_alias(__memmove,memmove) +END(memmove) +libc_hidden_def(memmove) -ENTRY(__memcpy) /* %o0=dst %o1=src %o2=len */ +ENTRY(memcpy) /* %o0=dst %o1=src %o2=len */ sub %o0, %o1, %o4 st %o0, [%sp + 64] 9: andcc %o4, 3, %o5 @@ -966,5 +965,5 @@ ENTRY(__memcpy) /* %o0=dst %o1=src %o2=len */ sub %o7, %o4, %o5 110: retl sub %o7, %g6, %o5 -END(__memcpy) -strong_alias(__memcpy,memcpy) +END(memcpy) +libc_hidden_def(memcpy) diff --git a/libc/string/sparc/sparc32/memset.S b/libc/string/sparc/sparc32/memset.S index b60b881be..d5e1350f2 100644 --- a/libc/string/sparc/sparc32/memset.S +++ b/libc/string/sparc/sparc32/memset.S @@ -43,7 +43,7 @@ .text .align 4 -ENTRY(__bzero) +ENTRY(bzero) b 1f mov %g0, %g3 @@ -60,10 +60,9 @@ ENTRY(__bzero) add %o1, %o2, %o1 b 4f sub %o0, %o2, %o0 -END(__bzero) -strong_alias(__bzero,bzero) +END(bzero) -ENTRY(__memset) +ENTRY(memset) and %o1, 0xff, %g3 sll %g3, 8, %g2 or %g3, %g2, %g3 @@ -148,5 +147,5 @@ ENTRY(__memset) stb %g3, [%o0 + 6] 0: retl nop -END(__memset) -strong_alias(__memset,memset) +END(memset) +libc_hidden_def(memset) diff --git a/libc/string/sparc/sparc32/stpcpy.S b/libc/string/sparc/sparc32/stpcpy.S index 26d2fecbd..daf116eb1 100644 --- a/libc/string/sparc/sparc32/stpcpy.S +++ b/libc/string/sparc/sparc32/stpcpy.S @@ -65,7 +65,7 @@ 1: retl add %o0, -1, %o0 -ENTRY(__stpcpy) +ENTRY(stpcpy) andcc %o1, 3, %g0 bne 10b sethi %hi(0x80808080), %o4 @@ -156,6 +156,6 @@ ENTRY(__stpcpy) add %o0, 1, %o0 19: retl nop -END(__stpcpy) +END(stpcpy) -strong_alias(__stpcpy,stpcpy) +libc_hidden_def(stpcpy) diff --git a/libc/string/sparc/sparc32/strcat.S b/libc/string/sparc/sparc32/strcat.S index 2ee630b23..eda029a16 100644 --- a/libc/string/sparc/sparc32/strcat.S +++ b/libc/string/sparc/sparc32/strcat.S @@ -91,7 +91,7 @@ b 3f sub %o0, 1, %o0 -ENTRY(__strcat) +ENTRY(strcat) mov %o0, %g2 andcc %o0, 3, %g0 bne 11b @@ -343,6 +343,6 @@ ENTRY(__strcat) srl %o5, 16, %o4 retl mov %g2, %o0 -END(__strcat) +END(strcat) -strong_alias(__strcat,strcat) +libc_hidden_def(strcat) diff --git a/libc/string/sparc/sparc32/strchr.S b/libc/string/sparc/sparc32/strchr.S index 69360c53a..d06bbe3cc 100644 --- a/libc/string/sparc/sparc32/strchr.S +++ b/libc/string/sparc/sparc32/strchr.S @@ -67,7 +67,7 @@ 1: retl sub %o0, 1, %o0 -ENTRY(__strchr) +ENTRY(strchr) andcc %o1, 0xff, %o1 be 12f sll %o1, 8, %o2 @@ -215,11 +215,11 @@ ENTRY(__strchr) 1: or %o4, %lo(0x01010101), %o2 b 7f ld [%o0], %g4 -END(__strchr) -strong_alias(__strchr,strchr) -strong_alias(__strchr,index) +END(strchr) +libc_hidden_def(strchr) +strong_alias(strchr,index) -ENTRY(__strrchr) +ENTRY(strrchr) andcc %o1, 0xff, %o1 clr %o5 be 12b @@ -276,6 +276,6 @@ ENTRY(__strrchr) ld [%o0], %g4 9: retl mov %o5, %o0 -END(__strrchr) -strong_alias(__strrchr,strrchr) -strong_alias(__strrchr,rindex) +END(strrchr) +libc_hidden_def(strrchr) +strong_alias(strrchr,rindex) diff --git a/libc/string/sparc/sparc32/strcmp.S b/libc/string/sparc/sparc32/strcmp.S index 6a807e08a..d43883de6 100644 --- a/libc/string/sparc/sparc32/strcmp.S +++ b/libc/string/sparc/sparc32/strcmp.S @@ -74,7 +74,7 @@ 2: retl mov %o4, %o0 -ENTRY(__strcmp) +ENTRY(strcmp) andcc %o0, 3, %g0 bne 10b sethi %hi(0x80808080), %g1 @@ -252,6 +252,5 @@ ENTRY(__strcmp) ld [%i0], %i4 jmpl %i7 + 8, %g0 restore %g4, %g0, %o0 -END(__strcmp) - -strong_alias(__strcmp,strcmp) +END(strcmp) +libc_hidden_def(strcmp) diff --git a/libc/string/sparc/sparc32/strcpy.S b/libc/string/sparc/sparc32/strcpy.S index ab57e00a5..4d7742ebc 100644 --- a/libc/string/sparc/sparc32/strcpy.S +++ b/libc/string/sparc/sparc32/strcpy.S @@ -63,7 +63,7 @@ b 6f andcc %o0, 3, %g3 -ENTRY(__strcpy) +ENTRY(strcpy) mov %o0, %g2 andcc %o1, 3, %g0 bne 1b @@ -269,6 +269,5 @@ ENTRY(__strcpy) srl %o5, 16, %o4 retl mov %g2, %o0 -END(__strcpy) - -strong_alias(__strcpy,strcpy) +END(strcpy) +libc_hidden_def(strcpy) diff --git a/libc/string/sparc/sparc32/strlen.S b/libc/string/sparc/sparc32/strlen.S index 81beb7f62..4edfe7e78 100644 --- a/libc/string/sparc/sparc32/strlen.S +++ b/libc/string/sparc/sparc32/strlen.S @@ -63,7 +63,7 @@ 3: retl mov 2, %o0 -ENTRY(__strlen) +ENTRY(strlen) mov %o0, %o1 andcc %o0, 3, %g0 bne 10b @@ -98,6 +98,5 @@ ENTRY(__strlen) add %o4, 1, %o4 13: retl sub %o4, %o1, %o0 -END(__strlen) - -strong_alias(__strlen,strlen) +END(strlen) +libc_hidden_def(strlen) diff --git a/libc/string/sparc/sparc64/memchr.S b/libc/string/sparc/sparc64/memchr.S index 7017b5540..6096cc218 100644 --- a/libc/string/sparc/sparc64/memchr.S +++ b/libc/string/sparc/sparc64/memchr.S @@ -54,7 +54,7 @@ .text .align 32 -ENTRY(__memchr) +ENTRY(memchr) and %o1, 0xff, %o1 /* IEU0 Group */ #ifdef USE_BPR brz,pn %o2, 12f /* CTI+IEU1 */ @@ -253,9 +253,9 @@ ENTRY(__memchr) 23: retl /* CTI+IEU1 Group */ add %o0, -1, %o0 /* IEU0 */ -END(__memchr) +END(memchr) -strong_alias(__memchr,memchr) +libc_hidden_def(memchr) #if !__BOUNDED_POINTERS__ -weak_alias(__memchr,__ubp_memchr) +weak_alias(memchr,__ubp_memchr) #endif diff --git a/libc/string/sparc/sparc64/memcpy.S b/libc/string/sparc/sparc64/memcpy.S index 4201b5ec2..2fdff7b52 100644 --- a/libc/string/sparc/sparc64/memcpy.S +++ b/libc/string/sparc/sparc64/memcpy.S @@ -191,7 +191,7 @@ .text .align 32 -ENTRY(__bcopy) +ENTRY(bcopy) sub %o1, %o0, %o4 /* IEU0 Group */ mov %o0, %g3 /* IEU1 */ cmp %o4, %o2 /* IEU1 Group */ @@ -205,8 +205,7 @@ ENTRY(__bcopy) add %o0, %o2, %o0 /* IEU0 */ retl nop -END(__bcopy) -strong_alias(__bcopy,bcopy) +END(bcopy) .align 32 200: be,pt %xcc, 201f /* CTI */ @@ -504,7 +503,7 @@ END(__align_cpy_16) #endif .align 32 -ENTRY(__memcpy) +ENTRY(memcpy) 210: #ifndef USE_BPR srl %o2, 0, %o2 /* IEU1 Group */ @@ -695,8 +694,8 @@ ENTRY(__memcpy) 214: wr %g0, FPRS_FEF, %fprs retl mov %g4, %o0 -END(__memcpy) -strong_alias(__memcpy,memcpy) +END(memcpy) +libc_hidden_def(memcpy) .align 32 228: andcc %o2, 1, %g0 /* IEU1 Group */ @@ -721,7 +720,7 @@ strong_alias(__memcpy,memcpy) nop .align 32 -ENTRY(__memmove) +ENTRY(memmove) #ifndef USE_BPR srl %o2, 0, %o2 /* IEU1 Group */ #endif @@ -912,10 +911,10 @@ ENTRY(__memmove) 234: wr %g0, FPRS_FEF, %fprs retl mov %g4, %o0 -END(__memmove) -strong_alias(__memmove,memmove) +END(memmove) +libc_hidden_def(memmove) #ifdef USE_BPR -weak_alias(__memcpy,__align_cpy_1) -weak_alias(__memcpy,__align_cpy_2) +weak_alias(memcpy,__align_cpy_1) +weak_alias(memcpy,__align_cpy_2) #endif diff --git a/libc/string/sparc/sparc64/memset.S b/libc/string/sparc/sparc64/memset.S index 6fb25d211..284713556 100644 --- a/libc/string/sparc/sparc64/memset.S +++ b/libc/string/sparc/sparc64/memset.S @@ -36,7 +36,7 @@ /* Well, memset is a lot easier to get right than bcopy... */ .text .align 32 -ENTRY(__memset) +ENTRY(memset) andcc %o1, 0xff, %o1 mov %o0, %o5 be,a,pt %icc, 50f @@ -176,8 +176,8 @@ ENTRY(__memset) nop ba,pt %xcc, 18b ldd [%o0], %f0 -END(__memset) -strong_alias(__memset,memset) +END(memset) +libc_hidden_def(memset) #define ZERO_BLOCKS(base, offset, source) \ stx source, [base - offset - 0x38]; \ @@ -191,7 +191,7 @@ strong_alias(__memset,memset) .text .align 32 -ENTRY(__bzero) +ENTRY(bzero) #ifndef USE_BPR srl %o1, 0, %o1 #endif @@ -309,5 +309,4 @@ ENTRY(__bzero) stb %g0, [%o0 - 1] 0: retl mov %o5, %o0 -END(__bzero) -strong_alias(__bzero,bzero) +END(bzero) diff --git a/libc/string/sparc/sparc64/sparcv9b/memcpy.S b/libc/string/sparc/sparc64/sparcv9b/memcpy.S index dd381c7ef..b49c9cde9 100644 --- a/libc/string/sparc/sparc64/sparcv9b/memcpy.S +++ b/libc/string/sparc/sparc64/sparcv9b/memcpy.S @@ -36,7 +36,7 @@ .text .align 32 -ENTRY(__bcopy) +ENTRY(bcopy) sub %o1, %o0, %o4 mov %o0, %g4 cmp %o4, %o2 @@ -50,8 +50,7 @@ ENTRY(__bcopy) add %o0, %o2, %o0 retl nop -END(__bcopy) -strong_alias(__bcopy,bcopy) +END(bcopy) /* Special/non-trivial issues of this code: * @@ -68,7 +67,7 @@ strong_alias(__bcopy,bcopy) * of up to 2.4GB per second. */ .align 32 -ENTRY(__memcpy) +ENTRY(memcpy) 100: /* %o0=dst, %o1=src, %o2=len */ mov %o0, %g5 @@ -329,8 +328,8 @@ small_copy_unaligned: retl mov %g5, %o0 -END(__memcpy) -strong_alias(__memcpy,memcpy) +END(memcpy) +libc_hidden_def(memcpy) #define RMOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \ ldx [%src - offset - 0x20], %t0; \ @@ -405,7 +404,7 @@ strong_alias(__memcpy,memcpy) mov %g4, %o0 .align 32 -ENTRY(__memmove) +ENTRY(memmove) mov %o0, %g5 #ifndef USE_BPR srl %o2, 0, %o2 /* IEU1 Group */ @@ -597,8 +596,8 @@ ENTRY(__memmove) 234: wr %g0, FPRS_FEF, %fprs retl mov %g4, %o0 -END(__memmove) -strong_alias(__memmove,memmove) +END(memmove) +libc_hidden_def(memmove) #ifdef USE_BPR weak_alias(memcpy,__align_cpy_1) diff --git a/libc/string/sparc/sparc64/stpcpy.S b/libc/string/sparc/sparc64/stpcpy.S index 6bd24cfee..8c26c6bec 100644 --- a/libc/string/sparc/sparc64/stpcpy.S +++ b/libc/string/sparc/sparc64/stpcpy.S @@ -45,7 +45,7 @@ .text .align 32 -ENTRY(__stpcpy) +ENTRY(stpcpy) sethi %hi(0x01010101), %g1 /* IEU0 Group */ or %g1, %lo(0x01010101), %g1 /* IEU0 Group */ andcc %o0, 7, %g0 /* IEU1 */ @@ -267,6 +267,5 @@ ENTRY(__stpcpy) retl /* CTI+IEU1 Group */ mov %g6, %o0 /* IEU0 */ -END(__stpcpy) - -strong_alias(__stpcpy,stpcpy) +END(stpcpy) +libc_hidden_def(stpcpy) diff --git a/libc/string/sparc/sparc64/strcat.S b/libc/string/sparc/sparc64/strcat.S index fb3ad2d12..fcc4ba59c 100644 --- a/libc/string/sparc/sparc64/strcat.S +++ b/libc/string/sparc/sparc64/strcat.S @@ -47,7 +47,7 @@ .text .align 32 -ENTRY(__strcat) +ENTRY(strcat) sethi %hi(0x01010101), %g1 /* IEU0 Group */ ldub [%o0], %o3 /* Load */ or %g1, %lo(0x01010101), %g1 /* IEU0 Group */ @@ -335,6 +335,5 @@ ENTRY(__strcat) stb %o4, [%o0 - 8] /* Store */ retl /* CTI+IEU1 Group */ mov %g6, %o0 /* IEU0 */ -END(__strcat) - -strong_alias(__strcat,strcat) +END(strcat) +libc_hidden_def(strcat) diff --git a/libc/string/sparc/sparc64/strchr.S b/libc/string/sparc/sparc64/strchr.S index 34c30df31..6a371352a 100644 --- a/libc/string/sparc/sparc64/strchr.S +++ b/libc/string/sparc/sparc64/strchr.S @@ -47,7 +47,7 @@ .text .align 32 -ENTRY(__strchr) +ENTRY(strchr) andcc %o1, 0xff, %o1 /* IEU1 Group */ be,pn %icc, 17f /* CTI */ sllx %o1, 8, %g3 /* IEU0 Group */ @@ -327,12 +327,12 @@ ENTRY(__strchr) lduba [%o0] ASI_PNF, %o3 /* Load */ retl /* CTI+IEU1 Group */ add %o0, -1, %o0 /* IEU0 */ -END(__strchr) -strong_alias(__strchr,strchr) -strong_alias(__strchr,index) +END(strchr) +libc_hidden_def(strchr) +strong_alias(strchr,index) .align 32 -ENTRY(__strrchr) +ENTRY(strrchr) andcc %o1, 0xff, %o1 /* IEU1 Group */ be,pn %icc, 17b /* CTI */ clr %g4 /* IEU0 */ @@ -476,6 +476,6 @@ ENTRY(__strrchr) ba,pt %xcc, 1b /* CTI Group */ ldx [%o0], %o3 /* Load */ -END(__strrchr) -strong_alias(__strrchr,strrchr) -strong_alias(__strrchr,rindex) +END(strrchr) +libc_hidden_def(strrchr) +strong_alias(strrchr,rindex) diff --git a/libc/string/sparc/sparc64/strcmp.S b/libc/string/sparc/sparc64/strcmp.S index 0e078e9ac..df9e69179 100644 --- a/libc/string/sparc/sparc64/strcmp.S +++ b/libc/string/sparc/sparc64/strcmp.S @@ -45,7 +45,7 @@ .text .align 32 -ENTRY(__strcmp) +ENTRY(strcmp) sethi %hi(0x01010101), %g1 /* IEU0 Group */ andcc %o0, 7, %g0 /* IEU1 */ bne,pn %icc, 7f /* CTI */ @@ -275,6 +275,5 @@ ENTRY(__strcmp) ba,pt %xcc, 11b /* CTI Group */ ldxa [%o1 + %o0] ASI_PNF, %g6 /* Load */ -END(__strcmp) - -strong_alias(__strcmp,strcmp) +END(strcmp) +libc_hidden_def(strcmp) diff --git a/libc/string/sparc/sparc64/strcpy.S b/libc/string/sparc/sparc64/strcpy.S index d9dff104a..1317d5489 100644 --- a/libc/string/sparc/sparc64/strcpy.S +++ b/libc/string/sparc/sparc64/strcpy.S @@ -45,7 +45,7 @@ .text .align 32 -ENTRY(__strcpy) +ENTRY(strcpy) sethi %hi(0x01010101), %g1 /* IEU0 Group */ mov %o0, %g6 /* IEU1 */ or %g1, %lo(0x01010101), %g1 /* IEU0 Group */ @@ -240,6 +240,6 @@ ENTRY(__strcpy) stb %o4, [%o0 - 8] /* Store */ retl /* CTI+IEU1 Group */ mov %g6, %o0 /* IEU0 */ -END(__strcpy) +END(strcpy) -strong_alias(__strcpy,strcpy) +libc_hidden_def(strcpy) diff --git a/libc/string/sparc/sparc64/strlen.S b/libc/string/sparc/sparc64/strlen.S index 3c1cfc0d8..1fe854961 100644 --- a/libc/string/sparc/sparc64/strlen.S +++ b/libc/string/sparc/sparc64/strlen.S @@ -39,7 +39,7 @@ .text .align 32 -ENTRY(__strlen) +ENTRY(strlen) sethi %hi(0x01010101), %g1 /* IEU0 Group */ ldub [%o0], %o3 /* Load */ or %g1, %lo(0x01010101), %g1 /* IEU0 Group */ @@ -169,6 +169,5 @@ ENTRY(__strlen) add %o0, -1, %o0 /* IEU0 Group */ retl /* CTI+IEU1 Group */ sub %o0, %o1, %o0 /* IEU0 */ -END(__strlen) - -strong_alias(__strlen,strlen) +END(strlen) +libc_hidden_def(strlen) diff --git a/libc/string/sparc/strcmp.S b/libc/string/sparc/strcmp.S index f72ee4a14..556537ce3 100644 --- a/libc/string/sparc/strcmp.S +++ b/libc/string/sparc/strcmp.S @@ -11,3 +11,8 @@ #else # include "sparc64/strcmp.S" #endif + +#ifndef __UCLIBC_HAS_LOCALE__ +strong_alias(strcmp,strcoll) +libc_hidden_def(strcoll) +#endif diff --git a/libc/string/stpcpy.c b/libc/string/stpcpy.c index 540d04831..f34b9f65a 100644 --- a/libc/string/stpcpy.c +++ b/libc/string/stpcpy.c @@ -8,14 +8,13 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstpcpy __wcpcpy # define Wstpcpy wcpcpy #else -# define __Wstpcpy __stpcpy +libc_hidden_proto(stpcpy) # define Wstpcpy stpcpy #endif -Wchar attribute_hidden *__Wstpcpy(register Wchar * __restrict s1, const Wchar * __restrict s2) +Wchar *Wstpcpy(register Wchar * __restrict s1, const Wchar * __restrict s2) { #ifdef __BCC__ do { @@ -28,4 +27,6 @@ Wchar attribute_hidden *__Wstpcpy(register Wchar * __restrict s1, const Wchar * return s1 - 1; } -strong_alias(__Wstpcpy,Wstpcpy) +#ifndef WANT_WIDE +libc_hidden_def(stpcpy) +#endif diff --git a/libc/string/stpncpy.c b/libc/string/stpncpy.c index 5b45d0ef9..2603d2bd0 100644 --- a/libc/string/stpncpy.c +++ b/libc/string/stpncpy.c @@ -8,14 +8,13 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstpncpy __wcpncpy # define Wstpncpy wcpncpy #else -# define __Wstpncpy __stpncpy +libc_hidden_proto(stpncpy) # define Wstpncpy stpncpy #endif -Wchar attribute_hidden *__Wstpncpy(register Wchar * __restrict s1, +Wchar *Wstpncpy(register Wchar * __restrict s1, register const Wchar * __restrict s2, size_t n) { @@ -38,4 +37,6 @@ Wchar attribute_hidden *__Wstpncpy(register Wchar * __restrict s1, #endif } -strong_alias(__Wstpncpy,Wstpncpy) +#ifndef WANT_WIDE +libc_hidden_def(stpncpy) +#endif diff --git a/libc/string/strcasecmp.c b/libc/string/strcasecmp.c index 1d758e2ca..ac3f562a7 100644 --- a/libc/string/strcasecmp.c +++ b/libc/string/strcasecmp.c @@ -9,44 +9,44 @@ #include <ctype.h> #include <locale.h> -#ifdef __UCLIBC_HAS_XLOCALE__ -extern int __strcasecmp_l (__const char *__s1, __const char *__s2, - __locale_t __loc) - __THROW __attribute_pure__ __nonnull ((1, 2, 3)) attribute_hidden; -extern int __wcscasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2, - __locale_t __loc) __THROW attribute_hidden; -#endif - #ifdef WANT_WIDE # define strcasecmp wcscasecmp -# define __strcasecmp __wcscasecmp # define strcasecmp_l wcscasecmp_l -# define __strcasecmp_l __wcscasecmp_l # ifdef __UCLIBC_DO_XLOCALE -# define TOLOWER(C) __towlower_l((C), locale_arg) -extern wint_t __towlower_l (wint_t __wc, __locale_t __locale) __THROW attribute_hidden; +libc_hidden_proto(towlower_l) +# define TOLOWER(C) towlower_l((C), locale_arg) # else -# define TOLOWER(C) __towlower((C)) +libc_hidden_proto(towlower) +# define TOLOWER(C) towlower((C)) # endif #else # ifdef __UCLIBC_DO_XLOCALE -# define TOLOWER(C) __tolower_l((C), locale_arg) +libc_hidden_proto(tolower_l) +# define TOLOWER(C) tolower_l((C), locale_arg) # else -# define TOLOWER(C) __tolower((C)) +#ifndef __UCLIBC_HAS_XLOCALE__ +libc_hidden_proto(__ctype_tolower) +#endif +libc_hidden_proto(tolower) +# define TOLOWER(C) tolower((C)) # endif #endif #if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) -int attribute_hidden __strcasecmp(register const Wchar *s1, register const Wchar *s2) +libc_hidden_proto(strcasecmp_l) + +libc_hidden_proto(strcasecmp) +int strcasecmp(register const Wchar *s1, register const Wchar *s2) { - return __strcasecmp_l(s1, s2, __UCLIBC_CURLOCALE); + return strcasecmp_l(s1, s2, __UCLIBC_CURLOCALE); } -strong_alias(__strcasecmp,strcasecmp) +libc_hidden_def(strcasecmp) #else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */ -int attribute_hidden __UCXL(strcasecmp)(register const Wchar *s1, register const Wchar *s2 +libc_hidden_proto(__XL_NPP(strcasecmp)) +int __XL_NPP(strcasecmp)(register const Wchar *s1, register const Wchar *s2 __LOCALE_PARAM ) { #ifdef WANT_WIDE @@ -70,6 +70,6 @@ int attribute_hidden __UCXL(strcasecmp)(register const Wchar *s1, register const return r; #endif } -__UCXL_ALIAS(strcasecmp) +libc_hidden_def(__XL_NPP(strcasecmp)) #endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */ diff --git a/libc/string/strcasestr.c b/libc/string/strcasestr.c index 5222eda71..72c1e4702 100644 --- a/libc/string/strcasestr.c +++ b/libc/string/strcasestr.c @@ -8,7 +8,14 @@ #include "_string.h" #include <ctype.h> -char attribute_hidden *__strcasestr(const char *s1, const char *s2) +#ifndef __UCLIBC_HAS_XLOCALE__ +libc_hidden_proto(__ctype_tolower) +#else +libc_hidden_proto(__ctype_tolower_loc) +#endif +libc_hidden_proto(tolower) + +char *strcasestr(const char *s1, const char *s2) { register const char *s = s1; register const char *p = s2; @@ -19,7 +26,7 @@ char attribute_hidden *__strcasestr(const char *s1, const char *s2) return (char *) s1;; } if ((*p == *s) - || (__tolower(*((unsigned char *)p)) == __tolower(*((unsigned char *)s))) + || (tolower(*((unsigned char *)p)) == tolower(*((unsigned char *)s))) ) { ++p; ++s; @@ -34,7 +41,7 @@ char attribute_hidden *__strcasestr(const char *s1, const char *s2) #else while (*p && *s) { if ((*p == *s) - || (__tolower(*((unsigned char *)p)) == __tolower(*((unsigned char *)s))) + || (tolower(*((unsigned char *)p)) == tolower(*((unsigned char *)s))) ) { ++p; ++s; @@ -47,5 +54,3 @@ char attribute_hidden *__strcasestr(const char *s1, const char *s2) return (*p) ? NULL : (char *) s1; #endif } - -strong_alias(__strcasestr,strcasestr) diff --git a/libc/string/strcat.c b/libc/string/strcat.c index 5288f93ed..40a9be111 100644 --- a/libc/string/strcat.c +++ b/libc/string/strcat.c @@ -8,14 +8,14 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrcat __wcscat # define Wstrcat wcscat #else -# define __Wstrcat __strcat # define Wstrcat strcat #endif -Wchar attribute_hidden *__Wstrcat(Wchar * __restrict s1, register const Wchar * __restrict s2) +libc_hidden_proto(Wstrcat) + +Wchar *Wstrcat(Wchar * __restrict s1, register const Wchar * __restrict s2) { register Wchar *s = s1; @@ -25,5 +25,4 @@ Wchar attribute_hidden *__Wstrcat(Wchar * __restrict s1, register const Wchar * return s1; } - -strong_alias(__Wstrcat,Wstrcat) +libc_hidden_def(Wstrcat) diff --git a/libc/string/strchr.c b/libc/string/strchr.c index 93f394ab1..6bfd2077d 100644 --- a/libc/string/strchr.c +++ b/libc/string/strchr.c @@ -8,14 +8,14 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrchr __wcschr # define Wstrchr wcschr #else -# define __Wstrchr __strchr # define Wstrchr strchr #endif -Wchar attribute_hidden *__Wstrchr(register const Wchar *s, Wint c) +libc_hidden_proto(Wstrchr) + +Wchar *Wstrchr(register const Wchar *s, Wint c) { do { if (*s == ((Wchar)c)) { @@ -25,9 +25,8 @@ Wchar attribute_hidden *__Wstrchr(register const Wchar *s, Wint c) return NULL; } - -strong_alias(__Wstrchr,Wstrchr) +libc_hidden_def(Wstrchr) #ifndef WANT_WIDE -strong_alias(__strchr,index) +strong_alias(strchr,index) #endif diff --git a/libc/string/strchrnul.c b/libc/string/strchrnul.c index c498532fd..cc3883402 100644 --- a/libc/string/strchrnul.c +++ b/libc/string/strchrnul.c @@ -8,18 +8,17 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrchrnul __wcschrnul # define Wstrchrnul wcschrnul #else -# define __Wstrchrnul __strchrnul # define Wstrchrnul strchrnul #endif -Wchar attribute_hidden *__Wstrchrnul(register const Wchar *s, Wint c) +libc_hidden_proto(Wstrchrnul) + +Wchar *Wstrchrnul(register const Wchar *s, Wint c) { --s; while (*++s && (*s != ((Wchar)c))); return (Wchar *) s; } - -strong_alias(__Wstrchrnul,Wstrchrnul) +libc_hidden_def(Wstrchrnul) diff --git a/libc/string/strcmp.c b/libc/string/strcmp.c index 1fb8625ff..4a95ab882 100644 --- a/libc/string/strcmp.c +++ b/libc/string/strcmp.c @@ -8,14 +8,16 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrcmp __wcscmp # define Wstrcmp wcscmp +# define Wstrcoll wcscoll #else -# define __Wstrcmp __strcmp # define Wstrcmp strcmp +# define Wstrcoll strcoll #endif -int attribute_hidden __Wstrcmp(register const Wchar *s1, register const Wchar *s2) +libc_hidden_proto(Wstrcmp) + +int Wstrcmp(register const Wchar *s1, register const Wchar *s2) { #ifdef WANT_WIDE while (*((Wuchar *)s1) == *((Wuchar *)s2)) { @@ -35,15 +37,10 @@ int attribute_hidden __Wstrcmp(register const Wchar *s1, register const Wchar *s return r; #endif } - -strong_alias(__Wstrcmp,Wstrcmp) +libc_hidden_def(Wstrcmp) #ifndef __UCLIBC_HAS_LOCALE__ -# ifdef WANT_WIDE -hidden_strong_alias(__wcscmp,__wcscoll) -strong_alias(__wcscmp,wcscoll) -# else -hidden_strong_alias(__strcmp,__strcoll) -strong_alias(__strcmp,strcoll) -# endif +libc_hidden_proto(Wstrcoll) +strong_alias(Wstrcmp,Wstrcoll) +libc_hidden_def(Wstrcoll) #endif diff --git a/libc/string/strcpy.c b/libc/string/strcpy.c index 3b0e490eb..cda4094ac 100644 --- a/libc/string/strcpy.c +++ b/libc/string/strcpy.c @@ -8,14 +8,14 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrcpy __wcscpy # define Wstrcpy wcscpy #else -# define __Wstrcpy __strcpy # define Wstrcpy strcpy #endif -Wchar attribute_hidden *__Wstrcpy(Wchar * __restrict s1, const Wchar * __restrict s2) +libc_hidden_proto(Wstrcpy) + +Wchar *Wstrcpy(Wchar * __restrict s1, const Wchar * __restrict s2) { register Wchar *s = s1; @@ -29,5 +29,4 @@ Wchar attribute_hidden *__Wstrcpy(Wchar * __restrict s1, const Wchar * __restric return s1; } - -strong_alias(__Wstrcpy,Wstrcpy) +libc_hidden_def(Wstrcpy) diff --git a/libc/string/strcspn.c b/libc/string/strcspn.c index 7a709a77f..75d2e081b 100644 --- a/libc/string/strcspn.c +++ b/libc/string/strcspn.c @@ -8,14 +8,13 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrcspn __wcscspn # define Wstrcspn wcscspn #else -# define __Wstrcspn __strcspn +libc_hidden_proto(strcspn) # define Wstrcspn strcspn #endif -size_t attribute_hidden __Wstrcspn(const Wchar *s1, const Wchar *s2) +size_t Wstrcspn(const Wchar *s1, const Wchar *s2) { register const Wchar *s; register const Wchar *p; @@ -29,4 +28,6 @@ size_t attribute_hidden __Wstrcspn(const Wchar *s1, const Wchar *s2) return s - s1; } -strong_alias(__Wstrcspn,Wstrcspn) +#ifndef WANT_WIDE +libc_hidden_def(strcspn) +#endif diff --git a/libc/string/strdup.c b/libc/string/strdup.c index e2ccead9d..dff5af60a 100644 --- a/libc/string/strdup.c +++ b/libc/string/strdup.c @@ -9,18 +9,21 @@ #include <stdlib.h> #ifdef WANT_WIDE -# define __Wstrdup __wcsdup +libc_hidden_proto(wcslen) +libc_hidden_proto(wcscpy) # define Wstrdup wcsdup -# define Wstrlen __wcslen -# define Wstrcpy __wcscpy +# define Wstrlen wcslen +# define Wstrcpy wcscpy #else -# define __Wstrdup __strdup +libc_hidden_proto(strdup) +libc_hidden_proto(strlen) +libc_hidden_proto(strcpy) # define Wstrdup strdup -# define Wstrlen __strlen -# define Wstrcpy __strcpy +# define Wstrlen strlen +# define Wstrcpy strcpy #endif -Wchar attribute_hidden *__Wstrdup(register const Wchar *s1) +Wchar *Wstrdup(register const Wchar *s1) { register Wchar *s; @@ -31,4 +34,6 @@ Wchar attribute_hidden *__Wstrdup(register const Wchar *s1) return s; } -strong_alias(__Wstrdup,Wstrdup) +#ifndef WANT_WIDE +libc_hidden_def(strdup) +#endif diff --git a/libc/string/strerror.c b/libc/string/strerror.c index a2f1f4833..1b5cb3ff2 100644 --- a/libc/string/strerror.c +++ b/libc/string/strerror.c @@ -9,13 +9,15 @@ #include <string.h> #include "_syserrmsg.h" -char attribute_hidden *__strerror(int errnum) +libc_hidden_proto(strerror) +libc_hidden_proto(__xpg_strerror_r) + +char *strerror(int errnum) { static char buf[_STRERROR_BUFSIZE]; - __xpg_strerror_r_internal(errnum, buf, sizeof(buf)); + __xpg_strerror_r(errnum, buf, sizeof(buf)); return buf; } - -strong_alias(__strerror,strerror) +libc_hidden_def(strerror) diff --git a/libc/string/strlcpy.c b/libc/string/strlcpy.c index 3920db083..e888b85b2 100644 --- a/libc/string/strlcpy.c +++ b/libc/string/strlcpy.c @@ -8,18 +8,25 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrlcpy __wcslcpy -# define Wstrlcpy wcslcpy +# define Wstrlcpy __wcslcpy +# define Wstrxfrm wcsxfrm #else -# define __Wstrlcpy __strlcpy +libc_hidden_proto(strlcpy) # 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. */ -size_t attribute_hidden __Wstrlcpy(register Wchar *__restrict dst, +#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) { @@ -42,15 +49,15 @@ size_t attribute_hidden __Wstrlcpy(register Wchar *__restrict dst, return src - src0; } - -strong_alias(__Wstrlcpy,Wstrlcpy) - +#ifndef WANT_WIDE +libc_hidden_def(strlcpy) +#ifndef __UCLIBC_HAS_LOCALE__ +libc_hidden_proto(strxfrm) +strong_alias(strlcpy,strxfrm) +libc_hidden_def(strxfrm) +#endif +#else #ifndef __UCLIBC_HAS_LOCALE__ -# ifdef WANT_WIDE -hidden_strong_alias(__wcslcpy,__wcsxfrm) strong_alias(__wcslcpy,wcsxfrm) -# else -hidden_strong_alias(__strlcpy,__strxfrm) -strong_alias(__strlcpy,strxfrm) -# endif +#endif #endif diff --git a/libc/string/strlen.c b/libc/string/strlen.c index 27cd8481c..bcb096b97 100644 --- a/libc/string/strlen.c +++ b/libc/string/strlen.c @@ -8,14 +8,14 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrlen __wcslen # define Wstrlen wcslen #else -# define __Wstrlen __strlen # define Wstrlen strlen #endif -size_t attribute_hidden __Wstrlen(const Wchar *s) +libc_hidden_proto(Wstrlen) + +size_t Wstrlen(const Wchar *s) { register const Wchar *p; @@ -23,5 +23,4 @@ size_t attribute_hidden __Wstrlen(const Wchar *s) return p - s; } - -strong_alias(__Wstrlen,Wstrlen) +libc_hidden_def(Wstrlen) diff --git a/libc/string/strncasecmp.c b/libc/string/strncasecmp.c index bfc865a8c..54de1b78c 100644 --- a/libc/string/strncasecmp.c +++ b/libc/string/strncasecmp.c @@ -9,44 +9,44 @@ #include <ctype.h> #include <locale.h> -#ifdef __UCLIBC_HAS_XLOCALE__ -extern int __strncasecmp_l (__const char *__s1, __const char *__s2, - size_t __n, __locale_t __loc) - __THROW __attribute_pure__ __nonnull ((1, 2, 4)) attribute_hidden; -extern int __wcsncasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2, - size_t __n, __locale_t __loc) __THROW attribute_hidden; -#endif - #ifdef WANT_WIDE # define strncasecmp wcsncasecmp -# define __strncasecmp __wcsncasecmp # define strncasecmp_l wcsncasecmp_l -# define __strncasecmp_l __wcsncasecmp_l # ifdef __UCLIBC_DO_XLOCALE -# define TOLOWER(C) __towlower_l((C), locale_arg) -extern wint_t __towlower_l (wint_t __wc, __locale_t __locale) __THROW attribute_hidden; +libc_hidden_proto(towlower_l) +# define TOLOWER(C) towlower_l((C), locale_arg) # else -# define TOLOWER(C) __towlower((C)) +libc_hidden_proto(towlower) +# define TOLOWER(C) towlower((C)) # endif #else # ifdef __UCLIBC_DO_XLOCALE -# define TOLOWER(C) __tolower_l((C), locale_arg) +libc_hidden_proto(tolower_l) +# define TOLOWER(C) tolower_l((C), locale_arg) # else -# define TOLOWER(C) __tolower((C)) +#ifndef __UCLIBC_HAS_XLOCALE__ +libc_hidden_proto(__ctype_tolower) +#endif +libc_hidden_proto(tolower) +# define TOLOWER(C) tolower((C)) # endif #endif #if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) -int attribute_hidden __strncasecmp(register const Wchar *s1, register const Wchar *s2, size_t n) +libc_hidden_proto(strncasecmp_l) + +libc_hidden_proto(strncasecmp) +int strncasecmp(register const Wchar *s1, register const Wchar *s2, size_t n) { - return __strncasecmp_l(s1, s2, n, __UCLIBC_CURLOCALE); + return strncasecmp_l(s1, s2, n, __UCLIBC_CURLOCALE); } -strong_alias(__strncasecmp,strncasecmp) +libc_hidden_def(strncasecmp) #else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */ -int attribute_hidden __UCXL(strncasecmp)(register const Wchar *s1, register const Wchar *s2, +libc_hidden_proto(__XL_NPP(strncasecmp)) +int __XL_NPP(strncasecmp)(register const Wchar *s1, register const Wchar *s2, size_t n __LOCALE_PARAM ) { #ifdef WANT_WIDE @@ -73,6 +73,6 @@ int attribute_hidden __UCXL(strncasecmp)(register const Wchar *s1, register cons return r; #endif } -__UCXL_ALIAS(strncasecmp) +libc_hidden_def(__XL_NPP(strncasecmp)) #endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */ diff --git a/libc/string/strncat.c b/libc/string/strncat.c index 20fbcfa27..61170c369 100644 --- a/libc/string/strncat.c +++ b/libc/string/strncat.c @@ -8,14 +8,13 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrncat __wcsncat # define Wstrncat wcsncat #else -# define __Wstrncat __strncat +libc_hidden_proto(strncat) # define Wstrncat strncat #endif -Wchar attribute_hidden *__Wstrncat(Wchar * __restrict s1, register const Wchar * __restrict s2, +Wchar *Wstrncat(Wchar * __restrict s1, register const Wchar * __restrict s2, size_t n) { register Wchar *s = s1; @@ -35,4 +34,6 @@ Wchar attribute_hidden *__Wstrncat(Wchar * __restrict s1, register const Wchar * return s1; } -strong_alias(__Wstrncat,Wstrncat) +#ifndef WANT_WIDE +libc_hidden_def(strncat) +#endif diff --git a/libc/string/strncmp.c b/libc/string/strncmp.c index ad80ce8e5..7305cbaa5 100644 --- a/libc/string/strncmp.c +++ b/libc/string/strncmp.c @@ -8,14 +8,13 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrncmp __wcsncmp # define Wstrncmp wcsncmp #else -# define __Wstrncmp __strncmp +libc_hidden_proto(strncmp) # define Wstrncmp strncmp #endif -int attribute_hidden __Wstrncmp(register const Wchar *s1, register const Wchar *s2, size_t n) +int Wstrncmp(register const Wchar *s1, register const Wchar *s2, size_t n) { #ifdef WANT_WIDE while (n && (*((Wuchar *)s1) == *((Wuchar *)s2))) { @@ -38,5 +37,6 @@ int attribute_hidden __Wstrncmp(register const Wchar *s1, register const Wchar * return r; #endif } - -strong_alias(__Wstrncmp,Wstrncmp) +#ifndef WANT_WIDE +libc_hidden_def(strncmp) +#endif diff --git a/libc/string/strncpy.c b/libc/string/strncpy.c index 09124ac99..40da93dac 100644 --- a/libc/string/strncpy.c +++ b/libc/string/strncpy.c @@ -8,14 +8,13 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrncpy __wcsncpy # define Wstrncpy wcsncpy #else -# define __Wstrncpy __strncpy +libc_hidden_proto(strncpy) # define Wstrncpy strncpy #endif -Wchar attribute_hidden *__Wstrncpy(Wchar * __restrict s1, register const Wchar * __restrict s2, +Wchar *Wstrncpy(Wchar * __restrict s1, register const Wchar * __restrict s2, size_t n) { register Wchar *s = s1; @@ -35,5 +34,6 @@ Wchar attribute_hidden *__Wstrncpy(Wchar * __restrict s1, register const Wchar * return s1; } - -strong_alias(__Wstrncpy,Wstrncpy) +#ifndef WANT_WIDE +libc_hidden_def(strncpy) +#endif diff --git a/libc/string/strndup.c b/libc/string/strndup.c index 5cee0272d..89c58ccec 100644 --- a/libc/string/strndup.c +++ b/libc/string/strndup.c @@ -8,18 +8,21 @@ #include "_string.h" #include <stdlib.h> -char attribute_hidden *__strndup(register const char *s1, size_t n) +libc_hidden_proto(strndup) +libc_hidden_proto(strnlen) +libc_hidden_proto(memcpy) + +char *strndup(register const char *s1, size_t n) { register char *s; - n = __strnlen(s1,n); /* Avoid problems if s1 not nul-terminated. */ + n = strnlen(s1,n); /* Avoid problems if s1 not nul-terminated. */ if ((s = malloc(n + 1)) != NULL) { - __memcpy(s, s1, n); + memcpy(s, s1, n); s[n] = 0; } return s; } - -strong_alias(__strndup,strndup) +libc_hidden_def(strndup) diff --git a/libc/string/strnlen.c b/libc/string/strnlen.c index 6732cc532..547dd23b2 100644 --- a/libc/string/strnlen.c +++ b/libc/string/strnlen.c @@ -8,14 +8,14 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrnlen __wcsnlen # define Wstrnlen wcsnlen #else -# define __Wstrnlen __strnlen # define Wstrnlen strnlen #endif -size_t attribute_hidden __Wstrnlen(const Wchar *s, size_t max) +libc_hidden_proto(Wstrnlen) + +size_t Wstrnlen(const Wchar *s, size_t max) { register const Wchar *p = s; #ifdef __BCC__ @@ -34,4 +34,4 @@ size_t attribute_hidden __Wstrnlen(const Wchar *s, size_t max) } #undef maxp -strong_alias(__Wstrnlen,Wstrnlen) +libc_hidden_def(Wstrnlen) diff --git a/libc/string/strpbrk.c b/libc/string/strpbrk.c index 704b1bc71..abeb84380 100644 --- a/libc/string/strpbrk.c +++ b/libc/string/strpbrk.c @@ -8,14 +8,14 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrpbrk __wcspbrk # define Wstrpbrk wcspbrk #else -# define __Wstrpbrk __strpbrk # define Wstrpbrk strpbrk #endif -Wchar attribute_hidden *__Wstrpbrk(const Wchar *s1, const Wchar *s2) +libc_hidden_proto(Wstrpbrk) + +Wchar *Wstrpbrk(const Wchar *s1, const Wchar *s2) { register const Wchar *s; register const Wchar *p; @@ -27,5 +27,4 @@ Wchar attribute_hidden *__Wstrpbrk(const Wchar *s1, const Wchar *s2) } return NULL; } - -strong_alias(__Wstrpbrk,Wstrpbrk) +libc_hidden_def(Wstrpbrk) diff --git a/libc/string/strrchr.c b/libc/string/strrchr.c index cb30afea7..8a9184f9f 100644 --- a/libc/string/strrchr.c +++ b/libc/string/strrchr.c @@ -8,14 +8,13 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrrchr __wcsrchr # define Wstrrchr wcsrchr #else -# define __Wstrrchr __strrchr +libc_hidden_proto(strrchr) # define Wstrrchr strrchr #endif -Wchar attribute_hidden *__Wstrrchr(register const Wchar *s, Wint c) +Wchar *Wstrrchr(register const Wchar *s, Wint c) { register const Wchar *p; @@ -28,8 +27,7 @@ Wchar attribute_hidden *__Wstrrchr(register const Wchar *s, Wint c) return (Wchar *) p; /* silence the warning */ } - -strong_alias(__Wstrrchr,Wstrrchr) #ifndef WANT_WIDE -strong_alias(__strrchr,rindex) +libc_hidden_def(strrchr) +strong_alias(strrchr,rindex) #endif diff --git a/libc/string/strsep.c b/libc/string/strsep.c index 993fafecb..7f421891e 100644 --- a/libc/string/strsep.c +++ b/libc/string/strsep.c @@ -7,18 +7,22 @@ #include "_string.h" -char attribute_hidden *__strsep(char ** __restrict s1, const char * __restrict s2) +libc_hidden_proto(strsep) +libc_hidden_proto(strpbrk) +libc_hidden_proto(strcspn) + +char *strsep(char ** __restrict s1, const char * __restrict s2) { register char *s = *s1; register char *p; #if 1 p = NULL; - if (s && *s && (p = __strpbrk(s, s2))) { + if (s && *s && (p = strpbrk(s, s2))) { *p++ = 0; } #else - if (s && *s && *(p = s + __strcspn(s, s2))) { + if (s && *s && *(p = s + strcspn(s, s2))) { *p++ = 0; } else { p = NULL; @@ -27,5 +31,4 @@ char attribute_hidden *__strsep(char ** __restrict s1, const char * __restrict s *s1 = p; return s; } - -strong_alias(__strsep,strsep) +libc_hidden_def(strsep) diff --git a/libc/string/strsignal.c b/libc/string/strsignal.c index 7d7f613fe..f8b6a9e9f 100644 --- a/libc/string/strsignal.c +++ b/libc/string/strsignal.c @@ -13,12 +13,14 @@ /* TODO: make a threadsafe version? */ -#define _GNU_SOURCE #include <features.h> #include <string.h> #include <bits/uClibc_uintmaxtostr.h> #include <signal.h> +libc_hidden_proto(strsignal) +libc_hidden_proto(memcpy) + #define _SYS_NSIG 32 #ifdef __UCLIBC_HAS_SIGNUM_MESSAGES__ @@ -35,7 +37,7 @@ #ifdef __UCLIBC_HAS_SIGNUM_MESSAGES__ -extern const char _string_syssigmsgs[]; +extern const char _string_syssigmsgs[] attribute_hidden; #if defined(__alpha__) || defined(__mips__) || defined(__hppa__) || defined(__sparc__) static const unsigned char sstridx[] = { @@ -55,10 +57,10 @@ static const unsigned char sstridx[] = { SIGPIPE, SIGALRM, SIGTERM, -#if defined(__alpha__) || defined(__mips__) || defined(__sparc__) - 0, -#else +#if defined SIGSTKFLT SIGSTKFLT, +#else + 0, #endif SIGCHLD, SIGCONT, @@ -75,13 +77,13 @@ static const unsigned char sstridx[] = { SIGIO, SIGPWR, SIGSYS, -#if defined(__alpha__) || defined(__mips__) || defined(__hppa__) || defined(__sparc__) +#if defined SIGEMT SIGEMT, #endif }; #endif -char attribute_hidden *__strsignal(int signum) +char *strsignal(int signum) { register char *s; int i; @@ -120,7 +122,7 @@ char attribute_hidden *__strsignal(int signum) } s = _int10tostr(buf+sizeof(buf)-1, signum) - sizeof(unknown); - __memcpy(s, unknown, sizeof(unknown)); + memcpy(s, unknown, sizeof(unknown)); DONE: return s; @@ -128,18 +130,18 @@ char attribute_hidden *__strsignal(int signum) #else /* __UCLIBC_HAS_SIGNUM_MESSAGES__ */ -char attribute_hidden *__strsignal(int signum) +char *strsignal(int signum) { static char buf[_STRSIGNAL_BUFSIZE]; static const char unknown[] = { 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 's', 'i', 'g', 'n', 'a', 'l', ' ' }; - return (char *) __memcpy(_int10tostr(buf+sizeof(buf)-1, signum) + return (char *) memcpy(_int10tostr(buf+sizeof(buf)-1, signum) - sizeof(unknown), unknown, sizeof(unknown)); } #endif /* __UCLIBC_HAS_SIGNUM_MESSAGES__ */ -strong_alias(__strsignal,strsignal) +libc_hidden_def(strsignal) diff --git a/libc/string/strspn.c b/libc/string/strspn.c index 9074c13ad..ca83ef900 100644 --- a/libc/string/strspn.c +++ b/libc/string/strspn.c @@ -8,14 +8,14 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrspn __wcsspn # define Wstrspn wcsspn #else -# define __Wstrspn __strspn # define Wstrspn strspn #endif -size_t attribute_hidden __Wstrspn(const Wchar *s1, const Wchar *s2) +libc_hidden_proto(Wstrspn) + +size_t Wstrspn(const Wchar *s1, const Wchar *s2) { register const Wchar *s = s1; register const Wchar *p = s2; @@ -28,5 +28,4 @@ size_t attribute_hidden __Wstrspn(const Wchar *s1, const Wchar *s2) } return s - s1; } - -strong_alias(__Wstrspn,Wstrspn) +libc_hidden_def(Wstrspn) diff --git a/libc/string/strstr.c b/libc/string/strstr.c index 7256b9da2..685a2f83c 100644 --- a/libc/string/strstr.c +++ b/libc/string/strstr.c @@ -8,16 +8,15 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrstr __wcsstr # define Wstrstr wcsstr #else -# define __Wstrstr __strstr +libc_hidden_proto(strstr) # define Wstrstr strstr #endif /* NOTE: This is the simple-minded O(len(s1) * len(s2)) worst-case approach. */ -Wchar attribute_hidden *__Wstrstr(const Wchar *s1, const Wchar *s2) +Wchar *Wstrstr(const Wchar *s1, const Wchar *s2) { register const Wchar *s = s1; register const Wchar *p = s2; @@ -38,8 +37,8 @@ Wchar attribute_hidden *__Wstrstr(const Wchar *s1, const Wchar *s2) } } while (1); } - -strong_alias(__Wstrstr,Wstrstr) -#ifdef WANT_WIDE -strong_alias(__wcsstr,wcswcs) +#ifndef WANT_WIDE +libc_hidden_def(strstr) +#else +strong_alias(wcsstr,wcswcs) #endif diff --git a/libc/string/strtok.c b/libc/string/strtok.c index 4b8aef6b5..127497c9d 100644 --- a/libc/string/strtok.c +++ b/libc/string/strtok.c @@ -9,12 +9,14 @@ #if 0 /*def WANT_WIDE*/ # define Wstrtok wcstok -# define Wstrtok_r __wcstok_r +# define Wstrtok_r wcstok_r #else # define Wstrtok strtok -# define Wstrtok_r __strtok_r +# define Wstrtok_r strtok_r #endif +libc_hidden_proto(Wstrtok_r) + Wchar *Wstrtok(Wchar * __restrict s1, const Wchar * __restrict s2) { static Wchar *next_start; /* Initialized to 0 since in bss. */ diff --git a/libc/string/strtok_r.c b/libc/string/strtok_r.c index c8ba588eb..bda56d71c 100644 --- a/libc/string/strtok_r.c +++ b/libc/string/strtok_r.c @@ -8,18 +8,21 @@ #include "_string.h" #ifdef WANT_WIDE -# define __Wstrtok_r __wcstok +libc_hidden_proto(wcsspn) +libc_hidden_proto(wcspbrk) # define Wstrtok_r wcstok -# define Wstrspn __wcsspn -# define Wstrpbrk __wcspbrk +# define Wstrspn wcsspn +# define Wstrpbrk wcspbrk #else -# define __Wstrtok_r __strtok_r +libc_hidden_proto(strtok_r) +libc_hidden_proto(strspn) +libc_hidden_proto(strpbrk) # define Wstrtok_r strtok_r -# define Wstrspn __strspn -# define Wstrpbrk __strpbrk +# define Wstrspn strspn +# define Wstrpbrk strpbrk #endif -Wchar attribute_hidden *__Wstrtok_r(Wchar * __restrict s1, const Wchar * __restrict s2, +Wchar *Wstrtok_r(Wchar * __restrict s1, const Wchar * __restrict s2, Wchar ** __restrict next_start) { register Wchar *s; @@ -52,4 +55,6 @@ Wchar attribute_hidden *__Wstrtok_r(Wchar * __restrict s1, const Wchar * __restr #endif } -strong_alias(__Wstrtok_r,Wstrtok_r) +#ifndef WANT_WIDE +libc_hidden_def(strtok_r) +#endif diff --git a/libc/string/sys_errlist.c b/libc/string/sys_errlist.c index a0b5e3b2f..17ed4d62c 100644 --- a/libc/string/sys_errlist.c +++ b/libc/string/sys_errlist.c @@ -8,7 +8,7 @@ #include <features.h> #include <errno.h> -extern const char _string_syserrmsgs[]; +extern const char _string_syserrmsgs[] attribute_hidden; #ifdef __UCLIBC_HAS_SYS_ERRLIST__ diff --git a/libc/string/sys_siglist.c b/libc/string/sys_siglist.c index 9337d00a9..844337536 100644 --- a/libc/string/sys_siglist.c +++ b/libc/string/sys_siglist.c @@ -10,7 +10,7 @@ #include <stddef.h> #include <signal.h> -extern const char _string_syssigmsgs[]; +extern const char _string_syssigmsgs[] attribute_hidden; #ifdef __UCLIBC_HAS_SYS_SIGLIST__ @@ -31,7 +31,7 @@ const char *const sys_siglist[_NSIG] = { [SIGPIPE] = _string_syssigmsgs + 178, [SIGALRM] = _string_syssigmsgs + 190, [SIGTERM] = _string_syssigmsgs + 202, -#if !(defined(__alpha__) || defined(__mips__) || defined(__sparc__)) +#if defined SIGSTKFLT /* not all arches define this, yeah ! */ [SIGSTKFLT] = _string_syssigmsgs + 213, #endif [SIGCHLD] = _string_syssigmsgs + 225, @@ -49,7 +49,7 @@ const char *const sys_siglist[_NSIG] = { [SIGIO] = _string_syssigmsgs + 445, [SIGPWR] = _string_syssigmsgs + 458, [SIGSYS] = _string_syssigmsgs + 472, -#if defined(__alpha__) || defined(__mips__) || defined(__hppa__) || defined(__sparc__) +#if defined SIGEMT /* only some arches define this, yeah ! */ [SIGEMT] = _string_syssigmsgs + 488, #endif }; diff --git a/libc/string/x86_64/Makefile b/libc/string/x86_64/Makefile index ac0063770..0a95346fd 100644 --- a/libc/string/x86_64/Makefile +++ b/libc/string/x86_64/Makefile @@ -5,9 +5,9 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -top_srcdir=../../../ -top_builddir=../../../ +top_srcdir:=../../../ +top_builddir:=../../../ all: objs include $(top_builddir)Rules.mak -include Makefile.arch +include ../Makefile.in include $(top_srcdir)Makerules diff --git a/libc/string/x86_64/Makefile.arch b/libc/string/x86_64/Makefile.arch deleted file mode 100644 index 56e5a5165..000000000 --- a/libc/string/x86_64/Makefile.arch +++ /dev/null @@ -1,28 +0,0 @@ -# Makefile for uClibc -# -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> -# -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. -# - -STRING_ARCH_DIR:=$(top_srcdir)libc/string/x86_64 -STRING_ARCH_OUT:=$(top_builddir)libc/string/x86_64 - -STRING_ARCH_SRC:=$(wildcard $(STRING_ARCH_DIR)/*.c) -STRING_ARCH_OBJ:=$(patsubst $(STRING_ARCH_DIR)/%.c,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SRC)) - -STRING_ARCH_SSRC:=$(wildcard $(STRING_ARCH_DIR)/*.S) -STRING_ARCH_SOBJ:=$(patsubst $(STRING_ARCH_DIR)/%.S,$(STRING_ARCH_OUT)/%.o,$(STRING_ARCH_SSRC)) - -STRING_ARCH_OBJS:=$(STRING_ARCH_OBJ) $(STRING_ARCH_SOBJ) - -libc-a-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS) -libc-so-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_OBJS:.o=.os) - -libc-multi-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_SRC) -libc-nomulti-$(UCLIBC_HAS_STRING_ARCH_OPT)+=$(STRING_ARCH_SOBJ) - -objclean-y+=string_x86_64_objclean - -string_x86_64_objclean: - $(RM) $(STRING_ARCH_OUT)/*.{o,os} diff --git a/libc/string/x86_64/_glibc_inc.h b/libc/string/x86_64/_glibc_inc.h index 3c31957db..88cef2ea3 100644 --- a/libc/string/x86_64/_glibc_inc.h +++ b/libc/string/x86_64/_glibc_inc.h @@ -14,7 +14,6 @@ #define ENTRY(sym) \ .global sym; \ - .hidden sym; \ .align ENTRY_ALIGN; \ .type sym,%function; \ sym: diff --git a/libc/string/x86_64/bzero.S b/libc/string/x86_64/bzero.S index 73ba75436..b6e41fb0f 100644 --- a/libc/string/x86_64/bzero.S +++ b/libc/string/x86_64/bzero.S @@ -1,3 +1,2 @@ -#define __memset __bzero +#define memset bzero #include "memset.S" -strong_alias(__bzero,bzero) diff --git a/libc/string/x86_64/memcpy.S b/libc/string/x86_64/memcpy.S index 973cd513f..b3bb0f96c 100644 --- a/libc/string/x86_64/memcpy.S +++ b/libc/string/x86_64/memcpy.S @@ -23,7 +23,7 @@ /* BEWARE: `#ifdef memcpy' means that memcpy is redefined as `mempcpy', and the return value is the byte after the last one copied in the destination. */ -#define MEMPCPY_P (defined __memcpy) +#define MEMPCPY_P (defined memcpy) .text #if defined PIC && !defined NOT_IN_libc @@ -32,7 +32,7 @@ ENTRY (__memcpy_chk) jb HIDDEN_JUMPTARGET (__chk_fail) END (__memcpy_chk) #endif -ENTRY (BP_SYM (__memcpy)) +ENTRY (BP_SYM (memcpy)) /* Cutoff for the big loop is a size of 32 bytes since otherwise the loop will never be entered. */ cmpq $32, %rdx @@ -92,7 +92,7 @@ ENTRY (BP_SYM (__memcpy)) #endif ret -END (BP_SYM (__memcpy)) +END (BP_SYM (memcpy)) #if !MEMPCPY_P -strong_alias(__memcpy,memcpy) +libc_hidden_def(memcpy) #endif diff --git a/libc/string/x86_64/mempcpy.S b/libc/string/x86_64/mempcpy.S index 3a8e925fd..3816d9f72 100644 --- a/libc/string/x86_64/mempcpy.S +++ b/libc/string/x86_64/mempcpy.S @@ -1,3 +1,3 @@ -#define __memcpy __mempcpy +#define memcpy mempcpy #include "memcpy.S" -strong_alias(__mempcpy,mempcpy) +libc_hidden_def(mempcpy) diff --git a/libc/string/x86_64/memset.S b/libc/string/x86_64/memset.S index 923e1c208..d72d74468 100644 --- a/libc/string/x86_64/memset.S +++ b/libc/string/x86_64/memset.S @@ -22,7 +22,7 @@ #include "_glibc_inc.h" /* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */ -#define BZERO_P (defined __memset) +#define BZERO_P (defined memset) /* This is somehow experimental and could made dependend on the cache size. */ @@ -35,7 +35,7 @@ ENTRY (__memset_chk) jb HIDDEN_JUMPTARGET (__chk_fail) END (__memset_chk) #endif -ENTRY (__memset) +ENTRY (memset) #if BZERO_P mov %rsi,%rdx /* Adjust parameter. */ xorl %esi,%esi /* Fill with 0s. */ @@ -131,9 +131,9 @@ ENTRY (__memset) jne 11b jmp 4b -END (__memset) +END (memset) #if !BZERO_P -strong_alias(__memset,memset) +libc_hidden_def(memset) #endif #if !BZERO_P && defined PIC && !defined NOT_IN_libc diff --git a/libc/string/x86_64/stpcpy.S b/libc/string/x86_64/stpcpy.S index 075773371..138d0fb17 100644 --- a/libc/string/x86_64/stpcpy.S +++ b/libc/string/x86_64/stpcpy.S @@ -1,4 +1,4 @@ #define USE_AS_STPCPY -#define STRCPY __stpcpy +#define STRCPY stpcpy #include "strcpy.S" -strong_alias(__stpcpy,stpcpy) +libc_hidden_def(stpcpy) diff --git a/libc/string/x86_64/strcat.S b/libc/string/x86_64/strcat.S index 6c7189a21..9b0068981 100644 --- a/libc/string/x86_64/strcat.S +++ b/libc/string/x86_64/strcat.S @@ -23,7 +23,7 @@ .text -ENTRY (BP_SYM (__strcat)) +ENTRY (BP_SYM (strcat)) movq %rdi, %rcx /* Dest. register. */ andl $7, %ecx /* mask alignment bits */ movq %rdi, %rax /* Duplicate destination pointer. */ @@ -253,6 +253,6 @@ ENTRY (BP_SYM (__strcat)) 24: movq %rdi, %rax /* Source is return value. */ retq -END (BP_SYM (__strcat)) +END (BP_SYM (strcat)) -strong_alias(__strcat,strcat) +libc_hidden_def(strcat) diff --git a/libc/string/x86_64/strchr.S b/libc/string/x86_64/strchr.S index 312d62b61..6f6635a39 100644 --- a/libc/string/x86_64/strchr.S +++ b/libc/string/x86_64/strchr.S @@ -22,7 +22,7 @@ .text -ENTRY (BP_SYM (__strchr)) +ENTRY (BP_SYM (strchr)) /* Before we start with the main loop we process single bytes until the source pointer is aligned. This has two reasons: @@ -282,7 +282,7 @@ ENTRY (BP_SYM (__strchr)) 6: nop retq -END (BP_SYM (__strchr)) +END (BP_SYM (strchr)) -strong_alias(__strchr,strchr) -strong_alias (BP_SYM (__strchr), BP_SYM (index)) +libc_hidden_def(strchr) +strong_alias (BP_SYM (strchr), BP_SYM (index)) diff --git a/libc/string/x86_64/strcmp.S b/libc/string/x86_64/strcmp.S index 1eaff1691..437e145bf 100644 --- a/libc/string/x86_64/strcmp.S +++ b/libc/string/x86_64/strcmp.S @@ -22,7 +22,7 @@ #include "_glibc_inc.h" .text -ENTRY (BP_SYM (__strcmp)) +ENTRY (BP_SYM (strcmp)) L(oop): movb (%rdi), %al cmpb (%rsi), %al jne L(neq) @@ -38,6 +38,10 @@ L(neq): movl $1, %eax movl $-1, %ecx cmovbl %ecx, %eax ret -END (BP_SYM (__strcmp)) +END (BP_SYM (strcmp)) -strong_alias(__strcmp,strcmp) +libc_hidden_def(strcmp) +#ifndef __UCLIBC_HAS_LOCALE__ +strong_alias(strcmp,strcoll) +libc_hidden_def(strcoll) +#endif diff --git a/libc/string/x86_64/strcpy.S b/libc/string/x86_64/strcpy.S index 0bd2a6471..d9a51b0bb 100644 --- a/libc/string/x86_64/strcpy.S +++ b/libc/string/x86_64/strcpy.S @@ -21,7 +21,7 @@ #include "_glibc_inc.h" #ifndef USE_AS_STPCPY -# define STRCPY __strcpy +# define STRCPY strcpy #endif .text @@ -152,5 +152,5 @@ ENTRY (BP_SYM (STRCPY)) retq END (BP_SYM (STRCPY)) #ifndef USE_AS_STPCPY -strong_alias(__strcpy,strcpy) +libc_hidden_def(strcpy) #endif diff --git a/libc/string/x86_64/strcspn.S b/libc/string/x86_64/strcspn.S index 35959e500..fed12b5f6 100644 --- a/libc/string/x86_64/strcspn.S +++ b/libc/string/x86_64/strcspn.S @@ -26,10 +26,10 @@ #include "_glibc_inc.h" /* BEWARE: `#ifdef strcspn' means that strcspn is redefined as `strpbrk' */ -#define STRPBRK_P (defined __strcspn) +#define STRPBRK_P (defined strcspn) .text -ENTRY (__strcspn) +ENTRY (strcspn) movq %rdi, %rdx /* Save SRC. */ @@ -120,8 +120,8 @@ L(4): addq $256, %rsp /* remove skipset */ non-valid character */ #endif ret -END (__strcspn) +END (strcspn) #if !STRPBRK_P -strong_alias(__strcspn,strcspn) +libc_hidden_def(strcspn) #endif diff --git a/libc/string/x86_64/strlen.S b/libc/string/x86_64/strlen.S index 77aae71ba..0441dc46c 100644 --- a/libc/string/x86_64/strlen.S +++ b/libc/string/x86_64/strlen.S @@ -22,7 +22,7 @@ .text -ENTRY (__strlen) +ENTRY (strlen) movq %rdi, %rcx /* Duplicate source pointer. */ andl $7, %ecx /* mask alignment bits */ movq %rdi, %rax /* duplicate destination. */ @@ -132,6 +132,6 @@ ENTRY (__strlen) 2: subq %rdi, %rax /* compute difference to string start */ ret -END (__strlen) +END (strlen) -strong_alias(__strlen,strlen) +libc_hidden_def(strlen) diff --git a/libc/string/x86_64/strpbrk.S b/libc/string/x86_64/strpbrk.S index 94b14d091..db6cc24c7 100644 --- a/libc/string/x86_64/strpbrk.S +++ b/libc/string/x86_64/strpbrk.S @@ -1,3 +1,3 @@ -#define __strcspn __strpbrk +#define strcspn strpbrk #include "strcspn.S" -strong_alias(__strpbrk,strpbrk) +libc_hidden_def(strpbrk) diff --git a/libc/string/x86_64/strspn.S b/libc/string/x86_64/strspn.S index ae5b4a1df..c126abd2e 100644 --- a/libc/string/x86_64/strspn.S +++ b/libc/string/x86_64/strspn.S @@ -26,7 +26,7 @@ #include "_glibc_inc.h" .text -ENTRY (__strspn) +ENTRY (strspn) movq %rdi, %rdx /* Save SRC. */ @@ -111,6 +111,6 @@ L(4): addq $256, %rsp /* remove stopset */ characters, so compute distance to first non-valid character */ ret -END (__strspn) +END (strspn) -strong_alias(__strspn,strspn) +libc_hidden_def(strspn) |