… | |
… | |
13 | if ($^O =~ /win32/i or $^O =~ /cygwin/) { |
13 | if ($^O =~ /win32/i or $^O =~ /cygwin/) { |
14 | $DEFINE = " -DCORO_LOOSE"; |
14 | $DEFINE = " -DCORO_LOOSE"; |
15 | } elsif ($^O =~ /irix/) { |
15 | } elsif ($^O =~ /irix/) { |
16 | $iface = "i"; |
16 | $iface = "i"; |
17 | } elsif ($^O =~ /linux/) { |
17 | } elsif ($^O =~ /linux/) { |
|
|
18 | # default to setjmp/longjmp on non-x86... |
|
|
19 | $iface = $Config{archname} =~ /^i[3456]86-/ ? "l" : "s"; |
|
|
20 | } elsif ($^O =~ /(free|net|open)bsd/) { |
|
|
21 | # FreeBSD 4.x has ucontext.h but no makecontext et al (see BUGS section of |
|
|
22 | # man context). Assume the same problem for all other BSDs. |
18 | $iface = "l"; |
23 | $iface = "s"; |
19 | } elsif ($^O =~ /solaris/) { |
24 | } elsif ($^O =~ /solaris/) { |
|
|
25 | $iface = "s"; |
|
|
26 | } elsif ($^O =~ /darwin/) { |
20 | $iface = "s"; |
27 | $iface = "s"; |
21 | } elsif (-e "/usr/include/ucontext.h") { |
28 | } elsif (-e "/usr/include/ucontext.h") { |
22 | $iface = "u"; |
29 | $iface = "u"; |
23 | } else { |
30 | } else { |
24 | $iface = "s"; |
31 | $iface = "s"; |
25 | } |
32 | } |
26 | |
33 | |
27 | print <<EOF; |
34 | print <<EOF; |
28 | |
35 | |
29 | Version 0.12 introduced experimental C context sharing. This makes it |
36 | Version 0.12 introduced C context sharing. This makes it possible to share |
30 | possible to share the C stack and context between many coroutines, |
37 | the C stack and context between many coroutines, resulting in memory |
31 | resulting in memory savings and slight speed gains, at the cost of |
38 | savings and slight speed gains, at the cost of potential (but mostly |
32 | potential segfaults (especially with exception handling). On my Linux/x86 |
39 | theoretical) segfaults. On my Linux/x86 machine this decreased the size |
33 | machine this decreased the size of a new coroutine from 9k to 5k, the |
40 | of a new coroutine from 9k to 5k, but the savings are much more apparent |
34 | savings are much more apparent on machines without mmap or good memory |
41 | on machines without mmap or good memory management. This algorithm relies |
35 | management. This algorithm relies on the non-fact that the same machine |
42 | on the non-fact that the same machine stack pointer indicates the same |
36 | stack pointer indicates the same function call nesting level, which |
43 | function call nesting level, which usually works good enough but might |
37 | usually works good enough but might fail... |
44 | fail... |
38 | |
45 | |
39 | The default (disabled) is safe, as it only increases memory consumption. |
46 | The default (enabled) has been in-use on productions servers for some time |
|
|
47 | now, without any problem reports so far. |
40 | |
48 | |
41 | EOF |
49 | EOF |
42 | |
50 | |
43 | print "Do you want to enable experimental context sharing (y/n) [n]? "; |
51 | if (prompt ("Do you want to enable C context sharing (y/n)", "y") !~ /^\s*n/i) { |
44 | |
|
|
45 | if (<> =~ /^\s*y/i) { |
|
|
46 | print "\nExperimental context sharing enabled.\n\n"; |
52 | print "\nExperimental context sharing enabled.\n\n"; |
47 | $DEFINE .= " -DCORO_LAZY_STACK"; |
53 | $DEFINE .= " -DCORO_LAZY_STACK"; |
48 | } |
54 | } |
49 | |
55 | |
50 | if ($iface) { |
56 | if ($iface) { |
… | |
… | |
64 | faster than with the ucontext functions). Unfortunately, glibc-2.1 and |
70 | faster than with the ucontext functions). Unfortunately, glibc-2.1 and |
65 | below don't even feature a working sigaltstack. |
71 | below don't even feature a working sigaltstack. |
66 | |
72 | |
67 | l Older GNU/Linux systems (glibc-2.1 and below) need this hack. Since it is |
73 | l Older GNU/Linux systems (glibc-2.1 and below) need this hack. Since it is |
68 | very linux-specific it is also quite fast for newer versions; when it |
74 | very linux-specific it is also quite fast for newer versions; when it |
69 | works, that is... |
75 | works, that is (currently x86 only)... |
70 | |
76 | |
71 | i IRIX. For some reason, SGI really does not like to follow the unix |
77 | i IRIX. For some reason, SGI really does not like to follow the unix |
72 | standard (does that surprise you?), so this workaround might be needed |
78 | standard (does that surprise you?), so this workaround might be needed |
73 | (it's fast), although s and u should also work now. |
79 | (it's fast), although s and u should also work now. |
74 | |
80 | |
|
|
81 | For most systems, the default chosen should be OK. If you experience |
|
|
82 | problems then you should experiment with this setting and/or turn off |
|
|
83 | optimizations (make OPTIMIZE=-O0). |
|
|
84 | |
75 | EOF |
85 | EOF |
76 | |
86 | |
77 | retry: |
87 | retry: |
78 | print "Use which implementation,\n", |
|
|
79 | "<s>etjmp/longjump, <u>context, <i>rix or <l>inux [$iface]? "; |
|
|
80 | |
88 | |
81 | my $r = <>; |
89 | my $r = prompt "Use which implementation,\n" . |
|
|
90 | "<s>etjmp/longjump, <u>context, <i>rix or <l>inux?", |
|
|
91 | $iface; |
82 | $iface = lc $1 if $r =~ /(\S)/; |
92 | $iface = lc $1 if $r =~ /(\S)/; |
83 | |
93 | |
84 | if ($iface eq "u") { |
94 | if ($iface eq "u") { |
85 | $DEFINE .= " -DCORO_UCONTEXT"; |
95 | $DEFINE .= " -DCORO_UCONTEXT"; |
86 | print "\nUsing ucontext implementation\n\n"; |
96 | print "\nUsing ucontext implementation\n\n"; |
… | |
… | |
106 | WriteMakefile( |
116 | WriteMakefile( |
107 | NAME => "Coro::State", |
117 | NAME => "Coro::State", |
108 | VERSION_FROM => "State.pm", |
118 | VERSION_FROM => "State.pm", |
109 | DEFINE => $DEFINE, |
119 | DEFINE => $DEFINE, |
110 | DIR => [], |
120 | DIR => [], |
111 | PM => { |
|
|
112 | 'State.pm' => '$(INST_LIBDIR)/State.pm', |
|
|
113 | |
|
|
114 | 'MakeMaker.pm' => '$(INST_LIBDIR)/MakeMaker.pm', |
|
|
115 | 'CoroAPI.h' => '$(INST_LIBDIR)/CoroAPI.h', |
|
|
116 | |
|
|
117 | 'Cont.pm' => '$(INST_LIBDIR)/Cont.pm', |
|
|
118 | |
|
|
119 | 'Specific.pm' => '$(INST_LIBDIR)/Specific.pm', |
|
|
120 | |
|
|
121 | 'Timer.pm' => '$(INST_LIBDIR)/Timer.pm', |
|
|
122 | 'Signal.pm' => '$(INST_LIBDIR)/Signal.pm', |
|
|
123 | 'Channel.pm' => '$(INST_LIBDIR)/Channel.pm', |
|
|
124 | 'Semaphore.pm' => '$(INST_LIBDIR)/Semaphore.pm', |
|
|
125 | 'SemaphoreSet.pm' => '$(INST_LIBDIR)/SemaphoreSet.pm', |
|
|
126 | 'RWLock.pm' => '$(INST_LIBDIR)/RWLock.pm', |
|
|
127 | }, |
|
|
128 | ); |
121 | ); |
129 | |
122 | |
130 | sub conftest { |
123 | sub conftest { |
131 | my $type = shift; |
124 | my $type = shift; |
132 | |
125 | |
… | |
… | |
146 | |
139 | |
147 | unlink "a.out"; |
140 | unlink "a.out"; |
148 | unlink "conftestval"; |
141 | unlink "conftestval"; |
149 | } |
142 | } |
150 | |
143 | |
|
|
144 | print <<EOF if $^O =~ /linux/; |
151 | |
145 | |
|
|
146 | ***************************************************************************** |
|
|
147 | * * |
|
|
148 | * HEY!! You are using Linux! That's not at all bad, but if you get seg- * |
|
|
149 | * faults with Coro almost all the time please refer to README.linux-glibc * |
|
|
150 | * * |
|
|
151 | ***************************************************************************** |
|
|
152 | |
|
|
153 | EOF |
|
|
154 | |