summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/common.h5
-rw-r--r--include/sort.h34
2 files changed, 34 insertions, 5 deletions
diff --git a/include/common.h b/include/common.h
index 97b661181b0..d17a2b2642c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -304,11 +304,6 @@ ulong ticks2usec (unsigned long ticks);
/* lib/lz4_wrapper.c */
int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
-/* lib/qsort.c */
-void qsort(void *base, size_t nmemb, size_t size,
- int(*compar)(const void *, const void *));
-int strcmp_compar(const void *, const void *);
-
/* lib/uuid.c */
#include <uuid.h>
diff --git a/include/sort.h b/include/sort.h
new file mode 100644
index 00000000000..0c6b588fcb0
--- /dev/null
+++ b/include/sort.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __SORT_H
+#define __SORT_H
+
+/**
+ * qsort() - Use the quicksort algorithm to sort some values
+ *
+ * @base: Base address of array to sort
+ * @nmemb: Number of members to sort
+ * @size: Size of each member in bytes
+ * @compar: Comparison function which should return:
+ * < 0 if element at s1 < element at s2,
+ * 0 if element at s1 == element at s2,
+ * > 0 if element at s1 > element at s2,
+ */
+void qsort(void *base, size_t nmemb, size_t size,
+ int (*compar)(const void *s1, const void *s2));
+
+/**
+ * strcmp_compar() - compar function for string arrays
+ *
+ * This can be passed to qsort when a string array is being sorted
+ *
+ * @s1: First string to compare
+ * @s2: Second string to compare
+ * @return comparison value (less than, equal to, or greater than 0)
+ */
+int strcmp_compar(const void *s1, const void *s2);
+
+#endif