summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-22 09:41:37 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-24 09:25:12 -0800
commitf2c01b15f5d3274b0f6ed66037d846fb617bf496 (patch)
tree6e5f35a86378710213580d65594c9405a311ffdc
parent23a52d6b1d16cc250eb1dba0dc48439ff677e635 (diff)
downloadperl-f2c01b15f5d3274b0f6ed66037d846fb617bf496.tar.gz
Add feature.h, with constants for feature bundles
-rw-r--r--Cross/Makefile-cross-SH4
-rw-r--r--MANIFEST1
-rwxr-xr-xMakefile.SH4
-rwxr-xr-xPorting/makerel1
-rw-r--r--feature.h20
-rw-r--r--regen/feature.pl49
6 files changed, 72 insertions, 7 deletions
diff --git a/Cross/Makefile-cross-SH b/Cross/Makefile-cross-SH
index eaa1057132..d71364d5a2 100644
--- a/Cross/Makefile-cross-SH
+++ b/Cross/Makefile-cross-SH
@@ -848,7 +848,7 @@ CHMOD_W = chmod +w
# opcode.pl: opcode.h opnames.h pp_proto.h
# regcomp.pl: regnodes.h
# warnings.pl: warnings.h lib/warnings.pm
-# feature.pl: lib/feature.pl
+# feature.pl: feature.h lib/feature.pl
# The correct versions should be already supplied with the perl kit,
# in case you don't have perl available.
# To force them to be regenerated, run
@@ -858,7 +858,7 @@ CHMOD_W = chmod +w
AUTOGEN_FILES = opcode.h opnames.h pp_proto.h proto.h embed.h embedvar.h \
perlapi.h perlapi.c regnodes.h warnings.h lib/warnings.pm \
- lib/feature.pm
+ lib/feature.pm feature.h
.PHONY: regen_headers regen_all
diff --git a/MANIFEST b/MANIFEST
index b9d796e2e1..47e7d4aaa8 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4002,6 +4002,7 @@ ext/XS-Typemap/Typemap.pm XS::Typemap extension
ext/XS-Typemap/Typemap.xs XS::Typemap extension
fakesdio.h stdio in terms of PerlIO
fakethr.h Fake threads header
+feature.h Feature header
form.h Public declarations for formats
generate_uudmap.c Generate uudmap.h, the uuencode decoding map
genpacksizetables.pl Generate the size tables for pack/unpack
diff --git a/Makefile.SH b/Makefile.SH
index 4791e5c73a..a9ed850a74 100755
--- a/Makefile.SH
+++ b/Makefile.SH
@@ -1153,7 +1153,7 @@ CHMOD_W = chmod +w
# opcode.pl: opcode.h opnames.h pp_proto.h
# regcomp.pl: regnodes.h
# warnings.pl: warnings.h lib/warnings.pm
-# feature.pl: lib/feature.pm
+# feature.pl: feature.h lib/feature.pm
# The correct versions should be already supplied with the perl kit,
# in case you don't have perl available.
# To force them to be regenerated, run
@@ -1163,7 +1163,7 @@ CHMOD_W = chmod +w
AUTOGEN_FILES = opcode.h opnames.h pp_proto.h proto.h embed.h embedvar.h \
perlapi.h perlapi.c regnodes.h warnings.h lib/warnings.pm \
- lib/feature.pm
+ lib/feature.pm feature.h
.PHONY: regen_headers regen_all
diff --git a/Porting/makerel b/Porting/makerel
index 35c8dceec6..ffbb741ed2 100755
--- a/Porting/makerel
+++ b/Porting/makerel
@@ -131,6 +131,7 @@ system("chmod +x @exe") == 0
my @writables = qw(
NetWare/config_H.wc
NetWare/Makefile
+ feature.h
keywords.h
keywords.c
opcode.h
diff --git a/feature.h b/feature.h
new file mode 100644
index 0000000000..03468f27c0
--- /dev/null
+++ b/feature.h
@@ -0,0 +1,20 @@
+/* -*- buffer-read-only: t -*-
+ !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
+ This file is built by regen/feature.pl.
+ Any changes made here will be lost!
+ */
+
+
+#if defined(PERL_CORE) || defined (PERL_EXT)
+
+#define HINT_FEATURE_SHIFT 26
+
+#define FEATURE_BUNDLE_DEFAULT 0
+#define FEATURE_BUNDLE_510 1
+#define FEATURE_BUNDLE_511 2
+#define FEATURE_BUNDLE_515 3
+#define FEATURE_BUNDLE_CUSTOM HINT_FEATURE_MASK >> HINT_FEATURE_SHIFT
+
+#endif /* PERL_CORE or PERL_EXT */
+
+/* ex: set ro: */
diff --git a/regen/feature.pl b/regen/feature.pl
index b57a30e342..d4e23368a3 100644
--- a/regen/feature.pl
+++ b/regen/feature.pl
@@ -3,6 +3,7 @@
# Regenerate (overwriting only if changed):
#
# lib/feature.pm
+# feature.h
#
# from information hardcoded into this script.
#
@@ -46,10 +47,24 @@ my %feature_bundle = (
###########################################################################
+my %UniqueBundles; # "say state switch" => 5.10
+my %Aliases; # 5.12 => 5.11
+for( sort keys %feature_bundle ) {
+ my $value = join(' ', sort @{$feature_bundle{$_}});
+ if (exists $UniqueBundles{$value}) {
+ $Aliases{$_} = $UniqueBundles{$value};
+ }
+ else {
+ $UniqueBundles{$value} = $_;
+ }
+}
-my ($pm) = map {
+###########################################################################
+
+
+my ($pm, $h) = map {
open_new($_, '>', { by => 'regen/feature.pl' });
-} 'lib/feature.pm';
+} 'lib/feature.pm', 'feature.h';
while (<DATA>) {
@@ -116,6 +131,8 @@ while (<DATA>) {
read_only_bottom_close_and_rename($pm);
+my $HintShift;
+
open "perl.h", "perl.h" or die "$0 cannot open perl.h: $!";
perlh: {
while (readline "perl.h") {
@@ -123,8 +140,9 @@ perlh: {
/(0x[A-Fa-f0-9]+)/ or die "No hex number in:\n\n$_\n ";
my $hex = $1;
my $bits = sprintf "%b", oct $1;
- $bits =~ /^0*1+0*\z/
+ $bits =~ /^0*1+(0*)\z/
or die "Non-contiguous bits in $bits (binary for $hex):\n\n$_\n ";
+ $HintShift = length $1;
my $bits_needed =
length sprintf "%b", scalar keys(%feature_bundle) - @same;
$bits =~ /1{$bits_needed}/
@@ -136,6 +154,31 @@ perlh: {
}
close "perl.h";
+my $first_bit = sprintf "0x%08x", 1 << $HintShift;
+print $h <<EOH;
+
+#if defined(PERL_CORE) || defined (PERL_EXT)
+
+#define HINT_FEATURE_SHIFT $HintShift
+
+#define FEATURE_BUNDLE_DEFAULT 0
+EOH
+
+my $count;
+for (sort values %UniqueBundles) {
+ (my $key = $_) =~ y/.//d;
+ next if $key =~ /\D/;
+ print $h "#define FEATURE_BUNDLE_$key ", ++$count, "\n";
+}
+
+print $h <<EOH;
+#define FEATURE_BUNDLE_CUSTOM HINT_FEATURE_MASK >> HINT_FEATURE_SHIFT
+
+#endif /* PERL_CORE or PERL_EXT */
+EOH
+
+read_only_bottom_close_and_rename($h);
+
__END__
package feature;