diff mbox

[v5,3/5] coroutine: implement coroutines using gthread

Message ID 9E69633B-6D95-430E-AA01-170CE26834FF@web.de
State New
Headers show

Commit Message

Andreas Färber June 25, 2011, 5:03 p.m. UTC
Am 12.06.2011 um 22:46 schrieb Stefan Hajnoczi:

> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>
> On platforms that don't support makecontext(3) use gthread based
> coroutine implementation.
>
> [Original patch by Aneesh, made consistent with coroutine-ucontext.c  
> and
> switched to GStaticPrivate by Stefan.  Tested on Linux and OpenBSD.]
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> ---
> Makefile.objs       |    4 ++
> configure           |   16 ++++++
> coroutine-gthread.c |  131 ++++++++++++++++++++++++++++++++++++++++++ 
> +++++++++
> 3 files changed, 151 insertions(+), 0 deletions(-)
> create mode 100644 coroutine-gthread.c

> diff --git a/configure b/configure
> index 3697eba..df63403 100755
> --- a/configure
> +++ b/configure
> @@ -2552,6 +2552,18 @@ if test "$trace_backend" = "dtrace"; then
> fi
>
> ##########################################
> +# check if we have makecontext
> +
> +ucontext_coroutine=no
> +cat > $TMPC << EOF
> +#include <ucontext.h>
> +int main(void) { makecontext(0, 0, 0); }
> +EOF
> +if compile_prog "" "" ; then
> +    ucontext_coroutine=yes
> +fi
> +
> +##########################################
> # End of CC checks
> # After here, no more $cc or $ld runs
>

This add-on patch inserts a check for Darwin to force  
ucontext_coroutine=no there (getcontext() returns -1, with errno ==  
ENOTSUP):


This fixes Darwin/ppc64 (and ppc) v10.5.
Don't know whether v10.6 / i386 might have a working implementation  
(cc'ing Alexand{re,er}).

Andreas

> @@ -3015,6 +3027,10 @@ if test "$rbd" = "yes" ; then
>   echo "CONFIG_RBD=y" >> $config_host_mak
> fi
>
> +if test "$ucontext_coroutine" = "yes" ; then
> +  echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
> +fi
> +
> # USB host support
> case "$usb" in
> linux)

Comments

Alexandre Raymond June 30, 2011, 12:51 a.m. UTC | #1
Hi Andreas,

> This fixes Darwin/ppc64 (and ppc) v10.5.
> Don't know whether v10.6 / i386 might have a working implementation (cc'ing
> Alexand{re,er}).

In 10.6, I get the following error when I try to compile a simple getcontext():
/usr/include/ucontext.h:42:2: error: #error ucontext routines are
deprecated, and require _XOPEN_SOURCE to be defined

On the other hand, if I do define _XOPEN_SOURCE, getcontext() returns 0.

Alexandre
diff mbox

Patch

diff --git a/configure b/configure
index c28ed7b..854f24a 100755
--- a/configure
+++ b/configure
@@ -2479,12 +2479,14 @@  fi
  # check if we have makecontext

  ucontext_coroutine=no
-cat > $TMPC << EOF
+if test "$darwin" != "yes"; then
+    cat > $TMPC << EOF
  #include <ucontext.h>
  int main(void) { makecontext(0, 0, 0); }
  EOF
-if compile_prog "" "" ; then
-    ucontext_coroutine=yes
+    if compile_prog "" "" ; then
+        ucontext_coroutine=yes
+    fi
  fi

  ##########################################