aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2013-08-26 21:42:11 +0300
committerEli Zaretskii2013-08-26 21:42:11 +0300
commit6e9fb70cdf763da6d264932f14f5a67d354ec38d (patch)
tree8c9ecd47a5078c8b1c20662853a095523a7b1989 /src
parentc160274456eb7bb09776b888f5274933f2ec2399 (diff)
downloademacs-6e9fb70cdf763da6d264932f14f5a67d354ec38d.tar.gz
emacs-6e9fb70cdf763da6d264932f14f5a67d354ec38d.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog19
-rw-r--r--src/callproc.c6
-rw-r--r--src/emacs.c8
-rw-r--r--src/filelock.c7
-rw-r--r--src/process.c11
-rw-r--r--src/sysdep.c24
-rw-r--r--src/sysselect.h43
-rw-r--r--src/w32.c7
-rw-r--r--src/w32.h27
-rw-r--r--src/w32proc.c2
10 files changed, 96 insertions, 58 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 70d722a02a4..a0682bdfd48 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,22 @@
12013-08-26 Eli Zaretskii <eliz@gnu.org>
2
3 * callproc.c:
4 * emacs.c:
5 * filelock.c:
6 * process.c:
7 * sysdep.c:
8 * w32.c: Reshuffle Windows-specific headers to avoid errors with
9 redefinition of fd_set etc.
10
11 * process.c: Don't use num_pending_connects when
12 NON_BLOCKING_CONNECT is not defined.
13
14 * sysselect.h: Move definitions of FD_* macros and of SELECT_TYPE
15 here from w32.h.
16
17 * w32proc.c (sys_select): Adjust the argument types to what
18 thread.h expects.
19
12013-08-24 Eli Zaretskii <eliz@gnu.org> 202013-08-24 Eli Zaretskii <eliz@gnu.org>
2 21
3 * xdisp.c (get_next_display_element): Don't apply to characters 22 * 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 <http://www.gnu.org/licenses/>. */
26 26
27#include <sys/file.h> 27#include <sys/file.h>
28#include <fcntl.h> 28#include <fcntl.h>
29#ifdef WINDOWSNT
30#define NOMINMAX
31#include <sys/socket.h> /* for fcntl */
32#endif
29 33
30#include "lisp.h" 34#include "lisp.h"
31 35
32#ifdef WINDOWSNT 36#ifdef WINDOWSNT
33#define NOMINMAX
34#include <sys/socket.h> /* for fcntl */
35#include <windows.h> 37#include <windows.h>
36#include "w32.h" 38#include "w32.h"
37#define _P_NOWAIT 1 /* from process.h */ 39#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 <http://www.gnu.org/licenses/>. */
29 29
30#include <close-stream.h> 30#include <close-stream.h>
31 31
32#include "lisp.h"
33
34#ifdef WINDOWSNT 32#ifdef WINDOWSNT
35#include <fcntl.h> 33#include <fcntl.h>
36#include <sys/socket.h> 34#include <sys/socket.h>
37#include "w32.h"
38#include "w32heap.h" 35#include "w32heap.h"
39#endif 36#endif
40 37
38#include "lisp.h"
39
41#if defined WINDOWSNT || defined HAVE_NTGUI 40#if defined WINDOWSNT || defined HAVE_NTGUI
41#ifdef WINDOWSNT
42#include "w32.h"
43#endif
42#include "w32select.h" 44#include "w32select.h"
43#include "w32font.h" 45#include "w32font.h"
44#include "w32common.h" 46#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 <http://www.gnu.org/licenses/>. */
36#include <sys/sysctl.h> 36#include <sys/sysctl.h>
37#endif /* __FreeBSD__ */ 37#endif /* __FreeBSD__ */
38 38
39#ifdef WINDOWSNT
40#include <share.h>
41#include <sys/socket.h> /* for fcntl */
42#endif
43
39#include <errno.h> 44#include <errno.h>
40 45
41#include <c-ctype.h> 46#include <c-ctype.h>
@@ -46,8 +51,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
46#include "coding.h" 51#include "coding.h"
47#include "systime.h" 52#include "systime.h"
48#ifdef WINDOWSNT 53#ifdef WINDOWSNT
49#include <share.h>
50#include <sys/socket.h> /* for fcntl */
51#include "w32.h" /* for dostounix_filename */ 54#include "w32.h" /* for dostounix_filename */
52#endif 55#endif
53 56
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 <http://www.gnu.org/licenses/>. */
31#include <unistd.h> 31#include <unistd.h>
32#include <fcntl.h> 32#include <fcntl.h>
33 33
34#include "lisp.h"
35
36/* Only MS-DOS does not define `subprocesses'. */ 34/* Only MS-DOS does not define `subprocesses'. */
37#ifdef subprocesses 35#ifdef subprocesses
38 36
@@ -96,6 +94,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
96 94
97#endif /* subprocesses */ 95#endif /* subprocesses */
98 96
97#include "lisp.h"
98
99#include "systime.h" 99#include "systime.h"
100#include "systty.h" 100#include "systty.h"
101 101
@@ -132,8 +132,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
132#endif 132#endif
133 133
134#ifdef WINDOWSNT 134#ifdef WINDOWSNT
135extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, 135#include "w32.h"
136 EMACS_TIME *, void *);
137#endif 136#endif
138 137
139#ifndef SOCK_CLOEXEC 138#ifndef SOCK_CLOEXEC
@@ -532,7 +531,9 @@ add_non_blocking_write_fd (int fd)
532 fd_callback_info[fd].flags |= FOR_WRITE | NON_BLOCKING_CONNECT_FD; 531 fd_callback_info[fd].flags |= FOR_WRITE | NON_BLOCKING_CONNECT_FD;
533 if (fd > max_desc) 532 if (fd > max_desc)
534 max_desc = fd; 533 max_desc = fd;
534#ifdef NON_BLOCKING_CONNECT
535 ++num_pending_connects; 535 ++num_pending_connects;
536#endif
536} 537}
537 538
538static void 539static void
@@ -560,11 +561,13 @@ delete_write_fd (int fd)
560 eassert (fd < MAXDESC); 561 eassert (fd < MAXDESC);
561 eassert (fd <= max_desc); 562 eassert (fd <= max_desc);
562 563
564#ifdef NON_BLOCKING_CONNECT
563 if ((fd_callback_info[fd].flags & NON_BLOCKING_CONNECT_FD) != 0) 565 if ((fd_callback_info[fd].flags & NON_BLOCKING_CONNECT_FD) != 0)
564 { 566 {
565 if (--num_pending_connects < 0) 567 if (--num_pending_connects < 0)
566 abort (); 568 abort ();
567 } 569 }
570#endif
568 fd_callback_info[fd].flags &= ~(FOR_WRITE | NON_BLOCKING_CONNECT_FD); 571 fd_callback_info[fd].flags &= ~(FOR_WRITE | NON_BLOCKING_CONNECT_FD);
569 if (fd_callback_info[fd].flags == 0) 572 if (fd_callback_info[fd].flags == 0)
570 { 573 {
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 <http://www.gnu.org/licenses/>. */
33#include <c-ctype.h> 33#include <c-ctype.h>
34#include <utimens.h> 34#include <utimens.h>
35 35
36#ifdef HAVE_SOCKETS
37#include <sys/socket.h>
38#include <netdb.h>
39#endif /* HAVE_SOCKETS */
40
41#ifdef TRY_AGAIN
42#ifndef HAVE_H_ERRNO
43extern int h_errno;
44#endif
45#endif /* TRY_AGAIN */
46
36#include "lisp.h" 47#include "lisp.h"
37#include "sysselect.h" 48#include "sysselect.h"
38#include "blockinput.h" 49#include "blockinput.h"
@@ -58,7 +69,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
58#ifndef STDERR_FILENO 69#ifndef STDERR_FILENO
59#define STDERR_FILENO fileno(GetStdHandle(STD_ERROR_HANDLE)) 70#define STDERR_FILENO fileno(GetStdHandle(STD_ERROR_HANDLE))
60#endif 71#endif
61#include <windows.h> 72#include "w32.h"
62#endif /* not WINDOWSNT */ 73#endif /* not WINDOWSNT */
63 74
64#include <sys/types.h> 75#include <sys/types.h>
@@ -1325,17 +1336,6 @@ setup_pty (int fd)
1325} 1336}
1326#endif /* HAVE_PTYS */ 1337#endif /* HAVE_PTYS */
1327 1338
1328#ifdef HAVE_SOCKETS
1329#include <sys/socket.h>
1330#include <netdb.h>
1331#endif /* HAVE_SOCKETS */
1332
1333#ifdef TRY_AGAIN
1334#ifndef HAVE_H_ERRNO
1335extern int h_errno;
1336#endif
1337#endif /* TRY_AGAIN */
1338
1339void 1339void
1340init_system_name (void) 1340init_system_name (void)
1341{ 1341{
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.
16You should have received a copy of the GNU General Public License 16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#ifndef EMACS_SYSSELECT_H
20#define EMACS_SYSSELECT_H
21
19#ifndef DOS_NT 22#ifndef DOS_NT
20#include <sys/select.h> 23#include <sys/select.h>
21#endif 24#endif
22 25
23/* The w32 build defines select stuff in w32.h, which is included 26#ifdef WINDOWSNT
24 where w32 needs it, but not where sysselect.h is included. The w32 27
25 definitions in w32.h are incompatible with the below. */ 28/* File descriptor set emulation. */
26#ifndef WINDOWSNT 29
30/* MSVC runtime library has limit of 64 descriptors by default */
31#define FD_SETSIZE 64
32typedef struct {
33 unsigned int bits[FD_SETSIZE / 32];
34} fd_set;
35
36/* standard access macros */
37#define FD_SET(n, p) \
38 do { \
39 if ((n) < FD_SETSIZE) { \
40 (p)->bits[(n)/32] |= (1 << (n)%32); \
41 } \
42 } while (0)
43#define FD_CLR(n, p) \
44 do { \
45 if ((n) < FD_SETSIZE) { \
46 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
47 } \
48 } while (0)
49#define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
50#define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
51
52#define SELECT_TYPE fd_set
53
54#include "systime.h"
55extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
56 EMACS_TIME *, sigset_t *);
57
58#else /* not WINDOWSNT */
59
27#ifdef FD_SET 60#ifdef FD_SET
28#ifdef FD_SETSIZE 61#ifdef FD_SETSIZE
29#define MAXDESC FD_SETSIZE 62#define MAXDESC FD_SETSIZE
@@ -50,3 +83,5 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
50#ifdef MSDOS 83#ifdef MSDOS
51#define pselect sys_select 84#define pselect sys_select
52#endif 85#endif
86
87#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 <http://www.gnu.org/licenses/>. */
39#include <config.h> 39#include <config.h>
40#include <mbstring.h> /* for _mbspbrk, _mbslwr, _mbsrchr, ... */ 40#include <mbstring.h> /* for _mbspbrk, _mbslwr, _mbsrchr, ... */
41 41
42#include <sys/socket.h>
43
42#undef access 44#undef access
43#undef chdir 45#undef chdir
44#undef chmod 46#undef chmod
@@ -70,7 +72,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
70#include <grp.h> 72#include <grp.h>
71 73
72/* MinGW64 (_W64) defines these in its _mingw.h. */ 74/* MinGW64 (_W64) defines these in its _mingw.h. */
73#if defined(__GNUC__) && !defined(_W64) 75#if !defined(_ANONYMOUS_UNION) && !defined(_ANONYMOUS_STRUCT)
74#define _ANONYMOUS_UNION 76#define _ANONYMOUS_UNION
75#define _ANONYMOUS_STRUCT 77#define _ANONYMOUS_STRUCT
76#endif 78#endif
@@ -197,7 +199,6 @@ typedef struct _REPARSE_DATA_BUFFER {
197#endif 199#endif
198 200
199/* TCP connection support. */ 201/* TCP connection support. */
200#include <sys/socket.h>
201#undef socket 202#undef socket
202#undef bind 203#undef bind
203#undef connect 204#undef connect
@@ -247,7 +248,7 @@ static BOOL WINAPI revert_to_self (void);
247extern int sys_access (const char *, int); 248extern int sys_access (const char *, int);
248extern void *e_malloc (size_t); 249extern void *e_malloc (size_t);
249extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, 250extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
250 EMACS_TIME *, void *); 251 EMACS_TIME *, sigset_t *);
251extern int sys_dup (int); 252extern int sys_dup (int);
252 253
253 254
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 <http://www.gnu.org/licenses/>. */
25 25
26#include <windows.h> 26#include <windows.h>
27 27
28
29/* File descriptor set emulation. */
30
31/* MSVC runtime library has limit of 64 descriptors by default */
32#define FD_SETSIZE 64
33typedef struct {
34 unsigned int bits[FD_SETSIZE / 32];
35} fd_set;
36
37/* standard access macros */
38#define FD_SET(n, p) \
39 do { \
40 if ((n) < FD_SETSIZE) { \
41 (p)->bits[(n)/32] |= (1 << (n)%32); \
42 } \
43 } while (0)
44#define FD_CLR(n, p) \
45 do { \
46 if ((n) < FD_SETSIZE) { \
47 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
48 } \
49 } while (0)
50#define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
51#define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
52
53#define SELECT_TYPE fd_set
54
55/* ------------------------------------------------------------------------- */ 28/* ------------------------------------------------------------------------- */
56 29
57/* child_process.status values */ 30/* 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[];
1916 1916
1917int 1917int
1918sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 1918sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
1919 EMACS_TIME *timeout, void *ignored) 1919 EMACS_TIME *timeout, sigset_t *ignored)
1920{ 1920{
1921 SELECT_TYPE orfds; 1921 SELECT_TYPE orfds;
1922 DWORD timeout_ms, start_time; 1922 DWORD timeout_ms, start_time;