]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCompareMem.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EfiCommonLib / EfiCompareMem.c
CommitLineData
3eb9473e 1/*++\r
2\r
4ea9375a
HT
3Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 EfiCompareMem.c\r
15\r
16Abstract:\r
17\r
18 Generic compare-memory routine. \r
19\r
20--*/\r
21\r
22#include "Tiano.h"\r
23#include "EfiDriverLib.h"\r
24\r
25\r
26INTN\r
27EfiCompareMem (\r
28 IN VOID *MemOne,\r
29 IN VOID *MemTwo,\r
30 IN UINTN Length\r
31 )\r
32/*++\r
33\r
34Routine Description:\r
35\r
36 Compares two memory buffers of a given length.\r
37\r
38Arguments:\r
39\r
40 MemOne - First memory buffer\r
41\r
42 MemTwo - Second memory buffer\r
43\r
44 Len - Length of Mem1 and Mem2 memory regions to compare\r
45\r
46Returns:\r
47\r
48 = 0 if MemOne == MemTwo\r
49\r
50--*/\r
51{\r
52 INTN ReturnValue;\r
53\r
54 if (!(EFI_UINTN_ALIGNED (MemOne) || EFI_UINTN_ALIGNED (MemTwo) || EFI_UINTN_ALIGNED (Length))) {\r
55 //\r
56 // If Destination/Source/Length are aligned do UINTN conpare\r
57 //\r
58 for (; Length > 0; Length -= sizeof (INTN), MemOne = (VOID *)((UINTN)MemOne + sizeof (INTN)), MemTwo = (VOID *)((UINTN)MemTwo + sizeof (INTN))) {\r
59 if (*(INTN *)MemOne != *(INTN *)MemTwo) {\r
60 break;\r
61 }\r
62 }\r
63 }\r
64\r
65 //\r
66 // If Destination/Source/Length not aligned do byte compare\r
67 //\r
68 for (; Length > 0; Length--, MemOne = (VOID *)((UINTN)MemOne + 1), MemTwo = (VOID *)((UINTN)MemTwo + 1)) {\r
69 ReturnValue = (INTN)(*(INT8 *)MemOne - *(INT8 *)MemTwo);\r
70 if (ReturnValue != 0) {\r
71 return ReturnValue;\r
72 }\r
73 }\r
74\r
75 return 0;\r
76}\r