Skip to content

Use unsafe callbacks #4341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
3 changes: 1 addition & 2 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4064,8 +4064,7 @@ fn test_linux(target: &str) {
"epoll_params" => true,

// FIXME(linux): Requires >= 6.12 kernel headers.
"dmabuf_cmsg" |
"dmabuf_token" => true,
"dmabuf_cmsg" | "dmabuf_token" => true,

_ => false,
}
Expand Down
4 changes: 2 additions & 2 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3616,7 +3616,7 @@ extern "C" {
pub fn abort() -> !;
pub fn exit(status: c_int) -> !;
pub fn _exit(status: c_int) -> !;
pub fn atexit(cb: extern "C" fn()) -> c_int;
pub fn atexit(cb: unsafe extern "C" fn()) -> c_int;
pub fn system(s: *const c_char) -> c_int;
pub fn getenv(s: *const c_char) -> *mut c_char;

Expand Down Expand Up @@ -4317,7 +4317,7 @@ extern "C" {
abstime: *const crate::timespec,
) -> c_int;
pub fn clone(
cb: extern "C" fn(*mut c_void) -> c_int,
cb: unsafe extern "C" fn(*mut c_void) -> c_int,
child_stack: *mut c_void,
flags: c_int,
arg: *mut c_void,
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3887,7 +3887,7 @@ extern "C" {
pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int;
pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int;
pub fn clone(
cb: extern "C" fn(*mut c_void) -> c_int,
cb: unsafe extern "C" fn(*mut c_void) -> c_int,
child_stack: *mut c_void,
flags: c_int,
arg: *mut c_void,
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6573,7 +6573,7 @@ extern "C" {
pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int;
pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int;
pub fn clone(
cb: extern "C" fn(*mut c_void) -> c_int,
cb: unsafe extern "C" fn(*mut c_void) -> c_int,
child_stack: *mut c_void,
flags: c_int,
arg: *mut c_void,
Expand Down
2 changes: 1 addition & 1 deletion src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ cfg_if! {
) -> ssize_t;
pub fn fmemopen(buf: *mut c_void, size: size_t, mode: *const c_char) -> *mut FILE;
pub fn open_memstream(ptr: *mut *mut c_char, sizeloc: *mut size_t) -> *mut FILE;
pub fn atexit(cb: extern "C" fn()) -> c_int;
pub fn atexit(cb: unsafe extern "C" fn()) -> c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")]
pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction)
-> c_int;
Expand Down
8 changes: 6 additions & 2 deletions src/unix/nto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3418,10 +3418,14 @@ extern "C" {

// Models the implementation in stdlib.h. Ctest will fail if trying to use the
// default symbol from libc
pub unsafe fn atexit(cb: extern "C" fn()) -> c_int {
pub unsafe fn atexit(cb: unsafe extern "C" fn()) -> c_int {
extern "C" {
static __dso_handle: *mut c_void;
pub fn __cxa_atexit(cb: extern "C" fn(), __arg: *mut c_void, __dso: *mut c_void) -> c_int;
pub fn __cxa_atexit(
cb: unsafe extern "C" fn(),
__arg: *mut c_void,
__dso: *mut c_void,
) -> c_int;
}
__cxa_atexit(cb, 0 as *mut c_void, __dso_handle)
}
Expand Down
2 changes: 1 addition & 1 deletion src/vxworks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ extern "C" {
pub fn free(p: *mut c_void);
pub fn abort() -> !;
pub fn exit(status: c_int) -> !;
pub fn atexit(cb: extern "C" fn()) -> c_int;
pub fn atexit(cb: unsafe extern "C" fn()) -> c_int;
pub fn system(s: *const c_char) -> c_int;
pub fn getenv(s: *const c_char) -> *mut c_char;

Expand Down
2 changes: 1 addition & 1 deletion src/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ extern "C" {
pub fn abort() -> !;
pub fn exit(status: c_int) -> !;
pub fn _exit(status: c_int) -> !;
pub fn atexit(cb: extern "C" fn()) -> c_int;
pub fn atexit(cb: unsafe extern "C" fn()) -> c_int;
pub fn system(s: *const c_char) -> c_int;
pub fn getenv(s: *const c_char) -> *mut c_char;

Expand Down
Loading