diff options
author | Ed Schouten <ed@FreeBSD.org> | 2022-09-30 22:26:30 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2022-09-30 22:26:30 +0000 |
commit | af3c78886fd8d4ca5eebdbe581a459a6f6d29d6a (patch) | |
tree | 9ff804d16ae1d811e013a58e71f8c824c2ff2488 /sys/netgraph | |
parent | 69d79ceb2c01931c129c5bafc300c33f3e106efd (diff) |
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/netgraph')
-rw-r--r-- | sys/netgraph/ng_ppp.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c index 6c61bcda0ae3..aafed858a26b 100644 --- a/sys/netgraph/ng_ppp.c +++ b/sys/netgraph/ng_ppp.c @@ -322,7 +322,7 @@ static void ng_ppp_frag_timeout(node_p node, hook_p hook, void *arg1, static void ng_ppp_frag_checkstale(node_p node); static void ng_ppp_frag_reset(node_p node); static void ng_ppp_mp_strategy(node_p node, int len, int *distrib); -static int ng_ppp_intcmp(void *latency, const void *v1, const void *v2); +static int ng_ppp_intcmp(const void *v1, const void *v2, void *latency); static struct mbuf *ng_ppp_addproto(struct mbuf *m, uint16_t proto, int compOK); static struct mbuf *ng_ppp_cutproto(struct mbuf *m, uint16_t *proto); static struct mbuf *ng_ppp_prepend(struct mbuf *m, const void *buf, int len); @@ -2316,8 +2316,8 @@ ng_ppp_mp_strategy(node_p node, int len, int *distrib) } /* Sort active links by latency */ - qsort_r(sortByLatency, - priv->numActiveLinks, sizeof(*sortByLatency), latency, ng_ppp_intcmp); + qsort_r(sortByLatency, priv->numActiveLinks, sizeof(*sortByLatency), + ng_ppp_intcmp, latency); /* Find the interval we need (add links in sortByLatency[] order) */ for (numFragments = 1; @@ -2401,7 +2401,7 @@ ng_ppp_mp_strategy(node_p node, int len, int *distrib) * Compare two integers */ static int -ng_ppp_intcmp(void *latency, const void *v1, const void *v2) +ng_ppp_intcmp(const void *v1, const void *v2, void *latency) { const int index1 = *((const int *) v1); const int index2 = *((const int *) v2); |