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