]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/OnigurumaIntrinsics.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / RegularExpressionDxe / Oniguruma / OnigurumaIntrinsics.c
1 /** @file
2
3 Provide intrinsics within Oniguruma
4
5 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8 **/
9
10 #include <Library/BaseMemoryLib.h>
11
12 //
13 // From CryptoPkg/IntrinsicLib
14 //
15
16 /* Copies bytes between buffers */
17 #pragma function(memcpy)
18 void * memcpy (void *dest, const void *src, unsigned int count)
19 {
20 return CopyMem (dest, src, (UINTN)count);
21 }
22
23 /* Sets buffers to a specified character */
24 #pragma function(memset)
25 void * memset (void *dest, char ch, unsigned int count)
26 {
27 //
28 // NOTE: Here we use one base implementation for memset, instead of the direct
29 // optimized SetMem() wrapper. Because the IntrinsicLib has to be built
30 // without whole program optimization option, and there will be some
31 // potential register usage errors when calling other optimized codes.
32 //
33
34 //
35 // Declare the local variables that actually move the data elements as
36 // volatile to prevent the optimizer from replacing this function with
37 // the intrinsic memset()
38 //
39 volatile UINT8 *Pointer;
40
41 Pointer = (UINT8 *)dest;
42 while (count-- != 0) {
43 *(Pointer++) = ch;
44 }
45
46 return dest;
47 }