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