git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "Eric Blake" <eblake@redhat.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Mark Levedahl" <mlevedahl@gmail.com>,
	"Ramsay Jones" <ramsay@ramsay1.demon.co.uk>,
	"Alex Riesen" <raa.lkml@gmail.com>,
	"Jason Pyeron" <jpyeron@pdinc.us>,
	git@vger.kernel.org, "Torsten Bögershausen" <tboegi@web.de>,
	"Stephen & Linda Smith" <ischis2@cox.net>
Subject: Re: [PATCH/RFC] mingw: rename WIN32 cpp macro to NATIVE_WINDOWS
Date: Sat, 26 Jan 2013 18:21:16 +0100	[thread overview]
Message-ID: <5104108C.6070402@web.de> (raw)
In-Reply-To: <20130126010359.GH3341@elie.Belkin>

On 26.01.13 02:03, Jonathan Nieder wrote:
> 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 NATIVE_WINDOWS instead,
> defined as follows:
>
> 	#if defined(WIN32) && !defined(__CYGWIN__)
> 	# define NATIVE_WINDOWS
> 	#endif
>
> After this change, it should be possible to drop the
> CYGWIN_V15_WIN32API setting without any negative effect.
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> Eric Blake wrote:
>
>> Which is why other projects, like gnulib, have
>>
>> # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
>>
>> all over the place.
> So, how about this?
>
> Completely untested.
>
>  abspath.c         |  2 +-
>  compat/terminal.c |  4 ++--
>  compat/win32.h    |  2 +-
>  diff-no-index.c   |  2 +-
>  git-compat-util.h |  3 ++-
>  help.c            |  2 +-
>  run-command.c     | 10 +++++-----
>  test-chmtime.c    |  2 +-
>  thread-utils.c    |  2 +-
>  9 files changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/abspath.c b/abspath.c
> index 40cdc462..c7d5458e 100644
> --- a/abspath.c
> +++ b/abspath.c
> @@ -216,7 +216,7 @@ const char *absolute_path(const char *path)
>  const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
>  {
>  	static char path[PATH_MAX];
> -#ifndef WIN32
> +#ifndef WINDOWS_NATIVE
>  	if (!pfx_len || is_absolute_path(arg))
>  		return arg;
>  	memcpy(path, pfx, pfx_len);
> diff --git a/compat/terminal.c b/compat/terminal.c
> index 9b5e3d1b..136e4a74 100644
> --- a/compat/terminal.c
> +++ b/compat/terminal.c
> @@ -3,7 +3,7 @@
>  #include "sigchain.h"
>  #include "strbuf.h"
>  
> -#if defined(HAVE_DEV_TTY) || defined(WIN32)
> +#if defined(HAVE_DEV_TTY) || defined(WINDOWS_NATIVE)
>  
>  static void restore_term(void);
>  
> @@ -53,7 +53,7 @@ error:
>  	return -1;
>  }
>  
> -#elif defined(WIN32)
> +#elif defined(WINDOWS_NATIVE)
>  
>  #define INPUT_PATH "CONIN$"
>  #define OUTPUT_PATH "CONOUT$"
> diff --git a/compat/win32.h b/compat/win32.h
> index 8ce91048..31dd30f7 100644
> --- a/compat/win32.h
> +++ b/compat/win32.h
> @@ -2,7 +2,7 @@
>  #define WIN32_H
>  
>  /* common Win32 functions for MinGW and Cygwin */
> -#ifndef WIN32         /* Not defined by Cygwin */
> +#ifndef WINDOWS_NATIVE	/* Not defined for Cygwin */
>  #include <windows.h>
>  #endif
>  
> diff --git a/diff-no-index.c b/diff-no-index.c
> index 74da6593..a0bc9c50 100644
> --- a/diff-no-index.c
> +++ b/diff-no-index.c
> @@ -45,7 +45,7 @@ static int get_mode(const char *path, int *mode)
>  
>  	if (!path || !strcmp(path, "/dev/null"))
>  		*mode = 0;
> -#ifdef _WIN32
> +#ifdef WINDOWS_NATIVE
>  	else if (!strcasecmp(path, "nul"))
>  		*mode = 0;
>  #endif
> diff --git a/git-compat-util.h b/git-compat-util.h
> index e5a4b745..ebbdff53 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -85,10 +85,11 @@
>  #define _NETBSD_SOURCE 1
>  #define _SGI_SOURCE 1
>  
> -#ifdef WIN32 /* Both MinGW and MSVC */
> +#if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */
>  #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */
>  #include <winsock2.h>
>  #include <windows.h>
> +#define WINDOWS_NATIVE
>  #endif
>  
>  #include <unistd.h>
> diff --git a/help.c b/help.c
> index 2a42ec6d..cc1e63f7 100644
> --- a/help.c
> +++ b/help.c
> @@ -106,7 +106,7 @@ static int is_executable(const char *name)
>  	    !S_ISREG(st.st_mode))
>  		return 0;
>  
> -#if defined(WIN32) || defined(__CYGWIN__)
> +#if defined(WINDOWS_NATIVE) || defined(__CYGWIN__)
>  #if defined(__CYGWIN__)
>  if ((st.st_mode & S_IXUSR) == 0)
>  #endif
> diff --git a/run-command.c b/run-command.c
> index 04712191..04ac6181 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -72,7 +72,7 @@ static inline void close_pair(int fd[2])
>  	close(fd[1]);
>  }
>  
> -#ifndef WIN32
> +#ifndef WINDOWS_NATIVE
>  static inline void dup_devnull(int to)
>  {
>  	int fd = open("/dev/null", O_RDWR);
> @@ -159,7 +159,7 @@ static const char **prepare_shell_cmd(const char **argv)
>  		die("BUG: shell command is empty");
>  
>  	if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) {
> -#ifndef WIN32
> +#ifndef WINDOWS_NATIVE
>  		nargv[nargc++] = SHELL_PATH;
>  #else
>  		nargv[nargc++] = "sh";
> @@ -182,7 +182,7 @@ static const char **prepare_shell_cmd(const char **argv)
>  	return nargv;
>  }
>  
> -#ifndef WIN32
> +#ifndef WINDOWS_NATIVE
>  static int execv_shell_cmd(const char **argv)
>  {
>  	const char **nargv = prepare_shell_cmd(argv);
> @@ -193,7 +193,7 @@ static int execv_shell_cmd(const char **argv)
>  }
>  #endif
>  
> -#ifndef WIN32
> +#ifndef WINDOWS_NATIVE
>  static int child_err = 2;
>  static int child_notifier = -1;
>  
> @@ -330,7 +330,7 @@ fail_pipe:
>  	trace_argv_printf(cmd->argv, "trace: run_command:");
>  	fflush(NULL);
>  
> -#ifndef WIN32
> +#ifndef WINDOWS_NATIVE
>  {
>  	int notify_pipe[2];
>  	if (pipe(notify_pipe))
> diff --git a/test-chmtime.c b/test-chmtime.c
> index 92713d16..803b6055 100644
> --- a/test-chmtime.c
> +++ b/test-chmtime.c
> @@ -87,7 +87,7 @@ int main(int argc, const char *argv[])
>  			return -1;
>  		}
>  
> -#ifdef WIN32
> +#ifdef WINDOWS_NATIVE
>  		if (!(sb.st_mode & S_IWUSR) &&
>  				chmod(argv[i], sb.st_mode | S_IWUSR)) {
>  			fprintf(stderr, "Could not make user-writable %s: %s",
> diff --git a/thread-utils.c b/thread-utils.c
> index 7f4b76a9..4c4cf2fa 100644
> --- a/thread-utils.c
> +++ b/thread-utils.c
> @@ -24,7 +24,7 @@ int online_cpus(void)
>  	long ncpus;
>  #endif
>  
> -#ifdef _WIN32
> +#ifdef WINDOWS_NATIVE
>  	SYSTEM_INFO info;
>  	GetSystemInfo(&info);
>  
Thanks, that looks good.

I run the test suite under XP,  the same test cases are broken as on 1.8.1.1

/Torsten

  parent reply	other threads:[~2013-01-26 17:21 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-06  2:04 Version 1.8.1 does not compile on Cygwin 1.7.14 Stephen & Linda Smith
2013-01-06  3:37 ` Jason Pyeron
2013-01-06  4:22   ` Jason Pyeron
2013-01-06  6:20 ` Stephen & Linda Smith
2013-01-06  6:29   ` Jason Pyeron
2013-01-06  7:23     ` Torsten Bögershausen
2013-01-06  9:32       ` Jonathan Nieder
2013-01-06  9:42         ` Torsten Bögershausen
2013-01-06  9:57           ` Jonathan Nieder
2013-01-06 11:48             ` Mark Levedahl
2013-01-06 12:09               ` Jonathan Nieder
2013-01-06 14:09                 ` Stephen & Linda Smith
2013-01-06 19:54                 ` Junio C Hamano
2013-01-06 20:51                   ` Torsten Bögershausen
2013-01-06 21:34                     ` Mark Levedahl
2013-01-06 21:09                   ` Mark Levedahl
2013-01-06 21:33                     ` Jason Pyeron
2013-01-06 21:35                     ` Junio C Hamano
2013-01-06 21:46                       ` Jason Pyeron
2013-01-06 22:00                       ` Mark Levedahl
2013-01-06 22:16                   ` Mark Levedahl
2013-01-07  5:37                     ` Jason Pyeron
2013-01-07  7:29                       ` Junio C Hamano
2013-01-07  9:10                         ` Pyeron, Jason J CTR (US)
2013-01-08  3:12                         ` Mark Levedahl
2013-01-11 20:08                           ` Alex Riesen
2013-01-11 20:17                             ` Alex Riesen
2013-01-13 18:58                               ` Mark Levedahl
2013-01-15 18:47                                 ` Ramsay Jones
2013-01-20 10:10                                   ` Jonathan Nieder
2013-01-20 10:48                                     ` Torsten Bögershausen
2013-01-20 11:06                                       ` Jonathan Nieder
2013-01-21  5:20                                         ` [msysGit] " Torsten Bögershausen
2013-01-22 18:38                                           ` Ramsay Jones
2013-01-22 18:31                                     ` Ramsay Jones
2013-01-25 23:58                                       ` Mark Levedahl
2013-01-26  0:11                                         ` Junio C Hamano
2013-01-26  0:34                                           ` Eric Blake
2013-01-26  1:03                                             ` [PATCH/RFC] mingw: rename WIN32 cpp macro to NATIVE_WINDOWS Jonathan Nieder
2013-01-26 14:11                                               ` Mark Levedahl
2013-01-26 17:21                                               ` Torsten Bögershausen [this message]
2013-01-28 18:29                                               ` Ramsay Jones
2013-02-25  6:44                                                 ` Junio C Hamano
2013-02-26  4:08                                                   ` Mark Levedahl
2013-02-26 16:40                                                     ` Torsten Bögershausen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5104108C.6070402@web.de \
    --to=tboegi@web.de \
    --cc=eblake@redhat.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ischis2@cox.net \
    --cc=jpyeron@pdinc.us \
    --cc=jrnieder@gmail.com \
    --cc=mlevedahl@gmail.com \
    --cc=raa.lkml@gmail.com \
    --cc=ramsay@ramsay1.demon.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).