summaryrefslogtreecommitdiff
path: root/ubifs-utils/common/sort.h
diff options
context:
space:
mode:
authorZhihao Cheng <chengzhihao1@huawei.com>2024-11-11 16:36:50 +0800
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-11-11 10:32:45 +0100
commit1bf5f879f01a1a1f6d99c5a2a13d710ca7908d64 (patch)
tree70072ae2a89c405c9907f3b4cb5355387252406e /ubifs-utils/common/sort.h
parent71354a4b25aa3f54ed214fc80638e34d3befa977 (diff)
ubifs-utils: Add sorting implementations
Add sorting implementations, because the sorting function is used in UBIFS linux kernel libs. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/common/sort.h')
-rw-r--r--ubifs-utils/common/sort.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/ubifs-utils/common/sort.h b/ubifs-utils/common/sort.h
new file mode 100644
index 0000000..8982942
--- /dev/null
+++ b/ubifs-utils/common/sort.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_SORT_H
+#define _LINUX_SORT_H
+
+typedef void (*swap_r_func_t)(void *a, void *b, int size, const void *priv);
+typedef void (*swap_func_t)(void *a, void *b, int size);
+
+typedef int (*cmp_r_func_t)(const void *a, const void *b, const void *priv);
+typedef int (*cmp_func_t)(const void *a, const void *b);
+
+void sort_r(void *base, size_t num, size_t size,
+ cmp_r_func_t cmp_func,
+ swap_r_func_t swap_func,
+ const void *priv);
+
+void sort(void *base, size_t num, size_t size,
+ cmp_func_t cmp_func,
+ swap_func_t swap_func);
+
+#endif