mirror of
https://github.com/mirror/tinycc.git
synced 2025-03-10 08:50:07 +08:00
Update pragma once for file operations
Use open/read/close instead of fopen/fread/fclose for tcc4tcl and ziptcc
This commit is contained in:
parent
4e363a1728
commit
c92f4f52d9
8
tccpp.c
8
tccpp.c
@ -1611,20 +1611,20 @@ bad_twosharp:
|
||||
static unsigned long long calc_file_hash(const char *filename)
|
||||
{
|
||||
unsigned long long hash = 14695981039346656037ull; // FNV_offset_basis;
|
||||
FILE *fp = fopen (filename, "rb");
|
||||
int fd = open (filename, O_RDONLY | O_BINARY);
|
||||
|
||||
if (fp == NULL)
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
for (;;) {
|
||||
unsigned char temp[IO_BUF_SIZE];
|
||||
int i, n = fread(temp, 1, sizeof(temp), fp);
|
||||
int i, n = read(fd, temp, sizeof(temp));
|
||||
|
||||
if (n <= 0)
|
||||
break;
|
||||
for (i = 0; i < n; i++)
|
||||
hash = hash * 1099511628211ull ^ temp[i]; // FNV_prime
|
||||
}
|
||||
fclose(fp);
|
||||
close(fd);
|
||||
return hash ? hash : 1ull;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user