]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c
• BaseMemoryLib:
[mirror_edk2.git] / MdePkg / Library / PeiMemoryLib / CompareMemWrapper.c
CommitLineData
24de7645 1/** @file\r
2 CompareMem() implementation.\r
3\r
4 Copyright (c) 2006, Intel Corporation<BR>\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13 Module Name: CompareMemWrapper.c\r
14\r
15 The following BaseMemoryLib instances share the same version of this file:\r
16\r
17 BaseMemoryLib\r
18 BaseMemoryLibMmx\r
19 BaseMemoryLibSse2\r
20 BaseMemoryLibRepStr\r
21 PeiMemoryLib\r
22 UefiMemoryLib\r
23\r
24**/\r
25\r
26#include "MemLibInternals.h"\r
27\r
28/**\r
4ba61e5e 29 Compares the contents of two buffers.\r
24de7645 30\r
4ba61e5e 31 This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.\r
32 If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the\r
33 value returned is the first mismatched byte in SourceBuffer subtracted from the first\r
34 mismatched byte in DestinationBuffer.\r
35 If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT().\r
36 If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT().\r
37 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). \r
38 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). \r
24de7645 39\r
24de7645 40\r
4ba61e5e 41 @param DestinationBuffer Pointer to the destination buffer to compare.\r
42 @param SourceBuffer Pointer to the source buffer to compare.\r
43 @param Length Number of bytes to compare.\r
24de7645 44\r
4ba61e5e 45 @return 0 All Length bytes of the two buffers are identical.\r
46 @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first\r
47 mismatched byte in DestinationBuffer.\r
24de7645 48\r
49**/\r
50INTN\r
51EFIAPI\r
52CompareMem (\r
24e25d11 53 IN CONST VOID *DestinationBuffer,\r
54 IN CONST VOID *SourceBuffer,\r
55 IN UINTN Length\r
24de7645 56 )\r
57{\r
24de7645 58 if (Length == 0) {\r
59 return 0;\r
60 }\r
4ba61e5e 61 ASSERT (DestinationBuffer != NULL);\r
62 ASSERT (SourceBuffer != NULL);\r
63 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r
64 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r
65\r
24de7645 66 return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);\r
67}\r