]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/CompilerIntrinsicsLib/memset.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ArmPkg / Library / CompilerIntrinsicsLib / memset.c
CommitLineData
429309e0 1// ------------------------------------------------------------------------------\r
11ceb258
LE
2//\r
3// Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
53aabb97 4// Copyright (c) 2021, Arm Limited. All rights reserved.<BR>\r
11ceb258
LE
5//\r
6// SPDX-License-Identifier: BSD-2-Clause-Patent\r
7//\r
429309e0 8// ------------------------------------------------------------------------------\r
11ceb258
LE
9\r
10typedef __SIZE_TYPE__ size_t;\r
11\r
429309e0
MK
12static __attribute__ ((__used__))\r
13void *\r
14__memset (\r
15 void *s,\r
16 int c,\r
17 size_t n\r
18 )\r
11ceb258 19{\r
429309e0 20 unsigned char *d;\r
fb48f1e2
PG
21\r
22 d = s;\r
11ceb258 23\r
53aabb97 24 while (n-- != 0) {\r
11ceb258 25 *d++ = c;\r
53aabb97 26 }\r
11ceb258
LE
27\r
28 return s;\r
29}\r
30\r
31//\r
32// Other modules (such as CryptoPkg/IntrinsicLib) may provide another\r
33// implementation of memset(), which may conflict with this one if this\r
34// object was pulled into the link due to the definitions below. So make\r
35// our memset() 'weak' to let the other implementation take precedence.\r
36//\r
429309e0
MK
37__attribute__ ((__weak__, __alias__ ("__memset")))\r
38void *\r
39memset (\r
40 void *dest,\r
41 int c,\r
42 size_t n\r
43 );\r
11ceb258
LE
44\r
45#ifdef __arm__\r
46\r
429309e0
MK
47void\r
48__aeabi_memset (\r
49 void *dest,\r
50 size_t n,\r
51 int c\r
52 )\r
11ceb258 53{\r
429309e0 54 __memset (dest, c, n);\r
11ceb258
LE
55}\r
56\r
429309e0
MK
57__attribute__ ((__alias__ ("__aeabi_memset")))\r
58void\r
59__aeabi_memset4 (\r
60 void *dest,\r
61 size_t n,\r
62 int c\r
63 );\r
11ceb258 64\r
429309e0
MK
65__attribute__ ((__alias__ ("__aeabi_memset")))\r
66void\r
67__aeabi_memset8 (\r
68 void *dest,\r
69 size_t n,\r
70 int c\r
71 );\r
11ceb258 72\r
429309e0
MK
73void\r
74__aeabi_memclr (\r
75 void *dest,\r
76 size_t n\r
77 )\r
11ceb258 78{\r
429309e0 79 __memset (dest, 0, n);\r
11ceb258
LE
80}\r
81\r
429309e0
MK
82__attribute__ ((__alias__ ("__aeabi_memclr")))\r
83void\r
84__aeabi_memclr4 (\r
85 void *dest,\r
86 size_t n\r
87 );\r
11ceb258 88\r
429309e0
MK
89__attribute__ ((__alias__ ("__aeabi_memclr")))\r
90void\r
91__aeabi_memclr8 (\r
92 void *dest,\r
93 size_t n\r
94 );\r
11ceb258
LE
95\r
96#endif\r