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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines