VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c

Last change on this file was 99404, checked in by vboxsync, 2 years ago

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1/** @file
2 CompareMem() implementation.
3
4 The following BaseMemoryLib instances contain the same copy of this file:
5 BaseMemoryLib
6 BaseMemoryLibMmx
7 BaseMemoryLibSse2
8 BaseMemoryLibRepStr
9 BaseMemoryLibOptDxe
10 BaseMemoryLibOptPei
11 PeiMemoryLib
12 UefiMemoryLib
13
14Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
15SPDX-License-Identifier: BSD-2-Clause-Patent
16
17**/
18
19#include "MemLibInternals.h"
20
21/**
22 Compares the contents of two buffers.
23
24 This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.
25 If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the
26 value returned is the first mismatched byte in SourceBuffer subtracted from the first
27 mismatched byte in DestinationBuffer.
28
29 If Length > 0 and DestinationBuffer is NULL, then ASSERT().
30 If Length > 0 and SourceBuffer is NULL, then ASSERT().
31 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
32 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
33
34 @param DestinationBuffer The pointer to the destination buffer to compare.
35 @param SourceBuffer The pointer to the source buffer to compare.
36 @param Length The number of bytes to compare.
37
38 @return 0 All Length bytes of the two buffers are identical.
39 @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
40 mismatched byte in DestinationBuffer.
41
42**/
43INTN
44EFIAPI
45CompareMem (
46 IN CONST VOID *DestinationBuffer,
47 IN CONST VOID *SourceBuffer,
48 IN UINTN Length
49 )
50{
51 if ((Length == 0) || (DestinationBuffer == SourceBuffer)) {
52 return 0;
53 }
54
55 ASSERT (DestinationBuffer != NULL);
56 ASSERT (SourceBuffer != NULL);
57 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));
58 ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));
59
60 return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);
61}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette