1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

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.
This commit is contained in:
Eli Zaretskii 2013-08-26 21:42:11 +03:00
parent c160274456
commit 6e9fb70cdf
12 changed files with 103 additions and 59 deletions

View file

@ -1,3 +1,8 @@
2013-08-26 Eli Zaretskii <eliz@gnu.org>
* inc/sys/socket.h: Include stdint.h. Include sysselect.h instead
of w32.h.
2013-08-25 Vincent Belaïche <vincentb1@users.sourceforge.net> 2013-08-25 Vincent Belaïche <vincentb1@users.sourceforge.net>
* configure.bat: Rather than disabling, make configure.bat produce * configure.bat: Rather than disabling, make configure.bat produce

View file

@ -53,6 +53,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <ws2tcpip.h> #include <ws2tcpip.h>
/* process.c uses uint16_t (from C99) for IPv6, but /* process.c uses uint16_t (from C99) for IPv6, but
apparently it is not defined in some versions of mingw and msvc. */ apparently it is not defined in some versions of mingw and msvc. */
#include <stdint.h>
#ifndef UINT16_C #ifndef UINT16_C
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
#endif #endif
@ -73,7 +74,7 @@ typedef unsigned short uint16_t;
/* allow us to provide our own version of fd_set */ /* allow us to provide our own version of fd_set */
#define fd_set ws_fd_set #define fd_set ws_fd_set
#include "w32.h" #include "sysselect.h"
#endif /* EMACS_CONFIG_H */ #endif /* EMACS_CONFIG_H */
#if defined (HAVE_TIMEVAL) && defined (_MSC_VER) #if defined (HAVE_TIMEVAL) && defined (_MSC_VER)

View file

@ -1,3 +1,22 @@
2013-08-26 Eli Zaretskii <eliz@gnu.org>
* 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 <eliz@gnu.org> 2013-08-24 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (get_next_display_element): Don't apply to characters * xdisp.c (get_next_display_element): Don't apply to characters

View file

@ -26,12 +26,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <sys/file.h> #include <sys/file.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef WINDOWSNT
#define NOMINMAX
#include <sys/socket.h> /* for fcntl */
#endif
#include "lisp.h" #include "lisp.h"
#ifdef WINDOWSNT #ifdef WINDOWSNT
#define NOMINMAX
#include <sys/socket.h> /* for fcntl */
#include <windows.h> #include <windows.h>
#include "w32.h" #include "w32.h"
#define _P_NOWAIT 1 /* from process.h */ #define _P_NOWAIT 1 /* from process.h */

View file

@ -29,16 +29,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <close-stream.h> #include <close-stream.h>
#include "lisp.h"
#ifdef WINDOWSNT #ifdef WINDOWSNT
#include <fcntl.h> #include <fcntl.h>
#include <sys/socket.h> #include <sys/socket.h>
#include "w32.h"
#include "w32heap.h" #include "w32heap.h"
#endif #endif
#include "lisp.h"
#if defined WINDOWSNT || defined HAVE_NTGUI #if defined WINDOWSNT || defined HAVE_NTGUI
#ifdef WINDOWSNT
#include "w32.h"
#endif
#include "w32select.h" #include "w32select.h"
#include "w32font.h" #include "w32font.h"
#include "w32common.h" #include "w32common.h"

View file

@ -36,6 +36,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif /* __FreeBSD__ */ #endif /* __FreeBSD__ */
#ifdef WINDOWSNT
#include <share.h>
#include <sys/socket.h> /* for fcntl */
#endif
#include <errno.h> #include <errno.h>
#include <c-ctype.h> #include <c-ctype.h>
@ -46,8 +51,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "coding.h" #include "coding.h"
#include "systime.h" #include "systime.h"
#ifdef WINDOWSNT #ifdef WINDOWSNT
#include <share.h>
#include <sys/socket.h> /* for fcntl */
#include "w32.h" /* for dostounix_filename */ #include "w32.h" /* for dostounix_filename */
#endif #endif

View file

@ -31,8 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include "lisp.h"
/* Only MS-DOS does not define `subprocesses'. */ /* Only MS-DOS does not define `subprocesses'. */
#ifdef subprocesses #ifdef subprocesses
@ -96,6 +94,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#endif /* subprocesses */ #endif /* subprocesses */
#include "lisp.h"
#include "systime.h" #include "systime.h"
#include "systty.h" #include "systty.h"
@ -132,8 +132,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#endif #endif
#ifdef WINDOWSNT #ifdef WINDOWSNT
extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, #include "w32.h"
EMACS_TIME *, void *);
#endif #endif
#ifndef SOCK_CLOEXEC #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; fd_callback_info[fd].flags |= FOR_WRITE | NON_BLOCKING_CONNECT_FD;
if (fd > max_desc) if (fd > max_desc)
max_desc = fd; max_desc = fd;
#ifdef NON_BLOCKING_CONNECT
++num_pending_connects; ++num_pending_connects;
#endif
} }
static void static void
@ -560,11 +561,13 @@ delete_write_fd (int fd)
eassert (fd < MAXDESC); eassert (fd < MAXDESC);
eassert (fd <= max_desc); eassert (fd <= max_desc);
#ifdef NON_BLOCKING_CONNECT
if ((fd_callback_info[fd].flags & NON_BLOCKING_CONNECT_FD) != 0) if ((fd_callback_info[fd].flags & NON_BLOCKING_CONNECT_FD) != 0)
{ {
if (--num_pending_connects < 0) if (--num_pending_connects < 0)
abort (); abort ();
} }
#endif
fd_callback_info[fd].flags &= ~(FOR_WRITE | NON_BLOCKING_CONNECT_FD); fd_callback_info[fd].flags &= ~(FOR_WRITE | NON_BLOCKING_CONNECT_FD);
if (fd_callback_info[fd].flags == 0) if (fd_callback_info[fd].flags == 0)
{ {

View file

@ -33,6 +33,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <c-ctype.h> #include <c-ctype.h>
#include <utimens.h> #include <utimens.h>
#ifdef HAVE_SOCKETS
#include <sys/socket.h>
#include <netdb.h>
#endif /* HAVE_SOCKETS */
#ifdef TRY_AGAIN
#ifndef HAVE_H_ERRNO
extern int h_errno;
#endif
#endif /* TRY_AGAIN */
#include "lisp.h" #include "lisp.h"
#include "sysselect.h" #include "sysselect.h"
#include "blockinput.h" #include "blockinput.h"
@ -58,7 +69,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifndef STDERR_FILENO #ifndef STDERR_FILENO
#define STDERR_FILENO fileno(GetStdHandle(STD_ERROR_HANDLE)) #define STDERR_FILENO fileno(GetStdHandle(STD_ERROR_HANDLE))
#endif #endif
#include <windows.h> #include "w32.h"
#endif /* not WINDOWSNT */ #endif /* not WINDOWSNT */
#include <sys/types.h> #include <sys/types.h>
@ -1325,17 +1336,6 @@ setup_pty (int fd)
} }
#endif /* HAVE_PTYS */ #endif /* HAVE_PTYS */
#ifdef HAVE_SOCKETS
#include <sys/socket.h>
#include <netdb.h>
#endif /* HAVE_SOCKETS */
#ifdef TRY_AGAIN
#ifndef HAVE_H_ERRNO
extern int h_errno;
#endif
#endif /* TRY_AGAIN */
void void
init_system_name (void) init_system_name (void)
{ {

View file

@ -16,14 +16,47 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifndef EMACS_SYSSELECT_H
#define EMACS_SYSSELECT_H
#ifndef DOS_NT #ifndef DOS_NT
#include <sys/select.h> #include <sys/select.h>
#endif #endif
/* The w32 build defines select stuff in w32.h, which is included #ifdef WINDOWSNT
where w32 needs it, but not where sysselect.h is included. The w32
definitions in w32.h are incompatible with the below. */ /* File descriptor set emulation. */
#ifndef WINDOWSNT
/* 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_SET
#ifdef FD_SETSIZE #ifdef FD_SETSIZE
#define MAXDESC FD_SETSIZE #define MAXDESC FD_SETSIZE
@ -50,3 +83,5 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifdef MSDOS #ifdef MSDOS
#define pselect sys_select #define pselect sys_select
#endif #endif
#endif /* EMACS_SYSSELECT_H */

View file

@ -39,6 +39,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h> #include <config.h>
#include <mbstring.h> /* for _mbspbrk, _mbslwr, _mbsrchr, ... */ #include <mbstring.h> /* for _mbspbrk, _mbslwr, _mbsrchr, ... */
#include <sys/socket.h>
#undef access #undef access
#undef chdir #undef chdir
#undef chmod #undef chmod
@ -70,7 +72,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <grp.h> #include <grp.h>
/* MinGW64 (_W64) defines these in its _mingw.h. */ /* 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_UNION
#define _ANONYMOUS_STRUCT #define _ANONYMOUS_STRUCT
#endif #endif
@ -197,7 +199,6 @@ typedef struct _REPARSE_DATA_BUFFER {
#endif #endif
/* TCP connection support. */ /* TCP connection support. */
#include <sys/socket.h>
#undef socket #undef socket
#undef bind #undef bind
#undef connect #undef connect
@ -247,7 +248,7 @@ static BOOL WINAPI revert_to_self (void);
extern int sys_access (const char *, int); extern int sys_access (const char *, int);
extern void *e_malloc (size_t); extern void *e_malloc (size_t);
extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
EMACS_TIME *, void *); EMACS_TIME *, sigset_t *);
extern int sys_dup (int); extern int sys_dup (int);

View file

@ -25,33 +25,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <windows.h> #include <windows.h>
/* 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 */ /* child_process.status values */

View file

@ -1916,7 +1916,7 @@ extern int proc_buffered_char[];
int int
sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 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; SELECT_TYPE orfds;
DWORD timeout_ms, start_time; DWORD timeout_ms, start_time;