summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2007-11-01 17:58:59 +0900
committerLauri Leukkunen <lle@rahina.org>2007-11-19 23:54:37 +0200
commit21ae4ce22f277bd02261f4febada1aa2d3190ffc (patch)
tree173c1223cea6ea368904c9f8f18d040d35712d18
parent5c43a6a16e4868136df1cfa7e801c98eacf09f53 (diff)
sbox2: Add pre-processor token support to gen-interface.
This adds support for pre-processor tokens in interface.master, the tokens are then in turn written-out to the auto-generated preload/{wrappers.c,exported.h}. This is necessary for cases where we need to use the autoconf defines to figure out what interfaces should be wrapped and which ones shouldn't. As an example, while the FTS interface is wrapped, it's not necessarily provided by the libc, resulting in compilation errors. The matching rationale is that any ^#[a-z] range is matched as a pre-processor token, and written-out to the generation buffers. This seemed like a more reasonable approach than having to special case every possible token, especially as interface.master already has some existing formatting rules and conventions. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rwxr-xr-xpreload/gen-interface.pl27
1 files changed, 25 insertions, 2 deletions
diff --git a/preload/gen-interface.pl b/preload/gen-interface.pl
index 4691932..f6a0867 100755
--- a/preload/gen-interface.pl
+++ b/preload/gen-interface.pl
@@ -736,28 +736,51 @@ sub command_export {
# Reads lines from standard input and call the above functions
# to perform actions.
my $line;
+my $token_cache; # cached pre-processor token
+
while ($line = <STDIN>) {
- next if ($line =~ m/^\s*#/); # skip comment lines
next if ($line =~ m/^\s*$/); # skip empty lines
while($line =~ s/\\$//) {
+ # Kill trailing whitespace when joining lines
+ $line =~ s/\s$//;
# line ends with \, glue next line to this one
my $nextline = <STDIN>;
$line .= $nextline;
if($debug) { printf "Continued: '%s'\n", $nextline; }
}
+ # '#' lines are special cased, they will either be comments
+ # or pre-processor directives.
+ if ($line =~ m/^\s*#/) {
+ # skip anything that's an obvious comment
+ next if ($line =~ m/^\s*#\s/);
+ next if ($line =~ m/^\s*#[A-Z]/);
+ next if ($line =~ m/^\s*#\s*$/);
+ $wrappers_c_buffer .= $token_cache = $line;
+ next
+ }
+
# Add the line as comment to the output C file
my $src_comment = $line;
- $src_comment =~ s/\n/\n * /g;
+ $src_comment =~ s/\n/\n */g;
$wrappers_c_buffer .= "/*$src_comment\n*/\n";
# replace multiple whitespaces by single spaces:
$line =~ s/\s+/ /g;
+ # Kill off trailing whitespace.
+ $line =~ s/\s$//;
+
# Split to fields. 1st=command, 2nd=function, 3rd=modifiers
my @field = split(/\s*:\s*/, $line);
+ # Order the cached pre-processor token first
+ if ($token_cache) {
+ $export_h_buffer .= $token_cache;
+ $token_cache = "";
+ }
+
if(($field[0] eq 'WRAP') || ($field[0] eq 'GATE')) {
# Generate a wrapper of a gate
command_wrap_or_gate(@field);