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.7 by root, Mon Oct 11 04:17:55 2010 UTC vs.
Revision 1.13 by root, Tue Jul 30 23:14:32 2013 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
5my ($fh, $oldstdout);
6
7BEGIN {
8 open $fh, ">lib/AnyEvent/constants.pl"
9 or die "lib/AnyEvent/constants.pl: $!\n";
10
11 $oldstdout = select $fh;
12
13 print "# automatically generated from constants.pl.PL\n";
14}
15
16{
17 # from common::sense 3.7
18 use strict qw(vars subs);
19 no warnings;
20 use warnings qw(FATAL closed threads internal debugging pack malloc portable prototype
21 inplace io pipe unpack deprecated glob digit printf
22 layer reserved taint closure semicolon);
23 no warnings qw(exec newline unopened);
24
25 BEGIN {
26 my $H = $^H;
27 my $WARN = ${^WARNING_BITS};
28
29 print "sub AnyEvent::common_sense {\n";
30 printf " local \$^W;\n";
31 printf " \${^WARNING_BITS} ^= \${^WARNING_BITS} ^ \"%s\";\n",
32 join "", map "\\x$_", unpack "(H2)*", ${^WARNING_BITS};
33 # use strict, use utf8;
34 printf " \$^H |= 0x%x;\n", $^H;
35 print "}\n";
36 }
37}
38
5use Config; 39use Config;
6use Socket;
7 40
8open my $fh, ">lib/AnyEvent/constants.pl"
9 or die "lib/AnyEvent/constants.pl: $_[0]\n";
10
11my $oldstdout = select $fh;
12
13print "# automatically generated from constants.pl.PL for perl $] built for $Config{archname}\n"; 41print "# generated for perl $] built for $Config{archname}\n";
42
43# when built as part of perl, these are not available
44BEGIN { eval "use Socket ()" }
45BEGIN { eval "use Fcntl ()" }
46BEGIN { eval "use POSIX ()" }
14 47
15sub i($$) { 48sub i($$) {
16 print "sub $_[0](){", $_[1]*1, "}\n"; 49 print "sub $_[0](){", $_[1]*1, "}\n";
17} 50}
18 51
27# used a lot 60# used a lot
28i CYGWIN => $^O =~ /cygwin/i; 61i CYGWIN => $^O =~ /cygwin/i;
29i WIN32 => $WIN32; 62i WIN32 => $WIN32;
30 63
31# add these purely to avoid loading Fcntl, which is slow and bloated. 64# add these purely to avoid loading Fcntl, which is slow and bloated.
32use Fcntl ();
33 65
34i F_SETFL => eval { Fcntl::F_SETFL() };
35i F_SETFD => eval { Fcntl::F_SETFD() }; 66i F_SETFD => eval { Fcntl::F_SETFD() } || 2;
67i F_SETFL => eval { Fcntl::F_SETFL() } || 4;
36i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() }; 68i O_NONBLOCK => eval { Fcntl::O_NONBLOCK() } || 04000;
37i FD_CLOEXEC => eval { Fcntl::FD_CLOEXEC() }; 69i FD_CLOEXEC => eval { Fcntl::FD_CLOEXEC() } || 1;
70
71print "package AnyEvent::Base;\n";
72
73# add these purely to avoid loading POSIX, which is slow and bloated.
74
75i WNOHANG => eval { POSIX::WNOHANG() } || 1;
76
77print "package AnyEvent::IO;\n";
78
79i O_RDONLY => eval { Fcntl::O_RDONLY() } || 0;
80i O_WRONLY => eval { Fcntl::O_WRONLY() } || 1;
81i O_RDWR => eval { Fcntl::O_RDWR () } || 2;
82i O_CREAT => eval { Fcntl::O_CREAT () } || 64;
83i O_EXCL => eval { Fcntl::O_EXCL () } || 128;
84i O_TRUNC => eval { Fcntl::O_TRUNC () } || 512;
85i O_APPEND => eval { Fcntl::O_APPEND() } || 1024;
38 86
39print "package AnyEvent::Util;\n"; 87print "package AnyEvent::Util;\n";
40 88
41# broken windows perls use undocumented error codes... 89# broken windows perls use undocumented error codes...
42if ($WIN32) { 90if ($WIN32) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines