]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibOptPei/CompareMemWrapper.c
Update copyright for files modified in this year
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptPei / CompareMemWrapper.c
1 /** @file
2 CompareMem() implementation.
3
4 The following BaseMemoryLib instances contain the same copy of this file:
5
6 BaseMemoryLib
7 BaseMemoryLibMmx
8 BaseMemoryLibSse2
9 BaseMemoryLibRepStr
10 BaseMemoryLibOptDxe
11 BaseMemoryLibOptPei
12 PeiMemoryLib
13 DxeMemoryLib
14
15 Copyright (c) 2006 - 2008, Intel Corporation
16 All rights reserved. This program and the accompanying materials
17 are licensed and made available under the terms and conditions of the BSD License
18 which accompanies this distribution. The full text of the license may be found at
19 http://opensource.org/licenses/bsd-license.php
20
21 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
22 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
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
36 If Length > 0 and DestinationBuffer is NULL, then ASSERT().
37 If Length > 0 and SourceBuffer is NULL, then ASSERT().
38 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
39 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
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 }