fixed fstat64 build error on mac

This commit is contained in:
Concedo 2023-05-29 15:50:07 +08:00
parent 28f1196f65
commit 97b39f875c
2 changed files with 5 additions and 5 deletions

View file

@ -210,7 +210,7 @@ maxctx = 2048
maxlen = 128 maxlen = 128
modelbusy = False modelbusy = False
defaultport = 5001 defaultport = 5001
KcppVersion = "1.26" KcppVersion = "1.27"
class ServerRequestHandler(http.server.SimpleHTTPRequestHandler): class ServerRequestHandler(http.server.SimpleHTTPRequestHandler):
sys_version = "" sys_version = ""

View file

@ -22,8 +22,8 @@
#include <sys/stat.h> // fstat #include <sys/stat.h> // fstat
#ifdef WIN32 #ifdef WIN32
#define stat64 _stat64 #define stat _stat64
#define fstat64 _fstat64 #define fstat _fstat64
#endif #endif
// --- Error handling --- // --- Error handling ---
@ -477,8 +477,8 @@ struct rwkv_context * rwkv_init_from_file(const char * file_path, const uint32_t
rwkv_file_guard file_guard { file }; rwkv_file_guard file_guard { file };
// Be very careful when changing this code. It must support files larger than 2 GB by using 64-bit functions to the get file length. // Be very careful when changing this code. It must support files larger than 2 GB by using 64-bit functions to the get file length.
struct stat64 file_stat; struct stat file_stat;
RWKV_ASSERT_NULL_MSG(RWKV_ERROR_FILE | RWKV_ERROR_FILE_STAT, fstat64(fileno(file), &file_stat) == 0, "Failed to stat file %s", file_path); RWKV_ASSERT_NULL_MSG(RWKV_ERROR_FILE | RWKV_ERROR_FILE_STAT, fstat(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"));