* [Qemu-devel] [PATCH 1/2] qemu_signalfd_available(): remove function due to lack of callers
2015-01-21 12:57 [Qemu-devel] [PATCH 0/2] clean up SYS_signalfd Laszlo Ersek
@ 2015-01-21 12:57 ` Laszlo Ersek
2015-01-21 12:57 ` [Qemu-devel] [PATCH 2/2] signalfd(): modernize detection and use Laszlo Ersek
2015-01-21 13:15 ` [Qemu-devel] [PATCH 0/2] clean up SYS_signalfd Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Laszlo Ersek @ 2015-01-21 12:57 UTC (permalink / raw)
To: qemu devel list, Paolo Bonzini, Peter Maydell, Laszlo Ersek
Noone calls qemu_signalfd_available(), let's remove it.
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
include/qemu/compatfd.h | 1 -
util/compatfd.c | 19 -------------------
2 files changed, 20 deletions(-)
diff --git a/include/qemu/compatfd.h b/include/qemu/compatfd.h
index 6b04877..fc37915 100644
--- a/include/qemu/compatfd.h
+++ b/include/qemu/compatfd.h
@@ -39,6 +39,5 @@ struct qemu_signalfd_siginfo {
};
int qemu_signalfd(const sigset_t *mask);
-bool qemu_signalfd_available(void);
#endif
diff --git a/util/compatfd.c b/util/compatfd.c
index 341ada6..e857150 100644
--- a/util/compatfd.c
+++ b/util/compatfd.c
@@ -108,22 +108,3 @@ int qemu_signalfd(const sigset_t *mask)
return qemu_signalfd_compat(mask);
}
-
-bool qemu_signalfd_available(void)
-{
-#ifdef CONFIG_SIGNALFD
- sigset_t mask;
- int fd;
- bool ok;
- sigemptyset(&mask);
- errno = 0;
- fd = syscall(SYS_signalfd, -1, &mask, _NSIG / 8);
- ok = (errno != ENOSYS);
- if (fd >= 0) {
- close(fd);
- }
- return ok;
-#else
- return false;
-#endif
-}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/2] signalfd(): modernize detection and use
2015-01-21 12:57 [Qemu-devel] [PATCH 0/2] clean up SYS_signalfd Laszlo Ersek
2015-01-21 12:57 ` [Qemu-devel] [PATCH 1/2] qemu_signalfd_available(): remove function due to lack of callers Laszlo Ersek
@ 2015-01-21 12:57 ` Laszlo Ersek
2015-01-21 13:15 ` [Qemu-devel] [PATCH 0/2] clean up SYS_signalfd Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Laszlo Ersek @ 2015-01-21 12:57 UTC (permalink / raw)
To: qemu devel list, Paolo Bonzini, Peter Maydell, Laszlo Ersek
qemu_signalfd() provides the (effects of the) Linux signalfd() syscall on
platforms that lack it. However, the check for the availability of
signalfd() in configure, and its use in qemu_signalfd() when it *is*
available, are seriously outdated (they date back to 2010-2011).
To wit, the SYS_signalfd-based check in configure can actually fail on at
least modern aarch64 Linux systems that *do* have signalfd().
(SYS_signalfd is deprecated and has been replaced by SYS_signalfd4 (note
the "4"). The signalfd() libc function selects the appropriate system
call.)
We should consider signalfd() accessible as a first class libc function on
platforms that support it. Modernize the related parts in configure and
"util/compatfd.c" (so that we end up with something similar to eventfd()'s
detection).
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
configure | 11 ++++++++---
util/compatfd.c | 5 ++---
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/configure b/configure
index 5ea1014..de0d21c 100755
--- a/configure
+++ b/configure
@@ -3280,10 +3280,15 @@ fi
# signalfd probe
signalfd="no"
cat > $TMPC << EOF
-#include <unistd.h>
-#include <sys/syscall.h>
+#include <sys/signalfd.h>
#include <signal.h>
-int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
+int main(void)
+{
+ sigset_t s;
+
+ sigfillset(&s);
+ return signalfd(-1, &s, SFD_CLOEXEC);
+}
EOF
if compile_prog "" "" ; then
diff --git a/util/compatfd.c b/util/compatfd.c
index e857150..7983391 100644
--- a/util/compatfd.c
+++ b/util/compatfd.c
@@ -17,7 +17,7 @@
#include "qemu/compatfd.h"
#include "qemu/thread.h"
-#include <sys/syscall.h>
+#include <sys/signalfd.h>
struct sigfd_compat_info
{
@@ -99,9 +99,8 @@ int qemu_signalfd(const sigset_t *mask)
#if defined(CONFIG_SIGNALFD)
int ret;
- ret = syscall(SYS_signalfd, -1, mask, _NSIG / 8);
+ ret = signalfd(-1, mask, SFD_CLOEXEC);
if (ret != -1) {
- qemu_set_cloexec(ret);
return ret;
}
#endif
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread