Cygwin: Allow to build without experimental AF_UNIX code by default

Introduce __WITH_AF_UNIX preprocessor flag to enable the new code

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2018-06-26 16:31:17 +02:00
parent 17918cc6a6
commit 6c55be9dbb
8 changed files with 36 additions and 1 deletions

View File

@ -520,9 +520,11 @@ fh_alloc (path_conv& pc)
case FH_LOCAL:
fh = cnew (fhandler_socket_local);
break;
#ifdef __WITH_AF_UNIX
case FH_UNIX:
fh = cnew (fhandler_socket_unix);
break;
#endif /* __WITH_AF_UNIX */
case FH_FS:
fh = cnew (fhandler_disk_file);
break;

View File

@ -951,6 +951,8 @@ class af_unix_shmem_t
struct ucred *peer_cred () { return &_peer_cred; }
};
#ifdef __WITH_AF_UNIX
class fhandler_socket_unix : public fhandler_socket
{
protected:
@ -1110,6 +1112,8 @@ class fhandler_socket_unix : public fhandler_socket
}
};
#endif /* __WITH_AF_UNIX */
class fhandler_base_overlapped: public fhandler_base
{
static HANDLE asio_done;
@ -2631,6 +2635,9 @@ typedef union
char __serial[sizeof (fhandler_serial)];
char __socket_inet[sizeof (fhandler_socket_inet)];
char __socket_local[sizeof (fhandler_socket_local)];
#ifdef __WITH_AF_UNIX
char __socket_unix[sizeof (fhandler_socket_unix)];
#endif /* __WITH_AF_UNIX */
char __termios[sizeof (fhandler_termios)];
char __pty_common[sizeof (fhandler_pty_common)];
char __pty_slave[sizeof (fhandler_pty_slave)];

View File

@ -8,6 +8,8 @@
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#ifdef __WITH_AF_UNIX
#include "winsup.h"
#include <w32api/winioctl.h>
#include <asm/byteorder.h>
@ -2376,3 +2378,5 @@ fhandler_socket_unix::link (const char *newpath)
fhandler_disk_file fh (pc);
return fh.link (newpath);
}
#endif /* __WITH_AF_UNIX */

View File

@ -136,7 +136,7 @@ struct OLD_msghdr
#define AF_UNSPEC 0 /* unspecified */
/* FIXME: This is for testing only, while developing the new
fhandler_socket_unix class. */
#ifdef __INSIDE_CYGWIN__
#if defined (__INSIDE_CYGWIN__) && defined (__WITH_AF_UNIX)
#define AF_UNIX 31
#else
#define AF_UNIX 1 /* local to host (pipes, portals) */

View File

@ -500,8 +500,12 @@ cygwin_socket (int af, int type, int protocol)
switch (af)
{
case AF_LOCAL:
#ifndef __WITH_AF_UNIX
dev = af_local_dev;
#else
case AF_UNIX:
dev = (af == AF_LOCAL) ? af_local_dev : af_unix_dev;
#endif /* __WITH_AF_UNIX */
break;
case AF_INET:
case AF_INET6:
@ -2285,8 +2289,12 @@ socketpair (int af, int type, int protocol, int sv[2])
switch (af)
{
case AF_LOCAL:
#ifndef __WITH_AF_UNIX
dev = af_local_dev;
#else
case AF_UNIX:
dev = (af == AF_LOCAL) ? af_local_dev : af_unix_dev;
#endif /* __WITH_AF_UNIX */
break;
default:
set_errno (EAFNOSUPPORT);

View File

@ -951,7 +951,11 @@ path_conv::check (const char *src, unsigned opt,
return;
}
fileattr = sym.fileattr;
#ifdef __WITH_AF_UNIX
dev.parse ((sym.pflags & PATH_REP) ? FH_UNIX : FH_LOCAL);
#else
dev.parse (FH_LOCAL);
#endif /* __WITH_AF_UNIX */
dev.setfs (1);
path_flags = sym.pflags;
goto out;
@ -2370,6 +2374,7 @@ check_reparse_point_target (HANDLE h, bool remote, PREPARSE_DATA_BUFFER rp,
if (check_reparse_point_string (psymbuf))
return PATH_SYMLINK | PATH_REP;
}
#ifdef __WITH_AF_UNIX
else if (rp->ReparseTag == IO_REPARSE_TAG_CYGUNIX)
{
PREPARSE_GUID_DATA_BUFFER rgp = (PREPARSE_GUID_DATA_BUFFER) rp;
@ -2377,6 +2382,7 @@ check_reparse_point_target (HANDLE h, bool remote, PREPARSE_DATA_BUFFER rp,
if (memcmp (CYGWIN_SOCKET_GUID, &rgp->ReparseGuid, sizeof (GUID)) == 0)
return PATH_SOCKET | PATH_REP;
}
#endif /* __WITH_AF_UNIX */
return 0;
}

View File

@ -192,8 +192,12 @@ class path_conv
int is_fs_device () const {return isdevice () && is_fs_special ();}
int is_fs_special () const {return dev.is_fs_special ();}
int is_lnk_special () const {return is_fs_device () || isfifo () || is_lnk_symlink ();}
#ifdef __WITH_AF_UNIX
int issocket () const {return dev.is_device (FH_LOCAL)
|| dev.is_device (FH_UNIX);}
#else
int issocket () const {return dev.is_device (FH_LOCAL);}
#endif /* __WITH_AF_UNIX */
int iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;}
int isopen () const {return path_flags & PATH_OPEN;}
int isctty_capable () const {return path_flags & PATH_CTTY;}

View File

@ -1602,6 +1602,8 @@ fhandler_socket_wsock::select_except (select_stuff *ss)
return s;
}
#ifdef __WITH_AF_UNIX
select_record *
fhandler_socket_unix::select_read (select_stuff *ss)
{
@ -1647,6 +1649,8 @@ fhandler_socket_unix::select_except (select_stuff *ss)
return s;
}
#endif /* __WITH_AF_UNIX */
static int
peek_windows (select_record *me, bool)
{