From: Eli Zaretskii Date: Mon, 26 Aug 2013 18:42:11 +0000 (+0300) Subject: Fix MS-Windows build. X-Git-Tag: emacs-26.0.90~1144^2~17^2~17 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6e9fb70cdf763da6d264932f14f5a67d354ec38d;p=emacs.git Fix MS-Windows build. src/callproc.c: src/emacs.c: src/filelock.c: src/process.c: src/sysdep.c: src/w32.c: Reshuffle Windows-specific headers to avoid errors with redefinition of fd_set etc. src/process.c: Don't use num_pending_connects when NON_BLOCKING_CONNECT is not defined. src/sysselect.h: Move definitions of FD_* macros and of SELECT_TYPE here from w32.h. src/w32proc.c (sys_select): Adjust the argument types to what thread.h expects. nt/inc/sys/socket.h: Include stdint.h. Include sysselect.h instead of w32.h. --- diff --git a/nt/ChangeLog b/nt/ChangeLog index ebc823071a3..cf0853c7045 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog @@ -1,3 +1,8 @@ +2013-08-26 Eli Zaretskii + + * inc/sys/socket.h: Include stdint.h. Include sysselect.h instead + of w32.h. + 2013-08-25 Vincent Belaïche * configure.bat: Rather than disabling, make configure.bat produce diff --git a/nt/inc/sys/socket.h b/nt/inc/sys/socket.h index 93bf9f91665..02a0584820f 100644 --- a/nt/inc/sys/socket.h +++ b/nt/inc/sys/socket.h @@ -53,6 +53,7 @@ along with GNU Emacs. If not, see . */ #include /* process.c uses uint16_t (from C99) for IPv6, but apparently it is not defined in some versions of mingw and msvc. */ +#include #ifndef UINT16_C typedef unsigned short uint16_t; #endif @@ -73,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 "w32.h" +#include "sysselect.h" #endif /* EMACS_CONFIG_H */ #if defined (HAVE_TIMEVAL) && defined (_MSC_VER) diff --git a/src/ChangeLog b/src/ChangeLog index 70d722a02a4..a0682bdfd48 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,22 @@ +2013-08-26 Eli Zaretskii + + * callproc.c: + * emacs.c: + * filelock.c: + * process.c: + * sysdep.c: + * w32.c: Reshuffle Windows-specific headers to avoid errors with + redefinition of fd_set etc. + + * process.c: Don't use num_pending_connects when + NON_BLOCKING_CONNECT is not defined. + + * sysselect.h: Move definitions of FD_* macros and of SELECT_TYPE + here from w32.h. + + * w32proc.c (sys_select): Adjust the argument types to what + thread.h expects. + 2013-08-24 Eli Zaretskii * xdisp.c (get_next_display_element): Don't apply to characters diff --git a/src/callproc.c b/src/callproc.c index d4b4a26ec3a..938c2fbd04b 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -26,12 +26,14 @@ 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 e6d612b8417..22bca915c7e 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -29,16 +29,18 @@ along with GNU Emacs. If not, see . */ #include -#include "lisp.h" - #ifdef WINDOWSNT #include #include -#include "w32.h" #include "w32heap.h" #endif +#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 df72eff5950..5ee5d32684e 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -36,6 +36,11 @@ along with GNU Emacs. If not, see . */ #include #endif /* __FreeBSD__ */ +#ifdef WINDOWSNT +#include +#include /* for fcntl */ +#endif + #include #include @@ -46,8 +51,6 @@ along with GNU Emacs. If not, see . */ #include "coding.h" #include "systime.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 3edc3b4f061..94ca3d4b1a0 100644 --- a/src/process.c +++ b/src/process.c @@ -31,8 +31,6 @@ along with GNU Emacs. If not, see . */ #include #include -#include "lisp.h" - /* Only MS-DOS does not define `subprocesses'. */ #ifdef subprocesses @@ -96,6 +94,8 @@ along with GNU Emacs. If not, see . */ #endif /* subprocesses */ +#include "lisp.h" + #include "systime.h" #include "systty.h" @@ -132,8 +132,7 @@ along with GNU Emacs. If not, see . */ #endif #ifdef WINDOWSNT -extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, - EMACS_TIME *, void *); +#include "w32.h" #endif #ifndef SOCK_CLOEXEC @@ -532,7 +531,9 @@ add_non_blocking_write_fd (int fd) fd_callback_info[fd].flags |= FOR_WRITE | NON_BLOCKING_CONNECT_FD; if (fd > max_desc) max_desc = fd; +#ifdef NON_BLOCKING_CONNECT ++num_pending_connects; +#endif } static void @@ -560,11 +561,13 @@ delete_write_fd (int fd) eassert (fd < MAXDESC); eassert (fd <= max_desc); +#ifdef NON_BLOCKING_CONNECT if ((fd_callback_info[fd].flags & NON_BLOCKING_CONNECT_FD) != 0) { if (--num_pending_connects < 0) abort (); } +#endif fd_callback_info[fd].flags &= ~(FOR_WRITE | NON_BLOCKING_CONNECT_FD); if (fd_callback_info[fd].flags == 0) { diff --git a/src/sysdep.c b/src/sysdep.c index 0d732526528..0533a5d3e02 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -33,6 +33,17 @@ 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" @@ -58,7 +69,7 @@ along with GNU Emacs. If not, see . */ #ifndef STDERR_FILENO #define STDERR_FILENO fileno(GetStdHandle(STD_ERROR_HANDLE)) #endif -#include +#include "w32.h" #endif /* not WINDOWSNT */ #include @@ -1325,17 +1336,6 @@ setup_pty (int fd) } #endif /* HAVE_PTYS */ -#ifdef HAVE_SOCKETS -#include -#include -#endif /* HAVE_SOCKETS */ - -#ifdef TRY_AGAIN -#ifndef HAVE_H_ERRNO -extern int h_errno; -#endif -#endif /* TRY_AGAIN */ - void init_system_name (void) { diff --git a/src/sysselect.h b/src/sysselect.h index 0a4f7e3ad96..244f0f7c067 100644 --- a/src/sysselect.h +++ b/src/sysselect.h @@ -16,14 +16,47 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ +#ifndef EMACS_SYSSELECT_H +#define EMACS_SYSSELECT_H + #ifndef DOS_NT #include #endif -/* 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 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 *, + EMACS_TIME *, sigset_t *); + +#else /* not WINDOWSNT */ + #ifdef FD_SET #ifdef FD_SETSIZE #define MAXDESC FD_SETSIZE @@ -50,3 +83,5 @@ along with GNU Emacs. If not, see . */ #ifdef MSDOS #define pselect sys_select #endif + +#endif /* EMACS_SYSSELECT_H */ diff --git a/src/w32.c b/src/w32.c index 7f9b96a77a5..631405fabb8 100644 --- a/src/w32.c +++ b/src/w32.c @@ -39,6 +39,8 @@ along with GNU Emacs. If not, see . */ #include #include /* for _mbspbrk, _mbslwr, _mbsrchr, ... */ +#include + #undef access #undef chdir #undef chmod @@ -70,7 +72,7 @@ along with GNU Emacs. If not, see . */ #include /* MinGW64 (_W64) defines these in its _mingw.h. */ -#if defined(__GNUC__) && !defined(_W64) +#if !defined(_ANONYMOUS_UNION) && !defined(_ANONYMOUS_STRUCT) #define _ANONYMOUS_UNION #define _ANONYMOUS_STRUCT #endif @@ -197,7 +199,6 @@ typedef struct _REPARSE_DATA_BUFFER { #endif /* TCP connection support. */ -#include #undef socket #undef bind #undef connect @@ -247,7 +248,7 @@ static BOOL WINAPI revert_to_self (void); extern int sys_access (const char *, int); extern void *e_malloc (size_t); extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, - EMACS_TIME *, void *); + EMACS_TIME *, sigset_t *); extern int sys_dup (int); diff --git a/src/w32.h b/src/w32.h index 9c1f1efa699..c65e40ce7ae 100644 --- a/src/w32.h +++ b/src/w32.h @@ -25,33 +25,6 @@ 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 */ diff --git a/src/w32proc.c b/src/w32proc.c index 84589388cd7..599cb3c3227 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -1916,7 +1916,7 @@ extern int proc_buffered_char[]; int sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, - EMACS_TIME *timeout, void *ignored) + EMACS_TIME *timeout, sigset_t *ignored) { SELECT_TYPE orfds; DWORD timeout_ms, start_time;