]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
CryptoPkg/IntrinsicLib: add missing BaseLib declaration
[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
630f67dd 5Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
97f98500
HT
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include <Base.h>\r
17#include <Library/BaseMemoryLib.h>\r
420e5083 18#include <Library/BaseLib.h>\r
97f98500 19\r
5d7a1d63
QL
20typedef UINTN size_t;\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
24int _fltused = 1;\r
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