* [PATCH] linux-user: Use public sigev_notify_thread_id member if available
@ 2021-05-26 3:55 Michael Forney
2021-06-15 6:42 ` Laurent Vivier
0 siblings, 1 reply; 2+ messages in thread
From: Michael Forney @ 2021-05-26 3:55 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel
_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>
---
configure | 16 ++++++++++++++++
linux-user/syscall.c | 6 +++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 676239c697..fa39b0a727 100755
--- a/configure
+++ b/configure
@@ -4462,6 +4462,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
@@ -5718,6 +5731,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 c9f812091c..63464f9a96 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7393,6 +7393,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)
{
@@ -7413,7 +7417,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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] linux-user: Use public sigev_notify_thread_id member if available
2021-05-26 3:55 [PATCH] linux-user: Use public sigev_notify_thread_id member if available Michael Forney
@ 2021-06-15 6:42 ` Laurent Vivier
0 siblings, 0 replies; 2+ messages in thread
From: Laurent Vivier @ 2021-06-15 6:42 UTC (permalink / raw)
To: Michael Forney; +Cc: qemu-devel
Le 26/05/2021 à 05:55, Michael Forney a écrit :
> _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>
> ---
> configure | 16 ++++++++++++++++
> linux-user/syscall.c | 6 +++++-
> 2 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 676239c697..fa39b0a727 100755
> --- a/configure
> +++ b/configure
> @@ -4462,6 +4462,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
>
> @@ -5718,6 +5731,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 c9f812091c..63464f9a96 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7393,6 +7393,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)
> {
> @@ -7413,7 +7417,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;
>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-15 6:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 3:55 [PATCH] linux-user: Use public sigev_notify_thread_id member if available Michael Forney
2021-06-15 6:42 ` Laurent Vivier
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).