From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: HAVE_SOCKETS in w32* Date: Wed, 15 Sep 2010 03:46:11 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1284515227 3876 80.91.229.12 (15 Sep 2010 01:47:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 15 Sep 2010 01:47:07 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dan Nicolaescu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 15 03:47:05 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ovh5V-0000Cf-58 for ged-emacs-devel@m.gmane.org; Wed, 15 Sep 2010 03:47:05 +0200 Original-Received: from localhost ([127.0.0.1]:49843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ovh5U-0001KO-N2 for ged-emacs-devel@m.gmane.org; Tue, 14 Sep 2010 21:47:04 -0400 Original-Received: from [140.186.70.92] (port=46862 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ovh5O-0001KJ-H7 for emacs-devel@gnu.org; Tue, 14 Sep 2010 21:46:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ovh5M-0005Rk-3V for emacs-devel@gnu.org; Tue, 14 Sep 2010 21:46:58 -0400 Original-Received: from mail-iw0-f169.google.com ([209.85.214.169]:39163) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ovh5K-0005RO-HB; Tue, 14 Sep 2010 21:46:54 -0400 Original-Received: by iwn33 with SMTP id 33so9592584iwn.0 for ; Tue, 14 Sep 2010 18:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=SiKEE9hgJ8/hKB6R/AgT1Kl3xPJHcNgM4qra+ZgTFrE=; b=qp1RLICCr3TFJYksL4MU7D0ErCVdNnRCRg09yMCVrK3BADof4yKU7Ec5LM4SaED9zY Bx6iTDoOGJj6m9GsFW0iQSKY2dn/ZeTUSIcpvJqYMI8DKxSS2ea8XWH1qJk3WzlwYyzk rmVrLMzvg7QhXELwzkd+q2B2UNTa+iAUdFZkk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=PGiwO+AsZh6JMlmJrk0+4ooL7coIHl9cwuxKGU+iv4UeaKn6rzEbjR6GrIT/AxRldD O0nkanOu/tbeOpTYPDqGm3Oxy1mpSPc3w9y00uJ9aXUer4ojUdPMqn9DCaI1XeAW66/w k6Hj9OSWI7Uyc2/NnaJcNetZRH9pssLJY7hXE= Original-Received: by 10.231.32.140 with SMTP id c12mr813135ibd.90.1284515212225; Tue, 14 Sep 2010 18:46:52 -0700 (PDT) Original-Received: by 10.231.150.195 with HTTP; Tue, 14 Sep 2010 18:46:11 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:130167 Archived-At: On Thu, Aug 5, 2010 at 20:05, Dan Nicolaescu wrote: > HAVE_SOCKETS is defined unconditionally in s/ms-w32.h, yet some w32*.c > files use HAVE_SOCKETS #ifdefs. > > It would be good to get rid of those. The following patch does that; it also removes the few uses of SOCK_REPLACE_HANDLE, which has been commented out since 1996. Eli, Jason? =C2=A0 =C2=A0 Juanma 2010-09-15 Juanma Barranquero Don't make code conditional on HAVE_SOCKETS, it's always defined on W32. * 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. =3D=3D=3D modified file 'src/w32.c' --- src/w32.c 2010-08-06 19:52:47 +0000 +++ src/w32.c 2010-09-15 01:24:04 +0000 @@ -110,7 +110,7 @@ DWORD PrivateUsage; } PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX; -#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ +/* TCP connection support. */ #include #undef socket #undef bind @@ -129,7 +129,6 @@ #undef accept #undef recvfrom #undef sendto -#endif #include "w32.h" #include "ndir.h" @@ -830,17 +829,6 @@ #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. */ struct load_sample { @@ -4348,8 +4336,6 @@ } =0C -#ifdef HAVE_SOCKETS - /* Wrappers for winsock functions to map between our file descriptors and winsock's handles; also set h_errno for convenience. @@ -4636,13 +4622,7 @@ but I believe the method of keeping the socket handle separate (and 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) -#endif int socket_to_fd (SOCKET s); @@ -4686,13 +4666,6 @@ fd =3D _open ("NUL:", _O_RDWR); if (fd >=3D 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 that it is possible that sockets aren't actually kernel handles, which appears to be the case on Windows 9x when @@ -4738,7 +4711,6 @@ } } fd_info[fd].hnd =3D (HANDLE) s; -#endif /* set our own internal flags */ fd_info[fd].flags =3D FILE_SOCKET | FILE_BINARY | FILE_READ | FILE_W= RITE; @@ -5099,8 +5071,6 @@ return SOCKET_ERROR; } -#endif /* HAVE_SOCKETS */ - /* Shadow main io functions: we need to handle pipes and sockets more intelligently, and implement non-blocking mode as well. */ @@ -5135,18 +5105,15 @@ } if (i =3D=3D MAXDESC) { -#ifdef HAVE_SOCKETS if (fd_info[fd].flags & FILE_SOCKET) { -#ifndef SOCK_REPLACE_HANDLE if (winsock_lib =3D=3D NULL) abort (); pfn_shutdown (SOCK_HANDLE (fd), 2); rc =3D pfn_closesocket (SOCK_HANDLE (fd)); -#endif + winsock_inuse--; /* count open sockets */ } -#endif delete_child (cp); } } @@ -5314,7 +5281,6 @@ return STATUS_READ_ERROR; } } -#ifdef HAVE_SOCKETS else if (fd_info[fd].flags & FILE_SOCKET) { unsigned long nblock =3D 0; @@ -5330,7 +5296,6 @@ pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock); } } -#endif if (rc =3D=3D sizeof (char)) cp->status =3D STATUS_READ_SUCCEEDED; @@ -5502,7 +5467,6 @@ nchars +=3D rc; } } -#ifdef HAVE_SOCKETS else /* FILE_SOCKET */ { if (winsock_lib =3D=3D NULL) abort (); @@ -5529,7 +5493,6 @@ nchars +=3D res; } } -#endif } else { @@ -5654,9 +5617,7 @@ } } } - else -#ifdef HAVE_SOCKETS - if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET) + else if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET) { unsigned long nblock =3D 0; if (winsock_lib =3D=3D NULL) abort (); @@ -5684,7 +5645,6 @@ } } else -#endif { /* Some networked filesystems don't like too large writes, so break them into smaller chunks. See the Comments section of @@ -5776,10 +5736,8 @@ void term_ntproc (void) { -#ifdef HAVE_SOCKETS /* shutdown the socket interface if necessary */ term_winsock (); -#endif term_w32select (); } @@ -5787,7 +5745,6 @@ void init_ntproc (void) { -#ifdef HAVE_SOCKETS /* Initialise the socket interface now if available and requested by the user by defining PRELOAD_WINSOCK; otherwise loading will be delayed until open-network-stream is called (w32-has-winsock can @@ -5801,7 +5758,6 @@ if (getenv ("PRELOAD_WINSOCK") !=3D NULL) init_winsock (TRUE); -#endif /* Initial preparation for subprocess support: replace our standard handles with non-inheritable versions. */ =3D=3D=3D modified file 'src/w32proc.c' --- src/w32proc.c 2010-07-08 21:25:08 +0000 +++ src/w32proc.c 2010-09-15 01:26:18 +0000 @@ -1694,8 +1694,6 @@ process_dir =3D dir; } -#ifdef HAVE_SOCKETS - /* To avoid problems with winsock implementations that work over dial-up connections causing or requiring a connection to exist while Emacs is running, Emacs no longer automatically loads winsock on startup if it @@ -1759,8 +1757,6 @@ return term_winsock () ? Qt : Qnil; } -#endif /* HAVE_SOCKETS */ - =0C /* Some miscellaneous functions that are Windows specific, but not GUI specific (ie. are applicable in terminal or batch mode as well). */ @@ -2268,10 +2264,9 @@ DEFSYM (Qhigh, "high"); DEFSYM (Qlow, "low"); -#ifdef HAVE_SOCKETS defsubr (&Sw32_has_winsock); defsubr (&Sw32_unload_winsock); -#endif + defsubr (&Sw32_short_file_name); defsubr (&Sw32_long_file_name); defsubr (&Sw32_set_process_priority);