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.6 by root, Mon Oct 11 03:41:39 2010 UTC vs.
Revision 1.7 by root, Mon Oct 11 04:17:55 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 4
5use Config;
5use Socket; 6use Socket;
6 7
7open my $fh, ">lib/AnyEvent/constants.pl" 8open my $fh, ">lib/AnyEvent/constants.pl"
8 or die "lib/AnyEvent/constants.pl: $_[0]\n"; 9 or die "lib/AnyEvent/constants.pl: $_[0]\n";
9 10
10my $oldstdout = select $fh; 11my $oldstdout = select $fh;
11 12
13print "# automatically generated from constants.pl.PL for perl $] built for $Config{archname}\n";
14
12sub i($$) { 15sub i($$) {
13 print "sub $_[0] () { ", $_[1]*1, " }\n"; 16 print "sub $_[0](){", $_[1]*1, "}\n";
14} 17}
15 18
16sub n($$) { 19sub n($$) {
17 print "sub $_[0] () { ", (defined $_[1] ? $_[1]*1 : "undef"), " }\n"; 20 print "sub $_[0](){", (defined $_[1] ? $_[1]*1 : "undef"), "}\n";
18} 21}
19 22
20print "package AnyEvent;\n"; 23print "package AnyEvent;\n";
21 24
22our $WIN32 = $^O =~ /mswin32/i; 25our $WIN32 = $^O =~ /mswin32/i;
23 26
27# used a lot
24i CYGWIN => $^O =~ /cygwin/i; 28i CYGWIN => $^O =~ /cygwin/i;
25i WIN32 => $WIN32; 29i WIN32 => $WIN32;
26 30
31# add these purely to avoid loading Fcntl, which is slow and bloated.
27use Fcntl (); 32use Fcntl ();
28 33
29i F_SETFL => eval { Fcntl::F_SETFL() }; 34i F_SETFL => eval { Fcntl::F_SETFL() };
30i F_SETFD => eval { Fcntl::F_SETFD() }; 35i F_SETFD => eval { Fcntl::F_SETFD() };
31i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() }; 36i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() };
45 i WSAEINPROGRESS => -1e99; 50 i WSAEINPROGRESS => -1e99;
46} 51}
47 52
48my $af_inet6; 53my $af_inet6;
49 54
50$af_inet6 ||= eval { Socket::AF_INET6 () }; 55$af_inet6 ||= eval { Socket::AF_INET6 () }; # where it should be
51$af_inet6 ||= eval { require Socket6; Socket6::AF_INET6() }; 56$af_inet6 ||= eval { require Socket6; Socket6::AF_INET6() }; # where it actually is ...
52 57
53# uhoh 58# ... or isn't, because nobody has it installed
54$af_inet6 ||= 10 if $^O =~ /linux/; 59$af_inet6 ||= 10 if $^O =~ /linux/;
55$af_inet6 ||= 23 if $^O =~ /cygwin/i; 60$af_inet6 ||= 23 if $^O =~ /cygwin/i;
56$af_inet6 ||= 23 if AnyEvent::WIN32; 61$af_inet6 ||= 23 if AnyEvent::WIN32;
57$af_inet6 ||= 24 if $^O =~ /openbsd|netbsd/; 62$af_inet6 ||= 24 if $^O =~ /openbsd|netbsd/;
58$af_inet6 ||= 28 if $^O =~ /freebsd/; 63$af_inet6 ||= 28 if $^O =~ /freebsd/;
59 64
60#TODO: WSAxxx, EDOM/ESPIPE 65#TODO: EDOM/ESPIPE
66#TODO: maybe move socket stuff to Socket::?
61 67
62i _AF_INET6 => $af_inet6; 68i _AF_INET6 => $af_inet6;
63#i AF_UNIX => Socket::AF_UNIX (); 69#i AF_UNIX => Socket::AF_UNIX ();
64#i SOCK_STREAM => Socket::SOCK_STREAM (); 70#i SOCK_STREAM => Socket::SOCK_STREAM ();
65#i SOCK_DGRAM => Socket::SOCK_DGRAM (); 71#i SOCK_DGRAM => Socket::SOCK_DGRAM ();
66#i SOL_SOCKET => Socket::SOL_SOCKET (); 72#i SOL_SOCKET => Socket::SOL_SOCKET ();
67#i SO_REUSEADDR => Socket::SO_REUSEADDR (); 73#i SO_REUSEADDR => Socket::SO_REUSEADDR ();
68#i SO_KEEPALIVE => Socket::SO_KEEPALIVE (); 74#i SO_KEEPALIVE => Socket::SO_KEEPALIVE ();
69#i SO_OOBINLINE => Socket::SO_OOBINLINE (); 75#i SO_OOBINLINE => Socket::SO_OOBINLINE ();
70#i IPPROTO_TCP => Socket::IPPROTO_TCP (); 76#i IPPROTO_TCP => Socket::IPPROTO_TCP ();
77
78print "package AnyEvent::Socket;\n";
71 79
72# more hardcoded os-specific constants - none 80# more hardcoded os-specific constants - none
73# of these are available via any known module, but we 81# of these are available via any known module, but we
74# are forward-looking and try Socket:: anyways. 82# are forward-looking and try Socket:: anyways.
75my %const; 83my %const;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines