]>
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 |
9095d37b | 14 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9344f092 | 15 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
eb1c78db | 16 | \r |
dd51a993 | 17 | **/\r |
18 | \r | |
19 | #include "MemLibInternals.h"\r | |
20 | \r | |
21 | /**\r | |
22 | Compares the contents of two buffers.\r | |
23 | \r | |
24 | This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.\r | |
25 | If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the\r | |
26 | value returned is the first mismatched byte in SourceBuffer subtracted from the first\r | |
27 | mismatched byte in DestinationBuffer.\r | |
9095d37b | 28 | \r |
2bfb6009 LG |
29 | If Length > 0 and DestinationBuffer is NULL, then ASSERT().\r |
30 | If Length > 0 and SourceBuffer is NULL, then ASSERT().\r | |
bad46384 | 31 | If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().\r |
32 | If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r | |
dd51a993 | 33 | \r |
2fc59a00 | 34 | @param DestinationBuffer The pointer to the destination buffer to compare.\r |
35 | @param SourceBuffer The pointer to the source buffer to compare.\r | |
36 | @param Length The number of bytes to compare.\r | |
dd51a993 | 37 | \r |
38 | @return 0 All Length bytes of the two buffers are identical.\r | |
39 | @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first\r | |
40 | mismatched byte in DestinationBuffer.\r | |
9095d37b | 41 | \r |
dd51a993 | 42 | **/\r |
43 | INTN\r | |
44 | EFIAPI\r | |
45 | CompareMem (\r | |
46 | IN CONST VOID *DestinationBuffer,\r | |
47 | IN CONST VOID *SourceBuffer,\r | |
48 | IN UINTN Length\r | |
49 | )\r | |
50 | {\r | |
cc4e0485 | 51 | if (Length == 0 || DestinationBuffer == SourceBuffer) {\r |
dd51a993 | 52 | return 0;\r |
53 | }\r | |
54 | ASSERT (DestinationBuffer != NULL);\r | |
55 | ASSERT (SourceBuffer != NULL);\r | |
56 | ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));\r | |
57 | ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));\r | |
58 | \r | |
59 | return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);\r | |
60 | }\r |