aboutsummaryrefslogtreecommitdiffhomepage
path: root/io.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-02 18:24:54 +0100
committerlemon <lsof@mailbox.org>2025-12-02 18:24:54 +0100
commitbfd58e2c515e8c360fda4bee3d0702c60d92ebf0 (patch)
tree33f11ac7d4d56cbbe65cdf79753728b7fd4dfc9c /io.c
parent3c6e4dd54d5c144369b96d6673da7f23df4940da (diff)
preprocessor: add #ifndef...#endif include guard optimization
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/io.c b/io.c
index 58ebf17..1721f7b 100644
--- a/io.c
+++ b/io.c
@@ -818,6 +818,7 @@ static struct file {
vec_of(uint) lineoffs;
bool once;
bool seen;
+ const char *guardmac;
} *fileht[1<<SPANFILEBITS];
static int nfiles;
@@ -913,19 +914,21 @@ getfilepos(int *line, int *col, int id, uint off)
}
bool
-isoncefile(int id)
+isoncefile(int id, const char **guard)
{
assert(id < arraylength(fileht) && fileht[id]);
+ *guard = fileht[id]->guardmac;
return fileht[id]->once;
}
+
void
-markfileonce(int id)
+markfileonce(int id, const char *guard)
{
assert(id < arraylength(fileht) && fileht[id]);
fileht[id]->once = 1;
+ fileht[id]->guardmac = guard;
}
-
void
markfileseen(int id)
{