Skip to content

Commit 46c8ecc

Browse files
authored
Merge pull request #1620 from malbarbo/qsort
Add qsort, qsort_r and bsearch
2 parents 8a7b02c + 1914ae8 commit 46c8ecc

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,19 @@ cfg_if! {
894894
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 3;
895895

896896
extern "C" {
897+
pub fn qsort_r(
898+
base: *mut ::c_void,
899+
num: ::size_t,
900+
size: ::size_t,
901+
compar: ::Option<
902+
unsafe extern "C" fn(
903+
*const ::c_void,
904+
*const ::c_void,
905+
*mut ::c_void,
906+
) -> ::c_int,
907+
>,
908+
arg: *mut ::c_void,
909+
);
897910
pub fn sendmmsg(
898911
sockfd: ::c_int,
899912
msgvec: *mut ::mmsghdr,

src/unix/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,23 @@ extern "C" {
388388
pub fn isblank(c: c_int) -> c_int;
389389
pub fn tolower(c: c_int) -> c_int;
390390
pub fn toupper(c: c_int) -> c_int;
391+
pub fn qsort(
392+
base: *mut c_void,
393+
num: size_t,
394+
size: size_t,
395+
compar: ::Option<
396+
unsafe extern "C" fn(*const c_void, *const c_void) -> c_int,
397+
>,
398+
);
399+
pub fn bsearch(
400+
key: *const c_void,
401+
base: *const c_void,
402+
num: size_t,
403+
size: size_t,
404+
compar: ::Option<
405+
unsafe extern "C" fn(*const c_void, *const c_void) -> c_int,
406+
>,
407+
) -> *mut c_void;
391408
#[cfg_attr(
392409
all(target_os = "macos", target_arch = "x86"),
393410
link_name = "fopen$UNIX2003"

0 commit comments

Comments
 (0)