gallium/hud: Fixes compile error in hud/hud_context.c:
authorYonggang Luo <luoyonggang@gmail.com>
Tue, 30 Aug 2022 18:05:35 +0000 (02:05 +0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Sep 2022 15:34:11 +0000 (15:34 +0000)
../../src/gallium/auxiliary/hud/hud_context.c:1017:1: error: static declaration of 'access' follows non-static declaration
These error will shown when any header #include <io.h>

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18333>

src/gallium/auxiliary/hud/hud_context.c

index 75a0a80..b76981f 100644 (file)
 #include <signal.h>
 #include <stdio.h>
 
+#include "util/detect_os.h"
+
+#if DETECT_OS_WINDOWS
+#include <io.h>
+
+/**
+ * Access flags W_OK are defined by mingw, but not defined by MSVC, we defined it according to
+ * https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess
+ */
+#ifndef W_OK
+#define W_OK 02
+#endif
+#endif /* DETECT_OS_WINDOWS */
+
 #include "hud/hud_context.h"
 #include "hud/hud_private.h"
 
@@ -1011,14 +1025,7 @@ static void strcat_without_spaces(char *dst, const char *src)
 }
 
 
-#ifdef PIPE_OS_WINDOWS
-#define W_OK 0
-static int
-access(const char *pathname, int mode)
-{
-   /* no-op */
-   return 0;
-}
+#if DETECT_OS_WINDOWS
 
 #define PATH_SEP "\\"