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