coroutine: implement coroutines using gthread

On platforms that don't support makecontext(3) use gthread based
coroutine implementation.

Darwin has makecontext(3) but getcontext(3) is stubbed out to return
ENOTSUP.  Andreas Färber <andreas.faerber@web.de> debugged this and
contributed the ./configure test which solves the issue for Darwin/ppc64
(and ppc) v10.5.

[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>
This commit is contained in:
Aneesh Kumar K.V 2011-06-09 23:11:06 +05:30 committed by Kevin Wolf
parent 00dccaf1f8
commit d0e2fce536
3 changed files with 153 additions and 0 deletions

18
configure vendored
View file

@ -2540,6 +2540,20 @@ EOF
fi
fi
##########################################
# check if we have makecontext
ucontext_coroutine=no
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
fi
fi
##########################################
# End of CC checks
# After here, no more $cc or $ld runs
@ -3015,6 +3029,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)