]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/BaseMemoryLibOptDxe/CompareMemWrapper.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptDxe / CompareMemWrapper.c
... / ...
CommitLineData
1/** @file\r
2 CompareMem() implementation.\r
3\r
4 The following BaseMemoryLib instances contain the same copy of this file:\r
5 BaseMemoryLib\r
6 BaseMemoryLibMmx\r
7 BaseMemoryLibSse2\r
8 BaseMemoryLibRepStr\r
9 BaseMemoryLibOptDxe\r
10 BaseMemoryLibOptPei\r
11 PeiMemoryLib\r
12 UefiMemoryLib\r
13\r
14Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
15SPDX-License-Identifier: BSD-2-Clause-Patent\r
16\r
17**/\r
18\r
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
28\r
29 If Length > 0 and DestinationBuffer is NULL, then ASSERT().\r
30 If Length > 0 and SourceBuffer is NULL, then ASSERT().\r
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
33\r
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
37\r
38 @return 0 All Length bytes of the two buffers are identical.\r
39 @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first\r
40 mismatched byte in DestinationBuffer.\r
41\r
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
51 if (Length == 0 || DestinationBuffer == SourceBuffer) {\r
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