Switch to fstat64 (#70)

Switch to fstat64
This commit is contained in:
LoganDark 2023-05-26 05:20:51 -07:00 committed by GitHub
parent 9e2a0de843
commit 7cbfbc55c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -16,6 +16,11 @@
#include <sys/stat.h> // fstat #include <sys/stat.h> // fstat
#ifdef WIN32
#define stat64 _stat64
#define fstat64 _fstat64
#endif
// --- Error handling --- // --- Error handling ---
thread_local enum rwkv_error_flags global_last_error = RWKV_ERROR_NONE; thread_local enum rwkv_error_flags global_last_error = RWKV_ERROR_NONE;
@ -292,8 +297,8 @@ struct rwkv_context * rwkv_init_from_file(const char * file_path, const uint32_t
RWKV_ASSERT_NULL_MSG(RWKV_ERROR_FILE | RWKV_ERROR_FILE_OPEN, file, "Failed to open file %s", file_path); RWKV_ASSERT_NULL_MSG(RWKV_ERROR_FILE | RWKV_ERROR_FILE_OPEN, file, "Failed to open file %s", file_path);
rwkv_file_guard file_guard { file }; rwkv_file_guard file_guard { file };
struct stat file_stat; struct stat64 file_stat;
RWKV_ASSERT_NULL_MSG(RWKV_ERROR_FILE | RWKV_ERROR_FILE_STAT, fstat(fileno(file), &file_stat) == 0, "Failed to stat file %s", file_path); RWKV_ASSERT_NULL_MSG(RWKV_ERROR_FILE | RWKV_ERROR_FILE_STAT, fstat64(fileno(file), &file_stat) == 0, "Failed to stat file %s", file_path);
int32_t magic; int32_t magic;
RWKV_ASSERT_NULL(RWKV_ERROR_FILE, read_int32(file, &magic, "magic")); RWKV_ASSERT_NULL(RWKV_ERROR_FILE, read_int32(file, &magic, "magic"));