Skip to content

Commit

Permalink
apple add pthread_jit_write_callback_t api related.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Sep 1, 2022
1 parent f1c3cfe commit 86a3a3e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libc-test/build.rs
Expand Up @@ -512,6 +512,9 @@ fn test_openbsd(target: &str) {
// futex() has volatile arguments, but that doesn't exist in Rust.
"futex" => true,

// FIXME: remove once the target in CI is updated
"pthread_jit_write_freeze_callbacks_np" => true,

_ => false,
}
});
Expand Down
3 changes: 3 additions & 0 deletions libc-test/semver/apple.txt
Expand Up @@ -1905,8 +1905,11 @@ pthread_introspection_getspecific_np
pthread_introspection_hook_t
pthread_introspection_hook_install
pthread_introspection_setspecific_np
pthread_jit_write_callbacks_t
pthread_jit_write_freeze_callbacks_np
pthread_jit_write_protect_np
pthread_jit_write_protect_supported_np
pthread_jit_write_with_callback_np
pthread_setschedparam
pthread_cancel
pthread_condattr_getpshared
Expand Down
12 changes: 12 additions & 0 deletions src/unix/bsd/apple/mod.rs
Expand Up @@ -119,6 +119,7 @@ pub type thread_throughput_qos_policy_t = *mut thread_throughput_qos_policy;

pub type pthread_introspection_hook_t =
extern "C" fn(event: ::c_uint, thread: ::pthread_t, addr: *mut ::c_void, size: ::size_t);
pub type pthread_jit_write_callback_t = Option<extern "C" fn(ctx: *mut ::c_void) -> ::c_int>;

pub type vm_statistics_t = *mut vm_statistics;
pub type vm_statistics_data_t = vm_statistics;
Expand Down Expand Up @@ -5020,6 +5021,17 @@ extern "C" {
) -> *mut ::c_void;
pub fn pthread_jit_write_protect_np(enabled: ::c_int);
pub fn pthread_jit_write_protect_supported_np() -> ::c_int;
// An array of pthread_jit_write_with_callback_np must declare
// the list of callbacks e.g.
// #[link_section = "__DATA_CONST,__pth_jit_func"]
// static callbacks: [libc::pthread_jit_write_callback_t; 2] = [native_jit_write_cb,
// std::mem::transmute::<libc::pthread_jit_write_callback_t>(std::ptr::null())];
// (a handy PTHREAD_JIT_WRITE_CALLBACK_NP macro for other languages).
pub fn pthread_jit_write_with_callback_np(
callback: ::pthread_jit_write_callback_t,
ctx: *mut ::c_void,
) -> ::c_int;
pub fn pthread_jit_write_freeze_callbacks_np();
pub fn pthread_cpu_number_np(cpu_number_out: *mut ::size_t) -> ::c_int;

pub fn thread_policy_set(
Expand Down

0 comments on commit 86a3a3e

Please sign in to comment.