--- AnyEvent/constants.pl.PL 2010/12/05 11:41:45 1.10 +++ AnyEvent/constants.pl.PL 2013/07/30 23:14:32 1.13 @@ -2,20 +2,49 @@ # this file is unfortunately only executed at Makefile.PL time +my ($fh, $oldstdout); + +BEGIN { + open $fh, ">lib/AnyEvent/constants.pl" + or die "lib/AnyEvent/constants.pl: $!\n"; + + $oldstdout = select $fh; + + print "# automatically generated from constants.pl.PL\n"; +} + +{ + # from common::sense 3.7 + use strict qw(vars subs); + no warnings; + use warnings qw(FATAL closed threads internal debugging pack malloc portable prototype + inplace io pipe unpack deprecated glob digit printf + layer reserved taint closure semicolon); + no warnings qw(exec newline unopened); + + BEGIN { + my $H = $^H; + my $WARN = ${^WARNING_BITS}; + + print "sub AnyEvent::common_sense {\n"; + printf " local \$^W;\n"; + printf " \${^WARNING_BITS} ^= \${^WARNING_BITS} ^ \"%s\";\n", + join "", map "\\x$_", unpack "(H2)*", ${^WARNING_BITS}; + # use strict, use utf8; + printf " \$^H |= 0x%x;\n", $^H; + print "}\n"; + } +} + use Config; +print "# generated for perl $] built for $Config{archname}\n"; + # when built as part of perl, these are not available BEGIN { eval "use Socket ()" } BEGIN { eval "use Fcntl ()" } BEGIN { eval "use POSIX ()" } -open my $fh, ">lib/AnyEvent/constants.pl" - or die "lib/AnyEvent/constants.pl: $_[0]\n"; - -my $oldstdout = select $fh; - -print "# automatically generated from constants.pl.PL for perl $] built for $Config{archname}\n"; - sub i($$) { print "sub $_[0](){", $_[1]*1, "}\n"; } @@ -45,6 +74,16 @@ i WNOHANG => eval { POSIX::WNOHANG() } || 1; +print "package AnyEvent::IO;\n"; + +i O_RDONLY => eval { Fcntl::O_RDONLY() } || 0; +i O_WRONLY => eval { Fcntl::O_WRONLY() } || 1; +i O_RDWR => eval { Fcntl::O_RDWR () } || 2; +i O_CREAT => eval { Fcntl::O_CREAT () } || 64; +i O_EXCL => eval { Fcntl::O_EXCL () } || 128; +i O_TRUNC => eval { Fcntl::O_TRUNC () } || 512; +i O_APPEND => eval { Fcntl::O_APPEND() } || 1024; + print "package AnyEvent::Util;\n"; # broken windows perls use undocumented error codes...