]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/CompilerIntrinsicsLib/memset.c
ArmPkg/CompilerIntrinsicsLib: use Clang-compatible 'weak' attribute
[mirror_edk2.git] / ArmPkg / Library / CompilerIntrinsicsLib / memset.c
CommitLineData
a0cf6b8d
AB
1//------------------------------------------------------------------------------
2//
3// Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
4//
5// This program and the accompanying materials are licensed and made
6// available under the terms and conditions of the BSD License which
7// accompanies this distribution. The full text of the license may be
8// found at http://opensource.org/licenses/bsd-license.php
9//
10// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
12// IMPLIED.
13//
14//------------------------------------------------------------------------------
15
16typedef __SIZE_TYPE__ size_t;
17
18static __attribute__((__used__))
19void *__memset(void *s, int c, size_t n)
20{
21 unsigned char *d = s;
22
23 while (n--)
24 *d++ = c;
25
26 return s;
27}
28
bc54e50e
AB
29//
30// Other modules (such as CryptoPkg/IntrinsicLib) may provide another
31// implementation of memset(), which may conflict with this one if this
32// object was pulled into the link due to the definitions below. So make
33// our memset() 'weak' to let the other implementation take precedence.
34//
ec68dc28 35__attribute__((__weak__, __alias__("__memset")))
bc54e50e
AB
36void *memset(void *dest, int c, size_t n);
37
ec68dc28
AB
38#ifdef __arm__
39
a0cf6b8d
AB
40void __aeabi_memset(void *dest, size_t n, int c)
41{
42 __memset(dest, c, n);
43}
44
45__attribute__((__alias__("__aeabi_memset")))
46void __aeabi_memset4(void *dest, size_t n, int c);
47
48__attribute__((__alias__("__aeabi_memset")))
49void __aeabi_memset8(void *dest, size_t n, int c);
50
51void __aeabi_memclr(void *dest, size_t n)
52{
53 __memset(dest, 0, n);
54}
55
56__attribute__((__alias__("__aeabi_memclr")))
57void __aeabi_memclr4(void *dest, size_t n);
58
59__attribute__((__alias__("__aeabi_memclr")))
60void __aeabi_memclr8(void *dest, size_t n);
61
62#endif