ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/Makefile.PL
Revision: 1.17
Committed: Fri Sep 28 14:15:14 2001 UTC (22 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.16: +1 -0 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 use ExtUtils::MakeMaker;
2
3 use 5.005;
4
5 use Config;
6
7 $|=1;
8
9 $DEFINE = "";
10
11 $DEFINE .= " -DHAVE_MMAP" if $Config{d_mmap} eq "define" && $Config{d_munmap} eq "define";
12
13 if ($^O =~ /win32/i) {
14 $DEFINE = " -DCORO_LOOSE";
15 } elsif ($^O =~ /irix/) {
16 $iface = "i";
17 } elsif ($^O =~ /linux/) {
18 $iface = "l";
19 } elsif ($^O =~ /solaris/) {
20 $iface = "s";
21 } elsif (-e "/usr/include/ucontext.h") {
22 $iface = "u";
23 } else {
24 $iface = "s";
25 }
26
27 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 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
39 The default (disabled) is safe, as it only increases memory consumption.
40
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 if ($iface) {
51 print <<EOF;
52
53 Coro has the option of using two different ways to implement coroutines
54 at the C level:
55
56 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 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
76 EOF
77
78 retry:
79 print "Use which implementation,\n",
80 "<s>etjmp/longjump, <u>context, <i>rix or <l>inux [$iface]? ";
81
82 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 conftest("TEST_makecontext");
89 } elsif ($iface eq "s") {
90 $DEFINE .= " -DCORO_SJLJ";
91 print "\nUsing setjmp/longjmp/sigaltstack implementation\n\n";
92 conftest("TEST_sigaltstack");
93 } elsif ($iface eq "l") {
94 $DEFINE .= " -DCORO_LINUX";
95 print "\nUsing linux-specific implementation\n\n";
96 } elsif ($iface eq "i") {
97 $DEFINE .= " -DCORO_IRIX";
98 print "\nUsing irix-specific implementation\n\n";
99 } else {
100 print "\nUnknown implementation \"$iface\"\n";
101 goto retry;
102 }
103 } else {
104 print "\nUsing microsoft compatible coroutines\n\n";
105 }
106
107 WriteMakefile(
108 NAME => "Coro::State",
109 VERSION_FROM => "State.pm",
110 DEFINE => $DEFINE,
111 DIR => [],
112 PM => {
113 'State.pm' => '$(INST_LIBDIR)/State.pm',
114
115 'MakeMaker.pm' => '$(INST_LIBDIR)/MakeMaker.pm',
116 'CoroAPI.h' => '$(INST_LIBDIR)/CoroAPI.h',
117
118 'Cont.pm' => '$(INST_LIBDIR)/Cont.pm',
119
120 'Specific.pm' => '$(INST_LIBDIR)/Specific.pm',
121
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 );
129
130 sub conftest {
131 my $type = shift;
132
133 print "\nTrying to detect stack growth direction (for $type)\n";
134 print "You might see some warnings, this should not concern you.\n\n";
135 system "$Config{cc} $Config{ccflags} -D$type libcoro/conftest.c";
136
137 my $res = qx<./a.out>;
138 $res =~ s/\s+$//;
139 my ($sp, $ss) = split /,/, $res;
140
141 print "\n\n*****************************************************************************\n";
142 print "If the testsuite fails PLEASE provide the following information\n";
143 print "to Marc Lehmann <pcg\@goof.com>: operating system name, version,\n";
144 print "architecture name and this string '$sp|$ss'. Thanks a lot!\n";#d#
145 print "*****************************************************************************\n\n";
146
147 unlink "a.out";
148 unlink "conftestval";
149 }
150
151