2 Copyright (c) 2014, Intel Corporation
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
15 * Neither the name of Intel Corporation nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <private/bionic_asm.h>
36 # define L(label) .L##label
40 # define ALIGN(n) .p2align n
44 ENTRY(__memset_chk_generic)
45 # %rdi = dst, %rsi = byte, %rdx = n, %rcx = dst_len
48 // Fall through to memset...
49 END(__memset_chk_generic)
52 .section .text.sse2,"ax",@progbits
56 mov $0x0101010101010101, %rcx
74 movq %rcx, -8(%rdi, %rdx)
79 movl %ecx, -4(%rdi, %rdx)
84 movw %cx, -2(%rdi, %rdx)
90 pshufd $0, %xmm0, %xmm0
92 movdqu %xmm0, -16(%rdi, %rdx)
95 movdqu %xmm0, 16(%rdi)
96 movdqu %xmm0, -32(%rdi, %rdx)
99 movdqu %xmm0, 32(%rdi)
100 movdqu %xmm0, 48(%rdi)
101 movdqu %xmm0, -64(%rdi, %rdx)
102 movdqu %xmm0, -48(%rdi, %rdx)
119 #ifdef SHARED_CACHE_SIZE
120 cmp $SHARED_CACHE_SIZE, %r8
122 cmp __x86_64_shared_cache_size(%rip), %r8
124 ja L(128bytesmore_nt)
127 L(128bytesmore_normal):
129 movaps %xmm0, 0x10(%rcx)
130 movaps %xmm0, 0x20(%rcx)
131 movaps %xmm0, 0x30(%rcx)
134 jne L(128bytesmore_normal)
139 movntdq %xmm0, (%rcx)
140 movntdq %xmm0, 0x10(%rcx)
141 movntdq %xmm0, 0x20(%rcx)
142 movntdq %xmm0, 0x30(%rcx)
145 jne L(128bytesmore_nt)