Skip to content

Commit 1c012ae

Browse files
committed
Add memmem
memmem is a non-standard extension, first added in GNU libc and later ported to other systems. Support for it is non-uniform, thus it was only added to platforms that seem to support it.
1 parent 8a7b02c commit 1c012ae

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,12 @@ extern "C" {
10861086
pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
10871087
pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
10881088
pub fn uname(buf: *mut ::utsname) -> ::c_int;
1089+
pub fn memmem(
1090+
haystack: *const ::c_void,
1091+
haystacklen: ::size_t,
1092+
needle: *const ::c_void,
1093+
needlelen: ::size_t,
1094+
) -> *mut ::c_void;
10891095
}
10901096

10911097
cfg_if! {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,12 @@ extern "C" {
14351435
flags: ::c_int,
14361436
timeout: *const ::timespec,
14371437
) -> ::ssize_t;
1438+
pub fn memmem(
1439+
haystack: *const ::c_void,
1440+
haystacklen: ::size_t,
1441+
needle: *const ::c_void,
1442+
needlelen: ::size_t,
1443+
) -> *mut ::c_void;
14381444
}
14391445

14401446
#[link(name = "util")]

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,6 +1894,12 @@ extern "C" {
18941894
) -> ::c_int;
18951895

18961896
pub fn _lwp_self() -> lwpid_t;
1897+
pub fn memmem(
1898+
haystack: *const ::c_void,
1899+
haystacklen: ::size_t,
1900+
needle: *const ::c_void,
1901+
needlelen: ::size_t,
1902+
) -> *mut ::c_void;
18971903
}
18981904

18991905
#[link(name = "util")]

src/unix/bsd/netbsdlike/openbsd/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,12 @@ extern "C" {
14781478
addr: caddr_t,
14791479
data: ::c_int,
14801480
) -> ::c_int;
1481+
pub fn memmem(
1482+
haystack: *const ::c_void,
1483+
haystacklen: ::size_t,
1484+
needle: *const ::c_void,
1485+
needlelen: ::size_t,
1486+
) -> *mut ::c_void;
14811487
}
14821488

14831489
cfg_if! {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,12 @@ extern "C" {
959959
buflen: ::size_t,
960960
flags: ::c_uint,
961961
) -> ::ssize_t;
962+
pub fn memmem(
963+
haystack: *const ::c_void,
964+
haystacklen: ::size_t,
965+
needle: *const ::c_void,
966+
needlelen: ::size_t,
967+
) -> *mut ::c_void;
962968
}
963969

964970
#[link(name = "util")]

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,12 @@ extern "C" {
416416
cpuset: *const ::cpu_set_t,
417417
) -> ::c_int;
418418
pub fn sched_getcpu() -> ::c_int;
419+
pub fn memmem(
420+
haystack: *const ::c_void,
421+
haystacklen: ::size_t,
422+
needle: *const ::c_void,
423+
needlelen: ::size_t,
424+
) -> *mut ::c_void;
419425
}
420426

421427
cfg_if! {

0 commit comments

Comments
 (0)