]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/CompilerIntrinsicsLib/memset.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ArmPkg / Library / CompilerIntrinsicsLib / memset.c
1 //------------------------------------------------------------------------------
2 //
3 // Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
4 //
5 // SPDX-License-Identifier: BSD-2-Clause-Patent
6 //
7 //------------------------------------------------------------------------------
8
9 typedef __SIZE_TYPE__ size_t;
10
11 static __attribute__((__used__))
12 void *__memset(void *s, int c, size_t n)
13 {
14 unsigned char *d = s;
15
16 while (n--)
17 *d++ = c;
18
19 return s;
20 }
21
22 //
23 // Other modules (such as CryptoPkg/IntrinsicLib) may provide another
24 // implementation of memset(), which may conflict with this one if this
25 // object was pulled into the link due to the definitions below. So make
26 // our memset() 'weak' to let the other implementation take precedence.
27 //
28 __attribute__((__weak__, __alias__("__memset")))
29 void *memset(void *dest, int c, size_t n);
30
31 #ifdef __arm__
32
33 void __aeabi_memset(void *dest, size_t n, int c)
34 {
35 __memset(dest, c, n);
36 }
37
38 __attribute__((__alias__("__aeabi_memset")))
39 void __aeabi_memset4(void *dest, size_t n, int c);
40
41 __attribute__((__alias__("__aeabi_memset")))
42 void __aeabi_memset8(void *dest, size_t n, int c);
43
44 void __aeabi_memclr(void *dest, size_t n)
45 {
46 __memset(dest, 0, n);
47 }
48
49 __attribute__((__alias__("__aeabi_memclr")))
50 void __aeabi_memclr4(void *dest, size_t n);
51
52 __attribute__((__alias__("__aeabi_memclr")))
53 void __aeabi_memclr8(void *dest, size_t n);
54
55 #endif