diff options
author | Eli Zaretskii <eliz@gnu.org> | 2013-08-26 21:42:11 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2013-08-26 21:42:11 +0300 |
commit | 6e9fb70cdf763da6d264932f14f5a67d354ec38d (patch) | |
tree | 8c9ecd47a5078c8b1c20662853a095523a7b1989 /src | |
parent | c160274456eb7bb09776b888f5274933f2ec2399 (diff) | |
download | emacs-6e9fb70cdf763da6d264932f14f5a67d354ec38d.tar.gz emacs-6e9fb70cdf763da6d264932f14f5a67d354ec38d.tar.bz2 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/ChangeLog | 19 | ||||
-rw-r--r-- | src/callproc.c | 6 | ||||
-rw-r--r-- | src/emacs.c | 8 | ||||
-rw-r--r-- | src/filelock.c | 7 | ||||
-rw-r--r-- | src/process.c | 11 | ||||
-rw-r--r-- | src/sysdep.c | 24 | ||||
-rw-r--r-- | src/sysselect.h | 43 | ||||
-rw-r--r-- | src/w32.c | 7 | ||||
-rw-r--r-- | src/w32.h | 27 | ||||
-rw-r--r-- | src/w32proc.c | 2 |
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 @@ +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> * 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/>. */ #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 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/>. */ #include <close-stream.h> -#include "lisp.h" - #ifdef WINDOWSNT #include <fcntl.h> #include <sys/socket.h> -#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 <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> @@ -46,8 +51,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "coding.h" #include "systime.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 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/>. */ #include <unistd.h> #include <fcntl.h> -#include "lisp.h" - /* Only MS-DOS does not define `subprocesses'. */ #ifdef subprocesses @@ -96,6 +94,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #endif /* subprocesses */ +#include "lisp.h" + #include "systime.h" #include "systty.h" @@ -132,8 +132,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #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 <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" @@ -58,7 +69,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #ifndef STDERR_FILENO #define STDERR_FILENO fileno(GetStdHandle(STD_ERROR_HANDLE)) #endif -#include <windows.h> +#include "w32.h" #endif /* not WINDOWSNT */ #include <sys/types.h> @@ -1325,17 +1336,6 @@ setup_pty (int fd) } #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 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 <http://www.gnu.org/licenses/>. */ +#ifndef EMACS_SYSSELECT_H +#define EMACS_SYSSELECT_H + #ifndef DOS_NT #include <sys/select.h> #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 <http://www.gnu.org/licenses/>. */ #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 <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 @@ -70,7 +72,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <grp.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_STRUCT #endif @@ -197,7 +199,6 @@ typedef struct _REPARSE_DATA_BUFFER { #endif /* TCP connection support. */ -#include <sys/socket.h> #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 <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 */ 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; |