]>
Commit | Line | Data |
---|---|---|
a0cf6b8d AB |
1 | //------------------------------------------------------------------------------ |
2 | // | |
3 | // Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR> | |
4 | // | |
4059386c | 5 | // SPDX-License-Identifier: BSD-2-Clause-Patent |
a0cf6b8d AB |
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 | ||
bc54e50e AB |
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 | // | |
ec68dc28 | 28 | __attribute__((__weak__, __alias__("__memset"))) |
bc54e50e AB |
29 | void *memset(void *dest, int c, size_t n); |
30 | ||
ec68dc28 AB |
31 | #ifdef __arm__ |
32 | ||
a0cf6b8d AB |
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 |