ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/Makefile.PL
Revision: 1.21
Committed: Thu Nov 21 13:08:06 2002 UTC (21 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.20: +13 -12 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 or $^O =~ /cygwin/) {
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 C context sharing. This makes it possible to share
30 the C stack and context between many coroutines, resulting in memory
31 savings and slight speed gains, at the cost of potential (but mostly
32 theoretical) segfaults. On my Linux/x86 machine this decreased the size
33 of a new coroutine from 9k to 5k, but the savings are much more apparent
34 on machines without mmap or good memory management. This algorithm relies
35 on the non-fact that the same machine stack pointer indicates the same
36 function call nesting level, which usually works good enough but might
37 fail...
38
39 The default (enabled) has been in-use on productions servers for some time
40 now, without any problem reports so far.
41
42 EOF
43
44 print "Do you want to enable C context sharing (y/n) [y]? ";
45
46 if (<> !~ /^\s*n/i) {
47 print "\nExperimental context sharing enabled.\n\n";
48 $DEFINE .= " -DCORO_LAZY_STACK";
49 }
50
51 if ($iface) {
52 print <<EOF;
53
54 Coro can use various ways to implement coroutines 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 workaround might be needed
74 (it's fast), although 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 'Timer.pm' => '$(INST_LIBDIR)/Timer.pm',
123 'Signal.pm' => '$(INST_LIBDIR)/Signal.pm',
124 'Channel.pm' => '$(INST_LIBDIR)/Channel.pm',
125 'Semaphore.pm' => '$(INST_LIBDIR)/Semaphore.pm',
126 'SemaphoreSet.pm' => '$(INST_LIBDIR)/SemaphoreSet.pm',
127 'RWLock.pm' => '$(INST_LIBDIR)/RWLock.pm',
128 },
129 );
130
131 sub conftest {
132 my $type = shift;
133
134 print "\nTrying to detect stack growth direction (for $type)\n";
135 print "You might see some warnings, this should not concern you.\n\n";
136 system "$Config{cc} $Config{ccflags} -D$type libcoro/conftest.c";
137
138 my $res = qx<./a.out>;
139 $res =~ s/\s+$//;
140 my ($sp, $ss) = split /,/, $res;
141
142 print "\n\n*****************************************************************************\n";
143 print "If the testsuite fails PLEASE provide the following information\n";
144 print "to Marc Lehmann <pcg\@goof.com>: operating system name, version,\n";
145 print "architecture name and this string '$sp|$ss'. Thanks a lot!\n";#d#
146 print "*****************************************************************************\n\n";
147
148 unlink "a.out";
149 unlink "conftestval";
150 }
151
152