From patchwork Sat Jun 25 17:03:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v5,3/5] coroutine: implement coroutines using gthread Date: Sat, 25 Jun 2011 07:03:44 -0000 From: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 102034 Message-Id: <9E69633B-6D95-430E-AA01-170CE26834FF@web.de> To: Stefan Hajnoczi Cc: Kevin Wolf , Anthony Liguori , Alexandre Raymond , qemu-devel Developers , Blue Swirl , "Aneesh Kumar K.V" , Alexander Graf , Paolo Bonzini , Venkateswararao Jujjuri Am 12.06.2011 um 22:46 schrieb Stefan Hajnoczi: > From: "Aneesh Kumar K.V" > > 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 > Signed-off-by: Stefan Hajnoczi > --- > 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 > +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) 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 int main(void) { makecontext(0, 0, 0); } EOF -if compile_prog "" "" ; then - ucontext_coroutine=yes + if compile_prog "" "" ; then + ucontext_coroutine=yes + fi fi ##########################################