]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLib/CompareMemWrapper.c
Import some basic libraries instances for Mde Packages.
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLib / 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 Module Name: CompareMemWrapper.c
14
15 The following BaseMemoryLib instances share the same version of this file:
16
17 BaseMemoryLib
18 BaseMemoryLibMmx
19 BaseMemoryLibSse2
20 BaseMemoryLibRepStr
21 PeiMemoryLib
22 DxeMemoryLib
23
24 **/
25
26 //
27 // Include common header file for this module.
28 //
29 #include "CommonHeader.h"
30
31 #include "MemLibInternals.h"
32
33 /**
34 Compares the contents of two buffers.
35
36 This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.
37 If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the
38 value returned is the first mismatched byte in SourceBuffer subtracted from the first
39 mismatched byte in DestinationBuffer.
40 If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT().
41 If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT().
42 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
43 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
44
45
46 @param DestinationBuffer Pointer to the destination buffer to compare.
47 @param SourceBuffer Pointer to the source buffer to compare.
48 @param Length Number of bytes to compare.
49
50 @return 0 All Length bytes of the two buffers are identical.
51 @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
52 mismatched byte in DestinationBuffer.
53
54 **/
55 INTN
56 EFIAPI
57 CompareMem (
58 IN CONST VOID *DestinationBuffer,
59 IN CONST VOID *SourceBuffer,
60 IN UINTN Length
61 )
62 {
63 if (Length == 0) {
64 return 0;
65 }
66 ASSERT (DestinationBuffer != NULL);
67 ASSERT (SourceBuffer != NULL);
68 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));
69 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));
70
71 return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);
72 }