ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/constants.pl.PL
(Generate patch)

Comparing AnyEvent/constants.pl.PL (file contents):
Revision 1.5 by root, Thu Apr 15 04:21:15 2010 UTC vs.
Revision 1.6 by root, Mon Oct 11 03:41:39 2010 UTC

1#! perl 1#! perl
2 2
3# this file is unfortunately only executed at Makefile.PL time 3# this file is unfortunately only executed at Makefile.PL time
4
5use Socket;
4 6
5open my $fh, ">lib/AnyEvent/constants.pl" 7open my $fh, ">lib/AnyEvent/constants.pl"
6 or die "lib/AnyEvent/constants.pl: $_[0]\n"; 8 or die "lib/AnyEvent/constants.pl: $_[0]\n";
7 9
8my $oldstdout = select $fh; 10my $oldstdout = select $fh;
9 11
10sub i($$) { 12sub i($$) {
11 print "sub $_[0] () { ", $_[1]*1, " }\n"; 13 print "sub $_[0] () { ", $_[1]*1, " }\n";
14}
15
16sub n($$) {
17 print "sub $_[0] () { ", (defined $_[1] ? $_[1]*1 : "undef"), " }\n";
12} 18}
13 19
14print "package AnyEvent;\n"; 20print "package AnyEvent;\n";
15 21
16our $WIN32 = $^O =~ /mswin32/i; 22our $WIN32 = $^O =~ /mswin32/i;
39 i WSAEINPROGRESS => -1e99; 45 i WSAEINPROGRESS => -1e99;
40} 46}
41 47
42my $af_inet6; 48my $af_inet6;
43 49
44$af_inet6 ||= eval { require Socket ; Socket::AF_INET6 () }; 50$af_inet6 ||= eval { Socket::AF_INET6 () };
45$af_inet6 ||= eval { require Socket6; Socket6::AF_INET6() }; 51$af_inet6 ||= eval { require Socket6; Socket6::AF_INET6() };
46 52
47# uhoh 53# uhoh
48$af_inet6 ||= 10 if $^O =~ /linux/; 54$af_inet6 ||= 10 if $^O =~ /linux/;
49$af_inet6 ||= 23 if $^O =~ /cygwin/i; 55$af_inet6 ||= 23 if $^O =~ /cygwin/i;
61#i SO_REUSEADDR => Socket::SO_REUSEADDR (); 67#i SO_REUSEADDR => Socket::SO_REUSEADDR ();
62#i SO_KEEPALIVE => Socket::SO_KEEPALIVE (); 68#i SO_KEEPALIVE => Socket::SO_KEEPALIVE ();
63#i SO_OOBINLINE => Socket::SO_OOBINLINE (); 69#i SO_OOBINLINE => Socket::SO_OOBINLINE ();
64#i IPPROTO_TCP => Socket::IPPROTO_TCP (); 70#i IPPROTO_TCP => Socket::IPPROTO_TCP ();
65 71
72# more hardcoded os-specific constants - none
73# of these are available via any known module, but we
74# are forward-looking and try Socket:: anyways.
75my %const;
76
77while (<DATA>) {
78 my ($os, $name, $default) = split /\s+/;
79
80 $const{$name} ||= undef; # make sure it exists
81
82 next unless $os eq $^O;
83
84 my $value = eval "Socket::$name ()";
85 $value = eval $default unless defined $value;
86
87 $const{$name} = $value;
88}
89
90for my $k (sort keys %const) {
91 n $k, $const{$k};
92}
93
66print "1;\n"; 94print "1;\n";
67 95
68close $fh; 96close $fh;
69select $oldstdout; 97select $oldstdout;
70 98
71rename "$ARGV[0]~", $ARGV[0]; 991
72 100
731 101__DATA__
102linux TCP_MAXSEG 2
103linux TCP_CORK 3
104linux TCP_KEEPIDLE 4
105linux TCP_KEEPINTVL 5
106linux TCP_KEEPCNT 6
107linux TCP_SYNCNT 7
108linux TCP_LINGER2 8
109linux TCP_DEFER_ACCEPT 9
110linux TCP_WINDOW_CLAMP 10
111linux TCP_INFO 11
112linux TCP_QUICKACK 12
113linux TCP_CONGESTION 13
114linux TCP_MD5SIG 14
115netbsd TCP_MAXSEG 2
116netbsd TCP_KEEPIDLE 3
117netbsd TCP_NOPUSH 4
118netbsd TCP_KEEPINTVL 5
119netbsd TCP_KEEPCNT 6
120netbsd TCP_KEEPINIT 7
121netbsd TCP_NOOPT 8
122netbsd TCP_MD5SIG 0x10
123netbsd TCP_CONGESTION 0x20
124cygwin TCP_MAXSEG 0x02
125cygwin TCP_NOPUSH 0x04
126cygwin TCP_NOOPT 0x08
127freebsd TCP_MAXSEG 0x02
128freebsd TCP_NOPUSH 0x04
129freebsd TCP_NOOPT 0x08
130freebsd TCP_MD5SIG 0x10
131freebsd TCP_INFO 0x20
132freebsd TCP_CONGESTION 0x40
133solaris TCP_CORK 0x18
134solaris TCP_LINGER2 0x1C
135solaris TCP_INIT_CWND 0x15
136solaris TCP_KEEPALIVE 0x8
137solaris TCP_MAXSEG 0x02
138openbsd TCP_MAXSEG 0x02
139openbsd TCP_MD5SIG 0x04
140openbsd TCP_SACK_ENABLE 0x08
141darwin TCP_MAXSEG 0x02
142darwin TCP_NOPUSH 0x04
143darwin TCP_NOOPT 0x08
144darwin TCP_KEEPALIVE 0x10
145darwin TCP_CONNECTIONTIMEOUT 0x20

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines