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