diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2016-07-13 14:23:48 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2016-07-13 14:23:48 -0700 |
commit | f7606613d047ff37ead008263284e2bc1ae9ce93 (patch) | |
tree | fb5d3a23d0304427c93bcaca699b42e2b0d7ab95 /macros | |
parent | 3d74b091e966842e70b34bd5e6e34448f81bc37a (diff) | |
download | nasm-f7606613d047ff37ead008263284e2bc1ae9ce93.tar.gz |
Handle multiple standard macro sets sanely
The ordering of the macro sets ended up changing due to the recent
file reorganization. Instead of forcing the order again, handle
multiple macro sets (rather than just two) in a coherent manner.
macros/macros.pl could use a cleanup of duplicated code, however.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'macros')
-rwxr-xr-x | macros/macros.pl | 66 | ||||
-rw-r--r-- | macros/standard.mac | 11 |
2 files changed, 52 insertions, 25 deletions
diff --git a/macros/macros.pl b/macros/macros.pl index 3c461194..d96324a2 100755 --- a/macros/macros.pl +++ b/macros/macros.pl @@ -102,9 +102,8 @@ print OUT "#include \"nasmlib.h\"\n"; print OUT "#include \"hashtbl.h\"\n"; print OUT "#include \"outform.h\"\n"; print OUT "\n"; -print OUT "#if 1\n"; -print OUT "const unsigned char nasm_stdmac[] = {"; +my $name = undef; my $npkg = 0; my @pkg_list = (); my %pkg_number = (); @@ -127,14 +126,14 @@ foreach $args ( @ARGV ) { chomp; $line++; } - if (m/^\s*\*END\*TASM\*MACROS\*\s*$/) { - $tasm_count = $index; - print OUT " /* End of TASM macros */\n"; - } elsif (m/^OUT:\s*(.*\S)\s*$/) { + if (m/^OUT:\s*(.*\S)\s*$/) { undef $pkg; my @out_alias = split(/\s+/, $1); - printf OUT " /* %4d */ 0\n", $index++; - print OUT "};\n#endif\n"; + if (defined($name)) { + printf OUT " /* %4d */ 0\n", $index++; + print OUT "};\n#endif\n"; + undef $name; + } $index = 0; print OUT "\n"; my $pfx = '#if'; @@ -142,22 +141,43 @@ foreach $args ( @ARGV ) { print OUT $pfx, " defined(OF_\U${al}\E)"; $pfx = ' ||'; } - printf OUT "\nconst unsigned char %s_stdmac[] = {\n", $out_alias[0]; - print OUT " /* From $fname */\n"; + $name = $out_alias[0] . '_stdmac'; + print OUT "\nconst unsigned char ${name}[] = {\n"; + print OUT " /* From $fname */\n"; $lastname = $fname; push(@out_list, $out_alias[0]); $out_index{$out_alias[0]} = $index; + } elsif (m/^STD:\s*(.*\S)\s*$/) { + undef $pkg; + my @out_alias = split(/\s+/, $1); + if (defined($name)) { + printf OUT " /* %4d */ 0\n", $index++; + print OUT "};\n#endif\n"; + undef $name; + } + $index = 0; + print OUT "\n#if 1"; + $name = 'nasm_stdmac_' . $out_alias[0]; + print OUT "\nconst unsigned char ${name}[] = {\n"; + print OUT " /* From $fname */\n"; + $lastname = $fname; + push(@std_list, $out_alias[0]); + $std_index{$std_alias[0]} = $index; } elsif (m/^USE:\s*(\S+)\s*$/) { $pkg = $1; if (defined($pkg_number{$pkg})) { die "$0: $fname: duplicate package: $pkg\n"; } - printf OUT " /* %4d */ 0\n", $index++; - print OUT "};\n#endif\n"; + if (defined($name)) { + printf OUT " /* %4d */ 0\n", $index++; + print OUT "};\n#endif\n"; + undef $name; + } $index = 0; - print OUT "\n#if 1\n"; - printf OUT "static const unsigned char nasm_stdmac_%s[] = {\n", $pkg; - print OUT " /* From $fname */\n"; + print OUT "\n#if 1"; + $name = 'nasm_usemac_' . $pkg; + print OUT "\nstatic const unsigned char ${name}[] = {\n"; + print OUT " /* From $fname */\n"; $lastname = $fname; push(@pkg_list, $pkg); $pkg_number{$pkg} = $npkg++; @@ -166,6 +186,11 @@ foreach $args ( @ARGV ) { $index += length($z)+1; } elsif (m/^\s*((\s*([^\"\';\s]+|\"[^\"]*\"|\'[^\']*\'))*)\s*(;.*)?$/) { my $s1, $s2, $pd, $ws; + + if (!defined($name)) { + die "$0: $fname: macro declarations outside a known block\n"; + } + $s1 = $1; $s2 = ''; while ($s1 =~ /(\%[a-zA-Z_][a-zA-Z0-9_]*)((\s+)(.*)|)$/) { @@ -197,9 +222,12 @@ foreach $args ( @ARGV ) { close(INPUT); } } -printf OUT " /* %4d */ 0\n};\n#endif\n\n", $index++; -print OUT "const unsigned char * const nasm_stdmac_after_tasm = ", - "&nasm_stdmac[$tasm_count];\n\n"; + +if (defined($name)) { + printf OUT " /* %4d */ 0\n", $index++; + print OUT "};\n#endif\n"; + undef $name; +} my @hashinfo = gen_perfect_hash(\%pkg_number); if (!@hashinfo) { @@ -217,7 +245,7 @@ print OUT " const char *package;\n"; print OUT " const unsigned char *macros;\n"; print OUT " } packages[$npkg] = {\n"; foreach $pkg (@pkg_list) { - printf OUT " { \"%s\", nasm_stdmac_%s },\n", + printf OUT " { \"%s\", nasm_usemac_%s },\n", $pkg, $pkg; } print OUT " };\n"; diff --git a/macros/standard.mac b/macros/standard.mac index 60c0387c..d89278a2 100644 --- a/macros/standard.mac +++ b/macros/standard.mac @@ -1,6 +1,6 @@ ;; -------------------------------------------------------------------------- ;; -;; Copyright 1996-2009 The NASM Authors - All Rights Reserved +;; Copyright 1996-2016 The NASM Authors - All Rights Reserved ;; See the file AUTHORS included with the NASM distribution for ;; the specific copyright holders. ;; @@ -33,9 +33,8 @@ ; Standard macro set for NASM -*- nasm -*- -; Macros to make NASM ignore some TASM directives before the first include -; directive. - +; Macros to make NASM ignore some TASM directives +STD: tasm %idefine IDEAL %idefine JUMPS %idefine P386 @@ -43,8 +42,8 @@ %idefine P586 %idefine END -; This is a magic token which indicates the end of the TASM macros -*END*TASM*MACROS* +; The normal standard macros +STD: nasm ; Note that although some user-level forms of directives are defined ; here, not all of them are: the user-level form of a format-specific |