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
22 lines
498 B
C
22 lines
498 B
C
/*
|
|
* This file is in the public domain. Originally written by Garrett
|
|
* A. Wollman.
|
|
*
|
|
* $FreeBSD$
|
|
*/
|
|
#include "block_abi.h"
|
|
#define I_AM_QSORT_R_COMPAT
|
|
#include "qsort.c"
|
|
|
|
typedef DECLARE_BLOCK(int, qsort_block, const void *, const void *);
|
|
|
|
void
|
|
qsort_b(void *base, size_t nel, size_t width, qsort_block compar)
|
|
{
|
|
__qsort_r_compat(base, nel, width, compar,
|
|
(int (*)(void *, const void *, const void *))
|
|
GET_BLOCK_FUNCTION(compar));
|
|
}
|
|
|
|
__sym_compat(qsort_r, __qsort_r_compat, FBSD_1.0);
|