From: Paul Floyd Date: Thu, 23 Nov 2023 06:24:11 +0000 (+0100) Subject: Darwin: add sigwait syscall wrapper X-Git-Tag: VALGRIND_3_23_0~242 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1b68697bac685986a8b694cb811b41e6cfcaa67;p=thirdparty%2Fvalgrind.git Darwin: add sigwait syscall wrapper The FreeBSD testcase doesn't work, but the problem seems to be with the initial signal()/raise(). Needs more work. --- diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index cb31fb51b1..c2dd3507f0 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -421,7 +421,7 @@ DECL_TEMPLATE(darwin, aio_write); // 319 DECL_TEMPLATE(darwin, issetugid); // 327 DECL_TEMPLATE(darwin, __pthread_kill); // 328 DECL_TEMPLATE(darwin, __pthread_sigmask); // 329 -// NYI __sigwait 330 +DECL_TEMPLATE(darwin, __sigwait); // 330 DECL_TEMPLATE(darwin, __disable_threadsignal); // 331 DECL_TEMPLATE(darwin, __pthread_markcancel); // 332 DECL_TEMPLATE(darwin, __pthread_canceled); // 333 diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 8de5ae7379..175ea27b32 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -2325,6 +2325,30 @@ POST(__pthread_sigmask) } +// SYS___sigwait 330 +// int sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait); +PRE(__sigwait) +{ + *flags |= SfMayBlock; + PRINT("sys_sigwait ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", + ARG1,ARG2); + PRE_REG_READ2(int, "sigwait", + const vki_sigset_t *, set, int *, sig); + if (ARG1 != 0) { + PRE_MEM_READ( "sigwait(set)", ARG1, sizeof(vki_sigset_t)); + } + if (ARG2 != 0) { + PRE_MEM_WRITE( "sigwait(sig)", ARG2, sizeof(int)); + } +} + +POST(__sigwait) +{ + if (ARG2 != 0) { + POST_MEM_WRITE( ARG2, sizeof(int)); + } +} + PRE(__pthread_canceled) { *flags |= SfMayBlock; /* might kill this thread??? */ @@ -10597,7 +10621,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { MACX_(__NR_issetugid, issetugid), MACX_(__NR___pthread_kill, __pthread_kill), MACX_(__NR___pthread_sigmask, __pthread_sigmask), -// _____(__NR___sigwait), + MACXY(__NR___sigwait, __sigwait), // 330 MACX_(__NR___disable_threadsignal, __disable_threadsignal), MACX_(__NR___pthread_markcancel, __pthread_markcancel), MACX_(__NR___pthread_canceled, __pthread_canceled), diff --git a/include/vki/vki-scnums-darwin.h b/include/vki/vki-scnums-darwin.h index 7af0465c54..3aa35d1fc6 100644 --- a/include/vki/vki-scnums-darwin.h +++ b/include/vki/vki-scnums-darwin.h @@ -609,7 +609,7 @@ #define __NR_issetugid VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(327) #define __NR___pthread_kill VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(328) #define __NR___pthread_sigmask VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(329) -#define __NR___sigwait VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(330) +#define __NR___sigwait VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(330) #define __NR___disable_threadsignal VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(331) #define __NR___pthread_markcancel VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(332) #define __NR___pthread_canceled VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(333)