Skip to content

Commit 52b45a7

Browse files
committed
apple add pthread_jit_write_callback_t api related.
1 parent f1c3cfe commit 52b45a7

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

libc-test/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ fn test_apple(target: &str) {
321321
// close calls the close_nocancel system call
322322
"close" => true,
323323

324+
// FIXME: remove once the target in CI is updated
325+
"pthread_jit_write_freeze_callbacks_np" => true,
326+
324327
_ => false,
325328
}
326329
});

libc-test/semver/apple.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,8 +1905,11 @@ pthread_introspection_getspecific_np
19051905
pthread_introspection_hook_t
19061906
pthread_introspection_hook_install
19071907
pthread_introspection_setspecific_np
1908+
pthread_jit_write_callback_t
1909+
pthread_jit_write_freeze_callbacks_np
19081910
pthread_jit_write_protect_np
19091911
pthread_jit_write_protect_supported_np
1912+
pthread_jit_write_with_callback_np
19101913
pthread_setschedparam
19111914
pthread_cancel
19121915
pthread_condattr_getpshared

src/unix/bsd/apple/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ pub type thread_throughput_qos_policy_t = *mut thread_throughput_qos_policy;
119119

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

123124
pub type vm_statistics_t = *mut vm_statistics;
124125
pub type vm_statistics_data_t = vm_statistics;
@@ -5020,6 +5021,17 @@ extern "C" {
50205021
) -> *mut ::c_void;
50215022
pub fn pthread_jit_write_protect_np(enabled: ::c_int);
50225023
pub fn pthread_jit_write_protect_supported_np() -> ::c_int;
5024+
// An array of pthread_jit_write_with_callback_np must declare
5025+
// the list of callbacks e.g.
5026+
// #[link_section = "__DATA_CONST,__pth_jit_func"]
5027+
// static callbacks: [libc::pthread_jit_write_callback_t; 2] = [native_jit_write_cb,
5028+
// std::mem::transmute::<libc::pthread_jit_write_callback_t>(std::ptr::null())];
5029+
// (a handy PTHREAD_JIT_WRITE_CALLBACK_NP macro for other languages).
5030+
pub fn pthread_jit_write_with_callback_np(
5031+
callback: ::pthread_jit_write_callback_t,
5032+
ctx: *mut ::c_void,
5033+
) -> ::c_int;
5034+
pub fn pthread_jit_write_freeze_callbacks_np();
50235035
pub fn pthread_cpu_number_np(cpu_number_out: *mut ::size_t) -> ::c_int;
50245036

50255037
pub fn thread_policy_set(

0 commit comments

Comments
 (0)