From 74d1d749596d9d60723e05be3a5e24600721a32c Mon Sep 17 00:00:00 2001 From: Matthew Macy Date: Tue, 3 Dec 2019 09:49:40 -0800 Subject: [PATCH] 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 Reviewed-by: Brian Behlendorf Signed-off-by: Matt Macy Closes #9663 --- include/os/linux/spl/sys/sysmacros.h | 6 +++++- module/lua/ltablib.c | 4 ++-- module/zcommon/zprop_common.c | 6 +----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/os/linux/spl/sys/sysmacros.h b/include/os/linux/spl/sys/sysmacros.h index c9d33f4075..7314588bcf 100644 --- a/include/os/linux/spl/sys/sysmacros.h +++ b/include/os/linux/spl/sys/sysmacros.h @@ -192,7 +192,11 @@ extern void spl_cleanup(void); #define SET_ERROR(err) \ (__set_error(__FILE__, __func__, __LINE__, err), err) -#if defined(_KERNEL) && !defined(_KMEMUSER) && !defined(offsetof) +#include +#define qsort(base, num, size, cmp) \ + sort(base, num, size, cmp, NULL) + +#if !defined(_KMEMUSER) && !defined(offsetof) /* avoid any possibility of clashing with version */ diff --git a/module/lua/ltablib.c b/module/lua/ltablib.c index be5b6375e4..51cafffaaf 100644 --- a/module/lua/ltablib.c +++ b/module/lua/ltablib.c @@ -244,7 +244,7 @@ static void auxsort (lua_State *L, int l, int u) { } /* 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); luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */ if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ @@ -266,7 +266,7 @@ static const luaL_Reg tab_funcs[] = { {"pack", pack}, {"unpack", unpack}, {"remove", tremove}, - {"sort", sort}, + {"sort", tsort}, {NULL, NULL} }; diff --git a/module/zcommon/zprop_common.c b/module/zcommon/zprop_common.c index 8416983fd9..c4256c66f3 100644 --- a/module/zcommon/zprop_common.c +++ b/module/zcommon/zprop_common.c @@ -41,11 +41,7 @@ #include "zfs_prop.h" #include "zfs_deleg.h" -#if defined(_KERNEL) -#include -#define qsort(base, num, size, cmp) \ - sort(base, num, size, cmp, NULL) -#else +#if !defined(_KERNEL) #include #include #include