ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/Makefile.PL
Revision: 1.14
Committed: Mon Sep 3 02:50:18 2001 UTC (22 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.13: +14 -3 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 use ExtUtils::MakeMaker;
2    
3 root 1.7 use 5.005;
4 root 1.1
5 root 1.2 use Config;
6    
7 root 1.6 $|=1;
8    
9 root 1.2 $DEFINE = "";
10    
11     $DEFINE .= " -DHAVE_MMAP" if $Config{d_mmap} eq "define" && $Config{d_munmap} eq "define";
12    
13 root 1.12 if ($^O =~ /win32/i) {
14 root 1.3 $DEFINE = " -DCORO_LOOSE";
15 root 1.14 } elsif ($^O =~ /irix/) {
16     $iface = "i";
17 root 1.4 } elsif ($^O =~ /linux/) {
18     $iface = "l";
19 root 1.8 } elsif ($^O =~ /solaris/) {
20     $iface = "s";
21 root 1.2 } elsif (-e "/usr/include/ucontext.h") {
22 root 1.3 $iface = "u";
23 root 1.2 } else {
24 root 1.3 $iface = "s";
25 root 1.2 }
26    
27 root 1.6 print <<EOF;
28    
29     Version 0.12 introduced experimental C context sharing. This makes it
30     possible to share the C stack and context between many coroutines,
31     resulting in memory savings and slight speed gains, at the cost of
32 root 1.10 potential segfaults (especially with exception handling). On my Linux/x86
33     machine this decreased the size of a new coroutine from 9k to 5k, the
34     savings are much more apparent on machines without mmap or good memory
35     management. This algorithm relies on the non-fact that the same machine
36     stack pointer indicates the same function call nesting level, which
37     usually works good enough but might fail...
38 root 1.6
39 root 1.10 The default (disabled) is safe, as it only increases memory consumption.
40 root 1.6
41     EOF
42    
43     print "Do you want to enable experimental context sharing (y/n) [n]? ";
44    
45     if (<> =~ /^\s*y/i) {
46     print "\nExperimental context sharing enabled.\n\n";
47     $DEFINE .= " -DCORO_LAZY_STACK";
48     }
49    
50 root 1.3 if ($iface) {
51     print <<EOF;
52 root 1.2
53 root 1.3 Coro has the option of using two different ways to implement coroutines
54 root 1.4 at the C level:
55 root 1.3
56 root 1.4 u The unix ucontext functions are newer and not implemented in older
57     unices (or broken libc's like glibc-2.2.2 and below). They allow very
58     fast coroutine creation and fast switching, and, most importantly, are
59     very stable.
60    
61     s If the ucontext functions are not working or you don't want
62     to use them for other reasons you can try a workaround using
63     setjmp/longjmp/sigaltstack (also standard unix functions). Coroutine
64     creation is rather slow, but switching is very fast as well (often much
65     faster than with the ucontext functions). Unfortunately, glibc-2.1 and
66     below don't even feature a working sigaltstack.
67    
68     l Older GNU/Linux systems (glibc-2.1 and below) need this hack. Since it is
69 root 1.14 very linux-specific it is also quite fast for newer versions; when it
70     works, that is...
71    
72     i IRIX. For some reason, SGI really does not like to follow the unix
73     standard (does that surprise you?), so this techniquee should be fast
74     and safe (althogh s and u should also work now).
75 root 1.2
76     EOF
77 root 1.3
78     retry:
79 root 1.14 print "Use which implementation,\n",
80     "<s>etjmp/longjump, <u>context, <i>rix or <l>inux [$iface]? ";
81    
82 root 1.3 my $r = <>;
83     $iface = lc $1 if $r =~ /(\S)/;
84    
85     if ($iface eq "u") {
86     $DEFINE .= " -DCORO_UCONTEXT";
87     print "\nUsing ucontext implementation\n\n";
88     } elsif ($iface eq "s") {
89     $DEFINE .= " -DCORO_SJLJ";
90     print "\nUsing setjmp/longjmp/sigaltstack implementation\n\n";
91 root 1.4 } elsif ($iface eq "l") {
92     $DEFINE .= " -DCORO_LINUX";
93     print "\nUsing linux-specific implementation\n\n";
94 root 1.14 } elsif ($iface eq "i") {
95     $DEFINE .= " -DCORO_IRIX";
96     print "\nUsing irix-specific implementation\n\n";
97 root 1.3 } else {
98     print "\nUnknown implementation \"$iface\"\n";
99     goto retry;
100     }
101     } else {
102     print "\nUsing microsoft coroutine implementation\n\n";
103     }
104 root 1.2
105 root 1.1 WriteMakefile(
106 root 1.2 NAME => "Coro::State",
107     VERSION_FROM => "State.pm",
108     DEFINE => $DEFINE,
109     DIR => [],
110 root 1.11 PM => {
111     'State.pm' => '$(INST_LIBDIR)/State.pm',
112    
113     'MakeMaker.pm' => '$(INST_LIBDIR)/MakeMaker.pm',
114     'CoroAPI.h' => '$(INST_LIBDIR)/CoroAPI.h',
115    
116     'Cont.pm' => '$(INST_LIBDIR)/Cont.pm',
117    
118     'Specific.pm' => '$(INST_LIBDIR)/Specific.pm',
119    
120     'Signal.pm' => '$(INST_LIBDIR)/Signal.pm',
121     'Channel.pm' => '$(INST_LIBDIR)/Channel.pm',
122     'Semaphore.pm' => '$(INST_LIBDIR)/Semaphore.pm',
123 root 1.13 'SemaphoreSet.pm' => '$(INST_LIBDIR)/SemaphoreSet.pm',
124 root 1.11 'RWLock.pm' => '$(INST_LIBDIR)/RWLock.pm',
125     },
126 root 1.1 );
127 root 1.2
128    
129 root 1.1