From b70abd5b614341947ce7d81c1de97877dec5f35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 30 Nov 2012 16:56:54 +0200 Subject: [PATCH 1/3] avutil: Include io.h with a separate condition from windows console functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not all versions of windows have the console color functions, while io.h might be needed for isatty (which can be found in unistd.h or io.h). Signed-off-by: Martin Storsjö --- libavutil/log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavutil/log.c b/libavutil/log.c index d2cf88fd4b..d335944330 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -29,6 +29,9 @@ #if HAVE_UNISTD_H #include #endif +#if HAVE_IO_H +#include +#endif #include #include "avstring.h" #include "avutil.h" @@ -40,7 +43,6 @@ static int flags; #if defined(_WIN32) && !defined(__MINGW32CE__) #include -#include static const uint8_t color[] = { 12, 12, 12, 14, 7, 10, 11 }; static int16_t background, attr_orig; static HANDLE con; From 7e6a11bcf71777ea54a32916411bcebed0e90842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 30 Nov 2012 16:56:57 +0200 Subject: [PATCH 2/3] avutil: Use a configure check to enable windows console functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not all versions or API subsets of windows have these functions. Signed-off-by: Martin Storsjö --- configure | 2 ++ libavutil/log.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 5e1be338b3..38f49e082c 100755 --- a/configure +++ b/configure @@ -1242,6 +1242,7 @@ HAVE_LIST=" sched_getaffinity sdl sdl_video_size + SetConsoleTextAttribute setmode setrlimit Sleep @@ -3305,6 +3306,7 @@ check_func_headers windows.h GetProcessAffinityMask check_func_headers windows.h GetProcessTimes check_func_headers windows.h GetSystemTimeAsFileTime check_func_headers windows.h MapViewOfFile +check_func_headers windows.h SetConsoleTextAttribute check_func_headers windows.h Sleep check_func_headers windows.h VirtualAlloc diff --git a/libavutil/log.c b/libavutil/log.c index d335944330..45c649aae6 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -41,7 +41,7 @@ static int av_log_level = AV_LOG_INFO; static int flags; -#if defined(_WIN32) && !defined(__MINGW32CE__) +#if HAVE_SETCONSOLETEXTATTRIBUTE #include static const uint8_t color[] = { 12, 12, 12, 14, 7, 10, 11 }; static int16_t background, attr_orig; @@ -59,7 +59,7 @@ static int use_color = -1; static void colored_fputs(int level, const char *str) { if (use_color < 0) { -#if defined(_WIN32) && !defined(__MINGW32CE__) +#if HAVE_SETCONSOLETEXTATTRIBUTE CONSOLE_SCREEN_BUFFER_INFO con_info; con = GetStdHandle(STD_ERROR_HANDLE); use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") && From 3bbe63d1a45853c6b760f1ea9551668568bff7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 30 Nov 2012 16:57:02 +0200 Subject: [PATCH 3/3] configure: Use headers in the check for _beginthreadex for w32threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When targeting the metro API subset, this function still exists in the link libraries, but is excluded from the headers. This makes sure w32threads is automatically disabled when targeting this API subset (since not all the necessary functions for it are available). Signed-off-by: Martin Storsjö --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 38f49e082c..02dd1c6a03 100755 --- a/configure +++ b/configure @@ -3332,7 +3332,7 @@ disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib if ! disabled w32threads && ! enabled pthreads; then - check_func _beginthreadex && enable w32threads + check_func_headers "windows.h process.h" _beginthreadex && enable w32threads fi # check for some common methods of building with pthread support