# This source file is generated from the standard macros file
# `standard.mac' by another Perl script. Again, it's part of the
# standard distribution.
-macros.c: macros.pl pptok.ph standard.mac version.mac $(srcdir)/macros/*.mac
+macros.c: macros.pl pptok.ph standard.mac version.mac \
+ $(srcdir)/macros/*.mac $(srcdir)/output/*.mac
$(PERL) $(srcdir)/macros.pl $(srcdir)/standard.mac version.mac \
- $(srcdir)/macros/*.mac
+ $(srcdir)/macros/*.mac $(srcdir)/output/*.mac
# These source files are generated from regs.dat by yet another
# perl script.
my $npkg = 0;
my @pkg_list = ();
my %pkg_number = ();
-my %pkg_index = ();
my $pkg;
+my @out_list = ();
+my $outfmt;
+my $lastname;
foreach $fname ( @ARGV ) {
open(INPUT,$fname) or die "unable to open $fname\n";
- print OUT "\n /* From $fname */\n";
while (<INPUT>) {
$line++;
chomp;
if (m/^\s*\*END\*TASM\*MACROS\*\s*$/) {
$tasm_count = $index;
print OUT " /* End of TASM macros */\n";
+ } elsif (m/^OUT:\s*(.*\S)\s*$/) {
+ undef $pkg;
+ my @out_alias = split(/\s+/, $1);
+ printf OUT " /* %4d */ NULL\n", $index++;
+ print OUT "};\n";
+ $index = 0;
+ printf OUT "const char * const %s_stdmac[] = {\n", $out_alias[0];
+ print OUT " /* From $fname */\n";
+ $lastname = $fname;
+ push(@out_list, $out_alias[0]);
+ $out_index{$out_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 */ NULL,\n", $index++;
- print OUT " /* %use $pkg */\n";
+ print OUT "};\n";
+ $index = 0;
+ printf OUT "static const char * const nasm_stdmac_%s[] = {\n", $pkg;
+ print OUT " /* From $fname */\n";
+ $lastname = $fname;
push(@pkg_list, $pkg);
$pkg_number{$pkg} = $npkg++;
$pkg_index{$pkg} = $index;
}
$s2 .= $s1;
if (length($s2) > 0) {
+ if ($lastname ne $fname) {
+ print OUT "\n /* From $fname */\n";
+ $lastname = $fname;
+ }
printf OUT " /* %4d */ \"%s\",\n", $index++, $s2;
}
} else {
print OUT " const char * const *macros;\n";
print OUT " } packages[$npkg] = {\n";
foreach $pkg (@pkg_list) {
- printf OUT " { \"%s\", nasm_stdmac+%d },\n",
- $pkg, $pkg_index{$pkg};
+ printf OUT " { \"%s\", nasm_stdmac_%s },\n",
+ $pkg, $pkg;
}
print OUT " };\n";
#include <inttypes.h>
#include "version.h" /* generated NASM version macros */
#include "nasmlib.h"
+#include "preproc.h"
#include "insnsi.h" /* For enum opcode */
#define NO_SEG -1L /* null segment value */
* and user-level equivalents for any format-specific
* directives).
*/
- const char **stdmac;
+ const macros_t *stdmac;
/*
* This procedure is called at the start of an output session.
standard_extension(inname, outname, ".o", error);
}
-static const char *aout_stdmac[] = {
- "%define __SECT__ [section .text]",
- "%macro __NASM_CDecl__ 1",
- "%endmacro",
- NULL
-};
+extern macros_t aout_stdmac[];
static int aout_set_info(enum geninfo type, char **val)
{
--- /dev/null
+OUT: aout
+%define __SECT__ [section .text]
+%macro __NASM_CDecl__ 1
+%endmacro
standard_extension(inname, outname, ".o", error);
}
-static const char *as86_stdmac[] = {
- "%define __SECT__ [section .text]",
- "%macro __NASM_CDecl__ 1",
- "%endmacro",
- NULL
-};
+extern macros_t as86_stdmac[];
static int as86_set_info(enum geninfo type, char **val)
{
--- /dev/null
+OUT: as86
+%define __SECT__ [section .text]
+%macro __NASM_CDecl__ 1
+%endmacro
static int map_control = 0;
static char *infile, *outfile;
-static const char *bin_stdmac[] = {
- "%define __SECT__ [section .text]",
- "%imacro org 1+.nolist",
- "[org %1]",
- "%endmacro",
- "%macro __NASM_CDecl__ 1",
- "%endmacro",
- NULL
-};
+extern macros_t bin_stdmac[];
static void add_reloc(struct Section *s, int32_t bytes, int32_t secref,
int32_t secrel)
--- /dev/null
+OUT: bin
+%define __SECT__ [section .text]
+%imacro org 1+.nolist
+[org %1]
+%endmacro
+%macro __NASM_CDecl__ 1
+%endmacro
standard_extension(inname, outname, ".obj", error);
}
-static const char *coff_stdmac[] = {
- "%define __SECT__ [section .text]",
- "%macro __NASM_CDecl__ 1",
- "%endmacro",
- "%imacro export 1+.nolist",
- "[export %1]",
- "%endmacro",
- "%imacro safeseh 1.nolist",
- "[safeseh %1]",
- "%endmacro",
- NULL
-};
+extern macros_t coff_stdmac[];
static int coff_set_info(enum geninfo type, char **val)
{
--- /dev/null
+OUT: coff
+%define __SECT__ [section .text]
+%macro __NASM_CDecl__ 1
+%endmacro
+%imacro export 1+.nolist
+[export %1]
+%endmacro
+%imacro safeseh 1.nolist
+[safeseh %1]
+%endmacro
--- /dev/null
+OUT: elf elf32 elf64
+%define __SECT__ [section .text]
+%macro __NASM_CDecl__ 1
+%define $_%1 $%1
+%endmacro
+%macro osabi 1+.nolist
+[osabi %1]
+%endmacro
standard_extension(inname, outname, ".o", error);
}
-static const char *elf_stdmac[] = {
- "%define __SECT__ [section .text]",
- "%macro __NASM_CDecl__ 1",
- "%define $_%1 $%1",
- "%endmacro",
- "%macro osabi 1+.nolist",
- "[osabi %1]",
- "%endmacro",
- NULL
-};
+extern macros_t elf_stdmac[];
+
static int elf_set_info(enum geninfo type, char **val)
{
(void)type;
standard_extension(inname, outname, ".o", error);
}
-static const char *elf_stdmac[] = {
- "%define __SECT__ [section .text]",
- "%macro __NASM_CDecl__ 1",
- "%define $_%1 $%1",
- "%endmacro",
- "%macro osabi 1+.nolist",
- "[osabi %1]",
- "%endmacro",
- NULL
-};
+extern macros_t elf_stdmac[];
+
static int elf_set_info(enum geninfo type, char **val)
{
(void)type;
standard_extension(inname, outname, ".o", error);
}
-static const char *macho_stdmac[] = {
- "%define __SECT__ [section .text]",
- "%macro __NASM_CDecl__ 1",
- "%endmacro",
- NULL
-};
+extern macros_t macho_stdmac[];
/* Comparison function for qsort symbol layout. */
static int layout_compare (const struct symbol **s1,
--- /dev/null
+OUT: macho win32 win64
+%define __SECT__ [section .text]
+%macro __NASM_CDecl__ 1
+%endmacro
fputc((-cksum) & 0xFF, ofp);
}
-static const char *obj_stdmac[] = {
- "%define __SECT__ [section .text]",
- "%imacro group 1+.nolist",
- "[group %1]",
- "%endmacro",
- "%imacro uppercase 0+.nolist",
- "[uppercase %1]",
- "%endmacro",
- "%imacro export 1+.nolist",
- "[export %1]",
- "%endmacro",
- "%imacro import 1+.nolist",
- "[import %1]",
- "%endmacro",
- "%macro __NASM_CDecl__ 1",
- "%endmacro",
- NULL
-};
+extern macros_t obj_stdmac[];
void dbgbi_init(struct ofmt *of, void *id, FILE * fp, efunc error)
{
--- /dev/null
+OUT: obj
+%define __SECT__ [section .text]
+%imacro group 1+.nolist
+[group %1]
+%endmacro
+%imacro uppercase 0+.nolist
+[uppercase %1]
+%endmacro
+%imacro export 1+.nolist
+[export %1]
+%endmacro
+%imacro import 1+.nolist
+[import %1]
+%endmacro
+%macro __NASM_CDecl__ 1
+%endmacro
standard_extension(inname, outname, ".rdf", error);
}
-static char *rdf_stdmac[] = {
- "%define __SECT__ [section .text]",
- "%imacro library 1+.nolist",
- "[library %1]",
- "%endmacro",
- "%macro __NASM_CDecl__ 1",
- "%endmacro",
- NULL
-};
+extern macros_t rdf_stdmac[];
static int rdf_set_info(enum geninfo type, char **val)
{
--- /dev/null
+OUT: rdf
+%define __SECT__ [section .text]
+%imacro library 1+.nolist
+[library %1]
+%endmacro
+%macro __NASM_CDecl__ 1
+%endmacro
standard_extension(inname, outname, ".rdf", error);
}
-static const char *rdf2_stdmac[] = {
- "%define __SECT__ [section .text]",
- "%imacro library 1+.nolist",
- "[library %1]",
- "%endmacro",
- "%imacro module 1+.nolist",
- "[module %1]",
- "%endmacro",
- "%macro __NASM_CDecl__ 1",
- "%endmacro",
- NULL
-};
+extern macros_t rdf2_stdmac[];
static int rdf2_set_info(enum geninfo type, char **val)
{
--- /dev/null
+OUT: rdf2
+%define __SECT__ [section .text]
+%imacro library 1+.nolist
+[library %1]
+%endmacro
+%imacro module 1+.nolist
+[module %1]
+%endmacro
+%macro __NASM_CDecl__ 1
+%endmacro
* any.
*/
static const char * const *extrastdmac = NULL;
-bool any_extrastdmac;
+static bool any_extrastdmac;
/*
* Tokens are allocated in blocks to improve speed
}
-void pp_extra_stdmac(const char **macros)
+void pp_extra_stdmac(const macros_t *macros)
{
extrastdmac = macros;
}
extern const char * const pp_directives[];
extern const int pp_directives_len[];
+/* Pointer to a macro chain */
+typedef const char * const macros_t;
+
enum preproc_token pp_token_hash(const char *token);
void pp_include_path(char *);
void pp_pre_include(char *);
void pp_pre_define(char *);
void pp_pre_undefine(char *);
void pp_runtime(char *);
-void pp_extra_stdmac(const char **);
+void pp_extra_stdmac(const macros_t *);
#endif