]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibMmx/CompareMemWrapper.c
c8199d8dc31cb2badd25ee641ade2fb443fddf91
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibMmx / 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 UefiMemoryLib
23
24 **/
25
26 #include "MemLibInternals.h"
27
28 /**
29 Compares two memory buffers of a given length.
30
31 This function compares Length bytes of SourceBuffer to Length bytes of
32 DestinationBuffer. If all Length bytes of the two buffers are identical, then
33 0 is returned. Otherwise, the value returned is the first mismatched byte in
34 SourceBuffer subtracted from the first mismatched byte in DestinationBuffer.
35
36 If DestinationBuffer is NULL and Length > 0, then ASSERT().
37 If SourceBuffer is NULL and Length > 0, then ASSERT().
38 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then
39 ASSERT().
40 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
41
42 @param DestinationBuffer First memory buffer
43 @param SourceBuffer Second memory buffer
44 @param Length Length of DestinationBuffer and SourceBuffer memory
45 regions to compare
46
47 @retval 0 if DestinationBuffer == SourceBuffer
48 @retval Non-zero if DestinationBuffer != SourceBuffer
49
50 **/
51 INTN
52 EFIAPI
53 CompareMem (
54 IN CONST VOID *DestinationBuffer,
55 IN CONST VOID *SourceBuffer,
56 IN UINTN Length
57 )
58 {
59 ASSERT (DestinationBuffer != NULL);
60 ASSERT (SourceBuffer != NULL);
61 ASSERT (Length <= MAX_ADDRESS - (UINTN)DestinationBuffer + 1);
62 ASSERT (Length <= MAX_ADDRESS - (UINTN)SourceBuffer + 1);
63 if (Length == 0) {
64 return 0;
65 }
66 return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);
67 }