]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
CryptoPkg IntrinsicLib: Make _fltused always be used
[mirror_edk2.git] / CryptoPkg / Library / IntrinsicLib / MemoryIntrinsics.c
CommitLineData
97f98500
HT
1/** @file\r
2 Intrinsic Memory Routines Wrapper Implementation for OpenSSL-based\r
3 Cryptographic Library.\r
4\r
933681b2 5Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>\r
2009f6b4 6SPDX-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
14typedef UINTN size_t;\r
15\r
933681b2
LG
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
97f98500
HT
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
933681b2 24int GLOBAL_USED _fltused = 1;\r
97f98500
HT
25\r
26/* Sets buffers to a specified character */\r
108ff4a0 27void * memset (void *dest, int ch, size_t count)\r
97f98500 28{\r
1b98d6ce
LQ
29 //\r
30 // NOTE: Here we use one base implementation for memset, instead of the direct\r
630f67dd
LG
31 // optimized SetMem() wrapper. Because the IntrinsicLib has to be built\r
32 // without whole program optimization option, and there will be some\r
1b98d6ce
LQ
33 // potential register usage errors when calling other optimized codes.\r
34 //\r
35\r
4a567c96 36 //\r
37 // Declare the local variables that actually move the data elements as\r
38 // volatile to prevent the optimizer from replacing this function with\r
39 // the intrinsic memset()\r
40 //\r
41 volatile UINT8 *Pointer;\r
42\r
43 Pointer = (UINT8 *)dest;\r
44 while (count-- != 0) {\r
108ff4a0 45 *(Pointer++) = (UINT8)ch;\r
4a567c96 46 }\r
630f67dd 47\r
4a567c96 48 return dest;\r
97f98500 49}\r
420e5083 50\r
5d7a1d63
QL
51/* Compare bytes in two buffers. */\r
52int memcmp (const void *buf1, const void *buf2, size_t count)\r
53{\r
54 return (int)CompareMem(buf1, buf2, count);\r
55}\r
56\r
420e5083
QL
57int strcmp (const char *s1, const char *s2)\r
58{\r
59 return (int)AsciiStrCmp(s1, s2);\r
60}\r