Module Name:    src
Committed By:   riastradh
Date:           Sun Dec 19 00:58:50 UTC 2021

Modified Files:
        src/sys/external/bsd/drm2/include/linux: sort.h

Log Message:
Hokey Linux sort routine. Doesn't support swap argument.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/external/bsd/drm2/include/linux/sort.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/sort.h
diff -u src/sys/external/bsd/drm2/include/linux/sort.h:1.1 src/sys/external/bsd/drm2/include/linux/sort.h:1.2
--- src/sys/external/bsd/drm2/include/linux/sort.h:1.1	Sun Dec 19 00:28:12 2021
+++ src/sys/external/bsd/drm2/include/linux/sort.h	Sun Dec 19 00:58:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sort.h,v 1.1 2021/12/19 00:28:12 riastradh Exp $	*/
+/*	$NetBSD: sort.h,v 1.2 2021/12/19 00:58:50 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,4 +32,24 @@
 #ifndef	_LINUX_SORT_H_
 #define	_LINUX_SORT_H_
 
+#include <sys/kmem.h>
+
+#include <lib/libkern/libkern.h>
+
+static inline void
+sort(void *array, size_t nelem, size_t elemsize,
+    int (*cmp)(const void *, const void *),
+    void (*swap)(void *, void *, int))
+{
+	void *tmp;
+
+	KASSERT(swap == NULL);	/* XXX */
+	KASSERT(elemsize != 0);
+	KASSERT(nelem <= SIZE_MAX/elemsize);
+
+	tmp = kmem_alloc(nelem*elemsize, KM_SLEEP);
+	kheapsort(array, nelem, elemsize, cmp, tmp);
+	kmem_free(tmp, nelem*elemsize);
+}
+
 #endif	/* _LINUX_SORT_H_ */

Reply via email to