ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/Makefile.PL
Revision: 1.5
Committed: Wed Jul 25 04:14:38 2001 UTC (22 years, 11 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.4: +2 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 use ExtUtils::MakeMaker;
2    
3     use 5.006;
4    
5 root 1.2 use Config;
6    
7     $DEFINE = "";
8    
9 root 1.5 $DEFINE .= " -DCORO_LAZY_STACK"; # experimental
10    
11 root 1.2 $DEFINE .= " -DHAVE_MMAP" if $Config{d_mmap} eq "define" && $Config{d_munmap} eq "define";
12    
13     if ($^O =~ /windows/) {
14 root 1.3 $DEFINE = " -DCORO_LOOSE";
15 root 1.4 } elsif ($^O =~ /linux/) {
16     $iface = "l";
17 root 1.2 } elsif (-e "/usr/include/ucontext.h") {
18 root 1.3 $iface = "u";
19 root 1.2 } else {
20 root 1.3 $iface = "s";
21 root 1.2 }
22    
23 root 1.3 if ($iface) {
24     print <<EOF;
25 root 1.2
26 root 1.3 Coro has the option of using two different ways to implement coroutines
27 root 1.4 at the C level:
28 root 1.3
29 root 1.4 u The unix ucontext functions are newer and not implemented in older
30     unices (or broken libc's like glibc-2.2.2 and below). They allow very
31     fast coroutine creation and fast switching, and, most importantly, are
32     very stable.
33    
34     s If the ucontext functions are not working or you don't want
35     to use them for other reasons you can try a workaround using
36     setjmp/longjmp/sigaltstack (also standard unix functions). Coroutine
37     creation is rather slow, but switching is very fast as well (often much
38     faster than with the ucontext functions). Unfortunately, glibc-2.1 and
39     below don't even feature a working sigaltstack.
40    
41     l Older GNU/Linux systems (glibc-2.1 and below) need this hack. Since it is
42     very linux-specific it is also quite fast; when it works, that is.
43 root 1.2
44     EOF
45 root 1.3
46     retry:
47     $|=1;
48 root 1.4 print "Use which implementation (s, u, l) [$iface]? ";
49 root 1.3 my $r = <>;
50     $iface = lc $1 if $r =~ /(\S)/;
51    
52     if ($iface eq "u") {
53     $DEFINE .= " -DCORO_UCONTEXT";
54     print "\nUsing ucontext implementation\n\n";
55     } elsif ($iface eq "s") {
56     $DEFINE .= " -DCORO_SJLJ";
57     print "\nUsing setjmp/longjmp/sigaltstack implementation\n\n";
58 root 1.4 } elsif ($iface eq "l") {
59     $DEFINE .= " -DCORO_LINUX";
60     print "\nUsing linux-specific implementation\n\n";
61 root 1.3 } else {
62     print "\nUnknown implementation \"$iface\"\n";
63     goto retry;
64     }
65     } else {
66     print "\nUsing microsoft coroutine implementation\n\n";
67     }
68 root 1.2
69 root 1.1 WriteMakefile(
70 root 1.2 NAME => "Coro::State",
71     VERSION_FROM => "State.pm",
72     DEFINE => $DEFINE,
73     DIR => [],
74 root 1.1 );
75 root 1.2
76    
77 root 1.1