1 /* memset/bzero -- set memory area to CH/0
2 Optimized version for x86-64.
3 Copyright (C) 2002-2015 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
25 movq %rdi, %rax /* Set return value. */
26 movq %rsi, %rdx /* Set n. */
28 jmp L(entry_from_bzero)
30 weak_alias (__bzero, bzero)
32 /* Like memset but takes additional parameter with return value. */
34 movq %rcx, %rax /* Set return value. */
37 punpcklbw %xmm0, %xmm0
38 punpcklwd %xmm0, %xmm0
39 pshufd $0, %xmm0, %xmm0
41 jmp L(entry_from_bzero)
45 #if defined PIC && IS_IN (libc)
46 ENTRY_CHK (__memset_chk)
48 jb HIDDEN_JUMPTARGET (__chk_fail)
49 END_CHK (__memset_chk)
55 punpcklbw %xmm0, %xmm0
56 punpcklwd %xmm0, %xmm0
57 pshufd $0, %xmm0, %xmm0
65 movdqu %xmm0, -16(%rdi,%rdx)
66 ja L(between_32_64_bytes)
71 L(between_32_64_bytes):
72 movdqu %xmm0, 16(%rdi)
73 movdqu %xmm0, -32(%rdi,%rdx)
80 movdqu %xmm0, -16(%rdi,%rdx)
81 movdqu %xmm0, 16(%rdi)
82 movdqu %xmm0, -32(%rdi,%rdx)
83 movdqu %xmm0, 32(%rdi)
84 movdqu %xmm0, -48(%rdi,%rdx)
85 movdqu %xmm0, 48(%rdi)
86 movdqu %xmm0, -64(%rdi,%rdx)
94 movdqa %xmm0, 16(%rcx)
95 movdqa %xmm0, 32(%rcx)
96 movdqa %xmm0, 48(%rcx)
105 jne L(between8_16bytes)
107 jne L(between4_7bytes)
114 movw %cx, -2(%rax,%rdx)
118 movl %ecx, -4(%rdi,%rdx)
122 movq %rcx, -8(%rdi,%rdx)
126 libc_hidden_builtin_def (memset)
128 #if defined PIC && IS_IN (libc) && !defined USE_MULTIARCH
129 strong_alias (__memset_chk, __memset_zero_constant_len_parameter)
130 .section .gnu.warning.__memset_zero_constant_len_parameter
131 .string "memset used with constant zero length parameter; this could be due to transposed parameters"