[patch] Update bsd-cygwin_util files (was Re: Announce: OpenSSH 6.2 released)
Roumen Petrov
openssh at roumenpetrov.info
Mon Apr 1 02:03:00 EST 2013
Hi ,
Corinna Vinschen wrote:
> On Mar 26 23:02, Corinna Vinschen wrote:
>> On Mar 26 23:36, Roumen Petrov wrote:
>>> Corinna Vinschen wrote:
>>>> The reason is a clash of the UINT64 type. It gets defined in umac.c as
>>>> well as in the Windows headers. The Windows headers define it like
>>>> this:
>>>>
>>>> typedef unsigned __int64 UINT64,*PUINT64;
>>> Question is if build is fine for UINTnn where nn < 64 , why fail for 64 ?
>> u_int64_t is unsigned long, while unsigned __int64 is unsigned long long.
>>
>>> May be correct patch is to define u_int64_t to be same as as
>>> unsigned __int64 ?
>> The right thing is to fix the __int64 definition in _mingw.h.in for
>> LP64 targets. I'll send a patch to the mingw64 ML tomorrow.
> On second thought (and after some sleep), this is probably not the right
> thing to do. Changing the type for UINT64 in the Windows headers just
> because of a single instance of clashing definitions in a POSIX file is
> pretty intrusive. The potential side effects of this change are simply
> not worth it.
>
> As a result I have now reworked the bsd-cygwin_util.* files in
> openbsd-compat. The most important change is not to include the
> windows.h header at all. The only two Windows definitions used are
> HANDLE and INVALID_HANDLE_VALUE. I defined those in bsd-cygwin_util.h
> so there's no reason anymore to include windows headers. This fixes
> the UINT64 issue as well, obviously.
>
> Additionally I made the handling of open vs. binary_open a bit more
> clear (I think) by introducing a NO_BINARY_OPEN definition.
>
> Is that ok to apply?
It seems to me do not use windows.h on cygwin is better solution (+1).
> Thanks,
> Corinna
Roumen
> Index: openbsd-compat/bsd-cygwin_util.c
> ===================================================================
> RCS file: /cvs/openssh/openbsd-compat/bsd-cygwin_util.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 bsd-cygwin_util.c
> --- openbsd-compat/bsd-cygwin_util.c 13 Feb 2012 19:38:38 -0000 1.24
> +++ openbsd-compat/bsd-cygwin_util.c 27 Mar 2013 12:59:07 -0000
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2000, 2001, 2011 Corinna Vinschen <vinschen at redhat.com>
> + * Copyright (c) 2000, 2001, 2011, 2013 Corinna Vinschen <vinschen at redhat.com>
> *
> * Redistribution and use in source and binary forms, with or without
> * modification, are permitted provided that the following conditions
> @@ -27,20 +27,15 @@
> * binary mode on Windows systems.
> */
>
> +#define NO_BINARY_OPEN /* Avoid redefining open to binary_open for this file */
> #include "includes.h"
>
> #ifdef HAVE_CYGWIN
>
> -#if defined(open) && open == binary_open
> -# undef open
> -#endif
> -
> #include <sys/types.h>
> -
> #include <fcntl.h>
> -#include <stdlib.h>
> +#include <string.h>
> #include <unistd.h>
> -#include <windows.h>
>
> #include "xmalloc.h"
>
> Index: openbsd-compat/bsd-cygwin_util.h
> ===================================================================
> RCS file: /cvs/openssh/openbsd-compat/bsd-cygwin_util.h,v
> retrieving revision 1.15
> diff -u -p -r1.15 bsd-cygwin_util.h
> --- openbsd-compat/bsd-cygwin_util.h 28 Aug 2012 09:57:19 -0000 1.15
> +++ openbsd-compat/bsd-cygwin_util.h 27 Mar 2013 12:59:07 -0000
> @@ -1,7 +1,7 @@
> /* $Id: bsd-cygwin_util.h,v 1.15 2012/08/28 09:57:19 dtucker Exp $ */
>
> /*
> - * Copyright (c) 2000, 2001, 2011 Corinna Vinschen <vinschen at redhat.com>
> + * Copyright (c) 2000, 2001, 2011, 2013 Corinna Vinschen <vinschen at redhat.com>
> *
> * Redistribution and use in source and binary forms, with or without
> * modification, are permitted provided that the following conditions
> @@ -36,24 +36,21 @@
>
> #undef ERROR
>
> -#define WIN32_LEAN_AND_MEAN
> +/* Avoid including windows headers. */
> +typedef void *HANDLE;
> +#define INVALID_HANDLE_VALUE ((HANDLE) -1)
>
> -#include <windows.h>
> #include <sys/cygwin.h>
> #include <io.h>
>
> -/* Make sure _WIN32 isn't defined later in the code, otherwise headers from
> - other packages might get the wrong idea about the target system. */
> -#ifdef _WIN32
> -#undef _WIN32
> -#endif
> -
> int binary_open(const char *, int , ...);
> int check_ntsec(const char *);
> char **fetch_windows_environment(void);
> void free_windows_environment(char **);
>
> +#ifndef NO_BINARY_OPEN
> #define open binary_open
> +#endif
>
> #endif /* HAVE_CYGWIN */
>
>
More information about the openssh-unix-dev
mailing list