]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/CompilerIntrinsicsLib/memset.c
ArmPkg: Fix Ecc error 5005 in ArmExceptionLib
[mirror_edk2.git] / ArmPkg / Library / CompilerIntrinsicsLib / memset.c
CommitLineData
11ceb258
LE
1//------------------------------------------------------------------------------\r
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
8//------------------------------------------------------------------------------\r
9\r
10typedef __SIZE_TYPE__ size_t;\r
11\r
12static __attribute__((__used__))\r
13void *__memset(void *s, int c, size_t n)\r
14{\r
15 unsigned char *d = s;\r
16\r
53aabb97 17 while (n-- != 0) {\r
11ceb258 18 *d++ = c;\r
53aabb97 19 }\r
11ceb258
LE
20\r
21 return s;\r
22}\r
23\r
24//\r
25// Other modules (such as CryptoPkg/IntrinsicLib) may provide another\r
26// implementation of memset(), which may conflict with this one if this\r
27// object was pulled into the link due to the definitions below. So make\r
28// our memset() 'weak' to let the other implementation take precedence.\r
29//\r
30__attribute__((__weak__, __alias__("__memset")))\r
31void *memset(void *dest, int c, size_t n);\r
32\r
33#ifdef __arm__\r
34\r
35void __aeabi_memset(void *dest, size_t n, int c)\r
36{\r
37 __memset(dest, c, n);\r
38}\r
39\r
40__attribute__((__alias__("__aeabi_memset")))\r
41void __aeabi_memset4(void *dest, size_t n, int c);\r
42\r
43__attribute__((__alias__("__aeabi_memset")))\r
44void __aeabi_memset8(void *dest, size_t n, int c);\r
45\r
46void __aeabi_memclr(void *dest, size_t n)\r
47{\r
48 __memset(dest, 0, n);\r
49}\r
50\r
51__attribute__((__alias__("__aeabi_memclr")))\r
52void __aeabi_memclr4(void *dest, size_t n);\r
53\r
54__attribute__((__alias__("__aeabi_memclr")))\r
55void __aeabi_memclr8(void *dest, size_t n);\r
56\r
57#endif\r