]>
Commit | Line | Data |
---|---|---|
97f98500 HT |
1 | /** @file\r |
2 | Intrinsic Memory Routines Wrapper Implementation for OpenSSL-based\r | |
3 | Cryptographic Library.\r | |
4 | \r | |
630f67dd | 5 | Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r |
2009f6b4 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
97f98500 HT |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include <Base.h>\r | |
11 | #include <Library/BaseMemoryLib.h>\r | |
420e5083 | 12 | #include <Library/BaseLib.h>\r |
97f98500 | 13 | \r |
5d7a1d63 QL |
14 | typedef UINTN size_t;\r |
15 | \r | |
97f98500 HT |
16 | /* OpenSSL will use floating point support, and C compiler produces the _fltused\r |
17 | symbol by default. Simply define this symbol here to satisfy the linker. */\r | |
18 | int _fltused = 1;\r | |
19 | \r | |
20 | /* Sets buffers to a specified character */\r | |
108ff4a0 | 21 | void * memset (void *dest, int ch, size_t count)\r |
97f98500 | 22 | {\r |
1b98d6ce LQ |
23 | //\r |
24 | // NOTE: Here we use one base implementation for memset, instead of the direct\r | |
630f67dd LG |
25 | // optimized SetMem() wrapper. Because the IntrinsicLib has to be built\r |
26 | // without whole program optimization option, and there will be some\r | |
1b98d6ce LQ |
27 | // potential register usage errors when calling other optimized codes.\r |
28 | //\r | |
29 | \r | |
4a567c96 | 30 | //\r |
31 | // Declare the local variables that actually move the data elements as\r | |
32 | // volatile to prevent the optimizer from replacing this function with\r | |
33 | // the intrinsic memset()\r | |
34 | //\r | |
35 | volatile UINT8 *Pointer;\r | |
36 | \r | |
37 | Pointer = (UINT8 *)dest;\r | |
38 | while (count-- != 0) {\r | |
108ff4a0 | 39 | *(Pointer++) = (UINT8)ch;\r |
4a567c96 | 40 | }\r |
630f67dd | 41 | \r |
4a567c96 | 42 | return dest;\r |
97f98500 | 43 | }\r |
420e5083 | 44 | \r |
5d7a1d63 QL |
45 | /* Compare bytes in two buffers. */\r |
46 | int memcmp (const void *buf1, const void *buf2, size_t count)\r | |
47 | {\r | |
48 | return (int)CompareMem(buf1, buf2, count);\r | |
49 | }\r | |
50 | \r | |
420e5083 QL |
51 | int strcmp (const char *s1, const char *s2)\r |
52 | {\r | |
53 | return (int)AsciiStrCmp(s1, s2);\r | |
54 | }\r |