Commit edd6e2bbd for llama.cpp

commit edd6e2bbdad5930899a93db8fa73c3b61c7b9bcc
Author: Adrien Gallouët <angt@huggingface.co>
Date:   Sat Oct 3 15:48:24 2026 +0200

    common : add common_is_tty() helper and fix deprecated warnings on Windows (#29860)

    Signed-off-by: Adrien Gallouët <angt@huggingface.co>

diff --git a/common/common.cpp b/common/common.cpp
index 0269bc895..d3617fbf1 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -1078,6 +1078,14 @@ std::vector<common_file_info> fs_list(const std::string & path, bool include_dir
 // TTY utils
 //

+bool common_is_tty(FILE * file) {
+#if defined(_WIN32)
+    return _isatty(_fileno(file));
+#else
+    return isatty(fileno(file));
+#endif
+}
+
 bool tty_can_use_colors() {
     // Check NO_COLOR environment variable (https://no-color.org/)
     if (const char * no_color = std::getenv("NO_COLOR")) {
@@ -1095,10 +1103,7 @@ bool tty_can_use_colors() {

     // Check if stdout and stderr are connected to a terminal
     // We check both because log messages can go to either
-    bool stdout_is_tty = isatty(fileno(stdout));
-    bool stderr_is_tty = isatty(fileno(stderr));
-
-    return stdout_is_tty || stderr_is_tty;
+    return common_is_tty(stdout) || common_is_tty(stderr);
 }

 //
diff --git a/common/common.h b/common/common.h
index 27be5c058..4308b0703 100644
--- a/common/common.h
+++ b/common/common.h
@@ -19,6 +19,7 @@
 #include <algorithm>
 #include <filesystem>
 #include <fstream>
+#include <cstdio>

 #if defined(_WIN32) && !defined(_WIN32_WINNT)
 #define _WIN32_WINNT 0x0A00
@@ -946,6 +947,9 @@ void fs_write_atomic(const std::filesystem::path & path, const std::string & dat
 // Auto-detect if colors can be enabled based on terminal and environment
 bool tty_can_use_colors();

+// Check if the given file is attached to a terminal
+bool common_is_tty(FILE * file);
+
 //
 // Model utils
 //
diff --git a/common/download.cpp b/common/download.cpp
index 6b7123e47..ae0f7ffed 100644
--- a/common/download.cpp
+++ b/common/download.cpp
@@ -35,13 +35,6 @@
 #endif
 #endif

-// isatty
-#if defined(_WIN32)
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
 //
 // downloader
 //
@@ -97,11 +90,7 @@ class ProgressBar : public common_download_callback {
     }

     static bool is_output_a_tty() {
-#if defined(_WIN32)
-        return _isatty(_fileno(stdout));
-#else
-        return isatty(1);
-#endif
+        return common_is_tty(stdout);
     }

 public:
diff --git a/common/log.cpp b/common/log.cpp
index 0a9a4eb9e..b60e8d268 100644
--- a/common/log.cpp
+++ b/common/log.cpp
@@ -14,19 +14,6 @@
 #include <vector>
 #include <algorithm>

-#if defined(_WIN32)
-#    define WIN32_LEAN_AND_MEAN
-#    ifndef NOMINMAX
-#       define NOMINMAX
-#    endif
-#    include <io.h>
-#    include <windows.h>
-#    define isatty _isatty
-#    define fileno _fileno
-#else
-#    include <unistd.h>
-#endif // defined(_WIN32)
-
 int common_log_verbosity_thold = LOG_DEFAULT_LLAMA;

 int common_log_get_verbosity_thold(void) {