From 1e2da75bad39c606cb343ccfe7422a758036e5c5 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 8 Dec 2024 22:20:59 +0000 Subject: [PATCH] adding POSIX memccpy and mempcpy GNU extension. [memccpy](https://pubs.opengroup.org/onlinepubs/9699919799/functions/memccpy.html) [mempcpy](https://man7.org/linux/man-pages/man3/mempcpy.3.html) (backport ) (cherry picked from commit ba5930dbc20dba0dbb3d39496313f6be4468cf01) --- libc-test/semver/linux-gnu.txt | 1 + libc-test/semver/unix.txt | 1 + src/unix/linux_like/linux/gnu/mod.rs | 2 ++ src/unix/mod.rs | 1 + 4 files changed, 5 insertions(+) diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index a6d6b6bf59d88..2aed5d7628eae 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -650,6 +650,7 @@ malloc_stats malloc_trim malloc_usable_size mallopt +mempcpy mq_notify nl_mmap_hdr nl_mmap_req diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index 093dde173137c..052c24178dfcc 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -638,6 +638,7 @@ localtime_r lseek lstat malloc +memccpy memchr memcmp memcpy diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 0d0278de2c8b3..75ac2e088f7d9 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1539,6 +1539,8 @@ extern "C" { timeout: *const crate::timespec, sigmask: *const crate::sigset_t, ) -> c_int; + + pub fn mempcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; } cfg_if! { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 661405f50eb1d..a14dafdf06d9e 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -681,6 +681,7 @@ extern "C" { pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, n: size_t) -> *mut c_void; } extern "C" {