View | Details | Raw Unified | Return to bug 231256 | Differences between
and this patch

Collapse All | Expand All

(-)include/stdlib.h (-2 / +15 lines)
Lines 297-304 Link Here
297
#endif
297
#endif
298
int	 mkostemp(char *, int);
298
int	 mkostemp(char *, int);
299
int	 mkostemps(char *, int, int);
299
int	 mkostemps(char *, int, int);
300
void	 qsort_r(void *, size_t, size_t, void *,
300
void	 qsort_r(void *, size_t, size_t,
301
	    int (*)(void *, const void *, const void *));
301
	    int (*)(const void *, const void *, void *), void *);
302
int	 radixsort(const unsigned char **, int, const unsigned char *,
302
int	 radixsort(const unsigned char **, int, const unsigned char *,
303
	    unsigned);
303
	    unsigned);
304
void	*reallocarray(void *, size_t, size_t) __result_use_check
304
void	*reallocarray(void *, size_t, size_t) __result_use_check
Lines 319-324 Link Here
319
__uint64_t
319
__uint64_t
320
	 strtouq(const char *, char **, int);
320
	 strtouq(const char *, char **, int);
321
321
322
/*
323
 * Attempt to trap calls of the historical qsort_r() function. The order
324
 * of the last two arguments of this function have changed. If the last
325
 * argument matches the type of the traditional comparator function,
326
 * call an integer instead, which will generate a compiler error.
327
 */
328
#if defined(__generic) && !defined(__cplusplus)
329
extern int __calling_qsort_r_incorrectly;
330
#define	qsort_r(base, nel, width, compar, arg)				\
331
    __generic(arg, int (*)(void *, const void *, const void *),		\
332
        __calling_qsort_r_incorrectly, qsort_r)(base, nel, width, compar, arg)
333
#endif
334
322
extern char *suboptarg;			/* getsubopt(3) external variable */
335
extern char *suboptarg;			/* getsubopt(3) external variable */
323
#endif /* __BSD_VISIBLE */
336
#endif /* __BSD_VISIBLE */
324
337
(-)lib/libc/gen/scandir-compat11.c (-4 / +4 lines)
Lines 60-67 Link Here
60
#define	SELECT(x)	select(x)
60
#define	SELECT(x)	select(x)
61
#endif
61
#endif
62
62
63
static int freebsd11_alphasort_thunk(void *thunk, const void *p1,
63
static int freebsd11_alphasort_thunk(const void *p1, const void *p2,
64
    const void *p2);
64
    void *thunk);
65
65
66
int
66
int
67
#ifdef I_AM_SCANDIR_B
67
#ifdef I_AM_SCANDIR_B
Lines 129-135 Link Here
129
		    (void*)dcomp);
129
		    (void*)dcomp);
130
#else
130
#else
131
		qsort_r(names, numitems, sizeof(struct freebsd11_dirent *),
131
		qsort_r(names, numitems, sizeof(struct freebsd11_dirent *),
132
		    &dcomp, freebsd11_alphasort_thunk);
132
		    freebsd11_alphasort_thunk, &dcomp);
133
#endif
133
#endif
134
	*namelist = names;
134
	*namelist = names;
135
	return (numitems);
135
	return (numitems);
Lines 155-161 Link Here
155
}
155
}
156
156
157
static int
157
static int
158
freebsd11_alphasort_thunk(void *thunk, const void *p1, const void *p2)
158
freebsd11_alphasort_thunk(const void *p1, const void *p2, void *thunk)
159
{
159
{
160
	int (*dc)(const struct freebsd11_dirent **, const struct
160
	int (*dc)(const struct freebsd11_dirent **, const struct
161
	    freebsd11_dirent **);
161
	    freebsd11_dirent **);
(-)lib/libc/gen/scandir.c (-3 / +3 lines)
Lines 57-63 Link Here
57
#define	SELECT(x)	select(x)
57
#define	SELECT(x)	select(x)
58
#endif
58
#endif
59
59
60
static int alphasort_thunk(void *thunk, const void *p1, const void *p2);
60
static int alphasort_thunk(const void *p1, const void *p2, void *thunk);
61
61
62
int
62
int
63
#ifdef I_AM_SCANDIR_B
63
#ifdef I_AM_SCANDIR_B
Lines 121-127 Link Here
121
		qsort_b(names, numitems, sizeof(struct dirent *), (void*)dcomp);
121
		qsort_b(names, numitems, sizeof(struct dirent *), (void*)dcomp);
122
#else
122
#else
123
		qsort_r(names, numitems, sizeof(struct dirent *),
123
		qsort_r(names, numitems, sizeof(struct dirent *),
124
		    &dcomp, alphasort_thunk);
124
		    alphasort_thunk, &dcomp);
125
#endif
125
#endif
126
	*namelist = names;
126
	*namelist = names;
127
	return (numitems);
127
	return (numitems);
Lines 146-152 Link Here
146
}
146
}
147
147
148
static int
148
static int
149
alphasort_thunk(void *thunk, const void *p1, const void *p2)
149
alphasort_thunk(const void *p1, const void *p2, void *thunk)
150
{
150
{
151
	int (*dc)(const struct dirent **, const struct dirent **);
151
	int (*dc)(const struct dirent **, const struct dirent **);
152
152
(-)lib/libc/stdlib/Makefile.inc (-2 / +2 lines)
Lines 11-18 Link Here
11
	getsubopt.c hcreate.c hcreate_r.c hdestroy_r.c heapsort.c heapsort_b.c \
11
	getsubopt.c hcreate.c hcreate_r.c hdestroy_r.c heapsort.c heapsort_b.c \
12
	hsearch_r.c imaxabs.c imaxdiv.c \
12
	hsearch_r.c imaxabs.c imaxdiv.c \
13
	insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c \
13
	insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c \
14
	merge.c mergesort_b.c ptsname.c qsort.c qsort_r.c quick_exit.c \
14
	merge.c mergesort_b.c ptsname.c qsort.c qsort_r.c qsort_r_compat.c \
15
	radixsort.c rand.c \
15
	quick_exit.c radixsort.c rand.c \
16
	random.c reallocarray.c reallocf.c realpath.c remque.c \
16
	random.c reallocarray.c reallocf.c realpath.c remque.c \
17
	set_constraint_handler_s.c strfmon.c strtoimax.c \
17
	set_constraint_handler_s.c strfmon.c strtoimax.c \
18
	strtol.c strtold.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
18
	strtol.c strtold.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
(-)lib/libc/stdlib/Symbol.map (-1 / +1 lines)
Lines 49-55 Link Here
49
	lfind;
49
	lfind;
50
	mergesort;
50
	mergesort;
51
	putenv;
51
	putenv;
52
	qsort_r;
53
	qsort;
52
	qsort;
54
	radixsort;
53
	radixsort;
55
	sradixsort;
54
	sradixsort;
Lines 122-127 Link Here
122
	abort_handler_s;
121
	abort_handler_s;
123
	ignore_handler_s;
122
	ignore_handler_s;
124
	set_constraint_handler_s;
123
	set_constraint_handler_s;
124
	qsort_r;
125
};
125
};
126
126
127
FBSDprivate_1.0 {
127
FBSDprivate_1.0 {
(-)lib/libc/stdlib/qsort.3 (-3 / +9 lines)
Lines 32-38 Link Here
32
.\"     @(#)qsort.3	8.1 (Berkeley) 6/4/93
32
.\"     @(#)qsort.3	8.1 (Berkeley) 6/4/93
33
.\" $FreeBSD$
33
.\" $FreeBSD$
34
.\"
34
.\"
35
.Dd February 20, 2013
35
.Dd September 8, 2018
36
.Dt QSORT 3
36
.Dt QSORT 3
37
.Os
37
.Os
38
.Sh NAME
38
.Sh NAME
Lines 67-74 Link Here
67
.Fa "void *base"
67
.Fa "void *base"
68
.Fa "size_t nmemb"
68
.Fa "size_t nmemb"
69
.Fa "size_t size"
69
.Fa "size_t size"
70
.Fa "int \*[lp]*compar\*[rp]\*[lp]const void *, const void *, void *\*[rp]"
70
.Fa "void *thunk"
71
.Fa "void *thunk"
71
.Fa "int \*[lp]*compar\*[rp]\*[lp]void *, const void *, const void *\*[rp]"
72
.Fc
72
.Fc
73
.Ft int
73
.Ft int
74
.Fo heapsort
74
.Fo heapsort
Lines 148-154 Link Here
148
.Fn qsort ,
148
.Fn qsort ,
149
except that it takes an additional argument,
149
except that it takes an additional argument,
150
.Fa thunk ,
150
.Fa thunk ,
151
which is passed unchanged as the first argument to function pointed to
151
which is passed unchanged as the last argument to function pointed to
152
.Fa compar .
152
.Fa compar .
153
This allows the comparison function to access additional
153
This allows the comparison function to access additional
154
data without using global variables, and thus
154
data without using global variables, and thus
Lines 370-372 Link Here
370
The variants of these functions that take blocks as arguments first appeared in
370
The variants of these functions that take blocks as arguments first appeared in
371
Mac OS X.
371
Mac OS X.
372
This implementation was created by David Chisnall.
372
This implementation was created by David Chisnall.
373
.Pp
374
In
375
.Fx 13.0 ,
376
the prototype of
377
.Fn qsort_r
378
was updated to match glibc.
(-)lib/libc/stdlib/qsort.c (-9 / +20 lines)
Lines 37-43 Link Here
37
37
38
#include <stdlib.h>
38
#include <stdlib.h>
39
39
40
#ifdef I_AM_QSORT_R
40
#if defined(I_AM_QSORT_R)
41
typedef int		 cmp_t(const void *, const void *, void *);
42
#elif defined(I_AM_QSORT_R_COMPAT)
41
typedef int		 cmp_t(void *, const void *, const void *);
43
typedef int		 cmp_t(void *, const void *, const void *);
42
#else
44
#else
43
typedef int		 cmp_t(const void *, const void *);
45
typedef int		 cmp_t(const void *, const void *);
Lines 65-71 Link Here
65
#define	vecswap(a, b, n)				\
67
#define	vecswap(a, b, n)				\
66
	if ((n) > 0) swapfunc(a, b, n)
68
	if ((n) > 0) swapfunc(a, b, n)
67
69
68
#ifdef I_AM_QSORT_R
70
#if defined(I_AM_QSORT_R)
71
#define	CMP(t, x, y) (cmp((x), (y), (t)))
72
#elif defined(I_AM_QSORT_R_COMPAT)
69
#define	CMP(t, x, y) (cmp((t), (x), (y)))
73
#define	CMP(t, x, y) (cmp((t), (x), (y)))
70
#else
74
#else
71
#define	CMP(t, x, y) (cmp((x), (y)))
75
#define	CMP(t, x, y) (cmp((x), (y)))
Lines 73-79 Link Here
73
77
74
static inline char *
78
static inline char *
75
med3(char *a, char *b, char *c, cmp_t *cmp, void *thunk
79
med3(char *a, char *b, char *c, cmp_t *cmp, void *thunk
76
#ifndef I_AM_QSORT_R
80
#if !defined(I_AM_QSORT_R) && !defined(I_AM_QSORT_R_COMPAT)
77
__unused
81
__unused
78
#endif
82
#endif
79
)
83
)
Lines 83-91 Link Here
83
	      :(CMP(thunk, b, c) > 0 ? b : (CMP(thunk, a, c) < 0 ? a : c ));
87
	      :(CMP(thunk, b, c) > 0 ? b : (CMP(thunk, a, c) < 0 ? a : c ));
84
}
88
}
85
89
86
#ifdef I_AM_QSORT_R
90
#if defined(I_AM_QSORT_R)
87
void
91
void
88
qsort_r(void *a, size_t n, size_t es, void *thunk, cmp_t *cmp)
92
(qsort_r)(void *a, size_t n, size_t es, cmp_t *cmp, void *thunk)
93
#elif defined(I_AM_QSORT_R_COMPAT)
94
void
95
__qsort_r_compat(void *a, size_t n, size_t es, void *thunk, cmp_t *cmp)
89
#else
96
#else
90
#define	thunk NULL
97
#define	thunk NULL
91
void
98
void
Lines 168-175 Link Here
168
	if (d1 <= d2) {
175
	if (d1 <= d2) {
169
		/* Recurse on left partition, then iterate on right partition */
176
		/* Recurse on left partition, then iterate on right partition */
170
		if (d1 > es) {
177
		if (d1 > es) {
171
#ifdef I_AM_QSORT_R
178
#if defined(I_AM_QSORT_R)
172
			qsort_r(a, d1 / es, es, thunk, cmp);
179
			qsort_r(a, d1 / es, es, cmp, thunk);
180
#elif defined(I_AM_QSORT_R_COMPAT)
181
			__qsort_r_compat(a, d1 / es, es, thunk, cmp);
173
#else
182
#else
174
			qsort(a, d1 / es, es, cmp);
183
			qsort(a, d1 / es, es, cmp);
175
#endif
184
#endif
Lines 184-191 Link Here
184
	} else {
193
	} else {
185
		/* Recurse on right partition, then iterate on left partition */
194
		/* Recurse on right partition, then iterate on left partition */
186
		if (d2 > es) {
195
		if (d2 > es) {
187
#ifdef I_AM_QSORT_R
196
#if defined(I_AM_QSORT_R)
188
			qsort_r(pn - d2, d2 / es, es, thunk, cmp);
197
			qsort_r(pn - d2, d2 / es, es, cmp, thunk);
198
#elif defined(I_AM_QSORT_R_COMPAT)
199
			__qsort_r_compat(pn - d2, d2 / es, es, thunk, cmp);
189
#else
200
#else
190
			qsort(pn - d2, d2 / es, es, cmp);
201
			qsort(pn - d2, d2 / es, es, cmp);
191
#endif
202
#endif
(-)lib/libc/stdlib/qsort_r.c (-11 lines)
Lines 4-19 Link Here
4
 *
4
 *
5
 * $FreeBSD$
5
 * $FreeBSD$
6
 */
6
 */
7
#include "block_abi.h"
8
#define I_AM_QSORT_R
7
#define I_AM_QSORT_R
9
#include "qsort.c"
8
#include "qsort.c"
10
11
typedef DECLARE_BLOCK(int, qsort_block, const void *, const void *);
12
13
void
14
qsort_b(void *base, size_t nel, size_t width, qsort_block compar)
15
{
16
	qsort_r(base, nel, width, compar,
17
		(int (*)(void *, const void *, const void *))
18
		GET_BLOCK_FUNCTION(compar));
19
}
(-)lib/libc/stdlib/qsort_r_compat.c (+21 lines)
Line 0 Link Here
1
/*
2
 * This file is in the public domain.  Originally written by Garrett
3
 * A. Wollman.
4
 *
5
 * $FreeBSD$
6
 */
7
#include "block_abi.h"
8
#define I_AM_QSORT_R_COMPAT
9
#include "qsort.c"
10
11
typedef DECLARE_BLOCK(int, qsort_block, const void *, const void *);
12
13
void
14
qsort_b(void *base, size_t nel, size_t width, qsort_block compar)
15
{
16
	__qsort_r_compat(base, nel, width, compar,
17
		(int (*)(void *, const void *, const void *))
18
		GET_BLOCK_FUNCTION(compar));
19
}
20
21
__sym_compat(qsort_r, __qsort_r_compat, FBSD_1.0);
(-)lib/libproc/proc_sym.c (-2 / +2 lines)
Lines 108-114 Link Here
108
};
108
};
109
109
110
static int
110
static int
111
symvalcmp(void *_thunk, const void *a1, const void *a2)
111
symvalcmp(const void *a1, const void *a2, void *_thunk)
112
{
112
{
113
	GElf_Sym sym1, sym2;
113
	GElf_Sym sym1, sym2;
114
	struct symsort_thunk *thunk;
114
	struct symsort_thunk *thunk;
Lines 195-201 Link Here
195
195
196
	thunk.e = e;
196
	thunk.e = e;
197
	thunk.symtab = symtab;
197
	thunk.symtab = symtab;
198
	qsort_r(symtab->index, nsyms, sizeof(u_int), &thunk, symvalcmp);
198
	qsort_r(symtab->index, nsyms, sizeof(u_int), symvalcmp, &thunk);
199
199
200
	return (0);
200
	return (0);
201
}
201
}
(-)sys/compat/linuxkpi/common/src/linux_compat.c (-2 / +2 lines)
Lines 2059-2065 Link Here
2059
};
2059
};
2060
2060
2061
static inline int
2061
static inline int
2062
linux_le_cmp(void *priv, const void *d1, const void *d2)
2062
linux_le_cmp(const void *d1, const void *d2, void *priv)
2063
{
2063
{
2064
	struct list_head *le1, *le2;
2064
	struct list_head *le1, *le2;
2065
	struct list_sort_thunk *thunk;
2065
	struct list_sort_thunk *thunk;
Lines 2087-2093 Link Here
2087
		ar[i++] = le;
2087
		ar[i++] = le;
2088
	thunk.cmp = cmp;
2088
	thunk.cmp = cmp;
2089
	thunk.priv = priv;
2089
	thunk.priv = priv;
2090
	qsort_r(ar, count, sizeof(struct list_head *), &thunk, linux_le_cmp);
2090
	qsort_r(ar, count, sizeof(struct list_head *), linux_le_cmp, &thunk);
2091
	INIT_LIST_HEAD(head);
2091
	INIT_LIST_HEAD(head);
2092
	for (i = 0; i < count; i++)
2092
	for (i = 0; i < count; i++)
2093
		list_add_tail(ar[i], head);
2093
		list_add_tail(ar[i], head);
(-)sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c (-5 / +4 lines)
Lines 59-66 Link Here
59
59
60
#include "bhnd_nvram_storevar.h"
60
#include "bhnd_nvram_storevar.h"
61
61
62
static int			 bhnd_nvstore_idx_cmp(void *ctx,
62
static int bhnd_nvstore_idx_cmp(const void *lhs, const void *rhs, void *ctx);
63
				     const void *lhs, const void *rhs);
64
63
65
/**
64
/**
66
 * Allocate and initialize a new path instance.
65
 * Allocate and initialize a new path instance.
Lines 198-204 Link Here
198
197
199
/* sort function for bhnd_nvstore_index_prepare() */
198
/* sort function for bhnd_nvstore_index_prepare() */
200
static int
199
static int
201
bhnd_nvstore_idx_cmp(void *ctx, const void *lhs, const void *rhs)
200
bhnd_nvstore_idx_cmp(const void *lhs, const void *rhs, void *ctx)
202
{
201
{
203
	struct bhnd_nvram_store	*sc;
202
	struct bhnd_nvram_store	*sc;
204
	void			*l_cookiep, *r_cookiep;
203
	void			*l_cookiep, *r_cookiep;
Lines 259-266 Link Here
259
	BHND_NVSTORE_LOCK_ASSERT(sc, MA_OWNED);
258
	BHND_NVSTORE_LOCK_ASSERT(sc, MA_OWNED);
260
259
261
	/* Sort the index table */
260
	/* Sort the index table */
262
	qsort_r(index->cookiep, index->count, sizeof(index->cookiep[0]), sc,
261
	qsort_r(index->cookiep, index->count, sizeof(index->cookiep[0]),
263
	    bhnd_nvstore_idx_cmp);
262
	    bhnd_nvstore_idx_cmp, sc);
264
263
265
	return (0);
264
	return (0);
266
}
265
}
(-)sys/dev/drm2/drm_linux_list_sort.c (-2 / +2 lines)
Lines 38-44 Link Here
38
};
38
};
39
39
40
static int
40
static int
41
drm_le_cmp(void *priv, const void *d1, const void *d2)
41
drm_le_cmp(const void *d1, const void *d2, void *priv)
42
{
42
{
43
	struct list_head *le1, *le2;
43
	struct list_head *le1, *le2;
44
	struct drm_list_sort_thunk *thunk;
44
	struct drm_list_sort_thunk *thunk;
Lines 69-75 Link Here
69
		ar[i++] = le;
69
		ar[i++] = le;
70
	thunk.cmp = cmp;
70
	thunk.cmp = cmp;
71
	thunk.priv = priv;
71
	thunk.priv = priv;
72
	qsort_r(ar, count, sizeof(struct list_head *), &thunk, drm_le_cmp);
72
	qsort_r(ar, count, sizeof(struct list_head *), drm_le_cmp, &thunk);
73
	INIT_LIST_HEAD(head);
73
	INIT_LIST_HEAD(head);
74
	for (i = 0; i < count; i++)
74
	for (i = 0; i < count; i++)
75
		list_add_tail(ar[i], head);
75
		list_add_tail(ar[i], head);
(-)sys/libkern/qsort.c (-5 / +5 lines)
Lines 36-42 Link Here
36
#include <sys/libkern.h>
36
#include <sys/libkern.h>
37
37
38
#ifdef I_AM_QSORT_R
38
#ifdef I_AM_QSORT_R
39
typedef int		 cmp_t(void *, const void *, const void *);
39
typedef int		 cmp_t(const void *, const void *, void *);
40
#else
40
#else
41
typedef int		 cmp_t(const void *, const void *);
41
typedef int		 cmp_t(const void *, const void *);
42
#endif
42
#endif
Lines 88-94 Link Here
88
	if ((n) > 0) swapfunc(a, b, n, swaptype_long, swaptype_int)
88
	if ((n) > 0) swapfunc(a, b, n, swaptype_long, swaptype_int)
89
89
90
#ifdef I_AM_QSORT_R
90
#ifdef I_AM_QSORT_R
91
#define	CMP(t, x, y) (cmp((t), (x), (y)))
91
#define	CMP(t, x, y) (cmp((x), (y), (t)))
92
#else
92
#else
93
#define	CMP(t, x, y) (cmp((x), (y)))
93
#define	CMP(t, x, y) (cmp((x), (y)))
94
#endif
94
#endif
Lines 107-113 Link Here
107
107
108
#ifdef I_AM_QSORT_R
108
#ifdef I_AM_QSORT_R
109
void
109
void
110
qsort_r(void *a, size_t n, size_t es, void *thunk, cmp_t *cmp)
110
(qsort_r)(void *a, size_t n, size_t es, cmp_t *cmp, void *thunk)
111
#else
111
#else
112
#define	thunk NULL
112
#define	thunk NULL
113
void
113
void
Lines 192-198 Link Here
192
		/* Recurse on left partition, then iterate on right partition */
192
		/* Recurse on left partition, then iterate on right partition */
193
		if (d1 > es) {
193
		if (d1 > es) {
194
#ifdef I_AM_QSORT_R
194
#ifdef I_AM_QSORT_R
195
			qsort_r(a, d1 / es, es, thunk, cmp);
195
			qsort_r(a, d1 / es, es, cmp, thunk);
196
#else
196
#else
197
			qsort(a, d1 / es, es, cmp);
197
			qsort(a, d1 / es, es, cmp);
198
#endif
198
#endif
Lines 208-214 Link Here
208
		/* Recurse on right partition, then iterate on left partition */
208
		/* Recurse on right partition, then iterate on left partition */
209
		if (d2 > es) {
209
		if (d2 > es) {
210
#ifdef I_AM_QSORT_R
210
#ifdef I_AM_QSORT_R
211
			qsort_r(pn - d2, d2 / es, es, thunk, cmp);
211
			qsort_r(pn - d2, d2 / es, es, cmp, thunk);
212
#else
212
#else
213
			qsort(pn - d2, d2 / es, es, cmp);
213
			qsort(pn - d2, d2 / es, es, cmp);
214
#endif
214
#endif
(-)sys/netgraph/ng_ppp.c (-4 / +4 lines)
Lines 322-328 Link Here
322
static void	ng_ppp_frag_checkstale(node_p node);
322
static void	ng_ppp_frag_checkstale(node_p node);
323
static void	ng_ppp_frag_reset(node_p node);
323
static void	ng_ppp_frag_reset(node_p node);
324
static void	ng_ppp_mp_strategy(node_p node, int len, int *distrib);
324
static void	ng_ppp_mp_strategy(node_p node, int len, int *distrib);
325
static int	ng_ppp_intcmp(void *latency, const void *v1, const void *v2);
325
static int	ng_ppp_intcmp(const void *v1, const void *v2, void *latency);
326
static struct mbuf *ng_ppp_addproto(struct mbuf *m, uint16_t proto, int compOK);
326
static struct mbuf *ng_ppp_addproto(struct mbuf *m, uint16_t proto, int compOK);
327
static struct mbuf *ng_ppp_cutproto(struct mbuf *m, uint16_t *proto);
327
static struct mbuf *ng_ppp_cutproto(struct mbuf *m, uint16_t *proto);
328
static struct mbuf *ng_ppp_prepend(struct mbuf *m, const void *buf, int len);
328
static struct mbuf *ng_ppp_prepend(struct mbuf *m, const void *buf, int len);
Lines 2319-2326 Link Here
2319
	}
2319
	}
2320
2320
2321
	/* Sort active links by latency */
2321
	/* Sort active links by latency */
2322
	qsort_r(sortByLatency,
2322
	qsort_r(sortByLatency, priv->numActiveLinks, sizeof(*sortByLatency),
2323
	    priv->numActiveLinks, sizeof(*sortByLatency), latency, ng_ppp_intcmp);
2323
	    ng_ppp_intcmp, latency);
2324
2324
2325
	/* Find the interval we need (add links in sortByLatency[] order) */
2325
	/* Find the interval we need (add links in sortByLatency[] order) */
2326
	for (numFragments = 1;
2326
	for (numFragments = 1;
Lines 2404-2410 Link Here
2404
 * Compare two integers
2404
 * Compare two integers
2405
 */
2405
 */
2406
static int
2406
static int
2407
ng_ppp_intcmp(void *latency, const void *v1, const void *v2)
2407
ng_ppp_intcmp(const void *v1, const void *v2, void *latency)
2408
{
2408
{
2409
	const int index1 = *((const int *) v1);
2409
	const int index1 = *((const int *) v1);
2410
	const int index2 = *((const int *) v2);
2410
	const int index2 = *((const int *) v2);
(-)sys/sys/libkern.h (-2 / +15 lines)
Lines 162-169 Link Here
162
void	*memmem(const void *l, size_t l_len, const void *s, size_t s_len);
162
void	*memmem(const void *l, size_t l_len, const void *s, size_t s_len);
163
void	 qsort(void *base, size_t nmemb, size_t size,
163
void	 qsort(void *base, size_t nmemb, size_t size,
164
	    int (*compar)(const void *, const void *));
164
	    int (*compar)(const void *, const void *));
165
void	 qsort_r(void *base, size_t nmemb, size_t size, void *thunk,
165
void	 qsort_r(void *base, size_t nmemb, size_t size,
166
	    int (*compar)(void *, const void *, const void *));
166
	    int (*compar)(const void *, const void *, void *), void *thunk);
167
u_long	 random(void);
167
u_long	 random(void);
168
int	 scanc(u_int, const u_char *, const u_char *, int);
168
int	 scanc(u_int, const u_char *, const u_char *, int);
169
void	 srandom(u_long);
169
void	 srandom(u_long);
Lines 189-194 Link Here
189
char	*strstr(const char *, const char *);
189
char	*strstr(const char *, const char *);
190
int	 strvalid(const char *, size_t);
190
int	 strvalid(const char *, size_t);
191
191
192
/*
193
 * Attempt to trap calls of the historical qsort_r() function. The order
194
 * of the last two arguments of this function have changed. If the last
195
 * argument matches the type of the traditional comparator function,
196
 * call an integer instead, which will generate a compiler error.
197
 */
198
#if defined(__generic) && !defined(__cplusplus)
199
extern int __calling_qsort_r_incorrectly;
200
#define	qsort_r(base, nel, width, compar, arg)				\
201
    __generic(arg, int (*)(void *, const void *, const void *),		\
202
        __calling_qsort_r_incorrectly, qsort_r)(base, nel, width, compar, arg)
203
#endif
204
192
extern const uint32_t crc32_tab[];
205
extern const uint32_t crc32_tab[];
193
206
194
static __inline uint32_t
207
static __inline uint32_t

Return to bug 231256