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