This replaces the deprecated `syscall()` to `__pthread_kill` with its wrapper version, which will continue working when the syscall numbers change (happens luckily very rarely on XNU compared to NT).
Also replaces the deprecated `bootstrap_register` with `bootstrap_register2` (which although being private is being used by `-[NSMachBootstrapServer registerPort:name:]`, and what `bootstrap_register` calls into as well).
Both of these are available on at least OSX 10.5+ as far as I can tell, so should be fine support wise.
I took the liberty to also slightly adjust the formatting of `void init_tracing_mechanism(void)` to better fit into the surrounding code.
For me this makes it so mach.c now builds with 0 warnings all in all.
From: Marc-Aurel Zent mzent@codeweavers.com
--- server/mach.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/server/mach.c b/server/mach.c index a619c1cd2a8..81c5ef10ab1 100644 --- a/server/mach.c +++ b/server/mach.c @@ -28,9 +28,6 @@ #include <stdarg.h> #include <sys/types.h> #include <unistd.h> -#ifdef HAVE_SYS_SYSCALL_H -#include <sys/syscall.h> -#endif #ifdef HAVE_SYS_SYSCTL_H #include <sys/sysctl.h> #endif @@ -358,6 +355,8 @@ done: #endif }
+extern int __pthread_kill( mach_port_t, int ); + int send_thread_signal( struct thread *thread, int sig ) { int ret = -1; @@ -371,7 +370,7 @@ int send_thread_signal( struct thread *thread, int sig ) if (!mach_port_extract_right( process_port, thread->unix_tid, MACH_MSG_TYPE_COPY_SEND, &port, &type )) { - ret = syscall( SYS___pthread_kill, port, sig ); + ret = __pthread_kill( port, sig ); mach_port_deallocate( mach_task_self(), port ); } else errno = ESRCH;
From: Marc-Aurel Zent mzent@codeweavers.com
--- server/mach.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/server/mach.c b/server/mach.c index 81c5ef10ab1..5f4c710da4f 100644 --- a/server/mach.c +++ b/server/mach.c @@ -93,6 +93,8 @@ static int is_rosetta( void ) return rosetta_status; }
+extern kern_return_t bootstrap_register2( mach_port_t bp, name_t service_name, mach_port_t sp, uint64_t flags ); + /* initialize the process control mechanism */ void init_tracing_mechanism(void) { @@ -107,7 +109,7 @@ void init_tracing_mechanism(void) server_mach_port, MACH_MSG_TYPE_MAKE_SEND ) != KERN_SUCCESS) fatal_error("Error inserting rights\n"); - if (bootstrap_register(bp, server_dir, server_mach_port) != KERN_SUCCESS) + if (bootstrap_register2( bp, server_dir, server_mach_port, 0 ) != KERN_SUCCESS) fatal_error("Can't check in server_mach_port\n"); mach_port_deallocate(mach_task_self(), bp); }
From: Marc-Aurel Zent mzent@codeweavers.com
--- server/mach.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/server/mach.c b/server/mach.c index 5f4c710da4f..86ff7eac382 100644 --- a/server/mach.c +++ b/server/mach.c @@ -100,18 +100,18 @@ void init_tracing_mechanism(void) { mach_port_t bp;
- if (task_get_bootstrap_port(mach_task_self(), &bp) != KERN_SUCCESS) - fatal_error("Can't find bootstrap port\n"); - if (mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &server_mach_port) != KERN_SUCCESS) - fatal_error("Can't allocate port\n"); + if (task_get_bootstrap_port( mach_task_self(), &bp ) != KERN_SUCCESS) + fatal_error( "Can't find bootstrap port\n" ); + if (mach_port_allocate( mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &server_mach_port ) != KERN_SUCCESS) + fatal_error( "Can't allocate port\n" ); if (mach_port_insert_right( mach_task_self(), server_mach_port, server_mach_port, MACH_MSG_TYPE_MAKE_SEND ) != KERN_SUCCESS) - fatal_error("Error inserting rights\n"); + fatal_error( "Error inserting rights\n" ); if (bootstrap_register2( bp, server_dir, server_mach_port, 0 ) != KERN_SUCCESS) - fatal_error("Can't check in server_mach_port\n"); - mach_port_deallocate(mach_task_self(), bp); + fatal_error( "Can't check in server_mach_port\n" ); + mach_port_deallocate( mach_task_self(), bp ); }
/* initialize the per-process tracing mechanism */