]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/CompilerIntrinsicsLib/memset.c
ArmPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / ArmPkg / Library / CompilerIntrinsicsLib / memset.c
CommitLineData
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
9typedef __SIZE_TYPE__ size_t;
10
11static __attribute__((__used__))
12void *__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
29void *memset(void *dest, int c, size_t n);
30
ec68dc28
AB
31#ifdef __arm__
32
a0cf6b8d
AB
33void __aeabi_memset(void *dest, size_t n, int c)
34{
35 __memset(dest, c, n);
36}
37
38__attribute__((__alias__("__aeabi_memset")))
39void __aeabi_memset4(void *dest, size_t n, int c);
40
41__attribute__((__alias__("__aeabi_memset")))
42void __aeabi_memset8(void *dest, size_t n, int c);
43
44void __aeabi_memclr(void *dest, size_t n)
45{
46 __memset(dest, 0, n);
47}
48
49__attribute__((__alias__("__aeabi_memclr")))
50void __aeabi_memclr4(void *dest, size_t n);
51
52__attribute__((__alias__("__aeabi_memclr")))
53void __aeabi_memclr8(void *dest, size_t n);
54
55#endif