Commit 7d701334 authored by Juanma Barranquero's avatar Juanma Barranquero
Browse files

Don't make W32 code conditional on HAVE_SOCKETS, it's always defined.

* w32.c: Remove top-level uses of #ifdef HAVE_SOCKETS.
  (gethostname) [!HAVE_SOCKETS]: Remove.
  (SOCK_REPLACE_HANDLE): Remove macro.
  (socket_to_fd, sys_close, _sys_read_ahead, sys_read, sys_write)
  (term_ntproc, init_ntproc): Don't conditionalize on HAVE_SOCKETS.
* w32proc.c: Remove top-level uses of #ifdef HAVE_SOCKETS.
  (syms_of_ntproc): Don't conditionalize on HAVE_SOCKETS.
parent 50e4f0bf
2010-09-20 Juanma Barranquero <lekktu@gmail.com>
Don't make W32 code conditional on HAVE_SOCKETS, it's always defined.
* w32.c: Remove top-level uses of #ifdef HAVE_SOCKETS.
(gethostname) [!HAVE_SOCKETS]: Remove.
(SOCK_REPLACE_HANDLE): Remove macro.
(socket_to_fd, sys_close, _sys_read_ahead, sys_read, sys_write)
(term_ntproc, init_ntproc): Don't conditionalize on HAVE_SOCKETS.
* w32proc.c: Remove top-level uses of #ifdef HAVE_SOCKETS.
(syms_of_ntproc): Don't conditionalize on HAVE_SOCKETS.
2010-09-18 Eli Zaretskii <eliz@gnu.org> 2010-09-18 Eli Zaretskii <eliz@gnu.org>
   
* deps.mk (xml.o): Add dependencies. * deps.mk (xml.o): Add dependencies.
......
...@@ -114,7 +114,7 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX { ...@@ -114,7 +114,7 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX {
} PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX; } PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX;
#endif #endif
#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ /* TCP connection support. */
#include <sys/socket.h> #include <sys/socket.h>
#undef socket #undef socket
#undef bind #undef bind
...@@ -133,7 +133,6 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX { ...@@ -133,7 +133,6 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX {
#undef accept #undef accept
#undef recvfrom #undef recvfrom
#undef sendto #undef sendto
#endif
#include "w32.h" #include "w32.h"
#include "ndir.h" #include "ndir.h"
...@@ -834,17 +833,6 @@ getwd (char *dir) ...@@ -834,17 +833,6 @@ getwd (char *dir)
#endif #endif
} }
#ifndef HAVE_SOCKETS
/* Emulate gethostname. */
int
gethostname (char *buffer, int size)
{
/* NT only allows small host names, so the buffer is
certainly large enough. */
return !GetComputerName (buffer, &size);
}
#endif /* HAVE_SOCKETS */
/* Emulate getloadavg. */ /* Emulate getloadavg. */
struct load_sample { struct load_sample {
...@@ -4352,8 +4340,6 @@ system_process_attributes (Lisp_Object pid) ...@@ -4352,8 +4340,6 @@ system_process_attributes (Lisp_Object pid)
} }
#ifdef HAVE_SOCKETS
/* Wrappers for winsock functions to map between our file descriptors /* Wrappers for winsock functions to map between our file descriptors
and winsock's handles; also set h_errno for convenience. and winsock's handles; also set h_errno for convenience.
...@@ -4640,13 +4626,7 @@ sys_strerror (int error_no) ...@@ -4640,13 +4626,7 @@ sys_strerror (int error_no)
but I believe the method of keeping the socket handle separate (and but I believe the method of keeping the socket handle separate (and
insuring it is not inheritable) is the correct one. */ insuring it is not inheritable) is the correct one. */
//#define SOCK_REPLACE_HANDLE
#ifdef SOCK_REPLACE_HANDLE
#define SOCK_HANDLE(fd) ((SOCKET) _get_osfhandle (fd))
#else
#define SOCK_HANDLE(fd) ((SOCKET) fd_info[fd].hnd) #define SOCK_HANDLE(fd) ((SOCKET) fd_info[fd].hnd)
#endif
int socket_to_fd (SOCKET s); int socket_to_fd (SOCKET s);
...@@ -4690,13 +4670,6 @@ socket_to_fd (SOCKET s) ...@@ -4690,13 +4670,6 @@ socket_to_fd (SOCKET s)
fd = _open ("NUL:", _O_RDWR); fd = _open ("NUL:", _O_RDWR);
if (fd >= 0) if (fd >= 0)
{ {
#ifdef SOCK_REPLACE_HANDLE
/* now replace handle to NUL with our socket handle */
CloseHandle ((HANDLE) _get_osfhandle (fd));
_free_osfhnd (fd);
_set_osfhnd (fd, s);
/* setmode (fd, _O_BINARY); */
#else
/* Make a non-inheritable copy of the socket handle. Note /* Make a non-inheritable copy of the socket handle. Note
that it is possible that sockets aren't actually kernel that it is possible that sockets aren't actually kernel
handles, which appears to be the case on Windows 9x when handles, which appears to be the case on Windows 9x when
...@@ -4742,7 +4715,6 @@ socket_to_fd (SOCKET s) ...@@ -4742,7 +4715,6 @@ socket_to_fd (SOCKET s)
} }
} }
fd_info[fd].hnd = (HANDLE) s; fd_info[fd].hnd = (HANDLE) s;
#endif
/* set our own internal flags */ /* set our own internal flags */
fd_info[fd].flags = FILE_SOCKET | FILE_BINARY | FILE_READ | FILE_WRITE; fd_info[fd].flags = FILE_SOCKET | FILE_BINARY | FILE_READ | FILE_WRITE;
...@@ -5103,8 +5075,6 @@ fcntl (int s, int cmd, int options) ...@@ -5103,8 +5075,6 @@ fcntl (int s, int cmd, int options)
return SOCKET_ERROR; return SOCKET_ERROR;
} }
#endif /* HAVE_SOCKETS */
/* Shadow main io functions: we need to handle pipes and sockets more /* Shadow main io functions: we need to handle pipes and sockets more
intelligently, and implement non-blocking mode as well. */ intelligently, and implement non-blocking mode as well. */
...@@ -5139,18 +5109,15 @@ sys_close (int fd) ...@@ -5139,18 +5109,15 @@ sys_close (int fd)
} }
if (i == MAXDESC) if (i == MAXDESC)
{ {
#ifdef HAVE_SOCKETS
if (fd_info[fd].flags & FILE_SOCKET) if (fd_info[fd].flags & FILE_SOCKET)
{ {
#ifndef SOCK_REPLACE_HANDLE
if (winsock_lib == NULL) abort (); if (winsock_lib == NULL) abort ();
pfn_shutdown (SOCK_HANDLE (fd), 2); pfn_shutdown (SOCK_HANDLE (fd), 2);
rc = pfn_closesocket (SOCK_HANDLE (fd)); rc = pfn_closesocket (SOCK_HANDLE (fd));
#endif
winsock_inuse--; /* count open sockets */ winsock_inuse--; /* count open sockets */
} }
#endif
delete_child (cp); delete_child (cp);
} }
} }
...@@ -5318,7 +5285,6 @@ _sys_read_ahead (int fd) ...@@ -5318,7 +5285,6 @@ _sys_read_ahead (int fd)
return STATUS_READ_ERROR; return STATUS_READ_ERROR;
} }
} }
#ifdef HAVE_SOCKETS
else if (fd_info[fd].flags & FILE_SOCKET) else if (fd_info[fd].flags & FILE_SOCKET)
{ {
unsigned long nblock = 0; unsigned long nblock = 0;
...@@ -5334,7 +5300,6 @@ _sys_read_ahead (int fd) ...@@ -5334,7 +5300,6 @@ _sys_read_ahead (int fd)
pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock); pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock);
} }
} }
#endif
if (rc == sizeof (char)) if (rc == sizeof (char))
cp->status = STATUS_READ_SUCCEEDED; cp->status = STATUS_READ_SUCCEEDED;
...@@ -5506,7 +5471,6 @@ sys_read (int fd, char * buffer, unsigned int count) ...@@ -5506,7 +5471,6 @@ sys_read (int fd, char * buffer, unsigned int count)
nchars += rc; nchars += rc;
} }
} }
#ifdef HAVE_SOCKETS
else /* FILE_SOCKET */ else /* FILE_SOCKET */
{ {
if (winsock_lib == NULL) abort (); if (winsock_lib == NULL) abort ();
...@@ -5533,7 +5497,6 @@ sys_read (int fd, char * buffer, unsigned int count) ...@@ -5533,7 +5497,6 @@ sys_read (int fd, char * buffer, unsigned int count)
nchars += res; nchars += res;
} }
} }
#endif
} }
else else
{ {
...@@ -5658,9 +5621,7 @@ sys_write (int fd, const void * buffer, unsigned int count) ...@@ -5658,9 +5621,7 @@ sys_write (int fd, const void * buffer, unsigned int count)
} }
} }
} }
else else if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET)
#ifdef HAVE_SOCKETS
if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET)
{ {
unsigned long nblock = 0; unsigned long nblock = 0;
if (winsock_lib == NULL) abort (); if (winsock_lib == NULL) abort ();
...@@ -5688,7 +5649,6 @@ sys_write (int fd, const void * buffer, unsigned int count) ...@@ -5688,7 +5649,6 @@ sys_write (int fd, const void * buffer, unsigned int count)
} }
} }
else else
#endif
{ {
/* Some networked filesystems don't like too large writes, so /* Some networked filesystems don't like too large writes, so
break them into smaller chunks. See the Comments section of break them into smaller chunks. See the Comments section of
...@@ -5780,10 +5740,8 @@ check_windows_init_file (void) ...@@ -5780,10 +5740,8 @@ check_windows_init_file (void)
void void
term_ntproc (void) term_ntproc (void)
{ {
#ifdef HAVE_SOCKETS
/* shutdown the socket interface if necessary */ /* shutdown the socket interface if necessary */
term_winsock (); term_winsock ();
#endif
term_w32select (); term_w32select ();
} }
...@@ -5791,7 +5749,6 @@ term_ntproc (void) ...@@ -5791,7 +5749,6 @@ term_ntproc (void)
void void
init_ntproc (void) init_ntproc (void)
{ {
#ifdef HAVE_SOCKETS
/* Initialise the socket interface now if available and requested by /* Initialise the socket interface now if available and requested by
the user by defining PRELOAD_WINSOCK; otherwise loading will be the user by defining PRELOAD_WINSOCK; otherwise loading will be
delayed until open-network-stream is called (w32-has-winsock can delayed until open-network-stream is called (w32-has-winsock can
...@@ -5805,7 +5762,6 @@ init_ntproc (void) ...@@ -5805,7 +5762,6 @@ init_ntproc (void)
if (getenv ("PRELOAD_WINSOCK") != NULL) if (getenv ("PRELOAD_WINSOCK") != NULL)
init_winsock (TRUE); init_winsock (TRUE);
#endif
/* Initial preparation for subprocess support: replace our standard /* Initial preparation for subprocess support: replace our standard
handles with non-inheritable versions. */ handles with non-inheritable versions. */
......
...@@ -1694,8 +1694,6 @@ set_process_dir (char * dir) ...@@ -1694,8 +1694,6 @@ set_process_dir (char * dir)
process_dir = dir; process_dir = dir;
} }
#ifdef HAVE_SOCKETS
/* To avoid problems with winsock implementations that work over dial-up /* To avoid problems with winsock implementations that work over dial-up
connections causing or requiring a connection to exist while Emacs is connections causing or requiring a connection to exist while Emacs is
running, Emacs no longer automatically loads winsock on startup if it running, Emacs no longer automatically loads winsock on startup if it
...@@ -1759,8 +1757,6 @@ socket connections still exist. */) ...@@ -1759,8 +1757,6 @@ socket connections still exist. */)
return term_winsock () ? Qt : Qnil; return term_winsock () ? Qt : Qnil;
} }
#endif /* HAVE_SOCKETS */
/* Some miscellaneous functions that are Windows specific, but not GUI /* Some miscellaneous functions that are Windows specific, but not GUI
specific (ie. are applicable in terminal or batch mode as well). */ specific (ie. are applicable in terminal or batch mode as well). */
...@@ -2268,10 +2264,9 @@ syms_of_ntproc (void) ...@@ -2268,10 +2264,9 @@ syms_of_ntproc (void)
DEFSYM (Qhigh, "high"); DEFSYM (Qhigh, "high");
DEFSYM (Qlow, "low"); DEFSYM (Qlow, "low");
#ifdef HAVE_SOCKETS
defsubr (&Sw32_has_winsock); defsubr (&Sw32_has_winsock);
defsubr (&Sw32_unload_winsock); defsubr (&Sw32_unload_winsock);
#endif
defsubr (&Sw32_short_file_name); defsubr (&Sw32_short_file_name);
defsubr (&Sw32_long_file_name); defsubr (&Sw32_long_file_name);
defsubr (&Sw32_set_process_priority); defsubr (&Sw32_set_process_priority);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment