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