diff mbox series

[v2,12/20] mach: Declare the new thread_set_self_state () trap

Message ID 20240323173301.151066-13-bugaevc@gmail.com
State New
Headers show
Series aarch64-gnu port & GNU/Hurd on AArch64 progress | expand

Commit Message

Sergey Bugaev March 23, 2024, 5:32 p.m. UTC
This is a new Mach trap for setting the state of the current thread, as
if with thread_set_state () RPC.  The trap has been added to GNU Mach as
a part of the AArch64 port, to make it possible to implement sigreturn
in glibc; however, the trap itself is fully arch-independent.

There does not seem to be an easy way to feature-test, in a header, for
existence of traps in the Mach version being built against.  Instead,
just declare the trap prototype unconditionally, and don't add an
exported version for now.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
 sysdeps/mach/include/mach/mach_traps.h | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/sysdeps/mach/include/mach/mach_traps.h b/sysdeps/mach/include/mach/mach_traps.h
index c4334952..a942212c 100644
--- a/sysdeps/mach/include/mach/mach_traps.h
+++ b/sysdeps/mach/include/mach/mach_traps.h
@@ -19,5 +19,12 @@  kern_return_t __thread_switch (mach_port_t new_thread,
 libc_hidden_proto (__thread_switch)
 kern_return_t __evc_wait (unsigned int event);
 libc_hidden_proto (__evc_wait)
+
+/* Set current thread's state, as if with thread_set_state() RPC.
+   This syscall is only really available in recent enough GNU Mach.  */
+extern kern_return_t __thread_set_self_state (int flavor,
+					      natural_t *new_state,
+					      natural_t new_state_count);
+libc_hidden_proto (__thread_set_self_state)
 #endif
 #endif