ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/constants.pl.PL
Revision: 1.3
Committed: Sat Mar 13 00:08:08 2010 UTC (14 years, 2 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-5_251
Changes since 1.2: +9 -3 lines
Log Message:
5.251

File Contents

# Content
1 #! perl
2
3 open my $fh, ">lib/AnyEvent/constants.pl"
4 or die "lib/AnyEvent/constants.pl: $_[0]\n";
5
6 my $oldstdout = select $fh;
7
8 sub i($$) {
9 print "sub $_[0] () { ", $_[1]*1, " }\n";
10 }
11
12 print "package AnyEvent;\n";
13
14 our $WIN32 = $^O =~ /mswin32/i;
15
16
17 i CYGWIN => $^O =~ /cygwin/i;
18 i WIN32 => $WIN32;
19
20 use Fcntl ();
21
22 i F_SETFL => eval { Fcntl::F_SETFL() };
23 i F_SETFD => eval { Fcntl::F_SETFD() };
24 i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() };
25 i FD_CLOEXEC => eval { Fcntl::FD_CLOEXEC() };
26
27 print "package AnyEvent::Util;\n";
28
29 # broken windows perls use undocumented error codes...
30 if ($WIN32) {
31 i WSAEINVAL => 10022;
32 i WSAEWOULDBLOCK => 10035;
33 i WSAEINPROGRESS => 10036;
34 } else {
35 # these should never match any errno value
36 i WSAEINVAL => -1e99;
37 i WSAEWOULDBLOCK => -1e99;
38 i WSAEINPROGRESS => -1e99;
39 }
40
41 my $af_inet6;
42
43 $af_inet6 ||= eval { require Socket ; Socket::AF_INET6 () };
44 $af_ine6t ||= eval { require Socket6; Socket6::AF_INET6() };
45
46 # uhoh
47 $af_inet6 ||= 10 if $^O =~ /linux/;
48 $af_inet6 ||= 23 if $^O =~ /cygwin/i;
49 $af_inet6 ||= 23 if AnyEvent::WIN32;
50 $af_inet6 ||= 24 if $^O =~ /openbsd|netbsd/;
51 $af_inet6 ||= 28 if $^O =~ /freebsd/;
52
53 #TODO: WSAxxx, EDOM/ESPIPE
54
55 i _AF_INET6 => $af_inet6;
56 #i AF_UNIX => Socket::AF_UNIX ();
57 #i SOCK_STREAM => Socket::SOCK_STREAM ();
58 #i SOCK_DGRAM => Socket::SOCK_DGRAM ();
59 #i SOL_SOCKET => Socket::SOL_SOCKET ();
60 #i SO_REUSEADDR => Socket::SO_REUSEADDR ();
61 #i SO_KEEPALIVE => Socket::SO_KEEPALIVE ();
62 #i SO_OOBINLINE => Socket::SO_OOBINLINE ();
63 #i IPPROTO_TCP => Socket::IPPROTO_TCP ();
64
65 print "1;\n";
66
67 close $fh;
68 select $oldstdout;
69
70 rename "$ARGV[0]~", $ARGV[0];
71
72 1