use strict; use ExtUtils::MakeMaker; use Config; $|=1; my $DEFINE; my @LIBS = []; my $threads = $Config{usethreads}; use Config; print <= 4.4 ? "s" : "p"); } elsif ($^O =~ /solaris/) { # setjmp, ucontext seem to work, as well as asm $iface = $iface_asm || "s"; } elsif ($^O =~ /darwin/) { # assembler doesn't support .type # ucontext is of course totally broken (it just crashes) # surprisingly, pthreads seem to work $iface = "s"; } elsif ($^O =~ /dragonfly/) { # ucontext is totally broken on dragonfly bsd: # Fatal error 'siglongjmp()ing between thread contexts is undefined by POSIX 1003.1 $iface = "s"; } elsif (-e "/usr/include/ucontext.h") { # shame on this heuristic $iface = "u"; } else { $iface = "s"; } print <= 2.5) stop working with this implementation however. i IRIX. For some reason, SGI really does not like to follow POSIX (does that surprise you?), so this workaround might be needed (it's fast), although [s] and [u] should also work now. w Microsoft Windows. Try this on Microsoft Windows when using Cygwin or the MSVC compilers (e.g. ActiveState Perl, but see "a" for Strawberry Perl), although, as there is no standard on how to do this under windows, different environments might work differently. Doh. p Use pthread API. Try to avoid this option, it was only created to make a point about the programming language shootout. It is unlikely to work with perls that have windows process emulation enabled ("perl threads"). It is also likely the slowest method of implementing coroutines. It might work fine as a last resort, however, as the pthread API is slightly better tested than ucontext functions for example. Of course, not on BSDs, who usually have very broken pthread implementations. Coro tries hard to come up with a suitable default for most systems, so pressing return at the prompt usually does the right thing. If you experience problems (e.g. make test fails) then you should experiment with this setting. EOF retry: my $r = prompt "Use which implementation,\n" . "etjmp, ctx, sm, rix, inux, indows or

threads?", $iface; $iface = lc $1 if $r =~ /(\S)/; if ($iface eq "u") { $DEFINE .= " -DCORO_UCONTEXT"; print "\nUsing ucontext implementation\n\n"; conftest ("TEST_makecontext"); } elsif ($iface eq "s") { $DEFINE .= " -DCORO_SJLJ"; print "\nUsing setjmp/longjmp/sigaltstack implementation\n\n"; conftest ("TEST_sigaltstack"); } elsif ($iface eq "l") { $DEFINE .= " -DCORO_LINUX"; print "\nUsing linux-specific implementation\n\n"; } elsif ($iface eq "i") { $DEFINE .= " -DCORO_IRIX"; print "\nUsing irix-specific implementation\n\n"; } elsif ($iface eq "w") { $DEFINE .= " -DCORO_LOSER"; print "\nUsing windows-specific implementation\n\n"; } elsif ($iface eq "a") { $DEFINE .= " -DCORO_ASM"; print "\nUsing handcoded assembler implementation\n\n"; } elsif ($iface eq "p") { $DEFINE .= " -DCORO_PTHREAD"; @LIBS = ["-lpthread"]; print "\nUsing pthread implementation\n\n"; } else { print "\nUnknown implementation \"$iface\"\n"; goto retry; } print < header file available. Valgrind support is completely optional, so disabling it is the safe choice. EOF my $valgrind = prompt ("Enable valgrind support (y/n)?", -r "/usr/include/valgrind/valgrind.h" ? "y" : "n"); $DEFINE .= " -DCORO_USE_VALGRIND=1" if $valgrind =~ /[yY]/; print <clone method (y/n)?", $masturbate); $DEFINE .= " -DCORO_CLONE=1" if $masturbate =~ /[yY]/; print < "Coro::State", VERSION_FROM => "State.pm", DEFINE => $DEFINE, LIBS => @LIBS, DIR => [], depend => { "State.c" => "state.h clone.c libcoro/coro.h libcoro/coro.c", }, ); sub conftest { my $type = shift; print "\nTrying to detect stack growth direction (for $type)\n"; print "You might see some warnings, this should not concern you.\n\n"; system "$Config{cc} $Config{ccflags} -D$type libcoro/conftest.c"; my $res = qx<./a.out>; $res =~ s/\s+$//; my ($sp, $ss) = split /,/, $res; print "\n\n*****************************************************************************\n"; print "If the testsuite fails PLEASE provide the following information\n"; print "to Marc Lehmann : operating system name, version,\n"; print "architecture name and this string '$sp|$ss'. Thanks a lot!\n";#d# print "*****************************************************************************\n\n"; unlink "a.out"; unlink "conftestval"; }