Merge "riscv64: fix ODR violations." into main am: 0db95a4f23

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2808261

Change-Id: If1afa07f816ff4111a4ebbdb6015c9a1f2e4b582
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Elliott Hughes 2023-10-30 15:04:32 +00:00 committed by Automerger Merge Worker
commit 7cbe1fad9d
27 changed files with 112 additions and 888 deletions

View file

@ -136,6 +136,8 @@ cc_defaults {
},
apex_available: ["com.android.runtime"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
}
libc_scudo_product_variables = {
@ -251,7 +253,6 @@ cc_library_static {
cc_library_static {
defaults: ["libc_defaults"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"tzcode/**/*.c",
"tzcode/bionic.cpp",
@ -302,7 +303,6 @@ cc_library_static {
cc_library_static {
defaults: ["libc_defaults"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"dns/**/*.c*",
@ -345,7 +345,6 @@ cc_library_static {
cc_library_static {
defaults: ["libc_defaults"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-freebsd/lib/libc/stdlib/getopt_long.c",
"upstream-freebsd/lib/libc/stdlib/hcreate.c",
@ -411,7 +410,6 @@ cc_library_static {
cc_library_static {
defaults: ["libc_defaults"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-freebsd/lib/libc/gen/glob.c",
],
@ -439,7 +437,6 @@ cc_library_static {
cc_library_static {
defaults: ["libc_defaults"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-netbsd/common/lib/libc/stdlib/random.c",
"upstream-netbsd/lib/libc/gen/nice.c",
@ -497,7 +494,6 @@ cc_library_static {
cc_library_static {
name: "libc_openbsd_ndk",
defaults: ["libc_defaults"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-openbsd/lib/libc/gen/alarm.c",
"upstream-openbsd/lib/libc/gen/ctype_.c",
@ -616,7 +612,6 @@ cc_library_static {
cc_library_static {
name: "libc_openbsd_large_stack",
defaults: ["libc_defaults"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"stdio/vfprintf.cpp",
"stdio/vfwprintf.cpp",
@ -646,78 +641,54 @@ cc_library_static {
// automatically included.
cc_library_static {
defaults: ["libc_defaults"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
// These two depend on getentropy, which isn't in libc_ndk.a.
"upstream-openbsd/lib/libc/crypt/arc4random.c",
"upstream-openbsd/lib/libc/crypt/arc4random_uniform.c",
// May be overriden by per-arch optimized versions
"upstream-openbsd/lib/libc/string/memchr.c",
"upstream-openbsd/lib/libc/string/memrchr.c",
"upstream-openbsd/lib/libc/string/stpcpy.c",
"upstream-openbsd/lib/libc/string/stpncpy.c",
"upstream-openbsd/lib/libc/string/strcat.c",
"upstream-openbsd/lib/libc/string/strcpy.c",
"upstream-openbsd/lib/libc/string/strlcat.c",
"upstream-openbsd/lib/libc/string/strlcpy.c",
"upstream-openbsd/lib/libc/string/strncat.c",
"upstream-openbsd/lib/libc/string/strncmp.c",
"upstream-openbsd/lib/libc/string/strncpy.c",
],
// Each architecture has optimized versions of some routines,
// and only includes the portable C versions of ones it's missing.
arch: {
arm: {
exclude_srcs: [
"upstream-openbsd/lib/libc/string/strcpy.c",
"upstream-openbsd/lib/libc/string/stpcpy.c",
"upstream-openbsd/lib/libc/string/strcat.c",
srcs: [
"upstream-openbsd/lib/libc/string/memchr.c",
"upstream-openbsd/lib/libc/string/memrchr.c",
"upstream-openbsd/lib/libc/string/stpncpy.c",
"upstream-openbsd/lib/libc/string/strlcat.c",
"upstream-openbsd/lib/libc/string/strlcpy.c",
"upstream-openbsd/lib/libc/string/strncat.c",
"upstream-openbsd/lib/libc/string/strncmp.c",
"upstream-openbsd/lib/libc/string/strncpy.c",
],
},
arm64: {
exclude_srcs: [
"upstream-openbsd/lib/libc/string/memchr.c",
"upstream-openbsd/lib/libc/string/memrchr.c",
"upstream-openbsd/lib/libc/string/stpcpy.c",
"upstream-openbsd/lib/libc/string/strcpy.c",
"upstream-openbsd/lib/libc/string/strncmp.c",
srcs: [
"upstream-openbsd/lib/libc/string/stpncpy.c",
"upstream-openbsd/lib/libc/string/strcat.c",
"upstream-openbsd/lib/libc/string/strlcat.c",
"upstream-openbsd/lib/libc/string/strlcpy.c",
"upstream-openbsd/lib/libc/string/strncat.c",
"upstream-openbsd/lib/libc/string/strncpy.c",
],
},
riscv64: {
srcs: [
"upstream-freebsd/lib/libc/string/memcmp.c",
"upstream-freebsd/lib/libc/string/memcpy.c",
"upstream-freebsd/lib/libc/string/memmove.c",
"upstream-freebsd/lib/libc/string/memset.c",
"upstream-openbsd/lib/libc/string/strcmp.c",
"upstream-openbsd/lib/libc/string/strlen.c",
"upstream-openbsd/lib/libc/string/memrchr.c",
"upstream-openbsd/lib/libc/string/stpncpy.c",
"upstream-openbsd/lib/libc/string/strlcat.c",
"upstream-openbsd/lib/libc/string/strlcpy.c",
],
},
x86: {
exclude_srcs: [
// This space intentionally left blank.
},
x86_64: {
srcs: [
"upstream-openbsd/lib/libc/string/memchr.c",
"upstream-openbsd/lib/libc/string/memrchr.c",
"upstream-openbsd/lib/libc/string/stpcpy.c",
"upstream-openbsd/lib/libc/string/stpncpy.c",
"upstream-openbsd/lib/libc/string/strcat.c",
"upstream-openbsd/lib/libc/string/strcpy.c",
"upstream-openbsd/lib/libc/string/strncmp.c",
"upstream-openbsd/lib/libc/string/strncpy.c",
"upstream-openbsd/lib/libc/string/strlcat.c",
"upstream-openbsd/lib/libc/string/strlcpy.c",
"upstream-openbsd/lib/libc/string/strncat.c",
],
},
x86_64: {
exclude_srcs: [
"upstream-openbsd/lib/libc/string/stpcpy.c",
"upstream-openbsd/lib/libc/string/stpncpy.c",
"upstream-openbsd/lib/libc/string/strcat.c",
"upstream-openbsd/lib/libc/string/strcpy.c",
"upstream-openbsd/lib/libc/string/strncat.c",
"upstream-openbsd/lib/libc/string/strncmp.c",
"upstream-openbsd/lib/libc/string/strncpy.c",
],
},
},
@ -745,7 +716,6 @@ cc_library_static {
cc_library_static {
defaults: ["libc_defaults"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"upstream-openbsd/android/gdtoa_support.cpp",
"upstream-openbsd/lib/libc/gdtoa/dmisc.c",
@ -861,26 +831,12 @@ cc_library_static {
// The following must not be statically linked into libc_ndk.a, because
// debuggerd will look for the abort message in libc.so's copy.
"bionic/android_set_abort_message.cpp",
"bionic/strchr.cpp",
"bionic/strchrnul.cpp",
"bionic/strnlen.c",
"bionic/strrchr.cpp",
],
arch: {
arm: {
asflags: libc_common_flags + ["-mno-restrict-it"],
srcs: [
"arch-arm/generic/bionic/memcmp.S",
"arch-arm/generic/bionic/memmove.S",
"arch-arm/generic/bionic/memset.S",
"arch-arm/generic/bionic/stpcpy.c",
"arch-arm/generic/bionic/strcat.c",
"arch-arm/generic/bionic/strcmp.S",
"arch-arm/generic/bionic/strcpy.S",
"arch-arm/generic/bionic/strlen.c",
"arch-arm/bionic/__aeabi_read_tp.S",
"arch-arm/bionic/__bionic_clone.S",
"arch-arm/bionic/__restore.S",
@ -893,6 +849,20 @@ cc_library_static {
"arch-arm/bionic/syscall.S",
"arch-arm/bionic/vfork.S",
"bionic/strchr.cpp",
"bionic/strchrnul.cpp",
"bionic/strnlen.c",
"bionic/strrchr.cpp",
"arch-arm/generic/bionic/memcmp.S",
"arch-arm/generic/bionic/memmove.S",
"arch-arm/generic/bionic/memset.S",
"arch-arm/generic/bionic/stpcpy.c",
"arch-arm/generic/bionic/strcat.c",
"arch-arm/generic/bionic/strcmp.S",
"arch-arm/generic/bionic/strcpy.S",
"arch-arm/generic/bionic/strlen.c",
"arch-arm/cortex-a15/bionic/memcpy.S",
"arch-arm/cortex-a15/bionic/memmove.S",
"arch-arm/cortex-a15/bionic/memset.S",
@ -930,12 +900,6 @@ cc_library_static {
"arch-arm64/bionic/syscall.S",
"arch-arm64/bionic/vfork.S",
],
exclude_srcs: [
"bionic/strchr.cpp",
"bionic/strchrnul.cpp",
"bionic/strnlen.c",
"bionic/strrchr.cpp",
],
},
riscv64: {
@ -946,26 +910,40 @@ cc_library_static {
"arch-riscv64/bionic/syscall.S",
"arch-riscv64/bionic/vfork.S",
"arch-riscv64/string/memchr_vext.S",
"arch-riscv64/string/memcmp_vext.S",
"arch-riscv64/string/memcpy_vext.S",
"arch-riscv64/string/memmove_vext.S",
"arch-riscv64/string/memset_vext.S",
"arch-riscv64/string/stpcpy_vext.S",
"arch-riscv64/string/strcat_vext.S",
"arch-riscv64/string/strchr_vext.S",
"arch-riscv64/string/strcmp_vext.S",
"arch-riscv64/string/strcpy_vext.S",
"arch-riscv64/string/strlen_vext.S",
"arch-riscv64/string/strncat_vext.S",
"arch-riscv64/string/strncmp_vext.S",
"arch-riscv64/string/strncpy_vext.S",
"arch-riscv64/string/strnlen_vext.S",
"bionic/strchrnul.cpp",
"bionic/strrchr.cpp",
"arch-riscv64/string/memchr.S",
"arch-riscv64/string/memcmp.S",
"arch-riscv64/string/memcpy.S",
"arch-riscv64/string/memmove.S",
"arch-riscv64/string/memset.S",
"arch-riscv64/string/stpcpy.S",
"arch-riscv64/string/strcat.S",
"arch-riscv64/string/strchr.S",
"arch-riscv64/string/strcmp.S",
"arch-riscv64/string/strcpy.S",
"arch-riscv64/string/strlen.S",
"arch-riscv64/string/strncat.S",
"arch-riscv64/string/strncmp.S",
"arch-riscv64/string/strncpy.S",
"arch-riscv64/string/strnlen.S",
],
},
x86: {
srcs: [
"arch-x86/bionic/__bionic_clone.S",
"arch-x86/bionic/_exit_with_stack_teardown.S",
"arch-x86/bionic/libcrt_compat.c",
"arch-x86/bionic/__restore.S",
"arch-x86/bionic/setjmp.S",
"arch-x86/bionic/syscall.S",
"arch-x86/bionic/vfork.S",
"arch-x86/bionic/__x86.get_pc_thunk.S",
"bionic/strchrnul.cpp",
"arch-x86/generic/string/memcmp.S",
"arch-x86/generic/string/strcmp.S",
"arch-x86/generic/string/strncmp.S",
@ -1013,25 +991,22 @@ cc_library_static {
"arch-x86/string/sse4-memcmp-slm.S",
"arch-x86/string/sse4-wmemcmp-slm.S",
"arch-x86/bionic/__bionic_clone.S",
"arch-x86/bionic/_exit_with_stack_teardown.S",
"arch-x86/bionic/libcrt_compat.c",
"arch-x86/bionic/__restore.S",
"arch-x86/bionic/setjmp.S",
"arch-x86/bionic/syscall.S",
"arch-x86/bionic/vfork.S",
"arch-x86/bionic/__x86.get_pc_thunk.S",
],
exclude_srcs: [
"bionic/strchr.cpp",
"bionic/strnlen.c",
"bionic/strrchr.cpp",
],
},
x86_64: {
srcs: [
"arch-x86_64/bionic/__bionic_clone.S",
"arch-x86_64/bionic/_exit_with_stack_teardown.S",
"arch-x86_64/bionic/__restore_rt.S",
"arch-x86_64/bionic/setjmp.S",
"arch-x86_64/bionic/syscall.S",
"arch-x86_64/bionic/vfork.S",
"bionic/strchr.cpp",
"bionic/strchrnul.cpp",
"bionic/strnlen.c",
"bionic/strrchr.cpp",
"arch-x86_64/string/avx2-memset-kbl.S",
"arch-x86_64/string/sse2-memmove-slm.S",
"arch-x86_64/string/sse2-memset-slm.S",
@ -1045,13 +1020,6 @@ cc_library_static {
"arch-x86_64/string/sse4-memcmp-slm.S",
"arch-x86_64/string/ssse3-strcmp-slm.S",
"arch-x86_64/string/ssse3-strncmp-slm.S",
"arch-x86_64/bionic/__bionic_clone.S",
"arch-x86_64/bionic/_exit_with_stack_teardown.S",
"arch-x86_64/bionic/__restore_rt.S",
"arch-x86_64/bionic/setjmp.S",
"arch-x86_64/bionic/syscall.S",
"arch-x86_64/bionic/vfork.S",
],
},
},
@ -1569,9 +1537,6 @@ cc_library_static {
arm64: {
srcs: ["arch-arm64/static_function_dispatch.S"],
},
riscv64: {
srcs: ["arch-riscv64/static_function_dispatch.S"]
},
},
}
@ -1600,9 +1565,6 @@ cc_library_static {
arm64: {
srcs: ["arch-arm64/dynamic_function_dispatch.cpp"],
},
riscv64: {
srcs: ["arch-riscv64/dynamic_function_dispatch.cpp"]
},
},
}
@ -2921,7 +2883,6 @@ cc_library {
cc_library_host_static {
name: "libfts",
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: [
"bionic/fts.c",
"upstream-openbsd/lib/libc/stdlib/recallocarray.c",
@ -2964,7 +2925,6 @@ cc_library_host_static {
cc_library_host_static {
name: "libb64",
visibility: ["//external/musl"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
export_include_dirs: ["b64/include"],
local_include_dirs: [

View file

@ -2075,38 +2075,6 @@ SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 1990, 1993
The Regents of the University of California. All rights reserved.
This code is derived from software contributed to Berkeley by
Mike Hibler and Chris Torek.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 1990, 1993
The Regents of the University of California. All rights reserved.
(c) UNIX System Laboratories, Inc.

View file

@ -1,112 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <private/bionic_ifuncs.h>
#include <stddef.h>
#include <sys/auxv.h>
#if defined(__riscv_v)
extern "C" {
typedef void* memchr_func(const void*, int, size_t);
DEFINE_IFUNC_FOR(memchr) {
RETURN_FUNC(memchr_func, memchr_vext);
}
typedef int memcmp_func(const void*, const void*, size_t);
DEFINE_IFUNC_FOR(memcmp) {
RETURN_FUNC(memcmp_func, memcmp_vext);
}
typedef void* memcpy_func(void*, const void*, size_t);
DEFINE_IFUNC_FOR(memcpy) {
RETURN_FUNC(memcpy_func, memcpy_vext);
}
typedef void* memmove_func(void*, const void*, size_t);
DEFINE_IFUNC_FOR(memmove) {
RETURN_FUNC(memmove_func, memmove_vext);
}
typedef void* memset_func(void*, int, size_t);
DEFINE_IFUNC_FOR(memset) {
RETURN_FUNC(memset_func, memset_vext);
}
typedef char* stpcpy_func(char*, const char*);
DEFINE_IFUNC_FOR(stpcpy) {
RETURN_FUNC(stpcpy_func, stpcpy_vext);
}
typedef char* strcat_func(char*, const char*);
DEFINE_IFUNC_FOR(strcat) {
RETURN_FUNC(strcat_func, strcat_vext);
}
typedef char* strchr_func(const char*, int);
DEFINE_IFUNC_FOR(strchr) {
RETURN_FUNC(strchr_func, strchr_vext);
}
typedef int strcmp_func(const char*, const char*);
DEFINE_IFUNC_FOR(strcmp) {
RETURN_FUNC(strcmp_func, strcmp_vext);
}
typedef char* strcpy_func(char*, const char*);
DEFINE_IFUNC_FOR(strcpy) {
RETURN_FUNC(strcpy_func, strcpy_vext);
}
typedef size_t strlen_func(const char*);
DEFINE_IFUNC_FOR(strlen) {
RETURN_FUNC(strlen_func, strlen_vext);
}
typedef char* strncat_func(char*, const char*, size_t);
DEFINE_IFUNC_FOR(strncat) {
RETURN_FUNC(strncat_func, strncat_vext);
}
typedef int strncmp_func(const char*, const char*, size_t);
DEFINE_IFUNC_FOR(strncmp) {
RETURN_FUNC(strncmp_func, strncmp_vext);
}
typedef char* strncpy_func(char*, const char*, size_t);
DEFINE_IFUNC_FOR(strncpy) {
RETURN_FUNC(strncpy_func, strncpy_vext);
}
typedef size_t strnlen_func(const char*, size_t);
DEFINE_IFUNC_FOR(strnlen) {
RETURN_FUNC(strnlen_func, strnlen_vext);
}
} // extern "C"
#endif

View file

@ -1,56 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <private/bionic_asm.h>
#define FUNCTION_DELEGATE(name, impl) \
ENTRY(name); \
j impl; \
END(name)
#if defined(__riscv_v)
FUNCTION_DELEGATE(memchr, memchr_vext)
FUNCTION_DELEGATE(memcmp, memcmp_vext)
FUNCTION_DELEGATE(memcpy, memcpy_vext)
FUNCTION_DELEGATE(memmove, memmove_vext)
FUNCTION_DELEGATE(memset, memset_vext)
FUNCTION_DELEGATE(stpcpy, stpcpy_vext)
FUNCTION_DELEGATE(strcat, strcat_vext)
FUNCTION_DELEGATE(strchr, strchr_vext)
FUNCTION_DELEGATE(strcmp, strcmp_vext)
FUNCTION_DELEGATE(strcpy, strcpy_vext)
FUNCTION_DELEGATE(strlen, strlen_vext)
FUNCTION_DELEGATE(strncat, strncat_vext)
FUNCTION_DELEGATE(strncmp, strncmp_vext)
FUNCTION_DELEGATE(strncpy, strncpy_vext)
FUNCTION_DELEGATE(strnlen, strnlen_vext)
#endif
NOTE_GNU_PROPERTY()

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define iResult a0
@ -70,7 +68,7 @@
#define vData v0
#define vMask v8
ENTRY(memchr_vext)
ENTRY(memchr)
L(loop):
vsetvli iVL, iNum, e8, ELEM_LMUL_SETTING, ta, ma
@ -95,6 +93,4 @@ L(found):
add iResult, pSrc, iTemp
ret
END(memchr_vext)
#endif
END(memchr)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define iResult a0
@ -73,7 +71,7 @@
#define vData2 v8
#define vMask v16
ENTRY(memcmp_vext)
ENTRY(memcmp)
L(loop):
vsetvli iVL, iNum, e8, ELEM_LMUL_SETTING, ta, ma
@ -105,6 +103,4 @@ L(found):
sub iResult, iTemp1, iTemp2
ret
END(memcmp_vext)
#endif
END(memcmp)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define pDst a0
@ -67,7 +65,7 @@
#define ELEM_LMUL_SETTING m8
#define vData v0
ENTRY(memcpy_vext)
ENTRY(memcpy)
mv pDstPtr, pDst
@ -84,6 +82,4 @@ L(loop):
ret
END(memcpy_vext)
#endif
END(memcpy)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define pDst a0
@ -69,7 +67,7 @@
#define ELEM_LMUL_SETTING m8
#define vData v0
ENTRY(memmove_vext)
ENTRY(memmove)
mv pDstPtr, pDst
@ -101,6 +99,4 @@ L(backward_copy_loop):
bnez iNum, L(backward_copy_loop)
ret
END(memmove_vext)
#endif
END(memmove)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define pDst a0
@ -68,7 +66,7 @@
#define ELEM_LMUL_SETTING m8
#define vData v0
ENTRY(memset_vext)
ENTRY(memset)
mv pDstPtr, pDst
@ -84,6 +82,4 @@ L(loop):
ret
END(memset_vext)
#endif
END(memset)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define pDstPtr a0
@ -70,7 +68,7 @@
#define vStr1 v8
#define vStr2 v16
ENTRY(stpcpy_vext)
ENTRY(stpcpy)
L(stpcpy_loop):
vsetvli iVL, zero, e8, ELEM_LMUL_SETTING, ta, ma
vle8ff.v vStr1, (pSrc)
@ -87,6 +85,4 @@ L(stpcpy_loop):
sub pDstPtr, pDstPtr, iCurrentVL
add pDstPtr, pDstPtr, iActiveElemPos
ret
END(stpcpy_vext)
#endif
END(stpcpy)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define pDst a0
@ -71,7 +69,7 @@
#define vStr1 v8
#define vStr2 v16
ENTRY(strcat_vext)
ENTRY(strcat)
mv pDstPtr, pDst
@ -106,6 +104,4 @@ L(strcpy_loop):
ret
END(strcat_vext)
#endif
END(strcat)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define pStr a0
@ -71,7 +69,7 @@
#define vMaskEnd v8
#define vMaskCh v9
ENTRY(strchr_vext)
ENTRY(strchr)
L(strchr_loop):
vsetvli iVL, zero, e8, ELEM_LMUL_SETTING, ta, ma
@ -93,6 +91,4 @@ L(found_ch):
add pStr, pStr, iChOffset
ret
END(strchr_vext)
#endif
END(strchr)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define iResult a0
@ -76,7 +74,7 @@
#define vMask1 v16
#define vMask2 v17
ENTRY(strcmp_vext)
ENTRY(strcmp)
# increase the lmul using the following sequences:
# 1/2, 1/2, 1, 2, 4, 4, 4, ...
@ -168,6 +166,4 @@ L(check2):
sub iResult, iTemp1, iTemp2
ret
END(strcmp_vext)
#endif
END(strcmp)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define pDst a0
@ -71,7 +69,7 @@
#define vStr1 v8
#define vStr2 v16
ENTRY(strcpy_vext)
ENTRY(strcpy)
mv pDstPtr, pDst
@ -90,6 +88,4 @@ L(strcpy_loop):
ret
END(strcpy_vext)
#endif
END(strcpy)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define iResult a0
@ -68,7 +66,7 @@
#define vStr v0
#define vMaskEnd v2
ENTRY(strlen_vext)
ENTRY(strlen)
mv pCopyStr, pStr
L(loop):
@ -87,5 +85,3 @@ L(loop):
ret
END(strlen)
#endif

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define pDst a0
@ -72,7 +70,7 @@
#define vStr1 v8
#define vStr2 v16
ENTRY(strncat_vext)
ENTRY(strncat)
mv pDstPtr, pDst
@ -116,6 +114,4 @@ L(fill_zero):
L(fill_zero_end):
ret
END(strncat_vext)
#endif
END(strncat)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define iResult a0
@ -73,7 +71,7 @@
#define vMask1 v8
#define vMask2 v9
ENTRY(strncmp_vext)
ENTRY(strncmp)
beqz iLength, L(zero_length)
@ -118,6 +116,4 @@ L(zero_length):
li iResult, 0
ret
END(strncmp_vext)
#endif
END(strncmp)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define pDst a0
@ -73,7 +71,7 @@
#define vStr1 v8
#define vStr2 v16
ENTRY(strncpy_vext)
ENTRY(strncpy)
mv pDstPtr, pDst
@ -113,6 +111,4 @@ L(fill_zero_loop):
ret
END(strncpy_vext)
#endif
END(strncpy)

View file

@ -53,8 +53,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__riscv_v)
#include <private/bionic_asm.h>
#define pStr a0
@ -68,7 +66,7 @@
#define vStr v0
#define vMaskEnd v8
ENTRY(strnlen_vext)
ENTRY(strnlen)
mv pCopyStr, pStr
mv iRetValue, iMaxlen
@ -88,6 +86,4 @@ L(strnlen_loop):
L(end_strnlen_loop):
ret
END(strnlen_vext)
#endif
END(strnlen)

View file

@ -1,137 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
typedef intptr_t word; /* "word" used for optimal copy speed */
#define wsize sizeof(word)
#define wmask (wsize - 1)
/*
* Copy a block of memory, handling overlap.
* This is the routine that actually implements
* (the portable versions of) bcopy, memcpy, and memmove.
*/
#if defined(MEMCOPY) || defined(MEMMOVE)
#include <string.h>
void *
#ifdef MEMCOPY
memcpy
#else
memmove
#endif
(void *dst0, const void *src0, size_t length)
#else
#include <strings.h>
void
bcopy(const void *src0, void *dst0, size_t length)
#endif
{
char *dst = dst0;
const char *src = src0;
size_t t;
if (length == 0 || dst == src) /* nothing to do */
goto done;
/*
* Macros: loop-t-times; and loop-t-times, t>0
*/
#define TLOOP(s) if (t) TLOOP1(s)
#define TLOOP1(s) do { s; } while (--t)
if ((unsigned long)dst < (unsigned long)src) {
/*
* Copy forward.
*/
t = (uintptr_t)src; /* only need low bits */
if ((t | (uintptr_t)dst) & wmask) {
/*
* Try to align operands. This cannot be done
* unless the low bits match.
*/
if ((t ^ (uintptr_t)dst) & wmask || length < wsize)
t = length;
else
t = wsize - (t & wmask);
length -= t;
TLOOP1(*dst++ = *src++);
}
/*
* Copy whole words, then mop up any trailing bytes.
*/
t = length / wsize;
TLOOP(*(word *)(void *)dst = *(const word *)(const void *)src;
src += wsize; dst += wsize);
t = length & wmask;
TLOOP(*dst++ = *src++);
} else {
/*
* Copy backwards. Otherwise essentially the same.
* Alignment works as before, except that it takes
* (t&wmask) bytes to align, not wsize-(t&wmask).
*/
src += length;
dst += length;
t = (uintptr_t)src;
if ((t | (uintptr_t)dst) & wmask) {
if ((t ^ (uintptr_t)dst) & wmask || length <= wsize)
t = length;
else
t &= wmask;
length -= t;
TLOOP1(*--dst = *--src);
}
t = length / wsize;
TLOOP(src -= wsize; dst -= wsize;
*(word *)(void *)dst = *(const word *)(const void *)src);
t = length & wmask;
TLOOP(*--dst = *--src);
}
done:
#if defined(MEMCOPY) || defined(MEMMOVE)
return (dst0);
#else
return;
#endif
}

View file

@ -1,58 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)memcmp.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <string.h>
/*
* Compare memory regions.
*/
int
memcmp(const void *s1, const void *s2, size_t n)
{
if (n != 0) {
const unsigned char *p1 = s1, *p2 = s2;
do {
if (*p1++ != *p2++)
return (*--p1 - *--p2);
} while (--n != 0);
}
return (0);
}

View file

@ -1,5 +0,0 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#define MEMCOPY
#include "bcopy.c"

View file

@ -1,5 +0,0 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#define MEMMOVE
#include "bcopy.c"

View file

@ -1,133 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Mike Hibler and Chris Torek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <limits.h>
#define wsize sizeof(u_long)
#define wmask (wsize - 1)
#ifdef BZERO
#include <strings.h>
#define RETURN return
#define VAL 0
#define WIDEVAL 0
void
bzero(void *dst0, size_t length)
#else
#include <string.h>
#define RETURN return (dst0)
#define VAL c0
#define WIDEVAL c
void *
memset(void *dst0, int c0, size_t length)
#endif
{
size_t t;
#ifndef BZERO
u_long c;
#endif
u_char *dst;
dst = dst0;
/*
* If not enough words, just fill bytes. A length >= 2 words
* guarantees that at least one of them is `complete' after
* any necessary alignment. For instance:
*
* |-----------|-----------|-----------|
* |00|01|02|03|04|05|06|07|08|09|0A|00|
* ^---------------------^
* dst dst+length-1
*
* but we use a minimum of 3 here since the overhead of the code
* to do word writes is substantial.
*
* TODO: This threshold might not be sensible for 64-bit u_long.
* We should benchmark and revisit this decision.
*/
if (length < 3 * wsize) {
while (length != 0) {
*dst++ = VAL;
--length;
}
RETURN;
}
#ifndef BZERO
if ((c = (u_char)c0) != 0) { /* Fill the word. */
c = (c << 8) | c; /* u_long is 16 bits. */
#if ULONG_MAX > 0xffff
c = (c << 16) | c; /* u_long is 32 bits. */
#endif
#if ULONG_MAX > 0xffffffff
c = (c << 32) | c; /* u_long is 64 bits. */
#endif
}
#endif
/* Align destination by filling in bytes. */
if ((t = (long)dst & wmask) != 0) {
t = wsize - t;
length -= t;
do {
*dst++ = VAL;
} while (--t != 0);
}
/* Fill words. Length was >= 2*words so we know t >= 1 here. */
t = length / wsize;
do {
*(u_long *)(void *)dst = WIDEVAL;
dst += wsize;
} while (--t != 0);
/* Mop up trailing bytes, if any. */
t = length & wmask;
if (t != 0)
do {
*dst++ = VAL;
} while (--t != 0);
RETURN;
}

View file

@ -1,48 +0,0 @@
/* $OpenBSD: strcmp.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <string.h>
/*
* Compare strings.
*/
int
strcmp(const char *s1, const char *s2)
{
while (*s1 == *s2++)
if (*s1++ == 0)
return (0);
return (*(unsigned char *)s1 - *(unsigned char *)--s2);
}
DEF_STRONG(strcmp);

View file

@ -1,46 +0,0 @@
/* $OpenBSD: strcpy.c,v 1.10 2017/11/28 06:55:49 tb Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <string.h>
#if defined(APIWARN)
__warn_references(strcpy,
"strcpy() is almost always misused, please use strlcpy()");
#endif
char *
strcpy(char *to, const char *from)
{
char *save = to;
for (; (*to = *from) != '\0'; ++from, ++to);
return(save);
}

View file

@ -1,44 +0,0 @@
/* $OpenBSD: strlen.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <string.h>
size_t
strlen(const char *str)
{
const char *s;
for (s = str; *s; ++s)
;
return (s - str);
}
DEF_STRONG(strlen);