]>
Commit | Line | Data |
---|---|---|
dd51a993 | 1 | /** @file\r |
2 | CompareMem() implementation.\r | |
3 | \r | |
2bfb6009 | 4 | The following BaseMemoryLib instances contain the same copy of this file:\r |
dd51a993 | 5 | BaseMemoryLib\r |
6 | BaseMemoryLibMmx\r | |
7 | BaseMemoryLibSse2\r | |
8 | BaseMemoryLibRepStr\r | |
2bfb6009 LG |
9 | BaseMemoryLibOptDxe\r |
10 | BaseMemoryLibOptPei\r | |
dd51a993 | 11 | PeiMemoryLib\r |
1fef058f | 12 | UefiMemoryLib\r |
dd51a993 | 13 | \r |
19388d29 HT |
14 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r |
15 | This program and the accompanying materials\r | |
eb1c78db | 16 | are licensed and made available under the terms and conditions of the BSD License\r |
17 | which accompanies this distribution. The full text of the license may be found at\r | |
18 | http://opensource.org/licenses/bsd-license.php\r | |
19 | \r | |
20 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
21 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
22 | \r | |
dd51a993 | 23 | **/\r |
24 | \r | |
25 | #include "MemLibInternals.h"\r | |
26 | \r | |
27 | /**\r | |
28 | Compares the contents of two buffers.\r | |
29 | \r | |
30 | This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.\r | |
31 | If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the\r | |
32 | value returned is the first mismatched byte in SourceBuffer subtracted from the first\r | |
33 | mismatched byte in DestinationBuffer.\r | |
070a76b1 | 34 | \r |
2bfb6009 LG |
35 | If Length > 0 and DestinationBuffer is NULL, then ASSERT().\r |
36 | If Length > 0 and SourceBuffer is NULL, then ASSERT().\r | |
eb1c78db | 37 | If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().\r |
38 | If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r | |
dd51a993 | 39 | \r |
2fc59a00 | 40 | @param DestinationBuffer The pointer to the destination buffer to compare.\r |
41 | @param SourceBuffer The pointer to the source buffer to compare.\r | |
42 | @param Length The number of bytes to compare.\r | |
dd51a993 | 43 | \r |
44 | @return 0 All Length bytes of the two buffers are identical.\r | |
45 | @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first\r | |
46 | mismatched byte in DestinationBuffer.\r | |
070a76b1 | 47 | \r |
dd51a993 | 48 | **/\r |
49 | INTN\r | |
50 | EFIAPI\r | |
51 | CompareMem (\r | |
52 | IN CONST VOID *DestinationBuffer,\r | |
53 | IN CONST VOID *SourceBuffer,\r | |
54 | IN UINTN Length\r | |
55 | )\r | |
56 | {\r | |
cc4e0485 | 57 | if (Length == 0 || DestinationBuffer == SourceBuffer) {\r |
dd51a993 | 58 | return 0;\r |
59 | }\r | |
60 | ASSERT (DestinationBuffer != NULL);\r | |
61 | ASSERT (SourceBuffer != NULL);\r | |
62 | ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r | |
63 | ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r | |
64 | \r | |
65 | return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);\r | |
66 | }\r |