aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2021-05-25 20:55:56 -0700
committerLaurent Vivier <laurent@vivier.eu>2021-06-20 16:41:47 +0200
commit96ff758c6e9cd5a01443ee15afbd0df4f00c37a8 (patch)
treeb9a4fa9a9f1bd37872a0c8b8fdee187c9837ee51
parentfebf6fade63801ebca765797fa2ad9de8d9f2700 (diff)
downloadqemu-96ff758c6e9cd5a01443ee15afbd0df4f00c37a8.zip
qemu-96ff758c6e9cd5a01443ee15afbd0df4f00c37a8.tar.gz
qemu-96ff758c6e9cd5a01443ee15afbd0df4f00c37a8.tar.bz2
linux-user: Use public sigev_notify_thread_id member if available
_sigev_un._tid is an internal glibc field and is not available on musl libc. The sigevent(7) man page and Linux UAPI headers both use sigev_notify_thread_id as a public way to access this field. musl libc supports this field since 1.2.2[0], and glibc plans to add support as well[1][2]. If sigev_notify_thread_id is not available, fall back to _sigev_un._tid as before. [0] http://git.musl-libc.org/cgit/musl/commit/?id=7c71792e87691451f2a6b76348e83ad1889f1dcb [1] https://www.openwall.com/lists/musl/2019/08/01/5 [2] https://sourceware.org/bugzilla/show_bug.cgi?id=27417 Signed-off-by: Michael Forney <mforney@mforney.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20210526035556.7931-1-mforney@mforney.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
-rwxr-xr-xconfigure16
-rw-r--r--linux-user/syscall.c6
2 files changed, 21 insertions, 1 deletions
diff --git a/configure b/configure
index 8dcb996..942c531 100755
--- a/configure
+++ b/configure
@@ -4441,6 +4441,19 @@ if compile_prog "" "" ; then
fi
##########################################
+# check if we have sigev_notify_thread_id
+
+sigev_notify_thread_id=no
+cat > $TMPC << EOF
+#include <stddef.h>
+#include <signal.h>
+int main(void) { return offsetof(struct sigevent, sigev_notify_thread_id); }
+EOF
+if compile_prog "" "" ; then
+ sigev_notify_thread_id=yes
+fi
+
+##########################################
# check if trace backend exists
$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
@@ -5692,6 +5705,9 @@ fi
if test "$st_atim" = "yes" ; then
echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
fi
+if test "$sigev_notify_thread_id" = "yes" ; then
+ echo "HAVE_SIGEV_NOTIFY_THREAD_ID=y" >> $config_host_mak
+fi
if test "$byteswap_h" = "yes" ; then
echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
fi
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 70ae888..64bbf33 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7405,6 +7405,10 @@ static inline abi_long host_to_target_timex64(abi_long target_addr,
}
#endif
+#ifndef HAVE_SIGEV_NOTIFY_THREAD_ID
+#define sigev_notify_thread_id _sigev_un._tid
+#endif
+
static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp,
abi_ulong target_addr)
{
@@ -7425,7 +7429,7 @@ static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp,
host_sevp->sigev_signo =
target_to_host_signal(tswap32(target_sevp->sigev_signo));
host_sevp->sigev_notify = tswap32(target_sevp->sigev_notify);
- host_sevp->_sigev_un._tid = tswap32(target_sevp->_sigev_un._tid);
+ host_sevp->sigev_notify_thread_id = tswap32(target_sevp->_sigev_un._tid);
unlock_user_struct(target_sevp, target_addr, 1);
return 0;