From 45f59f2c07e9c5f1d031b45da6bb8a12e1b4618e Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Wed, 7 Oct 2026 21:13:30 +0000 Subject: [PATCH] fix: use 64-bit seek/tell that MSVC has in the bundle loader fseeko and ftello are POSIX only, so the Windows cpu, cuda and vulkan builds of v0.6.0 failed with C3861 in model_loader.cpp and the release job was skipped. Wrap them in two small helpers that call _fseeki64 and _ftelli64 on Windows and keep fseeko/ftello elsewhere. Assisted-by: Claude:claude-sonnet-5-5 [Claude Code] --- src/model_loader.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/model_loader.cpp b/src/model_loader.cpp index 88c087b..f6037b2 100644 --- a/src/model_loader.cpp +++ b/src/model_loader.cpp @@ -11,6 +11,16 @@ #include #include #include + +// fseeko/ftello are POSIX; MSVC spells the 64-bit versions _fseeki64/_ftelli64. +#ifdef _WIN32 +static int pk_fseek64(FILE* f, uint64_t off, int whence){ return _fseeki64(f, (__int64)off, whence); } +static int64_t pk_ftell64(FILE* f){ return _ftelli64(f); } +#else +static int pk_fseek64(FILE* f, uint64_t off, int whence){ return fseeko(f, (off_t)off, whence); } +static int64_t pk_ftell64(FILE* f){ return (int64_t)ftello(f); } +#endif + namespace pk { int PromptCfg::resolve_index_or_throw(const std::string& target_lang) const { @@ -184,8 +194,8 @@ bool ModelLoader::load_component(const std::string& path, const std::string& com FILE* f = ctx_ ? fopen(path.c_str(), "rb") : nullptr; if(!f){ ggml_free(meta); return false; } // Size of the file, to refuse a truncated bundle before reading any tensor. - fseeko(f, 0, SEEK_END); - const uint64_t file_size = (uint64_t)ftello(f); + pk_fseek64(f, 0, SEEK_END); + const uint64_t file_size = (uint64_t)pk_ftell64(f); bool ok = true; for(int64_t i=0;i file_size){ PK_LOG("bundle %s is truncated (tensor %s)", path.c_str(), nm); ok = false; break; } - if(fseeko(f, (off_t)off, SEEK_SET)!=0 || fread(t->data, 1, ggml_nbytes(t), f)!=ggml_nbytes(t)) ok = false; + if(pk_fseek64(f, off, SEEK_SET)!=0 || fread(t->data, 1, ggml_nbytes(t), f)!=ggml_nbytes(t)) ok = false; } fclose(f); ggml_free(meta);