Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,7 @@ ptrace
pututxline
pwritev
qsort
qsort_r
querylocale
quotactl
radvisory
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2241,6 +2241,7 @@ ptsname_r
pututxline
pwritev
qsort
qsort_r
querylocale
rallocx
rand
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/netbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,7 @@ ptrace_siginfo
pututxline
pwritev
qsort
qsort_r
rand
readdir_r
readlinkat
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ putchar
putenv
putenv_s
puts
qsort
qsort_s
raise
rand
read
Expand Down
8 changes: 8 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5926,6 +5926,14 @@ extern "C" {
search_path: *const c_char,
argv: *const *mut c_char,
) -> c_int;

pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
arg: *mut c_void,
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
);
}

cfg_if! {
Expand Down
11 changes: 11 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,17 @@ extern "C" {
// in FreeBSD 12
pub fn dirname(path: *const c_char) -> *mut c_char;
pub fn basename(path: *const c_char) -> *mut c_char;

// Argument order of the function pointer changed in FreeBSD 14. From 14 onwards the signature
// matches the POSIX specification by having the third argument be a mutable pointer, on
// earlier versions the first argument is the mutable pointer.
pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
arg: *mut c_void,
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
);
}

cfg_if! {
Expand Down
8 changes: 8 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,14 @@ extern "C" {

pub fn dirname(path: *mut c_char) -> *mut c_char;
pub fn basename(path: *mut c_char) -> *mut c_char;

pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
arg: *mut c_void,
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
);
}

cfg_if! {
Expand Down
8 changes: 8 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,14 @@ extern "C" {

pub fn dirname(path: *mut c_char) -> *mut c_char;
pub fn basename(path: *mut c_char) -> *mut c_char;

pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
arg: *mut c_void,
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
);
}

#[link(name = "kvm")]
Expand Down
8 changes: 8 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,14 @@ extern "C" {

pub fn dirname(path: *mut c_char) -> *mut c_char;
pub fn basename(path: *mut c_char) -> *mut c_char;

pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>,
arg: *mut c_void,
);
Comment on lines +513 to +519
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't thunk before compar in FreeBSD 14 and 15?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not, the signature is

 void
       qsort_r(void *base,	       size_t nmemb,		  size_t size,
	   int (*compar)(const void *, const void *, void *), void *thunk);

(you have to re-submit the form for the correct docs version to load)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh sorry I commented the exact opposite of what I meant: on <= 13, it looks like it is before compar

       void
       qsort_r(void *base,     size_t nmemb,	 size_t	size,	  void *thunk,
	   int (*compar)(void *, const void *, const void *));
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cc @asomers for the FreeBSD review in any case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, right, fixed.

}

#[link(name = "kvm")]
Expand Down
8 changes: 8 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,14 @@ extern "C" {

pub fn dirname(path: *mut c_char) -> *mut c_char;
pub fn basename(path: *mut c_char) -> *mut c_char;

pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>,
arg: *mut c_void,
);
}

#[link(name = "kvm")]
Expand Down
8 changes: 8 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,14 @@ extern "C" {
new_value: *const itimerspec,
old_value: *mut itimerspec,
) -> c_int;

pub fn qsort_r(
base: *mut c_void,
num: size_t,
size: size_t,
compar: Option<unsafe extern "C" fn(*const c_void, *const c_void, *mut c_void) -> c_int>,
arg: *mut c_void,
);
}

#[link(name = "rt")]
Expand Down
13 changes: 13 additions & 0 deletions src/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,19 @@ extern "C" {
pub fn isblank(c: c_int) -> c_int;
pub fn tolower(c: c_int) -> c_int;
pub fn toupper(c: c_int) -> c_int;
pub fn qsort(
base: *mut c_void,
num: size_t,
size: size_t,
compar: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
);
pub fn qsort_s(
base: *mut c_void,
num: size_t,
size: size_t,
compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
arg: *mut c_void,
);
pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
pub fn fflush(file: *mut FILE) -> c_int;
Expand Down