mingw: rename WIN32 cpp macro to GIT_WINDOWS_NATIVE

Throughout git, it is assumed that the WIN32 preprocessor symbol is defined on native Windows setups (mingw and msvc) and not on Cygwin. On Cygwin, most of the time git can pretend this is just another Unix machine, and Windows-specific magic is generally counterproductive. Unfortunately Cygwin *does* define the WIN32 symbol in some headers. Best to rely on a new git-specific symbol GIT_WINDOWS_NATIVE instead, defined as follows: #if defined(WIN32) && !defined(__CYGWIN__) # define GIT_WINDOWS_NATIVE #endif After this change, it should be possible to drop the CYGWIN_V15_WIN32API setting without any negative effect. [rj: %s/WINDOWS_NATIVE/GIT_WINDOWS_NATIVE/g ] Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed May 2, 2013 at 20:26 UTC 380395d094b49834c3ec804407853fd6e81de702
9 files changed +15 -14
abspath.c
+1 -1
@@ -216,7 +216,7 @@ const char *absolute_path(const char *path)
216 const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
217 {
218 static char path[PATH_MAX];
219 -#ifndef WIN32
219 +#ifndef GIT_WINDOWS_NATIVE
220 if (!pfx_len || is_absolute_path(arg))
221 return arg;
222 memcpy(path, pfx, pfx_len);
compat/terminal.c
+2 -2
@@ -3,7 +3,7 @@
3 #include "sigchain.h"
4 #include "strbuf.h"
5
6 -#if defined(HAVE_DEV_TTY) || defined(WIN32)
6 +#if defined(HAVE_DEV_TTY) || defined(GIT_WINDOWS_NATIVE)
7
8 static void restore_term(void);
9
@@ -53,7 +53,7 @@ error:
53 return -1;
54 }
55
56 -#elif defined(WIN32)
56 +#elif defined(GIT_WINDOWS_NATIVE)
57
58 #define INPUT_PATH "CONIN$"
59 #define OUTPUT_PATH "CONOUT$"
compat/win32.h
+1 -1
@@ -2,7 +2,7 @@
2 #define WIN32_H
3
4 /* common Win32 functions for MinGW and Cygwin */
5 -#ifndef WIN32 /* Not defined by Cygwin */
5 +#ifndef GIT_WINDOWS_NATIVE /* Not defined for Cygwin */
6 #include <windows.h>
7 #endif
8
diff-no-index.c
+1 -1
@@ -45,7 +45,7 @@ static int get_mode(const char *path, int *mode)
45
46 if (!path || !strcmp(path, "/dev/null"))
47 *mode = 0;
48 -#ifdef _WIN32
48 +#ifdef GIT_WINDOWS_NATIVE
49 else if (!strcasecmp(path, "nul"))
50 *mode = 0;
51 #endif
git-compat-util.h
+2 -1
@@ -85,13 +85,14 @@
85 #define _NETBSD_SOURCE 1
86 #define _SGI_SOURCE 1
87
88 -#ifdef WIN32 /* Both MinGW and MSVC */
88 +#if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */
89 # if defined (_MSC_VER)
90 # define _WIN32_WINNT 0x0502
91 # endif
92 #define WIN32_LEAN_AND_MEAN /* stops windows.h including winsock.h */
93 #include <winsock2.h>
94 #include <windows.h>
95 +#define GIT_WINDOWS_NATIVE
96 #endif
97
98 #include <unistd.h>
help.c
+1 -1
@@ -106,7 +106,7 @@ static int is_executable(const char *name)
106 !S_ISREG(st.st_mode))
107 return 0;
108
109 -#if defined(WIN32) || defined(__CYGWIN__)
109 +#if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__)
110 #if defined(__CYGWIN__)
111 if ((st.st_mode & S_IXUSR) == 0)
112 #endif
run-command.c
+5 -5
@@ -72,7 +72,7 @@ static inline void close_pair(int fd[2])
72 close(fd[1]);
73 }
74
75 -#ifndef WIN32
75 +#ifndef GIT_WINDOWS_NATIVE
76 static inline void dup_devnull(int to)
77 {
78 int fd = open("/dev/null", O_RDWR);
@@ -159,7 +159,7 @@ static const char **prepare_shell_cmd(const char **argv)
159 die("BUG: shell command is empty");
160
161 if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) {
162 -#ifndef WIN32
162 +#ifndef GIT_WINDOWS_NATIVE
163 nargv[nargc++] = SHELL_PATH;
164 #else
165 nargv[nargc++] = "sh";
@@ -182,7 +182,7 @@ static const char **prepare_shell_cmd(const char **argv)
182 return nargv;
183 }
184
185 -#ifndef WIN32
185 +#ifndef GIT_WINDOWS_NATIVE
186 static int execv_shell_cmd(const char **argv)
187 {
188 const char **nargv = prepare_shell_cmd(argv);
@@ -193,7 +193,7 @@ static int execv_shell_cmd(const char **argv)
193 }
194 #endif
195
196 -#ifndef WIN32
196 +#ifndef GIT_WINDOWS_NATIVE
197 static int child_err = 2;
198 static int child_notifier = -1;
199
@@ -334,7 +334,7 @@ fail_pipe:
334 trace_argv_printf(cmd->argv, "trace: run_command:");
335 fflush(NULL);
336
337 -#ifndef WIN32
337 +#ifndef GIT_WINDOWS_NATIVE
338 {
339 int notify_pipe[2];
340 if (pipe(notify_pipe))
test-chmtime.c
+1 -1
@@ -87,7 +87,7 @@ int main(int argc, const char *argv[])
87 return -1;
88 }
89
90 -#ifdef WIN32
90 +#ifdef GIT_WINDOWS_NATIVE
91 if (!(sb.st_mode & S_IWUSR) &&
92 chmod(argv[i], sb.st_mode | S_IWUSR)) {
93 fprintf(stderr, "Could not make user-writable %s: %s",
thread-utils.c
+1 -1
@@ -24,7 +24,7 @@ int online_cpus(void)
24 long ncpus;
25 #endif
26
27 -#ifdef _WIN32
27 +#ifdef GIT_WINDOWS_NATIVE
28 SYSTEM_INFO info;
29 GetSystemInfo(&info);
30