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