aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-08-27 12:36:28 -0700
committerPaul Eggert2013-08-27 12:36:28 -0700
commitd486344e6fd74e4769cc7b3d09a1ea87387c5a11 (patch)
treee9ff0c112e6dbec49258aabe30122b389f9b6f20 /src
parentb73517d9ecf5efeea0d6cbde56730132f5e1b611 (diff)
downloademacs-d486344e6fd74e4769cc7b3d09a1ea87387c5a11.tar.gz
emacs-d486344e6fd74e4769cc7b3d09a1ea87387c5a11.zip
Simplify SELECT_TYPE-related code.
Like EMACS_TIME, this portability layer is no longer needed, since Emacs has been using fd_set as a portability layer for some time. * sysselect.h (FD_SETSIZE): Rename from MAXDESC. All uses changed. (SELECT_TYPE): Remove. All uses changed to fd_set. (fd_set) [!FD_SET]: New typedef.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/nsterm.m4
-rw-r--r--src/process.c52
-rw-r--r--src/sysdep.c4
-rw-r--r--src/sysselect.h11
-rw-r--r--src/xgselect.c4
-rw-r--r--src/xgselect.h4
-rw-r--r--src/xmenu.c2
-rw-r--r--src/xterm.c2
9 files changed, 46 insertions, 44 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5d5a811b3c4..185619f1890 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
12013-08-27 Paul Eggert <eggert@cs.ucla.edu> 12013-08-27 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Simplify SELECT_TYPE-related code.
4 Like EMACS_TIME, this portability layer is no longer needed, since
5 Emacs has been using fd_set as a portability layer for some time.
6 * sysselect.h (FD_SETSIZE): Rename from MAXDESC. All uses changed.
7 (SELECT_TYPE): Remove. All uses changed to fd_set.
8 (fd_set) [!FD_SET]: New typedef.
9
3 Simplify EMACS_TIME-related code. 10 Simplify EMACS_TIME-related code.
4 This portability layer is no longer needed, since Emacs has been 11 This portability layer is no longer needed, since Emacs has been
5 using struct timespec as a portability layer for some time. 12 using struct timespec as a portability layer for some time.
diff --git a/src/nsterm.m b/src/nsterm.m
index ec365df0c22..01ee2319ddf 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -4686,7 +4686,7 @@ not_in_argv (NSString *arg)
4686 int waiting = 1, nfds; 4686 int waiting = 1, nfds;
4687 char c; 4687 char c;
4688 4688
4689 SELECT_TYPE readfds, writefds, *wfds; 4689 fd_set readfds, writefds, *wfds;
4690 struct timespec timeout, *tmo; 4690 struct timespec timeout, *tmo;
4691 NSAutoreleasePool *pool = nil; 4691 NSAutoreleasePool *pool = nil;
4692 4692
@@ -4699,7 +4699,7 @@ not_in_argv (NSString *arg)
4699 4699
4700 if (waiting) 4700 if (waiting)
4701 { 4701 {
4702 SELECT_TYPE fds; 4702 fd_set fds;
4703 FD_ZERO (&fds); 4703 FD_ZERO (&fds);
4704 FD_SET (selfds[0], &fds); 4704 FD_SET (selfds[0], &fds);
4705 result = select (selfds[0]+1, &fds, NULL, NULL, NULL); 4705 result = select (selfds[0]+1, &fds, NULL, NULL, NULL);
diff --git a/src/process.c b/src/process.c
index 3b62f45bf0a..b52622ec1b6 100644
--- a/src/process.c
+++ b/src/process.c
@@ -132,7 +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 *, 135extern int sys_select (int, fd_set *, fd_set *, fd_set *,
136 struct timespec *, void *); 136 struct timespec *, void *);
137#endif 137#endif
138 138
@@ -280,7 +280,7 @@ static bool process_output_skip;
280 280
281static void create_process (Lisp_Object, char **, Lisp_Object); 281static void create_process (Lisp_Object, char **, Lisp_Object);
282#ifdef USABLE_SIGIO 282#ifdef USABLE_SIGIO
283static bool keyboard_bit_set (SELECT_TYPE *); 283static bool keyboard_bit_set (fd_set *);
284#endif 284#endif
285static void deactivate_process (Lisp_Object); 285static void deactivate_process (Lisp_Object);
286static void status_notify (struct Lisp_Process *); 286static void status_notify (struct Lisp_Process *);
@@ -299,26 +299,26 @@ static void exec_sentinel (Lisp_Object proc, Lisp_Object reason);
299 299
300/* Mask of bits indicating the descriptors that we wait for input on. */ 300/* Mask of bits indicating the descriptors that we wait for input on. */
301 301
302static SELECT_TYPE input_wait_mask; 302static fd_set input_wait_mask;
303 303
304/* Mask that excludes keyboard input descriptor(s). */ 304/* Mask that excludes keyboard input descriptor(s). */
305 305
306static SELECT_TYPE non_keyboard_wait_mask; 306static fd_set non_keyboard_wait_mask;
307 307
308/* Mask that excludes process input descriptor(s). */ 308/* Mask that excludes process input descriptor(s). */
309 309
310static SELECT_TYPE non_process_wait_mask; 310static fd_set non_process_wait_mask;
311 311
312/* Mask for selecting for write. */ 312/* Mask for selecting for write. */
313 313
314static SELECT_TYPE write_mask; 314static fd_set write_mask;
315 315
316#ifdef NON_BLOCKING_CONNECT 316#ifdef NON_BLOCKING_CONNECT
317/* Mask of bits indicating the descriptors that we wait for connect to 317/* Mask of bits indicating the descriptors that we wait for connect to
318 complete on. Once they complete, they are removed from this mask 318 complete on. Once they complete, they are removed from this mask
319 and added to the input_wait_mask and non_keyboard_wait_mask. */ 319 and added to the input_wait_mask and non_keyboard_wait_mask. */
320 320
321static SELECT_TYPE connect_wait_mask; 321static fd_set connect_wait_mask;
322 322
323/* Number of bits set in connect_wait_mask. */ 323/* Number of bits set in connect_wait_mask. */
324static int num_pending_connects; 324static int num_pending_connects;
@@ -331,7 +331,7 @@ static int max_process_desc;
331static int max_input_desc; 331static int max_input_desc;
332 332
333/* Indexed by descriptor, gives the process (if any) for that descriptor */ 333/* Indexed by descriptor, gives the process (if any) for that descriptor */
334static Lisp_Object chan_process[MAXDESC]; 334static Lisp_Object chan_process[FD_SETSIZE];
335 335
336/* Alist of elements (NAME . PROCESS) */ 336/* Alist of elements (NAME . PROCESS) */
337static Lisp_Object Vprocess_alist; 337static Lisp_Object Vprocess_alist;
@@ -342,18 +342,18 @@ static Lisp_Object Vprocess_alist;
342 output from the process is to read at least one char. 342 output from the process is to read at least one char.
343 Always -1 on systems that support FIONREAD. */ 343 Always -1 on systems that support FIONREAD. */
344 344
345static int proc_buffered_char[MAXDESC]; 345static int proc_buffered_char[FD_SETSIZE];
346 346
347/* Table of `struct coding-system' for each process. */ 347/* Table of `struct coding-system' for each process. */
348static struct coding_system *proc_decode_coding_system[MAXDESC]; 348static struct coding_system *proc_decode_coding_system[FD_SETSIZE];
349static struct coding_system *proc_encode_coding_system[MAXDESC]; 349static struct coding_system *proc_encode_coding_system[FD_SETSIZE];
350 350
351#ifdef DATAGRAM_SOCKETS 351#ifdef DATAGRAM_SOCKETS
352/* Table of `partner address' for datagram sockets. */ 352/* Table of `partner address' for datagram sockets. */
353static struct sockaddr_and_len { 353static struct sockaddr_and_len {
354 struct sockaddr *sa; 354 struct sockaddr *sa;
355 int len; 355 int len;
356} datagram_address[MAXDESC]; 356} datagram_address[FD_SETSIZE];
357#define DATAGRAM_CHAN_P(chan) (datagram_address[chan].sa != 0) 357#define DATAGRAM_CHAN_P(chan) (datagram_address[chan].sa != 0)
358#define DATAGRAM_CONN_P(proc) (PROCESSP (proc) && datagram_address[XPROCESS (proc)->infd].sa != 0) 358#define DATAGRAM_CONN_P(proc) (PROCESSP (proc) && datagram_address[XPROCESS (proc)->infd].sa != 0)
359#else 359#else
@@ -458,7 +458,7 @@ static struct fd_callback_data
458#define FOR_READ 1 458#define FOR_READ 1
459#define FOR_WRITE 2 459#define FOR_WRITE 2
460 int condition; /* mask of the defines above. */ 460 int condition; /* mask of the defines above. */
461} fd_callback_info[MAXDESC]; 461} fd_callback_info[FD_SETSIZE];
462 462
463 463
464/* Add a file descriptor FD to be monitored for when read is possible. 464/* Add a file descriptor FD to be monitored for when read is possible.
@@ -467,7 +467,7 @@ static struct fd_callback_data
467void 467void
468add_read_fd (int fd, fd_callback func, void *data) 468add_read_fd (int fd, fd_callback func, void *data)
469{ 469{
470 eassert (fd < MAXDESC); 470 eassert (fd < FD_SETSIZE);
471 add_keyboard_wait_descriptor (fd); 471 add_keyboard_wait_descriptor (fd);
472 472
473 fd_callback_info[fd].func = func; 473 fd_callback_info[fd].func = func;
@@ -480,7 +480,7 @@ add_read_fd (int fd, fd_callback func, void *data)
480void 480void
481delete_read_fd (int fd) 481delete_read_fd (int fd)
482{ 482{
483 eassert (fd < MAXDESC); 483 eassert (fd < FD_SETSIZE);
484 delete_keyboard_wait_descriptor (fd); 484 delete_keyboard_wait_descriptor (fd);
485 485
486 fd_callback_info[fd].condition &= ~FOR_READ; 486 fd_callback_info[fd].condition &= ~FOR_READ;
@@ -497,7 +497,7 @@ delete_read_fd (int fd)
497void 497void
498add_write_fd (int fd, fd_callback func, void *data) 498add_write_fd (int fd, fd_callback func, void *data)
499{ 499{
500 eassert (fd < MAXDESC); 500 eassert (fd < FD_SETSIZE);
501 FD_SET (fd, &write_mask); 501 FD_SET (fd, &write_mask);
502 if (fd > max_input_desc) 502 if (fd > max_input_desc)
503 max_input_desc = fd; 503 max_input_desc = fd;
@@ -528,7 +528,7 @@ delete_input_desc (int fd)
528void 528void
529delete_write_fd (int fd) 529delete_write_fd (int fd)
530{ 530{
531 eassert (fd < MAXDESC); 531 eassert (fd < FD_SETSIZE);
532 FD_CLR (fd, &write_mask); 532 FD_CLR (fd, &write_mask);
533 fd_callback_info[fd].condition &= ~FOR_WRITE; 533 fd_callback_info[fd].condition &= ~FOR_WRITE;
534 if (fd_callback_info[fd].condition == 0) 534 if (fd_callback_info[fd].condition == 0)
@@ -3232,7 +3232,7 @@ usage: (make-network-process &rest ARGS) */)
3232 wait for completion is pselect(). */ 3232 wait for completion is pselect(). */
3233 int sc; 3233 int sc;
3234 socklen_t len; 3234 socklen_t len;
3235 SELECT_TYPE fdset; 3235 fd_set fdset;
3236 retry_select: 3236 retry_select:
3237 FD_ZERO (&fdset); 3237 FD_ZERO (&fdset);
3238 FD_SET (s, &fdset); 3238 FD_SET (s, &fdset);
@@ -4232,8 +4232,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4232 struct Lisp_Process *wait_proc, int just_wait_proc) 4232 struct Lisp_Process *wait_proc, int just_wait_proc)
4233{ 4233{
4234 int channel, nfds; 4234 int channel, nfds;
4235 SELECT_TYPE Available; 4235 fd_set Available;
4236 SELECT_TYPE Writeok; 4236 fd_set Writeok;
4237 bool check_write; 4237 bool check_write;
4238 int check_delay; 4238 int check_delay;
4239 bool no_avail; 4239 bool no_avail;
@@ -4387,8 +4387,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4387 timeout to get our attention. */ 4387 timeout to get our attention. */
4388 if (update_tick != process_tick) 4388 if (update_tick != process_tick)
4389 { 4389 {
4390 SELECT_TYPE Atemp; 4390 fd_set Atemp;
4391 SELECT_TYPE Ctemp; 4391 fd_set Ctemp;
4392 4392
4393 if (kbd_on_hold_p ()) 4393 if (kbd_on_hold_p ())
4394 FD_ZERO (&Atemp); 4394 FD_ZERO (&Atemp);
@@ -4571,7 +4571,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4571 the gnutls library -- 2.12.14 has been confirmed 4571 the gnutls library -- 2.12.14 has been confirmed
4572 to need it. See 4572 to need it. See
4573 http://comments.gmane.org/gmane.emacs.devel/145074 */ 4573 http://comments.gmane.org/gmane.emacs.devel/145074 */
4574 for (channel = 0; channel < MAXDESC; ++channel) 4574 for (channel = 0; channel < FD_SETSIZE; ++channel)
4575 if (! NILP (chan_process[channel])) 4575 if (! NILP (chan_process[channel]))
4576 { 4576 {
4577 struct Lisp_Process *p = 4577 struct Lisp_Process *p =
@@ -6542,7 +6542,7 @@ keyboard_bit_set (fd_set *mask)
6542#else /* not subprocesses */ 6542#else /* not subprocesses */
6543 6543
6544/* Defined on msdos.c. */ 6544/* Defined on msdos.c. */
6545extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, 6545extern int sys_select (int, fd_set *, fd_set *, fd_set *,
6546 struct timespec *, void *); 6546 struct timespec *, void *);
6547 6547
6548/* Implementation of wait_reading_process_output, assuming that there 6548/* Implementation of wait_reading_process_output, assuming that there
@@ -6608,7 +6608,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6608 while (1) 6608 while (1)
6609 { 6609 {
6610 bool timeout_reduced_for_timers = 0; 6610 bool timeout_reduced_for_timers = 0;
6611 SELECT_TYPE waitchannels; 6611 fd_set waitchannels;
6612 int xerrno; 6612 int xerrno;
6613 6613
6614 /* If calling from keyboard input, do not quit 6614 /* If calling from keyboard input, do not quit
@@ -7072,7 +7072,7 @@ init_process_emacs (void)
7072 7072
7073 Vprocess_alist = Qnil; 7073 Vprocess_alist = Qnil;
7074 deleted_pid_list = Qnil; 7074 deleted_pid_list = Qnil;
7075 for (i = 0; i < MAXDESC; i++) 7075 for (i = 0; i < FD_SETSIZE; i++)
7076 { 7076 {
7077 chan_process[i] = Qnil; 7077 chan_process[i] = Qnil;
7078 proc_buffered_char[i] = -1; 7078 proc_buffered_char[i] = -1;
diff --git a/src/sysdep.c b/src/sysdep.c
index e43991f41ab..6439697501e 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -588,7 +588,7 @@ restore_signal_handlers (struct save_signal *saved_handlers)
588} 588}
589 589
590#ifdef USABLE_SIGIO 590#ifdef USABLE_SIGIO
591static int old_fcntl_flags[MAXDESC]; 591static int old_fcntl_flags[FD_SETSIZE];
592#endif 592#endif
593 593
594void 594void
@@ -817,7 +817,7 @@ emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp)
817 817
818 818
819#ifdef F_SETOWN 819#ifdef F_SETOWN
820static int old_fcntl_owner[MAXDESC]; 820static int old_fcntl_owner[FD_SETSIZE];
821#endif /* F_SETOWN */ 821#endif /* F_SETOWN */
822 822
823/* This may also be defined in stdio, 823/* This may also be defined in stdio,
diff --git a/src/sysselect.h b/src/sysselect.h
index 0a4f7e3ad96..5df0af9ed37 100644
--- a/src/sysselect.h
+++ b/src/sysselect.h
@@ -25,15 +25,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25 definitions in w32.h are incompatible with the below. */ 25 definitions in w32.h are incompatible with the below. */
26#ifndef WINDOWSNT 26#ifndef WINDOWSNT
27#ifdef FD_SET 27#ifdef FD_SET
28#ifdef FD_SETSIZE 28#ifndef FD_SETSIZE
29#define MAXDESC FD_SETSIZE 29#define FD_SETSIZE 64
30#else
31#define MAXDESC 64
32#endif 30#endif
33#define SELECT_TYPE fd_set
34#else /* no FD_SET */ 31#else /* no FD_SET */
35#define MAXDESC 32 32#define FD_SETSIZE 32
36#define SELECT_TYPE int 33typedef int fd_set;
37 34
38/* Define the macros to access a single-int bitmap of descriptors. */ 35/* Define the macros to access a single-int bitmap of descriptors. */
39#define FD_SET(n, p) (*(p) |= (1 << (n))) 36#define FD_SET(n, p) (*(p) |= (1 << (n)))
diff --git a/src/xgselect.c b/src/xgselect.c
index 45a34f2e0a5..7a754bd75c0 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -29,10 +29,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29#include "frame.h" 29#include "frame.h"
30 30
31int 31int
32xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 32xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds,
33 struct timespec const *timeout, sigset_t const *sigmask) 33 struct timespec const *timeout, sigset_t const *sigmask)
34{ 34{
35 SELECT_TYPE all_rfds, all_wfds; 35 fd_set all_rfds, all_wfds;
36 struct timespec tmo; 36 struct timespec tmo;
37 struct timespec const *tmop = timeout; 37 struct timespec const *tmop = timeout;
38 38
diff --git a/src/xgselect.h b/src/xgselect.h
index f85c17f7190..1f8555591d0 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -25,9 +25,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25#include "sysselect.h" 25#include "sysselect.h"
26 26
27extern int xg_select (int max_fds, 27extern int xg_select (int max_fds,
28 SELECT_TYPE *rfds, 28 fd_set *rfds, fd_set *wfds, fd_set *efds,
29 SELECT_TYPE *wfds,
30 SELECT_TYPE *efds,
31 struct timespec const *timeout, 29 struct timespec const *timeout,
32 sigset_t const *sigmask); 30 sigset_t const *sigmask);
33 31
diff --git a/src/xmenu.c b/src/xmenu.c
index 98473939373..823c63bfc6f 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -378,7 +378,7 @@ x_menu_wait_for_event (void *data)
378 ) 378 )
379 { 379 {
380 struct timespec next_time = timer_check (), *ntp; 380 struct timespec next_time = timer_check (), *ntp;
381 SELECT_TYPE read_fds; 381 fd_set read_fds;
382 struct x_display_info *dpyinfo; 382 struct x_display_info *dpyinfo;
383 int n = 0; 383 int n = 0;
384 384
diff --git a/src/xterm.c b/src/xterm.c
index 5a67c3b6f2f..777f13e431c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8676,7 +8676,7 @@ x_wait_for_event (struct frame *f, int eventtype)
8676{ 8676{
8677 int level = interrupt_input_blocked; 8677 int level = interrupt_input_blocked;
8678 8678
8679 SELECT_TYPE fds; 8679 fd_set fds;
8680 struct timespec tmo, tmo_at, time_now; 8680 struct timespec tmo, tmo_at, time_now;
8681 int fd = ConnectionNumber (FRAME_X_DISPLAY (f)); 8681 int fd = ConnectionNumber (FRAME_X_DISPLAY (f));
8682 8682