]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
mmap : fix fileno macro clash (#11076)
authorGeorgi Gerganov <redacted>
Mon, 6 Jan 2025 08:52:38 +0000 (10:52 +0200)
committerGitHub <redacted>
Mon, 6 Jan 2025 08:52:38 +0000 (10:52 +0200)
* mmap : fix fileno macro clash

ggml-ci

* cont

ggml-ci

src/llama-mmap.cpp
src/llama-mmap.h

index a9932633512a6ef54969975823cc36e5f60155dc..a8cb9439b6b737f49c362575ffb37bea856c27bc 100644 (file)
@@ -241,12 +241,16 @@ llama_file::~llama_file() = default;
 size_t llama_file::tell() const { return pimpl->tell(); }
 size_t llama_file::size() const { return pimpl->size; }
 
-int llama_file::fileno() const {
+int llama_file::file_id() const {
 #ifdef _WIN32
     return _fileno(pimpl->fp);
+#else
+#if defined(fileno)
+    return fileno(pimpl->fp);
 #else
     return ::fileno(pimpl->fp);
 #endif
+#endif
 }
 
 void llama_file::seek(size_t offset, int whence) const { pimpl->seek(offset, whence); }
@@ -265,7 +269,7 @@ struct llama_mmap::impl {
 
     impl(struct llama_file * file, size_t prefetch, bool numa) {
         size = file->size();
-        int fd = file->fileno();
+        int fd = file->file_id();
         int flags = MAP_SHARED;
         if (numa) { prefetch = 0; }
 #ifdef __linux__
@@ -357,7 +361,7 @@ struct llama_mmap::impl {
 
         size = file->size();
 
-        HANDLE hFile = (HANDLE) _get_osfhandle(file->fileno());
+        HANDLE hFile = (HANDLE) _get_osfhandle(file->file_id());
 
         HANDLE hMapping = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
 
index 6bcddee8c0adf6364222bc3f7d4ec7d16f232e30..1da9ecb6b9812e4cbd69c2baac3fecbf4d136d20 100644 (file)
@@ -18,7 +18,7 @@ struct llama_file {
     size_t tell() const;
     size_t size() const;
 
-    int fileno() const;
+    int file_id() const; // fileno overload
 
     void seek(size_t offset, int whence) const;