diff options
| author | Juanma Barranquero | 2010-09-20 02:18:18 +0200 |
|---|---|---|
| committer | Juanma Barranquero | 2010-09-20 02:18:18 +0200 |
| commit | 7d7013341081f77fadf2abf4810bafea550c335f (patch) | |
| tree | c2eccd60d6dbf7f40463249599cd57c83b37fe8d /src | |
| parent | 50e4f0bf347c8e977d9c1564f9bd9a8af3dcf140 (diff) | |
| download | emacs-7d7013341081f77fadf2abf4810bafea550c335f.tar.gz emacs-7d7013341081f77fadf2abf4810bafea550c335f.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/w32.c | 50 | ||||
| -rw-r--r-- | src/w32proc.c | 7 |
3 files changed, 15 insertions, 53 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ee282e9959a..945c23167eb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2010-09-20 Juanma Barranquero <lekktu@gmail.com> | ||
| 2 | |||
| 3 | Don't make W32 code conditional on HAVE_SOCKETS, it's always defined. | ||
| 4 | * w32.c: Remove top-level uses of #ifdef HAVE_SOCKETS. | ||
| 5 | (gethostname) [!HAVE_SOCKETS]: Remove. | ||
| 6 | (SOCK_REPLACE_HANDLE): Remove macro. | ||
| 7 | (socket_to_fd, sys_close, _sys_read_ahead, sys_read, sys_write) | ||
| 8 | (term_ntproc, init_ntproc): Don't conditionalize on HAVE_SOCKETS. | ||
| 9 | * w32proc.c: Remove top-level uses of #ifdef HAVE_SOCKETS. | ||
| 10 | (syms_of_ntproc): Don't conditionalize on HAVE_SOCKETS. | ||
| 11 | |||
| 1 | 2010-09-18 Eli Zaretskii <eliz@gnu.org> | 12 | 2010-09-18 Eli Zaretskii <eliz@gnu.org> |
| 2 | 13 | ||
| 3 | * deps.mk (xml.o): Add dependencies. | 14 | * deps.mk (xml.o): Add dependencies. |
| @@ -114,7 +114,7 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX { | |||
| 114 | } PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX; | 114 | } PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX; |
| 115 | #endif | 115 | #endif |
| 116 | 116 | ||
| 117 | #ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ | 117 | /* TCP connection support. */ |
| 118 | #include <sys/socket.h> | 118 | #include <sys/socket.h> |
| 119 | #undef socket | 119 | #undef socket |
| 120 | #undef bind | 120 | #undef bind |
| @@ -133,7 +133,6 @@ typedef struct _PROCESS_MEMORY_COUNTERS_EX { | |||
| 133 | #undef accept | 133 | #undef accept |
| 134 | #undef recvfrom | 134 | #undef recvfrom |
| 135 | #undef sendto | 135 | #undef sendto |
| 136 | #endif | ||
| 137 | 136 | ||
| 138 | #include "w32.h" | 137 | #include "w32.h" |
| 139 | #include "ndir.h" | 138 | #include "ndir.h" |
| @@ -834,17 +833,6 @@ getwd (char *dir) | |||
| 834 | #endif | 833 | #endif |
| 835 | } | 834 | } |
| 836 | 835 | ||
| 837 | #ifndef HAVE_SOCKETS | ||
| 838 | /* Emulate gethostname. */ | ||
| 839 | int | ||
| 840 | gethostname (char *buffer, int size) | ||
| 841 | { | ||
| 842 | /* NT only allows small host names, so the buffer is | ||
| 843 | certainly large enough. */ | ||
| 844 | return !GetComputerName (buffer, &size); | ||
| 845 | } | ||
| 846 | #endif /* HAVE_SOCKETS */ | ||
| 847 | |||
| 848 | /* Emulate getloadavg. */ | 836 | /* Emulate getloadavg. */ |
| 849 | 837 | ||
| 850 | struct load_sample { | 838 | struct load_sample { |
| @@ -4352,8 +4340,6 @@ system_process_attributes (Lisp_Object pid) | |||
| 4352 | } | 4340 | } |
| 4353 | 4341 | ||
| 4354 | 4342 | ||
| 4355 | #ifdef HAVE_SOCKETS | ||
| 4356 | |||
| 4357 | /* Wrappers for winsock functions to map between our file descriptors | 4343 | /* Wrappers for winsock functions to map between our file descriptors |
| 4358 | and winsock's handles; also set h_errno for convenience. | 4344 | and winsock's handles; also set h_errno for convenience. |
| 4359 | 4345 | ||
| @@ -4640,13 +4626,7 @@ sys_strerror (int error_no) | |||
| 4640 | but I believe the method of keeping the socket handle separate (and | 4626 | but I believe the method of keeping the socket handle separate (and |
| 4641 | insuring it is not inheritable) is the correct one. */ | 4627 | insuring it is not inheritable) is the correct one. */ |
| 4642 | 4628 | ||
| 4643 | //#define SOCK_REPLACE_HANDLE | ||
| 4644 | |||
| 4645 | #ifdef SOCK_REPLACE_HANDLE | ||
| 4646 | #define SOCK_HANDLE(fd) ((SOCKET) _get_osfhandle (fd)) | ||
| 4647 | #else | ||
| 4648 | #define SOCK_HANDLE(fd) ((SOCKET) fd_info[fd].hnd) | 4629 | #define SOCK_HANDLE(fd) ((SOCKET) fd_info[fd].hnd) |
| 4649 | #endif | ||
| 4650 | 4630 | ||
| 4651 | int socket_to_fd (SOCKET s); | 4631 | int socket_to_fd (SOCKET s); |
| 4652 | 4632 | ||
| @@ -4690,13 +4670,6 @@ socket_to_fd (SOCKET s) | |||
| 4690 | fd = _open ("NUL:", _O_RDWR); | 4670 | fd = _open ("NUL:", _O_RDWR); |
| 4691 | if (fd >= 0) | 4671 | if (fd >= 0) |
| 4692 | { | 4672 | { |
| 4693 | #ifdef SOCK_REPLACE_HANDLE | ||
| 4694 | /* now replace handle to NUL with our socket handle */ | ||
| 4695 | CloseHandle ((HANDLE) _get_osfhandle (fd)); | ||
| 4696 | _free_osfhnd (fd); | ||
| 4697 | _set_osfhnd (fd, s); | ||
| 4698 | /* setmode (fd, _O_BINARY); */ | ||
| 4699 | #else | ||
| 4700 | /* Make a non-inheritable copy of the socket handle. Note | 4673 | /* Make a non-inheritable copy of the socket handle. Note |
| 4701 | that it is possible that sockets aren't actually kernel | 4674 | that it is possible that sockets aren't actually kernel |
| 4702 | handles, which appears to be the case on Windows 9x when | 4675 | handles, which appears to be the case on Windows 9x when |
| @@ -4742,7 +4715,6 @@ socket_to_fd (SOCKET s) | |||
| 4742 | } | 4715 | } |
| 4743 | } | 4716 | } |
| 4744 | fd_info[fd].hnd = (HANDLE) s; | 4717 | fd_info[fd].hnd = (HANDLE) s; |
| 4745 | #endif | ||
| 4746 | 4718 | ||
| 4747 | /* set our own internal flags */ | 4719 | /* set our own internal flags */ |
| 4748 | fd_info[fd].flags = FILE_SOCKET | FILE_BINARY | FILE_READ | FILE_WRITE; | 4720 | fd_info[fd].flags = FILE_SOCKET | FILE_BINARY | FILE_READ | FILE_WRITE; |
| @@ -5103,8 +5075,6 @@ fcntl (int s, int cmd, int options) | |||
| 5103 | return SOCKET_ERROR; | 5075 | return SOCKET_ERROR; |
| 5104 | } | 5076 | } |
| 5105 | 5077 | ||
| 5106 | #endif /* HAVE_SOCKETS */ | ||
| 5107 | |||
| 5108 | 5078 | ||
| 5109 | /* Shadow main io functions: we need to handle pipes and sockets more | 5079 | /* Shadow main io functions: we need to handle pipes and sockets more |
| 5110 | intelligently, and implement non-blocking mode as well. */ | 5080 | intelligently, and implement non-blocking mode as well. */ |
| @@ -5139,18 +5109,15 @@ sys_close (int fd) | |||
| 5139 | } | 5109 | } |
| 5140 | if (i == MAXDESC) | 5110 | if (i == MAXDESC) |
| 5141 | { | 5111 | { |
| 5142 | #ifdef HAVE_SOCKETS | ||
| 5143 | if (fd_info[fd].flags & FILE_SOCKET) | 5112 | if (fd_info[fd].flags & FILE_SOCKET) |
| 5144 | { | 5113 | { |
| 5145 | #ifndef SOCK_REPLACE_HANDLE | ||
| 5146 | if (winsock_lib == NULL) abort (); | 5114 | if (winsock_lib == NULL) abort (); |
| 5147 | 5115 | ||
| 5148 | pfn_shutdown (SOCK_HANDLE (fd), 2); | 5116 | pfn_shutdown (SOCK_HANDLE (fd), 2); |
| 5149 | rc = pfn_closesocket (SOCK_HANDLE (fd)); | 5117 | rc = pfn_closesocket (SOCK_HANDLE (fd)); |
| 5150 | #endif | 5118 | |
| 5151 | winsock_inuse--; /* count open sockets */ | 5119 | winsock_inuse--; /* count open sockets */ |
| 5152 | } | 5120 | } |
| 5153 | #endif | ||
| 5154 | delete_child (cp); | 5121 | delete_child (cp); |
| 5155 | } | 5122 | } |
| 5156 | } | 5123 | } |
| @@ -5318,7 +5285,6 @@ _sys_read_ahead (int fd) | |||
| 5318 | return STATUS_READ_ERROR; | 5285 | return STATUS_READ_ERROR; |
| 5319 | } | 5286 | } |
| 5320 | } | 5287 | } |
| 5321 | #ifdef HAVE_SOCKETS | ||
| 5322 | else if (fd_info[fd].flags & FILE_SOCKET) | 5288 | else if (fd_info[fd].flags & FILE_SOCKET) |
| 5323 | { | 5289 | { |
| 5324 | unsigned long nblock = 0; | 5290 | unsigned long nblock = 0; |
| @@ -5334,7 +5300,6 @@ _sys_read_ahead (int fd) | |||
| 5334 | pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock); | 5300 | pfn_ioctlsocket (SOCK_HANDLE (fd), FIONBIO, &nblock); |
| 5335 | } | 5301 | } |
| 5336 | } | 5302 | } |
| 5337 | #endif | ||
| 5338 | 5303 | ||
| 5339 | if (rc == sizeof (char)) | 5304 | if (rc == sizeof (char)) |
| 5340 | cp->status = STATUS_READ_SUCCEEDED; | 5305 | cp->status = STATUS_READ_SUCCEEDED; |
| @@ -5506,7 +5471,6 @@ sys_read (int fd, char * buffer, unsigned int count) | |||
| 5506 | nchars += rc; | 5471 | nchars += rc; |
| 5507 | } | 5472 | } |
| 5508 | } | 5473 | } |
| 5509 | #ifdef HAVE_SOCKETS | ||
| 5510 | else /* FILE_SOCKET */ | 5474 | else /* FILE_SOCKET */ |
| 5511 | { | 5475 | { |
| 5512 | if (winsock_lib == NULL) abort (); | 5476 | if (winsock_lib == NULL) abort (); |
| @@ -5533,7 +5497,6 @@ sys_read (int fd, char * buffer, unsigned int count) | |||
| 5533 | nchars += res; | 5497 | nchars += res; |
| 5534 | } | 5498 | } |
| 5535 | } | 5499 | } |
| 5536 | #endif | ||
| 5537 | } | 5500 | } |
| 5538 | else | 5501 | else |
| 5539 | { | 5502 | { |
| @@ -5658,9 +5621,7 @@ sys_write (int fd, const void * buffer, unsigned int count) | |||
| 5658 | } | 5621 | } |
| 5659 | } | 5622 | } |
| 5660 | } | 5623 | } |
| 5661 | else | 5624 | else if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET) |
| 5662 | #ifdef HAVE_SOCKETS | ||
| 5663 | if (fd < MAXDESC && fd_info[fd].flags & FILE_SOCKET) | ||
| 5664 | { | 5625 | { |
| 5665 | unsigned long nblock = 0; | 5626 | unsigned long nblock = 0; |
| 5666 | if (winsock_lib == NULL) abort (); | 5627 | if (winsock_lib == NULL) abort (); |
| @@ -5688,7 +5649,6 @@ sys_write (int fd, const void * buffer, unsigned int count) | |||
| 5688 | } | 5649 | } |
| 5689 | } | 5650 | } |
| 5690 | else | 5651 | else |
| 5691 | #endif | ||
| 5692 | { | 5652 | { |
| 5693 | /* Some networked filesystems don't like too large writes, so | 5653 | /* Some networked filesystems don't like too large writes, so |
| 5694 | break them into smaller chunks. See the Comments section of | 5654 | break them into smaller chunks. See the Comments section of |
| @@ -5780,10 +5740,8 @@ check_windows_init_file (void) | |||
| 5780 | void | 5740 | void |
| 5781 | term_ntproc (void) | 5741 | term_ntproc (void) |
| 5782 | { | 5742 | { |
| 5783 | #ifdef HAVE_SOCKETS | ||
| 5784 | /* shutdown the socket interface if necessary */ | 5743 | /* shutdown the socket interface if necessary */ |
| 5785 | term_winsock (); | 5744 | term_winsock (); |
| 5786 | #endif | ||
| 5787 | 5745 | ||
| 5788 | term_w32select (); | 5746 | term_w32select (); |
| 5789 | } | 5747 | } |
| @@ -5791,7 +5749,6 @@ term_ntproc (void) | |||
| 5791 | void | 5749 | void |
| 5792 | init_ntproc (void) | 5750 | init_ntproc (void) |
| 5793 | { | 5751 | { |
| 5794 | #ifdef HAVE_SOCKETS | ||
| 5795 | /* Initialise the socket interface now if available and requested by | 5752 | /* Initialise the socket interface now if available and requested by |
| 5796 | the user by defining PRELOAD_WINSOCK; otherwise loading will be | 5753 | the user by defining PRELOAD_WINSOCK; otherwise loading will be |
| 5797 | delayed until open-network-stream is called (w32-has-winsock can | 5754 | delayed until open-network-stream is called (w32-has-winsock can |
| @@ -5805,7 +5762,6 @@ init_ntproc (void) | |||
| 5805 | 5762 | ||
| 5806 | if (getenv ("PRELOAD_WINSOCK") != NULL) | 5763 | if (getenv ("PRELOAD_WINSOCK") != NULL) |
| 5807 | init_winsock (TRUE); | 5764 | init_winsock (TRUE); |
| 5808 | #endif | ||
| 5809 | 5765 | ||
| 5810 | /* Initial preparation for subprocess support: replace our standard | 5766 | /* Initial preparation for subprocess support: replace our standard |
| 5811 | handles with non-inheritable versions. */ | 5767 | handles with non-inheritable versions. */ |
diff --git a/src/w32proc.c b/src/w32proc.c index af923723709..ae4e725b6ef 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -1694,8 +1694,6 @@ set_process_dir (char * dir) | |||
| 1694 | process_dir = dir; | 1694 | process_dir = dir; |
| 1695 | } | 1695 | } |
| 1696 | 1696 | ||
| 1697 | #ifdef HAVE_SOCKETS | ||
| 1698 | |||
| 1699 | /* To avoid problems with winsock implementations that work over dial-up | 1697 | /* To avoid problems with winsock implementations that work over dial-up |
| 1700 | connections causing or requiring a connection to exist while Emacs is | 1698 | connections causing or requiring a connection to exist while Emacs is |
| 1701 | running, Emacs no longer automatically loads winsock on startup if it | 1699 | running, Emacs no longer automatically loads winsock on startup if it |
| @@ -1759,8 +1757,6 @@ socket connections still exist. */) | |||
| 1759 | return term_winsock () ? Qt : Qnil; | 1757 | return term_winsock () ? Qt : Qnil; |
| 1760 | } | 1758 | } |
| 1761 | 1759 | ||
| 1762 | #endif /* HAVE_SOCKETS */ | ||
| 1763 | |||
| 1764 | 1760 | ||
| 1765 | /* Some miscellaneous functions that are Windows specific, but not GUI | 1761 | /* Some miscellaneous functions that are Windows specific, but not GUI |
| 1766 | specific (ie. are applicable in terminal or batch mode as well). */ | 1762 | specific (ie. are applicable in terminal or batch mode as well). */ |
| @@ -2268,10 +2264,9 @@ syms_of_ntproc (void) | |||
| 2268 | DEFSYM (Qhigh, "high"); | 2264 | DEFSYM (Qhigh, "high"); |
| 2269 | DEFSYM (Qlow, "low"); | 2265 | DEFSYM (Qlow, "low"); |
| 2270 | 2266 | ||
| 2271 | #ifdef HAVE_SOCKETS | ||
| 2272 | defsubr (&Sw32_has_winsock); | 2267 | defsubr (&Sw32_has_winsock); |
| 2273 | defsubr (&Sw32_unload_winsock); | 2268 | defsubr (&Sw32_unload_winsock); |
| 2274 | #endif | 2269 | |
| 2275 | defsubr (&Sw32_short_file_name); | 2270 | defsubr (&Sw32_short_file_name); |
| 2276 | defsubr (&Sw32_long_file_name); | 2271 | defsubr (&Sw32_long_file_name); |
| 2277 | defsubr (&Sw32_set_process_priority); | 2272 | defsubr (&Sw32_set_process_priority); |