coroutine: add libucontext as external library

iOS does not support ucontext natively for aarch64 and the sigaltstack is also unsupported (even worse, it fails silently, see: https://openradar.appspot.com/13002712 )
This commit is contained in:
osy
2019-03-29 15:41:07 -07:00
parent bd3929e6b3
commit 7b72c6b9c7
5 changed files with 48 additions and 2 deletions
+3
View File
@@ -58,3 +58,6 @@
[submodule "roms/qboot"]
path = roms/qboot
url = https://github.com/bonzini/qboot
[submodule "libucontext"]
path = libucontext
url = https://github.com/utmapp/libucontext.git
+10
View File
@@ -550,6 +550,9 @@ CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
CAP_CFLAGS += -DCAPSTONE_HAS_X86
LIBUCONTEXT_CFLAGS = $(CFLAGS) $(QEMU_CFLAGS)
LIBUCONTEXT_CFLAGS += -DCUSTOM_IMPL
.PHONY: capstone/all
capstone/all: .git-submodule-status
$(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=no BUILDDIR="$(BUILD_DIR)/capstone" CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" CFLAGS="$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_DIR)/capstone/$(LIBCAPSTONE))
@@ -562,6 +565,13 @@ slirp/all: .git-submodule-status
CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" \
CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
.PHONY: libucontext/all
libucontext/all: .git-submodule-status
$(call quiet-command,$(MAKE) -C $(SRC_PATH)/libucontext \
ARCH="$(ARCH)" BUILD_DIR="$(BUILD_DIR)/libucontext" \
CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" \
CFLAGS="$(LIBUCONTEXT_CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
$(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
$(qom-obj-y)
Vendored
+25 -2
View File
@@ -1870,7 +1870,7 @@ Advanced options (experts only):
--oss-lib path to OSS library
--cpu=CPU Build for host CPU [$cpu]
--with-coroutine=BACKEND coroutine backend. Supported options:
ucontext, sigaltstack, windows
ucontext, libucontext, sigaltstack, windows
--enable-gcov enable test coverage analysis with gcov
--gcov=GCOV use specified gcov [$gcov_tool]
--disable-blobs disable installing provided firmware blobs
@@ -5670,6 +5670,8 @@ if test "$coroutine" = ""; then
coroutine=win32
elif test "$ucontext_works" = "yes"; then
coroutine=ucontext
elif test "$ios" = "yes"; then
coroutine=libucontext
else
coroutine=sigaltstack
fi
@@ -5693,12 +5695,29 @@ else
error_exit "only the 'windows' coroutine backend is valid for Windows"
fi
;;
libucontext)
;;
*)
error_exit "unknown coroutine backend $coroutine"
;;
esac
fi
case $coroutine in
libucontext)
git_submodules="${git_submodules} libucontext"
mkdir -p libucontext
QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/libucontext/include"
LIBS="-L\$(BUILD_DIR)/libucontext -lucontext $LIBS"
;;
esac
if test "$coroutine" == "libucontext"; then
coroutine_impl=ucontext
else
coroutine_impl=$coroutine
fi
if test "$coroutine_pool" = ""; then
coroutine_pool=yes
fi
@@ -7705,7 +7724,7 @@ if test "$rbd" = "yes" ; then
echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
fi
echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
echo "CONFIG_COROUTINE_BACKEND=$coroutine_impl" >> $config_host_mak
if test "$coroutine_pool" = "yes" ; then
echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
else
@@ -8567,6 +8586,10 @@ fi
if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
echo "config-host.h: capstone/all" >> $config_host_mak
fi
if [ "$coroutine" = "libucontext" ]; then
echo "config-host.h: libucontext/all" >> $config_host_mak
echo "CONFIG_LIBUCONTEXT=y" >> $config_host_mak
fi
if test -n "$LIBCAPSTONE"; then
echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
fi
Submodule
+1
Submodule libucontext added at 148ec4c5b6
+9
View File
@@ -23,7 +23,16 @@
#undef _FORTIFY_SOURCE
#endif
#include "qemu/osdep.h"
#if defined(CONFIG_LIBUCONTEXT)
#include <libucontext.h>
#define ucontext_t libucontext_ucontext_t
#define getcontext libucontext_getcontext
#define setcontext libucontext_setcontext
#define swapcontext libucontext_swapcontext
#define makecontext libucontext_makecontext
#else
#include <ucontext.h>
#endif
#include "qemu/coroutine_int.h"
#ifdef CONFIG_VALGRIND_H