]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibOptDxe/CompareMemWrapper.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptDxe / CompareMemWrapper.c
CommitLineData
631f060b 1/** @file\r
2 CompareMem() implementation.\r
3\r
2bfb6009 4 The following BaseMemoryLib instances contain the same copy of this file:\r
631f060b 5 BaseMemoryLib\r
6 BaseMemoryLibMmx\r
7 BaseMemoryLibSse2\r
8 BaseMemoryLibRepStr\r
2bfb6009
LG
9 BaseMemoryLibOptDxe\r
10 BaseMemoryLibOptPei\r
631f060b 11 PeiMemoryLib\r
1fef058f 12 UefiMemoryLib\r
631f060b 13\r
9095d37b 14Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 15SPDX-License-Identifier: BSD-2-Clause-Patent\r
eb1c78db 16\r
631f060b 17**/\r
18\r
631f060b 19#include "MemLibInternals.h"\r
20\r
21/**\r
22 Compares the contents of two buffers.\r
23\r
24 This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.\r
25 If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the\r
26 value returned is the first mismatched byte in SourceBuffer subtracted from the first\r
27 mismatched byte in DestinationBuffer.\r
9095d37b 28\r
2bfb6009
LG
29 If Length > 0 and DestinationBuffer is NULL, then ASSERT().\r
30 If Length > 0 and SourceBuffer is NULL, then ASSERT().\r
eb1c78db 31 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().\r
32 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r
631f060b 33\r
2fc59a00 34 @param DestinationBuffer The pointer to the destination buffer to compare.\r
35 @param SourceBuffer The pointer to the source buffer to compare.\r
36 @param Length The number of bytes to compare.\r
631f060b 37\r
eb1c78db 38 @return 0 All Length bytes of the two buffers are identical.\r
631f060b 39 @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first\r
40 mismatched byte in DestinationBuffer.\r
9095d37b 41\r
631f060b 42**/\r
43INTN\r
44EFIAPI\r
45CompareMem (\r
46 IN CONST VOID *DestinationBuffer,\r
47 IN CONST VOID *SourceBuffer,\r
48 IN UINTN Length\r
49 )\r
50{\r
cc4e0485 51 if (Length == 0 || DestinationBuffer == SourceBuffer) {\r
631f060b 52 return 0;\r
53 }\r
54 ASSERT (DestinationBuffer != NULL);\r
55 ASSERT (SourceBuffer != NULL);\r
56 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r
57 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r
58\r
59 return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);\r
60}\r