ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/constants.pl.PL
Revision: 1.1
Committed: Sun Feb 21 09:28:18 2010 UTC (14 years, 8 months ago) by root
Content type: text/plain
Branch: MAIN
Log Message:
constants

File Contents

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