Merge "Remove __memcmp16 from bionic."
This commit is contained in:
commit
5d25d5480a
@ -57,7 +57,6 @@ libc_bionic_src_files_arm += \
|
||||
arch-arm/bionic/_exit_with_stack_teardown.S \
|
||||
arch-arm/bionic/__get_sp.S \
|
||||
arch-arm/bionic/libgcc_compat.c \
|
||||
arch-arm/bionic/memcmp16.S \
|
||||
arch-arm/bionic/memcmp.S \
|
||||
arch-arm/bionic/_setjmp.S \
|
||||
arch-arm/bionic/setjmp.S \
|
||||
|
@ -1,234 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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 <machine/cpu-features.h>
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
/*
|
||||
* Optimized memcmp16() for ARM9.
|
||||
* This would not be optimal on XScale or ARM11, where more prefetching
|
||||
* and use of pld will be needed.
|
||||
* The 2 major optimzations here are
|
||||
* (1) The main loop compares 16 bytes at a time
|
||||
* (2) The loads are scheduled in a way they won't stall
|
||||
*/
|
||||
|
||||
ENTRY(__memcmp16)
|
||||
pld [r0, #0]
|
||||
pld [r1, #0]
|
||||
|
||||
/* take of the case where length is nul or the buffers are the same */
|
||||
cmp r0, r1
|
||||
cmpne r2, #0
|
||||
moveq r0, #0
|
||||
bxeq lr
|
||||
|
||||
/* since r0 hold the result, move the first source
|
||||
* pointer somewhere else
|
||||
*/
|
||||
|
||||
mov r3, r0
|
||||
|
||||
/* make sure we have at least 12 words, this simplify things below
|
||||
* and avoid some overhead for small blocks
|
||||
*/
|
||||
|
||||
cmp r2, #12
|
||||
bpl 0f
|
||||
|
||||
/* small blocks (less then 12 words) */
|
||||
pld [r0, #32]
|
||||
pld [r1, #32]
|
||||
|
||||
1: ldrh r0, [r3], #2
|
||||
ldrh ip, [r1], #2
|
||||
subs r0, r0, ip
|
||||
bxne lr
|
||||
subs r2, r2, #1
|
||||
bne 1b
|
||||
bx lr
|
||||
|
||||
|
||||
/* save registers */
|
||||
0: stmfd sp!, {r4, lr}
|
||||
.cfi_def_cfa_offset 8
|
||||
.cfi_rel_offset r4, 0
|
||||
.cfi_rel_offset lr, 4
|
||||
|
||||
/* align first pointer to word boundary */
|
||||
tst r3, #2
|
||||
beq 0f
|
||||
|
||||
ldrh r0, [r3], #2
|
||||
ldrh ip, [r1], #2
|
||||
sub r2, r2, #1
|
||||
subs r0, r0, ip
|
||||
/* restore registers and return */
|
||||
ldmnefd sp!, {r4, lr}
|
||||
bxne lr
|
||||
|
||||
|
||||
0: /* here the first pointer is aligned, and we have at least 3 words
|
||||
* to process.
|
||||
*/
|
||||
|
||||
/* see if the pointers are congruent */
|
||||
eor r0, r3, r1
|
||||
ands r0, r0, #2
|
||||
bne 5f
|
||||
|
||||
/* congruent case, 16 half-words per iteration
|
||||
* We need to make sure there are at least 16+2 words left
|
||||
* because we effectively read ahead one long word, and we could
|
||||
* read past the buffer (and segfault) if we're not careful.
|
||||
*/
|
||||
|
||||
ldr ip, [r1]
|
||||
subs r2, r2, #(16 + 2)
|
||||
bmi 1f
|
||||
|
||||
0:
|
||||
pld [r3, #64]
|
||||
pld [r1, #64]
|
||||
ldr r0, [r3], #4
|
||||
ldr lr, [r1, #4]!
|
||||
eors r0, r0, ip
|
||||
ldreq r0, [r3], #4
|
||||
ldreq ip, [r1, #4]!
|
||||
eoreqs r0, r0, lr
|
||||
ldreq r0, [r3], #4
|
||||
ldreq lr, [r1, #4]!
|
||||
eoreqs r0, r0, ip
|
||||
ldreq r0, [r3], #4
|
||||
ldreq ip, [r1, #4]!
|
||||
eoreqs r0, r0, lr
|
||||
ldreq r0, [r3], #4
|
||||
ldreq lr, [r1, #4]!
|
||||
eoreqs r0, r0, ip
|
||||
ldreq r0, [r3], #4
|
||||
ldreq ip, [r1, #4]!
|
||||
eoreqs r0, r0, lr
|
||||
ldreq r0, [r3], #4
|
||||
ldreq lr, [r1, #4]!
|
||||
eoreqs r0, r0, ip
|
||||
ldreq r0, [r3], #4
|
||||
ldreq ip, [r1, #4]!
|
||||
eoreqs r0, r0, lr
|
||||
bne 2f
|
||||
subs r2, r2, #16
|
||||
bhs 0b
|
||||
|
||||
/* do we have at least 2 words left? */
|
||||
1: adds r2, r2, #(16 - 2 + 2)
|
||||
bmi 4f
|
||||
|
||||
/* finish off 2 words at a time */
|
||||
3: ldr r0, [r3], #4
|
||||
ldr ip, [r1], #4
|
||||
eors r0, r0, ip
|
||||
bne 2f
|
||||
subs r2, r2, #2
|
||||
bhs 3b
|
||||
|
||||
/* are we done? */
|
||||
4: adds r2, r2, #2
|
||||
bne 8f
|
||||
/* restore registers and return */
|
||||
mov r0, #0
|
||||
ldmfd sp!, {r4, lr}
|
||||
bx lr
|
||||
|
||||
2: /* the last 2 words are different, restart them */
|
||||
ldrh r0, [r3, #-4]
|
||||
ldrh ip, [r1, #-4]
|
||||
subs r0, r0, ip
|
||||
ldreqh r0, [r3, #-2]
|
||||
ldreqh ip, [r1, #-2]
|
||||
subeqs r0, r0, ip
|
||||
/* restore registers and return */
|
||||
ldmfd sp!, {r4, lr}
|
||||
bx lr
|
||||
|
||||
/* process the last few words */
|
||||
8: ldrh r0, [r3], #2
|
||||
ldrh ip, [r1], #2
|
||||
subs r0, r0, ip
|
||||
bne 9f
|
||||
subs r2, r2, #1
|
||||
bne 8b
|
||||
|
||||
9: /* restore registers and return */
|
||||
ldmfd sp!, {r4, lr}
|
||||
bx lr
|
||||
|
||||
|
||||
5: /*************** non-congruent case ***************/
|
||||
|
||||
/* align the unaligned pointer */
|
||||
bic r1, r1, #3
|
||||
ldr lr, [r1], #4
|
||||
sub r2, r2, #8
|
||||
|
||||
6:
|
||||
pld [r3, #64]
|
||||
pld [r1, #64]
|
||||
mov ip, lr, lsr #16
|
||||
ldr lr, [r1], #4
|
||||
ldr r0, [r3], #4
|
||||
orr ip, ip, lr, lsl #16
|
||||
eors r0, r0, ip
|
||||
moveq ip, lr, lsr #16
|
||||
ldreq lr, [r1], #4
|
||||
ldreq r0, [r3], #4
|
||||
orreq ip, ip, lr, lsl #16
|
||||
eoreqs r0, r0, ip
|
||||
moveq ip, lr, lsr #16
|
||||
ldreq lr, [r1], #4
|
||||
ldreq r0, [r3], #4
|
||||
orreq ip, ip, lr, lsl #16
|
||||
eoreqs r0, r0, ip
|
||||
moveq ip, lr, lsr #16
|
||||
ldreq lr, [r1], #4
|
||||
ldreq r0, [r3], #4
|
||||
orreq ip, ip, lr, lsl #16
|
||||
eoreqs r0, r0, ip
|
||||
bne 7f
|
||||
subs r2, r2, #8
|
||||
bhs 6b
|
||||
sub r1, r1, #2
|
||||
/* are we done? */
|
||||
adds r2, r2, #8
|
||||
moveq r0, #0
|
||||
beq 9b
|
||||
/* finish off the remaining bytes */
|
||||
b 8b
|
||||
|
||||
7: /* fix up the 2 pointers and fallthrough... */
|
||||
sub r1, r1, #2
|
||||
b 2b
|
||||
END(__memcmp16)
|
@ -2,7 +2,6 @@
|
||||
|
||||
libc_common_src_files_arm64 := \
|
||||
bionic/memchr.c \
|
||||
bionic/__memcmp16.cpp \
|
||||
bionic/memrchr.c \
|
||||
bionic/strchr.cpp \
|
||||
bionic/strrchr.cpp \
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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>
|
||||
|
||||
// u4 __memcmp16(const u2*, const u2*, size_t);
|
||||
ENTRY(__memcmp16)
|
||||
li t0,0
|
||||
li t1,0
|
||||
beqz a2,done /* 0 length string */
|
||||
beq a0,a1,done /* strings are identical */
|
||||
|
||||
/* Unoptimised... */
|
||||
1: lhu t0,0(a0)
|
||||
lhu t1,0(a1)
|
||||
addu a1,2
|
||||
bne t0,t1,done
|
||||
addu a0,2
|
||||
subu a2,1
|
||||
bnez a2,1b
|
||||
|
||||
done:
|
||||
subu v0,t0,t1
|
||||
j ra
|
||||
END(__memcmp16)
|
@ -61,7 +61,6 @@ libc_bionic_src_files_mips += \
|
||||
arch-mips/bionic/cacheflush.cpp \
|
||||
arch-mips/bionic/_exit_with_stack_teardown.S \
|
||||
arch-mips/bionic/__get_sp.S \
|
||||
arch-mips/bionic/memcmp16.S \
|
||||
arch-mips/bionic/_setjmp.S \
|
||||
arch-mips/bionic/setjmp.S \
|
||||
arch-mips/bionic/sigsetjmp.S \
|
||||
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.
|
||||
*/
|
||||
.text
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
/*
|
||||
* u4 __memcmp16(const u2* s0, const u2* s1, size_t count);
|
||||
*/
|
||||
LEAF(__memcmp16,0)
|
||||
move t0,$0
|
||||
move t1,$0
|
||||
beqz a2,.L_done /* 0 length string */
|
||||
beq a0,a1,.L_done /* strings are identical */
|
||||
|
||||
/* Unoptimised... */
|
||||
1: lhu t0,0(a0)
|
||||
lhu t1,0(a1)
|
||||
PTR_ADDU a1,2
|
||||
bne t0,t1,.L_done
|
||||
PTR_ADDU a0,2
|
||||
SUBU a2,1
|
||||
bnez a2,1b
|
||||
|
||||
.L_done:
|
||||
SUBU v0,t0,t1
|
||||
j ra
|
||||
END(__memcmp16)
|
@ -42,7 +42,6 @@ libc_bionic_src_files_mips64 := \
|
||||
arch-mips64/bionic/__bionic_clone.S \
|
||||
arch-mips64/bionic/_exit_with_stack_teardown.S \
|
||||
arch-mips64/bionic/__get_sp.S \
|
||||
arch-mips64/bionic/memcmp16.S \
|
||||
arch-mips64/bionic/_setjmp.S \
|
||||
arch-mips64/bionic/setjmp.S \
|
||||
arch-mips64/bionic/sigsetjmp.S \
|
||||
|
@ -14,7 +14,6 @@ libc_bionic_src_files_x86 += \
|
||||
arch-x86/atom/string/sse2-wcscmp-atom.S \
|
||||
arch-x86/atom/string/ssse3-bcopy-atom.S \
|
||||
arch-x86/atom/string/ssse3-memcmp-atom.S \
|
||||
arch-x86/atom/string/ssse3-memcmp16-atom.S \
|
||||
arch-x86/atom/string/ssse3-memcpy-atom.S \
|
||||
arch-x86/atom/string/ssse3-memmove-atom.S \
|
||||
arch-x86/atom/string/ssse3-strcat-atom.S \
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2013, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation 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 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.
|
||||
*/
|
||||
|
||||
#define MEMCMP __memcmp16
|
||||
|
||||
/* int __memcmp16(const unsigned short *ptr1, const unsigned short *ptr2, size_t n); */
|
||||
|
||||
#define USE_UTF16
|
||||
#define USE_AS_MEMCMP16 1
|
||||
#include "ssse3-memcmp-atom.S"
|
@ -28,7 +28,6 @@ libc_bionic_src_files_x86 += \
|
||||
arch-x86/atom/string/ssse3-strcmp-atom.S \
|
||||
arch-x86/atom/string/ssse3-strncmp-atom.S \
|
||||
arch-x86/atom/string/ssse3-strcat-atom.S \
|
||||
arch-x86/atom/string/ssse3-memcmp16-atom.S \
|
||||
arch-x86/atom/string/ssse3-wcscat-atom.S \
|
||||
arch-x86/atom/string/ssse3-wcscpy-atom.S
|
||||
else
|
||||
@ -36,7 +35,6 @@ libc_bionic_src_files_x86 += \
|
||||
arch-x86/generic/string/strcmp.S \
|
||||
arch-x86/generic/string/strncmp.S \
|
||||
arch-x86/generic/string/strcat.S \
|
||||
bionic/__memcmp16.cpp \
|
||||
upstream-freebsd/lib/libc/string/wcscpy.c \
|
||||
upstream-freebsd/lib/libc/string/wcscat.c \
|
||||
upstream-openbsd/lib/libc/string/strlcat.c \
|
||||
|
@ -29,6 +29,5 @@ libc_bionic_src_files_x86 += \
|
||||
arch-x86/atom/string/ssse3-strcmp-atom.S \
|
||||
arch-x86/atom/string/ssse3-strncmp-atom.S \
|
||||
arch-x86/atom/string/ssse3-strcat-atom.S \
|
||||
arch-x86/atom/string/ssse3-memcmp16-atom.S \
|
||||
arch-x86/atom/string/ssse3-wcscat-atom.S \
|
||||
arch-x86/atom/string/ssse3-wcscpy-atom.S
|
||||
|
@ -37,7 +37,6 @@ libc_bionic_src_files_x86_64 := \
|
||||
arch-x86_64/bionic/__set_tls.c \
|
||||
arch-x86_64/bionic/sigsetjmp.S \
|
||||
arch-x86_64/bionic/syscall.S \
|
||||
bionic/__memcmp16.cpp \
|
||||
|
||||
libc_bionic_src_files_x86_64 += \
|
||||
arch-x86_64/string/sse2-memcpy-slm.S \
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2013 Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation 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 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 <stddef.h>
|
||||
|
||||
// Unoptimized version of __memcmp16.
|
||||
extern "C" int __memcmp16(const unsigned short* lhs, const unsigned short* rhs, size_t n) {
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (*lhs != *rhs) {
|
||||
return *lhs - *rhs;
|
||||
}
|
||||
lhs++;
|
||||
rhs++;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -789,37 +789,6 @@ TEST(string, memcmp) {
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int __memcmp16(const unsigned short *ptr1, const unsigned short *ptr2, size_t n);
|
||||
|
||||
TEST(string, __memcmp16) {
|
||||
#if defined(__BIONIC__)
|
||||
StringTestState<unsigned short> state(SMALL);
|
||||
|
||||
for (size_t i = 0; i < state.n; i++) {
|
||||
for (size_t j = 0; j < POS_ITER; j++) {
|
||||
state.NewIteration();
|
||||
|
||||
unsigned short mask = 0xffff;
|
||||
unsigned short c1 = rand() & mask;
|
||||
unsigned short c2 = rand() & mask;
|
||||
|
||||
std::fill(state.ptr1, state.ptr1 + state.MAX_LEN, c1);
|
||||
std::fill(state.ptr2, state.ptr2 + state.MAX_LEN, c1);
|
||||
|
||||
int pos = (state.len[i] == 0) ? 0 : (random() % state.len[i]);
|
||||
state.ptr2[pos] = c2;
|
||||
|
||||
int expected = (static_cast<unsigned short>(c1) - static_cast<unsigned short>(c2));
|
||||
int actual = __memcmp16(state.ptr1, state.ptr2, (size_t) state.MAX_LEN);
|
||||
|
||||
ASSERT_EQ(signum(expected), signum(actual));
|
||||
}
|
||||
}
|
||||
#else // __BIONIC__
|
||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||
#endif // __BIONIC__
|
||||
}
|
||||
|
||||
TEST(string, wmemcmp) {
|
||||
StringTestState<wchar_t> state(SMALL);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user