On 6/27/23 19:44, grischka wrote:
On 25.06.2023 20:30, Herman ten Brugge via Tinycc-devel wrote:
I just pushed a patch to fix this.
Hi Hermann,
some numbers from Win32:
before:
# 6.334 s, 85768 lines/s, 27.9 MB/s
after first patch:
# 11.825 s, 45941 lines/s, 14.9 MB/s
after second patch:
# 10.406 s, 52206 lines/s, 17.0 MB/s
Hm ...
I tested this also before committing. I could not find a problem.
I only have an x86_64 machine on redhat linux and a raspberry pi with 32
and 64 bits.
I also have no Windows any more and my i386 machine died about 10 years ago.
So I did the measurement with wine (32/64 bits) and saw no difference
before and after commit.
I did make a small change to the hash function. See attached patch.
(I used a 32 bits hash instead of 64 bits)
I cannot currently think of a better solution for pragma once. Maybe you
can?
Herman
diff --git a/tcc.h b/tcc.h
index 78b0174..6cb248c 100644
--- a/tcc.h
+++ b/tcc.h
@@ -719,7 +719,7 @@ typedef struct InlineFunc {
typedef struct CachedInclude {
struct stat st;
#ifdef _WIN32
- unsigned long long hash;
+ unsigned int hash;
#endif
int ifndef_macro;
int once;
diff --git a/tccpp.c b/tccpp.c
index b95c63d..5701b41 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1608,9 +1608,9 @@ bad_twosharp:
}
#ifdef _WIN32
-static unsigned long long calc_file_hash(const char *filename)
+static unsigned int calc_file_hash(const char *filename)
{
- unsigned long long hash = 14695981039346656037ull; // FNV_offset_basis;
+ unsigned int hash = 2166136261u; // FNV_offset_basis;
int fd = open (filename, O_RDONLY | O_BINARY);
if (fd < 0)
@@ -1622,10 +1622,10 @@ static unsigned long long calc_file_hash(const char
*filename)
if (n <= 0)
break;
for (i = 0; i < n; i++)
- hash = hash * 1099511628211ull ^ temp[i]; // FNV_prime
+ hash = hash * 16777619u ^ temp[i]; // FNV_prime
}
close(fd);
- return hash ? hash : 1ull;
+ return hash ? hash : 1u;
}
#endif
@@ -1636,7 +1636,7 @@ static CachedInclude *search_cached_include(TCCState *s1,
const char *filename,
int i;
struct stat st;
#ifdef _WIN32
- unsigned long long hash = 0;
+ unsigned int hash = 0;
#endif
/* This is needed for #pragmae once
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel