diff options
author | Krzysztof Koch <krzysztof.koch@arm.com> | 2019-04-09 10:41:40 +0100 |
---|---|---|
committer | Sami Mujawar <sami.mujawar@arm.com> | 2019-06-10 20:44:31 +0100 |
commit | c1b53091f60fb301a71238e6ef38834d48757d96 (patch) | |
tree | 836d52ece145da3ac79bfddce62063da307855c8 /DynamicTablesPkg/Include/Library/TableHelperLib.h | |
parent | 75bf10a68914a50b1d5c57f63a8561fa52dc0973 (diff) | |
download | edk2-c1b53091f60fb301a71238e6ef38834d48757d96.tar.gz edk2-c1b53091f60fb301a71238e6ef38834d48757d96.tar.bz2 edk2-c1b53091f60fb301a71238e6ef38834d48757d96.zip |
DynamicTablesPkg: Add code for finding duplicate values in arrays
Added generic function for detecting duplicate values in an array.
Also defined a function prototype to test if two objects are equal.
The prototype is used as an argument to the 'FindDuplicateValues'
function.
Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Diffstat (limited to 'DynamicTablesPkg/Include/Library/TableHelperLib.h')
-rw-r--r-- | DynamicTablesPkg/Include/Library/TableHelperLib.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTablesPkg/Include/Library/TableHelperLib.h index 9c5b383541..e4a8dfa046 100644 --- a/DynamicTablesPkg/Include/Library/TableHelperLib.h +++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h @@ -4,6 +4,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
+ @par Glossary:
+ - PFN - Pointer to a Function
+
**/
#ifndef TABLE_HELPER_LIB_H_
@@ -59,4 +62,49 @@ AddAcpiHeader ( IN CONST UINT32 Length
);
+/**
+ Function prototype for testing if two arbitrary objects are equal.
+
+ @param [in] Object1 Pointer to the first object to compare.
+ @param [in] Object2 Pointer to the second object to compare.
+ @param [in] Index1 Index of Object1. This value is optional and
+ can be ignored by the specified implementation.
+ @param [in] Index2 Index of Object2. This value is optional and
+ can be ignored by the specified implementation.
+
+ @retval TRUE Object1 and Object2 are equal.
+ @retval FALSE Object1 and Object2 are NOT equal.
+**/
+typedef
+BOOLEAN
+(EFIAPI *PFN_IS_EQUAL)(
+ IN CONST VOID * Object1,
+ IN CONST VOID * Object2,
+ IN UINTN Index1 OPTIONAL,
+ IN UINTN Index2 OPTIONAL
+ );
+
+/**
+ Test and report if a duplicate entry exists in the given array of comparable
+ elements.
+
+ @param [in] Array Array of elements to test for duplicates.
+ @param [in] Count Number of elements in Array.
+ @param [in] ElementSize Size of an element in bytes
+ @param [in] EqualTestFunction The function to call to check if any two
+ elements are equal.
+
+ @retval TRUE A duplicate element was found or one of
+ the input arguments is invalid.
+ @retval FALSE Every element in Array is unique.
+**/
+BOOLEAN
+EFIAPI
+FindDuplicateValue (
+ IN CONST VOID * Array,
+ IN CONST UINTN Count,
+ IN CONST UINTN ElementSize,
+ IN PFN_IS_EQUAL EqualTestFunction
+ );
+
#endif // TABLE_HELPER_LIB_H_
|