aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/bhnd
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2022-09-30 22:26:30 +0000
committerXin LI <delphij@FreeBSD.org>2022-09-30 22:26:30 +0000
commitaf3c78886fd8d4ca5eebdbe581a459a6f6d29d6a (patch)
tree9ff804d16ae1d811e013a58e71f8c824c2ff2488 /sys/dev/bhnd
parent69d79ceb2c01931c129c5bafc300c33f3e106efd (diff)
downloadsrc-af3c78886fd8d4ca5eebdbe581a459a6f6d29d6a.tar.gz
src-af3c78886fd8d4ca5eebdbe581a459a6f6d29d6a.zip
Alter the prototype of qsort_r(3) to match POSIX, which adopted the
glibc-based interface. Unfortunately, the glibc maintainers, despite knowing the existence of the FreeBSD qsort_r(3) interface in 2004 and refused to add the same interface to glibc based on grounds of the lack of standardization and portability concerns, has decided it was a good idea to introduce their own qsort_r(3) interface in 2007 as a GNU extension with a slightly different and incompatible interface. With the adoption of their interface as POSIX standard, let's switch to the same prototype, there is no need to remain incompatible. C++ and C applications written for the historical FreeBSD interface get source level compatibility when building in C++ mode, or when building with a C compiler with C11 generics support, provided that the caller passes a fifth parameter of qsort_r() that exactly matches the historical FreeBSD comparator function pointer type and does not redefine the historical qsort_r(3) prototype in their source code. Symbol versioning is used to keep old binaries working. MFC: never Relnotes: yes Reviewed by: cem, imp, hps, pauamma Differential revision: https://reviews.freebsd.org/D17083
Diffstat (limited to 'sys/dev/bhnd')
-rw-r--r--sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c b/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c
index 730b9d51da45..fd05648147f5 100644
--- a/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c
+++ b/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c
@@ -59,8 +59,7 @@ __FBSDID("$FreeBSD$");
#include "bhnd_nvram_storevar.h"
-static int bhnd_nvstore_idx_cmp(void *ctx,
- const void *lhs, const void *rhs);
+static int bhnd_nvstore_idx_cmp(const void *lhs, const void *rhs, void *ctx);
/**
* Allocate and initialize a new path instance.
@@ -198,7 +197,7 @@ bhnd_nvstore_index_append(struct bhnd_nvram_store *sc,
/* sort function for bhnd_nvstore_index_prepare() */
static int
-bhnd_nvstore_idx_cmp(void *ctx, const void *lhs, const void *rhs)
+bhnd_nvstore_idx_cmp(const void *lhs, const void *rhs, void *ctx)
{
struct bhnd_nvram_store *sc;
void *l_cookiep, *r_cookiep;
@@ -259,8 +258,8 @@ bhnd_nvstore_index_prepare(struct bhnd_nvram_store *sc,
BHND_NVSTORE_LOCK_ASSERT(sc, MA_OWNED);
/* Sort the index table */
- qsort_r(index->cookiep, index->count, sizeof(index->cookiep[0]), sc,
- bhnd_nvstore_idx_cmp);
+ qsort_r(index->cookiep, index->count, sizeof(index->cookiep[0]),
+ bhnd_nvstore_idx_cmp, sc);
return (0);
}