Skip to content

Commit 11174f2

Browse files
committed
add qsort_r for unix, and qsort and qsort_s for windows
1 parent ea7fc0f commit 11174f2

File tree

12 files changed

+77
-0
lines changed

12 files changed

+77
-0
lines changed

libc-test/semver/apple.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,7 @@ ptrace
21212121
pututxline
21222122
pwritev
21232123
qsort
2124+
qsort_r
21242125
querylocale
21252126
quotactl
21262127
radvisory

libc-test/semver/freebsd.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,7 @@ ptsname_r
22412241
pututxline
22422242
pwritev
22432243
qsort
2244+
qsort_r
22442245
querylocale
22452246
rallocx
22462247
rand

libc-test/semver/netbsd.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,7 @@ ptrace_siginfo
15351535
pututxline
15361536
pwritev
15371537
qsort
1538+
qsort_r
15381539
rand
15391540
readdir_r
15401541
readlinkat

libc-test/semver/windows.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ putchar
275275
putenv
276276
putenv_s
277277
puts
278+
qsort
279+
qsort_s
278280
raise
279281
rand
280282
read

src/unix/bsd/apple/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5926,6 +5926,14 @@ extern "C" {
59265926
search_path: *const c_char,
59275927
argv: *const *mut c_char,
59285928
) -> c_int;
5929+
5930+
pub fn qsort_r(
5931+
base: *mut c_void,
5932+
num: size_t,
5933+
size: size_t,
5934+
arg: *mut c_void,
5935+
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
5936+
);
59295937
}
59305938

59315939
cfg_if! {

src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,17 @@ extern "C" {
424424
// in FreeBSD 12
425425
pub fn dirname(path: *const c_char) -> *mut c_char;
426426
pub fn basename(path: *const c_char) -> *mut c_char;
427+
428+
// Argument order of the function pointer changed in FreeBSD 14. From 14 onwards the signature
429+
// matches the POSIX specification by having the third argument be a mutable pointer, on
430+
// earlier versions the first argument is the mutable pointer.
431+
pub fn qsort_r(
432+
base: *mut c_void,
433+
num: size_t,
434+
size: size_t,
435+
arg: *mut c_void,
436+
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
437+
);
427438
}
428439

429440
cfg_if! {

src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,14 @@ extern "C" {
468468

469469
pub fn dirname(path: *mut c_char) -> *mut c_char;
470470
pub fn basename(path: *mut c_char) -> *mut c_char;
471+
472+
pub fn qsort_r(
473+
base: *mut c_void,
474+
num: size_t,
475+
size: size_t,
476+
arg: *mut c_void,
477+
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
478+
);
471479
}
472480

473481
cfg_if! {

src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,14 @@ extern "C" {
507507

508508
pub fn dirname(path: *mut c_char) -> *mut c_char;
509509
pub fn basename(path: *mut c_char) -> *mut c_char;
510+
511+
pub fn qsort_r(
512+
base: *mut c_void,
513+
num: size_t,
514+
size: size_t,
515+
arg: *mut c_void,
516+
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
517+
);
510518
}
511519

512520
#[link(name = "kvm")]

src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,14 @@ extern "C" {
509509

510510
pub fn dirname(path: *mut c_char) -> *mut c_char;
511511
pub fn basename(path: *mut c_char) -> *mut c_char;
512+
513+
pub fn qsort_r(
514+
base: *mut c_void,
515+
num: size_t,
516+
size: size_t,
517+
compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>,
518+
arg: *mut c_void,
519+
);
512520
}
513521

514522
#[link(name = "kvm")]

src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,14 @@ extern "C" {
511511

512512
pub fn dirname(path: *mut c_char) -> *mut c_char;
513513
pub fn basename(path: *mut c_char) -> *mut c_char;
514+
515+
pub fn qsort_r(
516+
base: *mut c_void,
517+
num: size_t,
518+
size: size_t,
519+
compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>,
520+
arg: *mut c_void,
521+
);
514522
}
515523

516524
#[link(name = "kvm")]

0 commit comments

Comments
 (0)