summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2015-11-02 19:04:06 +0200
committerEli Zaretskii <eliz@gnu.org>2015-11-02 19:04:06 +0200
commit470e3028d8a741d97349faa8fdeb148d913a49d0 (patch)
treed194711816fd6bc66726b0917ae74ef3116f38b1
parent39372e1a1032521be74575bb06f95a3898fbae30 (diff)
downloademacs-470e3028d8a741d97349faa8fdeb148d913a49d0.tar.gz
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
-rw-r--r--nt/inc/sys/socket.h2
-rw-r--r--src/callproc.c6
-rw-r--r--src/emacs.c10
-rw-r--r--src/filelock.c7
-rw-r--r--src/process.c7
-rw-r--r--src/sysdep.c22
-rw-r--r--src/sysselect.h38
-rw-r--r--src/thread.h4
-rw-r--r--src/w32.c3
-rw-r--r--src/w32.h26
10 files changed, 59 insertions, 66 deletions
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 <http://www.gnu.org/licenses/>. */
#include <sys/file.h>
#include <fcntl.h>
-#ifdef WINDOWSNT
-#define NOMINMAX
-#include <sys/socket.h> /* for fcntl */
-#endif
#include "lisp.h"
#ifdef WINDOWSNT
+#define NOMINMAX
+#include <sys/socket.h> /* for fcntl */
#include <windows.h>
#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 <http://www.gnu.org/licenses/>. */
#include <close-stream.h>
+#define MAIN_PROGRAM
+#include "lisp.h"
+
#ifdef WINDOWSNT
#include <fcntl.h>
#include <sys/socket.h>
#include <mbstring.h>
+#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 <http://www.gnu.org/licenses/>. */
#include <sys/sysctl.h>
#endif /* __FreeBSD__ */
-#ifdef WINDOWSNT
-#include <share.h>
-#include <sys/socket.h> /* for fcntl */
-#endif
-
#include <errno.h>
#include <c-ctype.h>
@@ -53,6 +48,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "buffer.h"
#include "coding.h"
#ifdef WINDOWSNT
+#include <share.h>
+#include <sys/socket.h> /* 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 <http://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <fcntl.h>
+#include "lisp.h"
+
/* Only MS-DOS does not define `subprocesses'. */
#ifdef subprocesses
@@ -92,8 +94,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#endif /* subprocesses */
-#include "lisp.h"
-
#include "systime.h"
#include "systty.h"
@@ -126,7 +126,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#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 <http://www.gnu.org/licenses/>. */
#include <c-ctype.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 "sysselect.h"
#include "blockinput.h"
@@ -68,6 +57,17 @@ extern int h_errno;
# include <math.h>
#endif
+#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 */
+
#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 <http://www.gnu.org/licenses/>. */
#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 <http://www.gnu.org/licenses/>. */
#include "regex.h"
+#ifdef WINDOWSNT
+#include <sys/socket.h>
+#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 <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <mbstring.h> /* for _mbspbrk, _mbslwr, _mbsrchr, ... */
-#include <sys/socket.h>
-
#undef access
#undef chdir
#undef chmod
@@ -205,6 +203,7 @@ typedef struct _REPARSE_DATA_BUFFER {
#endif
/* TCP connection support. */
+#include <sys/socket.h>
#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 <http://www.gnu.org/licenses/>. */
#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 */