qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>, Michael Forney <mforney@mforney.org>
Subject: [PULL 9/9] linux-user: Use public sigev_notify_thread_id member if available
Date: Mon, 21 Jun 2021 13:04:45 +0200	[thread overview]
Message-ID: <20210621110445.231771-10-laurent@vivier.eu> (raw)
In-Reply-To: <20210621110445.231771-1-laurent@vivier.eu>

From: Michael Forney <mforney@mforney.org>

_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>
---
 configure            | 16 ++++++++++++++++
 linux-user/syscall.c |  6 +++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 8dcb9965b24e..942c531cce63 100755
--- a/configure
+++ b/configure
@@ -4440,6 +4440,19 @@ if compile_prog "" "" ; then
     st_atim=yes
 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
 
@@ -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 70ae8884ee54..64bbf331b282 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;
-- 
2.31.1



  parent reply	other threads:[~2021-06-21 11:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
2021-06-21 11:04 ` [PULL 1/9] linux-user: Set CF_PARALLEL when mapping shared memory Laurent Vivier
2021-06-21 11:04 ` [PULL 2/9] linux-user: Disable static assert involving __SIGRTMAX if it is missing Laurent Vivier
2021-06-21 11:04 ` [PULL 3/9] linux-user/trace-events: fix minor typo in format string Laurent Vivier
2021-06-21 11:04 ` [PULL 4/9] linux-user: Implement pivot_root Laurent Vivier
2021-06-21 11:04 ` [PULL 5/9] linux-user: Let sigaction query SIGKILL/SIGSTOP Laurent Vivier
2021-06-21 11:04 ` [PULL 6/9] tests/tcg/linux-test: Check that sigaction can " Laurent Vivier
2021-06-21 11:04 ` [PULL 7/9] linux-user: Check for ieee128 fpbits in PPC64 HWCAP2 feature list Laurent Vivier
2021-06-21 11:04 ` [PULL 8/9] linux-user: Fix incorrect use of feature-test-macros Laurent Vivier
2021-06-21 11:04 ` Laurent Vivier [this message]
2021-06-22 17:13 ` [PULL 0/9] Linux user for 6.1 patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210621110445.231771-10-laurent@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=mforney@mforney.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).