From: Eli Zaretskii Date: Mon, 2 Nov 2015 17:04:06 +0000 (+0200) Subject: Fix the MS-Windows build X-Git-Tag: emacs-26.0.90~1144^2~17^2~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=470e3028d8a741d97349faa8fdeb148d913a49d0;p=emacs.git Fix the MS-Windows build * src/thread.h [WINDOWSNT]: Include sys/socket.h. * src/sysselect.h: Don't define fd_set and FD_* macros for MS-Windows here. * src/w32.h: Define them here. * src/process.h (sys_select): Declare prototype. * src/sysdep.c: * src/process.c: * src/filelock.c: * src/emacs.c: * src/callproc.c: Move inclusion of sys/select.h after lisp.h. * nt/inc/socket.h: Include w32.h instead of sysselect.h --- diff --git a/nt/inc/sys/socket.h b/nt/inc/sys/socket.h index 6ad121699c5..067effe929e 100644 --- a/nt/inc/sys/socket.h +++ b/nt/inc/sys/socket.h @@ -74,7 +74,7 @@ typedef unsigned short uint16_t; /* allow us to provide our own version of fd_set */ #define fd_set ws_fd_set -#include "sysselect.h" +#include "w32.h" #endif /* EMACS_CONFIG_H */ #if defined (HAVE_TIMEVAL) && defined (_MSC_VER) diff --git a/src/callproc.c b/src/callproc.c index a6c7bdafdba..bb21c35dccc 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -27,14 +27,12 @@ along with GNU Emacs. If not, see . */ #include #include -#ifdef WINDOWSNT -#define NOMINMAX -#include /* for fcntl */ -#endif #include "lisp.h" #ifdef WINDOWSNT +#define NOMINMAX +#include /* for fcntl */ #include #include "w32.h" #define _P_NOWAIT 1 /* from process.h */ diff --git a/src/emacs.c b/src/emacs.c index 9dc4e423547..f91e5499916 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -31,20 +31,18 @@ along with GNU Emacs. If not, see . */ #include +#define MAIN_PROGRAM +#include "lisp.h" + #ifdef WINDOWSNT #include #include #include +#include "w32.h" #include "w32heap.h" #endif -#define MAIN_PROGRAM -#include "lisp.h" - #if defined WINDOWSNT || defined HAVE_NTGUI -#ifdef WINDOWSNT -#include "w32.h" -#endif #include "w32select.h" #include "w32font.h" #include "w32common.h" diff --git a/src/filelock.c b/src/filelock.c index b37319c9ae8..7f9b6e7f8e8 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -40,11 +40,6 @@ along with GNU Emacs. If not, see . */ #include #endif /* __FreeBSD__ */ -#ifdef WINDOWSNT -#include -#include /* for fcntl */ -#endif - #include #include @@ -53,6 +48,8 @@ along with GNU Emacs. If not, see . */ #include "buffer.h" #include "coding.h" #ifdef WINDOWSNT +#include +#include /* for fcntl */ #include "w32.h" /* for dostounix_filename */ #endif diff --git a/src/process.c b/src/process.c index 791f8f5c308..5e9b687ba60 100644 --- a/src/process.c +++ b/src/process.c @@ -29,6 +29,8 @@ along with GNU Emacs. If not, see . */ #include #include +#include "lisp.h" + /* Only MS-DOS does not define `subprocesses'. */ #ifdef subprocesses @@ -92,8 +94,6 @@ along with GNU Emacs. If not, see . */ #endif /* subprocesses */ -#include "lisp.h" - #include "systime.h" #include "systty.h" @@ -126,7 +126,8 @@ along with GNU Emacs. If not, see . */ #endif #ifdef WINDOWSNT -#include "w32.h" +extern int sys_select (int, fd_set *, fd_set *, fd_set *, + struct timespec *, sigset_t *); #endif /* Work around GCC 4.7.0 bug with strict overflow checking; see diff --git a/src/sysdep.c b/src/sysdep.c index ba6be57278e..d75dcd3f9e3 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -39,17 +39,6 @@ along with GNU Emacs. If not, see . */ #include #include -#ifdef HAVE_SOCKETS -#include -#include -#endif /* HAVE_SOCKETS */ - -#ifdef TRY_AGAIN -#ifndef HAVE_H_ERRNO -extern int h_errno; -#endif -#endif /* TRY_AGAIN */ - #include "lisp.h" #include "sysselect.h" #include "blockinput.h" @@ -68,6 +57,17 @@ extern int h_errno; # include #endif +#ifdef HAVE_SOCKETS +#include +#include +#endif /* HAVE_SOCKETS */ + +#ifdef TRY_AGAIN +#ifndef HAVE_H_ERRNO +extern int h_errno; +#endif +#endif /* TRY_AGAIN */ + #ifdef WINDOWSNT #define read sys_read #define write sys_write diff --git a/src/sysselect.h b/src/sysselect.h index e0f7b4e13ee..d6c5d1c7148 100644 --- a/src/sysselect.h +++ b/src/sysselect.h @@ -25,40 +25,10 @@ along with GNU Emacs. If not, see . */ #include "lisp.h" -#ifdef WINDOWSNT - -/* File descriptor set emulation. */ - -/* MSVC runtime library has limit of 64 descriptors by default */ -#define FD_SETSIZE 64 -typedef struct { - unsigned int bits[FD_SETSIZE / 32]; -} fd_set; - -/* standard access macros */ -#define FD_SET(n, p) \ - do { \ - if ((n) < FD_SETSIZE) { \ - (p)->bits[(n)/32] |= (1 << (n)%32); \ - } \ - } while (0) -#define FD_CLR(n, p) \ - do { \ - if ((n) < FD_SETSIZE) { \ - (p)->bits[(n)/32] &= ~(1 << (n)%32); \ - } \ - } while (0) -#define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0) -#define FD_ZERO(p) memset((p), 0, sizeof(fd_set)) - -#define SELECT_TYPE fd_set - -#include "systime.h" -extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, - struct timespec *, sigset_t *); - -#else /* not WINDOWSNT */ - +/* The w32 build defines select stuff in w32.h, which is included + where w32 needs it, but not where sysselect.h is included. The w32 + definitions in w32.h are incompatible with the below. */ +#ifndef WINDOWSNT #ifdef FD_SET #ifndef FD_SETSIZE #define FD_SETSIZE 64 diff --git a/src/thread.h b/src/thread.h index d155837ccad..91bab8284e6 100644 --- a/src/thread.h +++ b/src/thread.h @@ -21,6 +21,10 @@ along with GNU Emacs. If not, see . */ #include "regex.h" +#ifdef WINDOWSNT +#include +#endif + #include "sysselect.h" /* FIXME */ #include "systime.h" /* FIXME */ diff --git a/src/w32.c b/src/w32.c index 0966b8df1ce..93eb6284cf2 100644 --- a/src/w32.c +++ b/src/w32.c @@ -42,8 +42,6 @@ along with GNU Emacs. If not, see . */ #include #include /* for _mbspbrk, _mbslwr, _mbsrchr, ... */ -#include - #undef access #undef chdir #undef chmod @@ -205,6 +203,7 @@ typedef struct _REPARSE_DATA_BUFFER { #endif /* TCP connection support. */ +#include #undef socket #undef bind #undef connect diff --git a/src/w32.h b/src/w32.h index 7de05478e93..29a3ae35cbf 100644 --- a/src/w32.h +++ b/src/w32.h @@ -25,6 +25,32 @@ along with GNU Emacs. If not, see . */ #include +/* File descriptor set emulation. */ + +/* MSVC runtime library has limit of 64 descriptors by default */ +#define FD_SETSIZE 64 +typedef struct { + unsigned int bits[FD_SETSIZE / 32]; +} fd_set; + +/* standard access macros */ +#define FD_SET(n, p) \ + do { \ + if ((n) < FD_SETSIZE) { \ + (p)->bits[(n)/32] |= (1 << (n)%32); \ + } \ + } while (0) +#define FD_CLR(n, p) \ + do { \ + if ((n) < FD_SETSIZE) { \ + (p)->bits[(n)/32] &= ~(1 << (n)%32); \ + } \ + } while (0) +#define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0) +#define FD_ZERO(p) memset((p), 0, sizeof(fd_set)) + +#define SELECT_TYPE fd_set + /* ------------------------------------------------------------------------- */ /* child_process.status values */