* [PATCH v3 1/9] build: Enable BSD symbols for Haiku
2020-07-03 14:56 [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
@ 2020-07-03 14:56 ` Peter Maydell
2020-07-03 14:56 ` [PATCH v3 2/9] util/qemu-openpty.c: Don't assume pty.h is glibc-only Peter Maydell
` (8 subsequent siblings)
9 siblings, 0 replies; 23+ messages in thread
From: Peter Maydell @ 2020-07-03 14:56 UTC (permalink / raw)
To: qemu-devel; +Cc: David Carlier, Gerd Hoffmann
From: David CARLIER <devnexen@gmail.com>
Tell Haiku to provide various BSD functions by setting BSD_SOURCE
and linking libbsd.
Signed-off-by: David Carlier <devnexen@gmail.com>
[PMM: expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
configure | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 8a65240d4a8..c9c135b70bc 100755
--- a/configure
+++ b/configure
@@ -903,8 +903,8 @@ SunOS)
;;
Haiku)
haiku="yes"
- QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
- LIBS="-lposix_error_mapper -lnetwork $LIBS"
+ QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -DBSD_SOURCE $QEMU_CFLAGS"
+ LIBS="-lposix_error_mapper -lnetwork -lbsd $LIBS"
;;
Linux)
audio_drv_list="try-pa oss"
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 2/9] util/qemu-openpty.c: Don't assume pty.h is glibc-only
2020-07-03 14:56 [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
2020-07-03 14:56 ` [PATCH v3 1/9] build: Enable BSD symbols " Peter Maydell
@ 2020-07-03 14:56 ` Peter Maydell
2020-07-03 15:12 ` Thomas Huth
2020-07-03 14:56 ` [PATCH v3 3/9] build: Check that mlockall() exists Peter Maydell
` (7 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Peter Maydell @ 2020-07-03 14:56 UTC (permalink / raw)
To: qemu-devel; +Cc: David Carlier, Gerd Hoffmann
From: David CARLIER <devnexen@gmail.com>
Instead of using an OS-specific ifdef test to select the "openpty()
is in pty.h" codepath, make configure check for the existence of
the header and use the new CONFIG_PTY instead.
This is necessary to build on Haiku, which also provides openpty()
via pty.h.
Signed-off-by: David Carlier <devnexen@gmail.com>
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
configure | 9 +++++++++
util/qemu-openpty.c | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index c9c135b70bc..5455ae10d05 100755
--- a/configure
+++ b/configure
@@ -2386,6 +2386,12 @@ else
l2tpv3=no
fi
+if check_include "pty.h" ; then
+ pty_h=yes
+else
+ pty_h=no
+fi
+
#########################################
# vhost interdependencies and host support
@@ -7856,6 +7862,9 @@ fi
if test "$sheepdog" = "yes" ; then
echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
fi
+if test "$pty_h" = "yes" ; then
+ echo "CONFIG_PTY=y" >> $config_host_mak
+fi
if test "$fuzzing" = "yes" ; then
if test "$have_fuzzer" = "yes"; then
FUZZ_LDFLAGS=" -fsanitize=address,fuzzer"
diff --git a/util/qemu-openpty.c b/util/qemu-openpty.c
index 2e8b43bdf57..9d8ad6905e0 100644
--- a/util/qemu-openpty.c
+++ b/util/qemu-openpty.c
@@ -35,7 +35,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
-#if defined(__GLIBC__)
+#if defined CONFIG_PTY
# include <pty.h>
#elif defined CONFIG_BSD
# include <termios.h>
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v3 2/9] util/qemu-openpty.c: Don't assume pty.h is glibc-only
2020-07-03 14:56 ` [PATCH v3 2/9] util/qemu-openpty.c: Don't assume pty.h is glibc-only Peter Maydell
@ 2020-07-03 15:12 ` Thomas Huth
2020-07-06 14:00 ` Eric Blake
0 siblings, 1 reply; 23+ messages in thread
From: Thomas Huth @ 2020-07-03 15:12 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 03/07/2020 16.56, Peter Maydell wrote:
> From: David CARLIER <devnexen@gmail.com>
>
> Instead of using an OS-specific ifdef test to select the "openpty()
> is in pty.h" codepath, make configure check for the existence of
> the header and use the new CONFIG_PTY instead.
>
> This is necessary to build on Haiku, which also provides openpty()
> via pty.h.
>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> [PMM: Expanded commit message]
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> configure | 9 +++++++++
> util/qemu-openpty.c | 2 +-
> 2 files changed, 10 insertions(+), 1 deletion(-)
[...]
> diff --git a/util/qemu-openpty.c b/util/qemu-openpty.c
> index 2e8b43bdf57..9d8ad6905e0 100644
> --- a/util/qemu-openpty.c
> +++ b/util/qemu-openpty.c
> @@ -35,7 +35,7 @@
> #include "qemu/osdep.h"
> #include "qemu-common.h"
>
> -#if defined(__GLIBC__)
> +#if defined CONFIG_PTY
Shouldn't there be some parentheses around CONFIG_PTY here?
Thomas
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 2/9] util/qemu-openpty.c: Don't assume pty.h is glibc-only
2020-07-03 15:12 ` Thomas Huth
@ 2020-07-06 14:00 ` Eric Blake
2020-07-06 16:50 ` Thomas Huth
0 siblings, 1 reply; 23+ messages in thread
From: Eric Blake @ 2020-07-06 14:00 UTC (permalink / raw)
To: Thomas Huth, Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 7/3/20 10:12 AM, Thomas Huth wrote:
>> +++ b/util/qemu-openpty.c
>> @@ -35,7 +35,7 @@
>> #include "qemu/osdep.h"
>> #include "qemu-common.h"
>>
>> -#if defined(__GLIBC__)
>> +#if defined CONFIG_PTY
>
> Shouldn't there be some parentheses around CONFIG_PTY here?
No, they are optional, and omitting them is more consistent with the
CONFIG_BSD just below.
> #elif defined CONFIG_BSD
> # include <termios.h>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 2/9] util/qemu-openpty.c: Don't assume pty.h is glibc-only
2020-07-06 14:00 ` Eric Blake
@ 2020-07-06 16:50 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2020-07-06 16:50 UTC (permalink / raw)
To: Eric Blake, Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 06/07/2020 16.00, Eric Blake wrote:
> On 7/3/20 10:12 AM, Thomas Huth wrote:
>
>>> +++ b/util/qemu-openpty.c
>>> @@ -35,7 +35,7 @@
>>> #include "qemu/osdep.h"
>>> #include "qemu-common.h"
>>> -#if defined(__GLIBC__)
>>> +#if defined CONFIG_PTY
>
>>
>> Shouldn't there be some parentheses around CONFIG_PTY here?
>
> No, they are optional, and omitting them is more consistent with the
> CONFIG_BSD just below.
Thanks, TIL - I'm doing so many years of C programming already, and
until now I never noticed any code that does not use parentheses after
"defined" ...
Thomas
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v3 3/9] build: Check that mlockall() exists
2020-07-03 14:56 [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
2020-07-03 14:56 ` [PATCH v3 1/9] build: Enable BSD symbols " Peter Maydell
2020-07-03 14:56 ` [PATCH v3 2/9] util/qemu-openpty.c: Don't assume pty.h is glibc-only Peter Maydell
@ 2020-07-03 14:56 ` Peter Maydell
2020-07-03 15:13 ` Thomas Huth
2020-07-03 14:56 ` [PATCH v3 4/9] osdep.h: Always include <sys/signal.h> if it exists Peter Maydell
` (6 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Peter Maydell @ 2020-07-03 14:56 UTC (permalink / raw)
To: qemu-devel; +Cc: David Carlier, Gerd Hoffmann
From: David CARLIER <devnexen@gmail.com>
Instead of assuming that all POSIX platforms provide mlockall(),
test for it in configure. If the host doesn't provide this platform
then os_mlock() will fail -ENOSYS, as it does already on Windows.
This is necessary for Haiku, which does not have mlockall().
Signed-off-by: David Carlier <devnexen@gmail.com>
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
configure | 15 +++++++++++++++
os-posix.c | 4 ++++
2 files changed, 19 insertions(+)
diff --git a/configure b/configure
index 5455ae10d05..ddc53d873ef 100755
--- a/configure
+++ b/configure
@@ -2392,6 +2392,18 @@ else
pty_h=no
fi
+cat > $TMPC <<EOF
+#include <sys/mman.h>
+int main(int argc, char *argv[]) {
+ return mlockall(MCL_FUTURE);
+}
+EOF
+if compile_prog "" "" ; then
+ have_mlockall=yes
+else
+ have_mlockall=no
+fi
+
#########################################
# vhost interdependencies and host support
@@ -7865,6 +7877,9 @@ fi
if test "$pty_h" = "yes" ; then
echo "CONFIG_PTY=y" >> $config_host_mak
fi
+if test "$have_mlockall" = "yes" ; then
+ echo "CONFIG_MLOCKALL=y" >> $config_host_mak
+fi
if test "$fuzzing" = "yes" ; then
if test "$have_fuzzer" = "yes"; then
FUZZ_LDFLAGS=" -fsanitize=address,fuzzer"
diff --git a/os-posix.c b/os-posix.c
index 3cd52e1e700..e02b566940c 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -337,6 +337,7 @@ bool is_daemonized(void)
int os_mlock(void)
{
+#if defined CONFIG_MLOCKALL
int ret = 0;
ret = mlockall(MCL_CURRENT | MCL_FUTURE);
@@ -345,4 +346,7 @@ int os_mlock(void)
}
return ret;
+#else
+ return -ENOSYS;
+#endif
}
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v3 3/9] build: Check that mlockall() exists
2020-07-03 14:56 ` [PATCH v3 3/9] build: Check that mlockall() exists Peter Maydell
@ 2020-07-03 15:13 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2020-07-03 15:13 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 03/07/2020 16.56, Peter Maydell wrote:
> From: David CARLIER <devnexen@gmail.com>
>
> Instead of assuming that all POSIX platforms provide mlockall(),
> test for it in configure. If the host doesn't provide this platform
> then os_mlock() will fail -ENOSYS, as it does already on Windows.
>
> This is necessary for Haiku, which does not have mlockall().
>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> [PMM: Expanded commit message]
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> configure | 15 +++++++++++++++
> os-posix.c | 4 ++++
> 2 files changed, 19 insertions(+)
[...]
> diff --git a/os-posix.c b/os-posix.c
> index 3cd52e1e700..e02b566940c 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -337,6 +337,7 @@ bool is_daemonized(void)
>
> int os_mlock(void)
> {
> +#if defined CONFIG_MLOCKALL
Also missing the parentheses?
Thomas
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v3 4/9] osdep.h: Always include <sys/signal.h> if it exists
2020-07-03 14:56 [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
` (2 preceding siblings ...)
2020-07-03 14:56 ` [PATCH v3 3/9] build: Check that mlockall() exists Peter Maydell
@ 2020-07-03 14:56 ` Peter Maydell
2020-07-03 15:15 ` Thomas Huth
2020-07-03 14:56 ` [PATCH v3 5/9] osdep.h: For Haiku, define SIGIO as equivalent to SIGPOLL Peter Maydell
` (5 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Peter Maydell @ 2020-07-03 14:56 UTC (permalink / raw)
To: qemu-devel; +Cc: David Carlier, Gerd Hoffmann
From: David CARLIER <devnexen@gmail.com>
Regularize our handling of <sys/signal.h>: currently we include it in
osdep.h, but only for OpenBSD, and we include it without an ifdef
guard in a couple of C files. This causes problems for Haiku, which
doesn't have that header.
Instead, check in configure whether sys/signal.h exists, and if it
does then always include it from osdep.h.
Signed-off-by: David Carlier <devnexen@gmail.com>
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
configure | 8 ++++++++
include/qemu/osdep.h | 2 +-
hw/xen/xen-legacy-backend.c | 1 -
util/oslib-posix.c | 1 -
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index ddc53d873ef..d131f760d8f 100755
--- a/configure
+++ b/configure
@@ -3212,6 +3212,11 @@ if ! check_include "ifaddrs.h" ; then
have_ifaddrs_h=no
fi
+have_sys_signal_h=no
+if check_include "sys/signal.h" ; then
+ have_sys_signal_h=yes
+fi
+
##########################################
# VTE probe
@@ -7398,6 +7403,9 @@ fi
if test "$have_broken_size_max" = "yes" ; then
echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
fi
+if test "$have_sys_signal_h" = "yes" ; then
+ echo "CONFIG_SYS_SIGNAL=y" >> $config_host_mak
+fi
# Work around a system header bug with some kernel/XFS header
# versions where they both try to define 'struct fsxattr':
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 0d26a1b9bd0..6e0cf9132d9 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -104,7 +104,7 @@ extern int daemon(int, int);
#include <setjmp.h>
#include <signal.h>
-#ifdef __OpenBSD__
+#ifdef CONFIG_SYS_SIGNAL
#include <sys/signal.h>
#endif
diff --git a/hw/xen/xen-legacy-backend.c b/hw/xen/xen-legacy-backend.c
index 7d4b13351e0..965abe3ad34 100644
--- a/hw/xen/xen-legacy-backend.c
+++ b/hw/xen/xen-legacy-backend.c
@@ -23,7 +23,6 @@
*/
#include "qemu/osdep.h"
-#include <sys/signal.h>
#include "hw/sysbus.h"
#include "hw/boards.h"
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 39ddc77c85b..7ad9195c445 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -38,7 +38,6 @@
#include "qemu/sockets.h"
#include "qemu/thread.h"
#include <libgen.h>
-#include <sys/signal.h>
#include "qemu/cutils.h"
#ifdef CONFIG_LINUX
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v3 4/9] osdep.h: Always include <sys/signal.h> if it exists
2020-07-03 14:56 ` [PATCH v3 4/9] osdep.h: Always include <sys/signal.h> if it exists Peter Maydell
@ 2020-07-03 15:15 ` Thomas Huth
2020-07-03 15:21 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 23+ messages in thread
From: Thomas Huth @ 2020-07-03 15:15 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 03/07/2020 16.56, Peter Maydell wrote:
> From: David CARLIER <devnexen@gmail.com>
>
> Regularize our handling of <sys/signal.h>: currently we include it in
> osdep.h, but only for OpenBSD, and we include it without an ifdef
> guard in a couple of C files. This causes problems for Haiku, which
> doesn't have that header.
>
> Instead, check in configure whether sys/signal.h exists, and if it
> does then always include it from osdep.h.
>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> [PMM: Expanded commit message]
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> configure | 8 ++++++++
> include/qemu/osdep.h | 2 +-
> hw/xen/xen-legacy-backend.c | 1 -
> util/oslib-posix.c | 1 -
> 4 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index ddc53d873ef..d131f760d8f 100755
> --- a/configure
> +++ b/configure
> @@ -3212,6 +3212,11 @@ if ! check_include "ifaddrs.h" ; then
> have_ifaddrs_h=no
> fi
>
> +have_sys_signal_h=no
> +if check_include "sys/signal.h" ; then
> + have_sys_signal_h=yes
> +fi
> +
> ##########################################
> # VTE probe
>
> @@ -7398,6 +7403,9 @@ fi
> if test "$have_broken_size_max" = "yes" ; then
> echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
> fi
> +if test "$have_sys_signal_h" = "yes" ; then
> + echo "CONFIG_SYS_SIGNAL=y" >> $config_host_mak
> +fi
I'd maybe rather name it HAVE_SYS_SIGNAL_H, but I guess that's just a
matter of taste.
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 4/9] osdep.h: Always include <sys/signal.h> if it exists
2020-07-03 15:15 ` Thomas Huth
@ 2020-07-03 15:21 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-03 15:21 UTC (permalink / raw)
To: Thomas Huth, Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 7/3/20 5:15 PM, Thomas Huth wrote:
> On 03/07/2020 16.56, Peter Maydell wrote:
>> From: David CARLIER <devnexen@gmail.com>
>>
>> Regularize our handling of <sys/signal.h>: currently we include it in
>> osdep.h, but only for OpenBSD, and we include it without an ifdef
>> guard in a couple of C files. This causes problems for Haiku, which
>> doesn't have that header.
>>
>> Instead, check in configure whether sys/signal.h exists, and if it
>> does then always include it from osdep.h.
>>
>> Signed-off-by: David Carlier <devnexen@gmail.com>
>> [PMM: Expanded commit message]
>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> configure | 8 ++++++++
>> include/qemu/osdep.h | 2 +-
>> hw/xen/xen-legacy-backend.c | 1 -
>> util/oslib-posix.c | 1 -
>> 4 files changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/configure b/configure
>> index ddc53d873ef..d131f760d8f 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3212,6 +3212,11 @@ if ! check_include "ifaddrs.h" ; then
>> have_ifaddrs_h=no
>> fi
>>
>> +have_sys_signal_h=no
>> +if check_include "sys/signal.h" ; then
>> + have_sys_signal_h=yes
>> +fi
>> +
>> ##########################################
>> # VTE probe
>>
>> @@ -7398,6 +7403,9 @@ fi
>> if test "$have_broken_size_max" = "yes" ; then
>> echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
>> fi
>> +if test "$have_sys_signal_h" = "yes" ; then
>> + echo "CONFIG_SYS_SIGNAL=y" >> $config_host_mak
>> +fi
>
> I'd maybe rather name it HAVE_SYS_SIGNAL_H, but I guess that's just a
> matter of taste.
Agreed, if possible.
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v3 5/9] osdep.h: For Haiku, define SIGIO as equivalent to SIGPOLL
2020-07-03 14:56 [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
` (3 preceding siblings ...)
2020-07-03 14:56 ` [PATCH v3 4/9] osdep.h: Always include <sys/signal.h> if it exists Peter Maydell
@ 2020-07-03 14:56 ` Peter Maydell
2020-07-03 15:16 ` Thomas Huth
2020-07-03 14:56 ` [PATCH v3 6/9] bswap.h: Include <endian.h> on Haiku for bswap operations Peter Maydell
` (4 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Peter Maydell @ 2020-07-03 14:56 UTC (permalink / raw)
To: qemu-devel; +Cc: David Carlier, Gerd Hoffmann
From: David CARLIER <devnexen@gmail.com>
Haiku doesn't provide SIGIO; fix this up in osdep.h by defining it as
equal to SIGPOLL.
Signed-off-by: David Carlier <devnexen@gmail.com>
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
include/qemu/osdep.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 6e0cf9132d9..e090ead8262 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -425,6 +425,10 @@ void qemu_anon_ram_free(void *ptr, size_t size);
#define HAVE_CHARDEV_PARPORT 1
#endif
+#if defined(__HAIKU__)
+#define SIGIO SIGPOLL
+#endif
+
#if defined(CONFIG_LINUX)
#ifndef BUS_MCEERR_AR
#define BUS_MCEERR_AR 4
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v3 5/9] osdep.h: For Haiku, define SIGIO as equivalent to SIGPOLL
2020-07-03 14:56 ` [PATCH v3 5/9] osdep.h: For Haiku, define SIGIO as equivalent to SIGPOLL Peter Maydell
@ 2020-07-03 15:16 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2020-07-03 15:16 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 03/07/2020 16.56, Peter Maydell wrote:
> From: David CARLIER <devnexen@gmail.com>
>
> Haiku doesn't provide SIGIO; fix this up in osdep.h by defining it as
> equal to SIGPOLL.
>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> [PMM: Expanded commit message]
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> include/qemu/osdep.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index 6e0cf9132d9..e090ead8262 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -425,6 +425,10 @@ void qemu_anon_ram_free(void *ptr, size_t size);
> #define HAVE_CHARDEV_PARPORT 1
> #endif
>
> +#if defined(__HAIKU__)
> +#define SIGIO SIGPOLL
> +#endif
> +
> #if defined(CONFIG_LINUX)
> #ifndef BUS_MCEERR_AR
> #define BUS_MCEERR_AR 4
Sounds reasonable.
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v3 6/9] bswap.h: Include <endian.h> on Haiku for bswap operations
2020-07-03 14:56 [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
` (4 preceding siblings ...)
2020-07-03 14:56 ` [PATCH v3 5/9] osdep.h: For Haiku, define SIGIO as equivalent to SIGPOLL Peter Maydell
@ 2020-07-03 14:56 ` Peter Maydell
2020-07-03 15:19 ` Thomas Huth
2020-07-03 15:22 ` Philippe Mathieu-Daudé
2020-07-03 14:56 ` [PATCH v3 7/9] util/compatfd.c: Only include <sys/syscall.h> if CONFIG_SIGNALFD Peter Maydell
` (3 subsequent siblings)
9 siblings, 2 replies; 23+ messages in thread
From: Peter Maydell @ 2020-07-03 14:56 UTC (permalink / raw)
To: qemu-devel; +Cc: David Carlier, Gerd Hoffmann
From: David CARLIER <devnexen@gmail.com>
Haiku puts the bswap* functions in <endian.h>; pull in that
include file on that platform.
Signed-off-by: David Carlier <devnexen@gmail.com>
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
include/qemu/bswap.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 2a9f3fe783e..1d3e4c24e41 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -8,6 +8,8 @@
# include <machine/bswap.h>
#elif defined(__FreeBSD__)
# include <sys/endian.h>
+#elif defined(__HAIKU__)
+# include <endian.h>
#elif defined(CONFIG_BYTESWAP_H)
# include <byteswap.h>
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v3 6/9] bswap.h: Include <endian.h> on Haiku for bswap operations
2020-07-03 14:56 ` [PATCH v3 6/9] bswap.h: Include <endian.h> on Haiku for bswap operations Peter Maydell
@ 2020-07-03 15:19 ` Thomas Huth
2020-07-03 15:22 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2020-07-03 15:19 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 03/07/2020 16.56, Peter Maydell wrote:
> From: David CARLIER <devnexen@gmail.com>
>
> Haiku puts the bswap* functions in <endian.h>; pull in that
> include file on that platform.
>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> [PMM: Expanded commit message]
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> include/qemu/bswap.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
> index 2a9f3fe783e..1d3e4c24e41 100644
> --- a/include/qemu/bswap.h
> +++ b/include/qemu/bswap.h
> @@ -8,6 +8,8 @@
> # include <machine/bswap.h>
> #elif defined(__FreeBSD__)
> # include <sys/endian.h>
> +#elif defined(__HAIKU__)
> +# include <endian.h>
> #elif defined(CONFIG_BYTESWAP_H)
> # include <byteswap.h>
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 6/9] bswap.h: Include <endian.h> on Haiku for bswap operations
2020-07-03 14:56 ` [PATCH v3 6/9] bswap.h: Include <endian.h> on Haiku for bswap operations Peter Maydell
2020-07-03 15:19 ` Thomas Huth
@ 2020-07-03 15:22 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-03 15:22 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 7/3/20 4:56 PM, Peter Maydell wrote:
> From: David CARLIER <devnexen@gmail.com>
>
> Haiku puts the bswap* functions in <endian.h>; pull in that
> include file on that platform.
>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> [PMM: Expanded commit message]
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> include/qemu/bswap.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
> index 2a9f3fe783e..1d3e4c24e41 100644
> --- a/include/qemu/bswap.h
> +++ b/include/qemu/bswap.h
> @@ -8,6 +8,8 @@
> # include <machine/bswap.h>
> #elif defined(__FreeBSD__)
> # include <sys/endian.h>
> +#elif defined(__HAIKU__)
> +# include <endian.h>
> #elif defined(CONFIG_BYTESWAP_H)
> # include <byteswap.h>
>
>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v3 7/9] util/compatfd.c: Only include <sys/syscall.h> if CONFIG_SIGNALFD
2020-07-03 14:56 [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
` (5 preceding siblings ...)
2020-07-03 14:56 ` [PATCH v3 6/9] bswap.h: Include <endian.h> on Haiku for bswap operations Peter Maydell
@ 2020-07-03 14:56 ` Peter Maydell
2020-07-03 15:19 ` Thomas Huth
2020-07-03 15:29 ` Philippe Mathieu-Daudé
2020-07-03 14:56 ` [PATCH v3 8/9] util/oslib-posix.c: Implement qemu_init_exec_dir() for Haiku Peter Maydell
` (2 subsequent siblings)
9 siblings, 2 replies; 23+ messages in thread
From: Peter Maydell @ 2020-07-03 14:56 UTC (permalink / raw)
To: qemu-devel; +Cc: David Carlier, Gerd Hoffmann
From: David CARLIER <devnexen@gmail.com>
util/compatfd.c includes <sys/syscall.h> so that the CONFIG_SIGNALFD
code can use SYS_signalfd. Guard the #include with CONFIG_SIGNALFD
to avoid portability issues on hosts like Haiku which do not
provide that header file.
Signed-off-by: David Carlier <devnexen@gmail.com>
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
util/compatfd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/util/compatfd.c b/util/compatfd.c
index c296f55d148..ee47dd80897 100644
--- a/util/compatfd.c
+++ b/util/compatfd.c
@@ -16,7 +16,9 @@
#include "qemu/osdep.h"
#include "qemu/thread.h"
+#if defined(CONFIG_SIGNALFD)
#include <sys/syscall.h>
+#endif
struct sigfd_compat_info
{
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v3 7/9] util/compatfd.c: Only include <sys/syscall.h> if CONFIG_SIGNALFD
2020-07-03 14:56 ` [PATCH v3 7/9] util/compatfd.c: Only include <sys/syscall.h> if CONFIG_SIGNALFD Peter Maydell
@ 2020-07-03 15:19 ` Thomas Huth
2020-07-03 15:29 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2020-07-03 15:19 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 03/07/2020 16.56, Peter Maydell wrote:
> From: David CARLIER <devnexen@gmail.com>
>
> util/compatfd.c includes <sys/syscall.h> so that the CONFIG_SIGNALFD
> code can use SYS_signalfd. Guard the #include with CONFIG_SIGNALFD
> to avoid portability issues on hosts like Haiku which do not
> provide that header file.
>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> [PMM: Expanded commit message]
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> util/compatfd.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/util/compatfd.c b/util/compatfd.c
> index c296f55d148..ee47dd80897 100644
> --- a/util/compatfd.c
> +++ b/util/compatfd.c
> @@ -16,7 +16,9 @@
> #include "qemu/osdep.h"
> #include "qemu/thread.h"
>
> +#if defined(CONFIG_SIGNALFD)
> #include <sys/syscall.h>
> +#endif
>
> struct sigfd_compat_info
> {
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 7/9] util/compatfd.c: Only include <sys/syscall.h> if CONFIG_SIGNALFD
2020-07-03 14:56 ` [PATCH v3 7/9] util/compatfd.c: Only include <sys/syscall.h> if CONFIG_SIGNALFD Peter Maydell
2020-07-03 15:19 ` Thomas Huth
@ 2020-07-03 15:29 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-03 15:29 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: David Carlier, Gerd Hoffmann
On 7/3/20 4:56 PM, Peter Maydell wrote:
> From: David CARLIER <devnexen@gmail.com>
>
> util/compatfd.c includes <sys/syscall.h> so that the CONFIG_SIGNALFD
> code can use SYS_signalfd. Guard the #include with CONFIG_SIGNALFD
> to avoid portability issues on hosts like Haiku which do not
> provide that header file.
>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> [PMM: Expanded commit message]
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> util/compatfd.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/util/compatfd.c b/util/compatfd.c
> index c296f55d148..ee47dd80897 100644
> --- a/util/compatfd.c
> +++ b/util/compatfd.c
> @@ -16,7 +16,9 @@
> #include "qemu/osdep.h"
> #include "qemu/thread.h"
>
> +#if defined(CONFIG_SIGNALFD)
Most of the code base guards <sys/syscall.h> with '#ifdef CONFIG_LINUX',
bsd-user/strace.c is the BSD exception.
CONFIG_SIGNALFD guards SYS_signalfd.
> #include <sys/syscall.h>
> +#endif
>
> struct sigfd_compat_info
> {
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v3 8/9] util/oslib-posix.c: Implement qemu_init_exec_dir() for Haiku
2020-07-03 14:56 [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
` (6 preceding siblings ...)
2020-07-03 14:56 ` [PATCH v3 7/9] util/compatfd.c: Only include <sys/syscall.h> if CONFIG_SIGNALFD Peter Maydell
@ 2020-07-03 14:56 ` Peter Maydell
2020-07-03 14:56 ` [PATCH v3 9/9] util/drm: make portable by avoiding struct dirent d_type Peter Maydell
2020-07-11 18:44 ` [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
9 siblings, 0 replies; 23+ messages in thread
From: Peter Maydell @ 2020-07-03 14:56 UTC (permalink / raw)
To: qemu-devel; +Cc: David Carlier, Gerd Hoffmann
From: David CARLIER <devnexen@gmail.com>
The qemu_init_exec_dir() function is inherently non-portable;
provide an implementation for Haiku hosts.
Signed-off-by: David Carlier <devnexen@gmail.com>
[PMM: Expanded commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
util/oslib-posix.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 7ad9195c445..72907d4d7fe 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -60,6 +60,10 @@
#include <mach-o/dyld.h>
#endif
+#ifdef __HAIKU__
+#include <kernel/image.h>
+#endif
+
#include "qemu/mmap-alloc.h"
#ifdef CONFIG_DEBUG_STACK_USAGE
@@ -389,6 +393,21 @@ void qemu_init_exec_dir(const char *argv0)
}
}
}
+#elif defined(__HAIKU__)
+ {
+ image_info ii;
+ int32_t c = 0;
+
+ *buf = '\0';
+ while (get_next_image_info(0, &c, &ii) == B_OK) {
+ if (ii.type == B_APP_IMAGE) {
+ strncpy(buf, ii.name, sizeof(buf));
+ buf[sizeof(buf) - 1] = 0;
+ p = buf;
+ break;
+ }
+ }
+ }
#endif
/* If we don't have any way of figuring out the actual executable
location then try argv[0]. */
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 9/9] util/drm: make portable by avoiding struct dirent d_type
2020-07-03 14:56 [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
` (7 preceding siblings ...)
2020-07-03 14:56 ` [PATCH v3 8/9] util/oslib-posix.c: Implement qemu_init_exec_dir() for Haiku Peter Maydell
@ 2020-07-03 14:56 ` Peter Maydell
2020-07-11 18:44 ` [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
9 siblings, 0 replies; 23+ messages in thread
From: Peter Maydell @ 2020-07-03 14:56 UTC (permalink / raw)
To: qemu-devel; +Cc: David Carlier, Gerd Hoffmann
From: Gerd Hoffmann <kraxel@redhat.com>
Given this isn't perforance critical at all lets avoid the non-portable
d_type and use fstat instead to check whenever the file is a chardev.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reported-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200701180302.14821-1-kraxel@redhat.com
[PMM: fixed comment style; tweaked subject line]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
util/drm.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/util/drm.c b/util/drm.c
index a23ff245382..dae8ffebc81 100644
--- a/util/drm.c
+++ b/util/drm.c
@@ -24,7 +24,8 @@ int qemu_drm_rendernode_open(const char *rendernode)
{
DIR *dir;
struct dirent *e;
- int r, fd;
+ struct stat st;
+ int r, fd, ret;
char *p;
if (rendernode) {
@@ -38,10 +39,6 @@ int qemu_drm_rendernode_open(const char *rendernode)
fd = -1;
while ((e = readdir(dir))) {
- if (e->d_type != DT_CHR) {
- continue;
- }
-
if (strncmp(e->d_name, "renderD", 7)) {
continue;
}
@@ -53,6 +50,18 @@ int qemu_drm_rendernode_open(const char *rendernode)
g_free(p);
continue;
}
+
+ /*
+ * prefer fstat() over checking e->d_type == DT_CHR for
+ * portability reasons
+ */
+ ret = fstat(r, &st);
+ if (ret < 0 || (st.st_mode & S_IFMT) != S_IFCHR) {
+ close(r);
+ g_free(p);
+ continue;
+ }
+
fd = r;
g_free(p);
break;
--
2.20.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v3 0/9] Build fixes for Haiku
2020-07-03 14:56 [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
` (8 preceding siblings ...)
2020-07-03 14:56 ` [PATCH v3 9/9] util/drm: make portable by avoiding struct dirent d_type Peter Maydell
@ 2020-07-11 18:44 ` Peter Maydell
2020-07-11 19:02 ` David CARLIER
9 siblings, 1 reply; 23+ messages in thread
From: Peter Maydell @ 2020-07-11 18:44 UTC (permalink / raw)
To: QEMU Developers; +Cc: David Carlier, Gerd Hoffmann
On Fri, 3 Jul 2020 at 15:56, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> This patchset is essentially a resend of David Carlier's build fixes
> for the Haiku platform. I've taken David's patches and put them together
> into a set of emails threaded in the way our CI tools expect, as the
> easiest way to get the patchew robot to run the build tests so we can
> check they didn't accidentally break one of the BSDs. I've also put
> in the patch from Gerd that fixes the drm.c issue. I've also expanded
> on the commit messages for all the patches so that we have a record
> of why we made the changes if we need to look back at it in future.
>
> Assuming no issues turn up, I'll arrange to get these into master
> at some point before the 5.1 release.
I've made the minor renames from CONFIG_ to HAVE_ where suggested
and will put these into the tree via a target-arm pullreq I'm
planning for Monday.
thanks
-- PMM
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 0/9] Build fixes for Haiku
2020-07-11 18:44 ` [PATCH v3 0/9] Build fixes for Haiku Peter Maydell
@ 2020-07-11 19:02 ` David CARLIER
0 siblings, 0 replies; 23+ messages in thread
From: David CARLIER @ 2020-07-11 19:02 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers, Gerd Hoffmann
[-- Attachment #1: Type: text/plain, Size: 1091 bytes --]
Alright thanks for the assistance. Regards.
On Sat, 11 Jul 2020 at 19:44, Peter Maydell <peter.maydell@linaro.org>
wrote:
> On Fri, 3 Jul 2020 at 15:56, Peter Maydell <peter.maydell@linaro.org>
> wrote:
> >
> > This patchset is essentially a resend of David Carlier's build fixes
> > for the Haiku platform. I've taken David's patches and put them together
> > into a set of emails threaded in the way our CI tools expect, as the
> > easiest way to get the patchew robot to run the build tests so we can
> > check they didn't accidentally break one of the BSDs. I've also put
> > in the patch from Gerd that fixes the drm.c issue. I've also expanded
> > on the commit messages for all the patches so that we have a record
> > of why we made the changes if we need to look back at it in future.
> >
> > Assuming no issues turn up, I'll arrange to get these into master
> > at some point before the 5.1 release.
>
> I've made the minor renames from CONFIG_ to HAVE_ where suggested
> and will put these into the tree via a target-arm pullreq I'm
> planning for Monday.
>
> thanks
> -- PMM
>
[-- Attachment #2: Type: text/html, Size: 1573 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread