summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-05-27 14:43:14 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-05-27 14:43:14 -0700
commitb4f4366ff3e5b76a69888b706e4c71da75b036e1 (patch)
tree321ef0da2621fc613190b76d6247bf3d5bfecbef
parentad42e0d1fb9843897171aa34bd58f28cd213c247 (diff)
downloadnasm-b4f4366ff3e5b76a69888b706e4c71da75b036e1.tar.gz
regs.pl: add include guards to generated header files
Add include guards to generated header files, and make sure the appropriate prerequisite headers are included if necessary.
-rwxr-xr-xregs.pl12
1 files changed, 9 insertions, 3 deletions
diff --git a/regs.pl b/regs.pl
index a56fa011..3a43ef06 100755
--- a/regs.pl
+++ b/regs.pl
@@ -79,6 +79,9 @@ close(REGS);
if ( $fmt eq 'h' ) {
# Output regs.h
print "/* automatically generated from $file - do not edit */\n\n";
+ print "#ifndef NASM_REGS_H\n";
+ print "#define NASM_REGS_H\n\n";
+
$expr_regs = 1;
printf "#define EXPR_REG_START %d\n\n", $expr_regs;
print "enum reg_enum {\n";
@@ -98,7 +101,7 @@ if ( $fmt eq 'h' ) {
foreach $reg ( sort(keys(%regs)) ) {
printf "#define %-15s %2d\n", "REG_NUM_\U${reg}", $regvals{$reg};
}
- print "\n";
+ print "\n\n#endif /* NASM_REGS_H */\n";
} elsif ( $fmt eq 'c' ) {
# Output regs.c
print "/* automatically generated from $file - do not edit */\n\n";
@@ -137,7 +140,6 @@ if ( $fmt eq 'h' ) {
} elsif ( $fmt eq 'dc' ) {
# Output regdis.c
print "/* automatically generated from $file - do not edit */\n\n";
- print "#include \"regs.h\"\n";
print "#include \"regdis.h\"\n\n";
foreach $class ( sort(keys(%disclass)) ) {
printf "const enum reg_enum nasm_rd_%-8s[%2d] = {",
@@ -155,11 +157,15 @@ if ( $fmt eq 'h' ) {
}
} elsif ( $fmt eq 'dh' ) {
# Output regdis.h
- print "/* automatically generated from $file - do not edit */\n";
+ print "/* automatically generated from $file - do not edit */\n\n";
+ print "#ifndef NASM_REGDIS_H\n";
+ print "#define NASM_REGDIS_H\n\n";
+ print "#include \"regs.h\"\n\n";
foreach $class ( sort(keys(%disclass)) ) {
printf "extern const enum reg_enum nasm_rd_%-8s[%2d];\n",
$class, scalar @{$disclass{$class}};
}
+ print "\n#endif /* NASM_REGDIS_H */\n";
} else {
die "$0: Unknown output format\n";
}