1// Copyright 2017 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "asm.h"
6
7// %rax = memset(%rdi, %rsi, %rdx)
8ENTRY(memset)
9    // Save return value.
10    mov %rdi, %r11
11
12    mov %sil, %al
13    mov %rdx, %rcx
14    rep stosb // while (rcx-- > 0) *rdi++ = al;
15
16    mov %r11, %rax
17    ret
18END(memset)
19
20ALIAS(memset, __unsanitized_memset)
21ASAN_WEAK_ALIAS(memset)
22
23// This name is called from inside libc to avoid going through the PLT.
24.hidden __libc_memset
25ALIAS(memset, __libc_memset)
26