Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Christopher Faylor <cgf-use-the-mailinglist-please@sourceware.org>
To: gdb-patches@sourceware.org,
		Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
Subject: Re: [RFC] Reenable compilation with cygwin 1.5 versions
Date: Wed, 03 Mar 2010 20:30:00 -0000	[thread overview]
Message-ID: <20100303203012.GA31597@ednor.casa.cgf.cx> (raw)
In-Reply-To: <002701cabaf2$39739ad0$ac5ad070$@muller@ics-cnrs.unistra.fr>

On Wed, Mar 03, 2010 at 05:54:43PM +0100, Pierre Muller wrote:
>Index: remote-fileio.c
>===================================================================
>RCS file: /cvs/src/src/gdb/remote-fileio.c,v
>retrieving revision 1.34
>diff -u -p -r1.34 remote-fileio.c
>--- remote-fileio.c	1 Mar 2010 09:09:24 -0000	1.34
>+++ remote-fileio.c	3 Mar 2010 16:11:15 -0000
>@@ -35,6 +35,11 @@
> #include <sys/time.h>
> #ifdef __CYGWIN__
> #include <sys/cygwin.h>		/* For
>cygwin_conv_to_full_posix_path.  */
>+#include <cygwin/version.h>
>+#if
>CYGWIN_VERSION_DLL_MAKE_COMBINED(CYGWIN_VERSION_API_MAJOR,CYGWIN_VERSION_API
>_MINOR) < 181
>+#define __USE_OLD_CYGWIN_API_
>+#endif
>+
> #endif
> #include <signal.h>
> 
>@@ -1021,14 +1026,24 @@ remote_fileio_func_rename (char *buf)
> 		errno = EISDIR;
> 	      else
> 		{
>+#ifndef __USE_OLD_CYGWIN_API_
> 		  char oldfullpath[PATH_MAX];
> 		  char newfullpath[PATH_MAX];
>+#else /* __USE_OLD_CYGWIN_API_ */
>+		  char oldfullpath[PATH_MAX + 1];
>+		  char newfullpath[PATH_MAX + 1];
>+#endif /* __USE_OLD_CYGWIN_API_ */
> 		  int len;
> 
>+#ifndef __USE_OLD_CYGWIN_API_
> 		  cygwin_conv_path (CCP_WIN_A_TO_POSIX, oldpath,
>oldfullpath,
> 				    PATH_MAX);
> 		  cygwin_conv_path (CCP_WIN_A_TO_POSIX, newpath,
>newfullpath,
> 				    PATH_MAX);
>+#else /* __USE_OLD_CYGWIN_API_ */
>+		  cygwin_conv_to_full_posix_path (oldpath, oldfullpath);
>+		  cygwin_conv_to_full_posix_path (newpath, newfullpath);
>+#endif /* __USE_OLD_CYGWIN_API_ */
> 		  len = strlen (oldfullpath);
> 		  if (newfullpath[len] == '/'
> 		      && !strncmp (oldfullpath, newfullpath, len))

I think it would be cleaner to define a cygwin_conv_path at the top of the file
based on cygwin_conv_to_full_posix_path.  Then no __USE_OLD_CYGWIN_API_ would
be necessary (given the understanding that the PATH_MAX changes aren't needed).

>Index: windows-nat.c
>===================================================================
>RCS file: /cvs/src/src/gdb/windows-nat.c,v
>retrieving revision 1.204
>diff -u -p -r1.204 windows-nat.c
>--- windows-nat.c	1 Mar 2010 09:09:24 -0000	1.204
>+++ windows-nat.c	3 Mar 2010 16:11:15 -0000
>@@ -41,6 +41,12 @@
> #include <psapi.h>
> #ifdef __CYGWIN__
> #include <sys/cygwin.h>
>+#include <cygwin/version.h>
>+#if
>CYGWIN_VERSION_DLL_MAKE_COMBINED(CYGWIN_VERSION_API_MAJOR,CYGWIN_VERSION_API
>_MINOR) < 181
>+#define __USE_OLD_CYGWIN_API_
>+#else
>+#define __USE_NEW_CYGWIN_API_
>+#endif
> #endif
> #include <signal.h>
> 
>@@ -71,11 +77,11 @@
> #define DebugBreakProcess		dyn_DebugBreakProcess
> #define DebugSetProcessKillOnExit	dyn_DebugSetProcessKillOnExit
> #define EnumProcessModules		dyn_EnumProcessModules
>-#ifndef __CYGWIN__
>+#ifndef __USE_NEW_CYGWIN_API_
> #define GetModuleFileNameExA		dyn_GetModuleFileNameExA
>-#else
>+#else /* __USE_NEW_CYGWIN_API_ */
> #define GetModuleFileNameExW		dyn_GetModuleFileNameExW
>-#endif
>+#endif /* __USE_NEW_CYGWIN_API_ */
> #define GetModuleInformation		dyn_GetModuleInformation
> #define LookupPrivilegeValueA		dyn_LookupPrivilegeValueA
> #define OpenProcessToken		dyn_OpenProcessToken
>@@ -87,13 +93,13 @@ static BOOL WINAPI (*DebugBreakProcess) 
> static BOOL WINAPI (*DebugSetProcessKillOnExit) (BOOL);
> static BOOL WINAPI (*EnumProcessModules) (HANDLE, HMODULE *, DWORD,
> 					  LPDWORD);
>-#ifndef __CYGWIN__
>+#ifndef __USE_NEW_CYGWIN_API_
> static DWORD WINAPI (*GetModuleFileNameExA) (HANDLE, HMODULE, LPSTR,
> 					    DWORD);
>-#else
>+#else /* __USE_NEW_CYGWIN_API_ */
> static DWORD WINAPI (*GetModuleFileNameExW) (HANDLE, HMODULE, LPWSTR,
> 					    DWORD);
>-#endif
>+#endif /* __USE_NEW_CYGWIN_API_ */
> static BOOL WINAPI (*GetModuleInformation) (HANDLE, HMODULE, LPMODULEINFO,
> 					    DWORD);
> static BOOL WINAPI (*LookupPrivilegeValueA)(LPCSTR, LPCSTR, PLUID);

Here also, it seems like just defining and using a GetModulesFileNameEx,
etc.  and deciding whether to do "A" or "W" in a macro would be much
cleaner.  You probably still need to make decisions about using wide
characters but the test should be on something like "USE_WIDE_CHARS"
rather than "__USE_NEW_CYGWIN_API" since, the use of wide characters
doesn't really have anything to do with the new Cygwin API.

cgf


  parent reply	other threads:[~2010-03-03 20:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-03 16:54 Pierre Muller
2010-03-03 17:14 ` Corinna Vinschen
2010-03-03 20:30 ` Christopher Faylor [this message]
2010-03-04 15:32   ` [RFC-v2] " Pierre Muller
2010-03-04 16:38     ` Christopher Faylor
2010-03-06 19:27       ` Christopher Faylor
2010-03-08 16:02         ` [RFA] " Pierre Muller
2010-03-08 22:11           ` Christopher Faylor
2010-03-08 23:15             ` Pierre Muller
2010-03-09 19:12               ` Christopher Faylor

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

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

  git send-email \
    --in-reply-to=20100303203012.GA31597@ednor.casa.cgf.cx \
    --to=cgf-use-the-mailinglist-please@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pierre.muller@ics-cnrs.unistra.fr \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox