Patchwork [2/3] coroutine: adding control flags (enable/disable) for ucontext compilation

login
register
mail settings
Submitter Alex Barcelo
Date Feb. 13, 2012, 2:42 p.m.
Message ID <1329144150-7720-3-git-send-email-abarcelo@ac.upc.edu>
Download mbox | patch
Permalink /patch/140912/
State New
Headers show

Comments

Alex Barcelo - Feb. 13, 2012, 2:42 p.m.
Configure tries, as a default, ucontext functions for the
coroutines. But now the user can force its use or disable
it at all (enable and disable flags)

Signed-off-by: Alex Barcelo <abarcelo@ac.upc.edu>
---
 configure |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)
Kevin Wolf - Feb. 13, 2012, 3:36 p.m.
Am 13.02.2012 15:42, schrieb Alex Barcelo:
> Configure tries, as a default, ucontext functions for the
> coroutines. But now the user can force its use or disable
> it at all (enable and disable flags)
> 
> Signed-off-by: Alex Barcelo <abarcelo@ac.upc.edu>

I think a better approach would be to have a
--coroutines=[ucontext|sigaltstack|gthread|windows] option, with the
appropriate default whereever it's possible to detect.

This would allow to build with gthread based coroutines even when
another option is available.

Kevin

Patch

diff --git a/configure b/configure
index 763db24..ed40da8 100755
--- a/configure
+++ b/configure
@@ -190,6 +190,7 @@  opengl=""
 zlib="yes"
 guest_agent="yes"
 libiscsi=""
+ucontext=""
 
 # parse CC options first
 for opt do
@@ -798,6 +799,10 @@  for opt do
   ;;
   --disable-guest-agent) guest_agent="no"
   ;;
+  --enable-ucontext) ucontext="yes"
+  ;;
+  --disable-ucontext) ucontext="no"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -1084,6 +1089,8 @@  echo "  --disable-usb-redir      disable usb network redirection support"
 echo "  --enable-usb-redir       enable usb network redirection support"
 echo "  --disable-guest-agent    disable building of the QEMU Guest Agent"
 echo "  --enable-guest-agent     enable building of the QEMU Guest Agent"
+echo "  --disable-ucontext       disable ucontext functions for coroutines"
+echo "  --enable-ucontext        enable ucontext functions for coroutines"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -2717,13 +2724,23 @@  fi
 # check if we have makecontext
 
 ucontext_coroutine=no
-if test "$darwin" != "yes"; then
-  cat > $TMPC << EOF
+if test "$ucontext" != "no"; then
+  if test "$darwin" != "yes"; then
+    cat > $TMPC << EOF
 #include <ucontext.h>
 int main(void) { makecontext(0, 0, 0); return 0; }
 EOF
-  if compile_prog "" "" ; then
-      ucontext_coroutine=yes
+    if compile_prog "" "" ; then
+        ucontext_coroutine=yes
+    elif test "$ucontext" = "yes" ; then
+        echo
+        echo "Error: ucontext check failed"
+        echo "Make sure that ucontext.h and its funcionts are supported"
+        echo
+        exit 1
+    fi
+  else
+    echo "Silently ignoring ucontext coroutine method under darwin"
   fi
 fi
 
@@ -2918,6 +2935,7 @@  echo "usb net redir     $usb_redir"
 echo "OpenGL support    $opengl"
 echo "libiscsi support  $libiscsi"
 echo "build guest agent $guest_agent"
+echo "ucontext coroutine support    $ucontext_coroutine"
 
 if test "$sdl_too_old" = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"