Move linux qsort def to platform header

Moving qsort to the platform header allows each platform to
provide an appropriate sorting implementation.

Reviewed-by: Allan Jude <allanjude@freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9663
This commit is contained in:
Matthew Macy 2019-12-03 09:49:40 -08:00 committed by Brian Behlendorf
parent e69bb31b71
commit 74d1d74959
3 changed files with 8 additions and 8 deletions

View File

@ -192,7 +192,11 @@ extern void spl_cleanup(void);
#define SET_ERROR(err) \ #define SET_ERROR(err) \
(__set_error(__FILE__, __func__, __LINE__, err), err) (__set_error(__FILE__, __func__, __LINE__, err), err)
#if defined(_KERNEL) && !defined(_KMEMUSER) && !defined(offsetof) #include <linux/sort.h>
#define qsort(base, num, size, cmp) \
sort(base, num, size, cmp, NULL)
#if !defined(_KMEMUSER) && !defined(offsetof)
/* avoid any possibility of clashing with <stddef.h> version */ /* avoid any possibility of clashing with <stddef.h> version */

View File

@ -244,7 +244,7 @@ static void auxsort (lua_State *L, int l, int u) {
} /* repeat the routine for the larger one */ } /* repeat the routine for the larger one */
} }
static int sort (lua_State *L) { static int tsort (lua_State *L) {
int n = aux_getn(L, 1); int n = aux_getn(L, 1);
luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */ luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
@ -266,7 +266,7 @@ static const luaL_Reg tab_funcs[] = {
{"pack", pack}, {"pack", pack},
{"unpack", unpack}, {"unpack", unpack},
{"remove", tremove}, {"remove", tremove},
{"sort", sort}, {"sort", tsort},
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -41,11 +41,7 @@
#include "zfs_prop.h" #include "zfs_prop.h"
#include "zfs_deleg.h" #include "zfs_deleg.h"
#if defined(_KERNEL) #if !defined(_KERNEL)
#include <linux/sort.h>
#define qsort(base, num, size, cmp) \
sort(base, num, size, cmp, NULL)
#else
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>