From 401bc051d7706e33046d79539465b8326383a1b2 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Tue, 5 Sep 2017 13:19:32 +0100 Subject: util/qemu-thread-posix.c: Replace OS ifdefs with CONFIG_HAVE_SEM_TIMEDWAIT In qemu-thread-posix.c we have two implementations of the various qemu_sem_* functions, one of which uses native POSIX sem_* and the other of which emulates them with pthread conditions. This is necessary because not all our host OSes support sem_timedwait(). Instead of a hard-coded list of OSes which don't implement sem_timedwait(), which gets out of date, make configure test for the presence of the function and set a new CONFIG_HAVE_SEM_TIMEDWAIT appropriately. In particular, newer NetBSDs have sem_timedwait(), so this commit will switch them over to using it. OSX still does not have an implementation. Signed-off-by: Peter Maydell Reviewed-by: Kamil Rytarowski Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- configure | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'configure') diff --git a/configure b/configure index 12d4e4ebfa..1f7b4f03ce 100755 --- a/configure +++ b/configure @@ -4424,6 +4424,18 @@ if compile_prog "" "" ; then posix_syslog=yes fi +########################################## +# check if we have sem_timedwait + +sem_timedwait=no +cat > $TMPC << EOF +#include +int main(void) { return sem_timedwait(0, 0); } +EOF +if compile_prog "" "" ; then + sem_timedwait=yes +fi + ########################################## # check if trace backend exists @@ -5678,6 +5690,9 @@ fi if test "$inotify1" = "yes" ; then echo "CONFIG_INOTIFY1=y" >> $config_host_mak fi +if test "$sem_timedwait" = "yes" ; then + echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak +fi if test "$byteswap_h" = "yes" ; then echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak fi -- cgit v1.2.1