]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify SELECT_TYPE-related code.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 27 Aug 2013 19:36:28 +0000 (12:36 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 27 Aug 2013 19:36:28 +0000 (12:36 -0700)
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.

src/ChangeLog
src/nsterm.m
src/process.c
src/sysdep.c
src/sysselect.h
src/xgselect.c
src/xgselect.h
src/xmenu.c
src/xterm.c

index 5d5a811b3c483c7ca773a98e40d5d334559cea0f..185619f18906aa83cfd42fb3c7e23a8dc23d43d4 100644 (file)
@@ -1,5 +1,12 @@
 2013-08-27  Paul Eggert  <eggert@cs.ucla.edu>
 
+       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.
+
        Simplify EMACS_TIME-related code.
        This portability layer is no longer needed, since Emacs has been
        using struct timespec as a portability layer for some time.
index ec365df0c224fc6dd22f7c4832fd170481931a90..01ee2319ddf0a4d2cd00bdf1ee03a77ebffd6a92 100644 (file)
@@ -4686,7 +4686,7 @@ not_in_argv (NSString *arg)
   int waiting = 1, nfds;
   char c;
 
-  SELECT_TYPE readfds, writefds, *wfds;
+  fd_set readfds, writefds, *wfds;
   struct timespec timeout, *tmo;
   NSAutoreleasePool *pool = nil;
 
@@ -4699,7 +4699,7 @@ not_in_argv (NSString *arg)
 
       if (waiting)
         {
-          SELECT_TYPE fds;
+          fd_set fds;
           FD_ZERO (&fds);
           FD_SET (selfds[0], &fds);
           result = select (selfds[0]+1, &fds, NULL, NULL, NULL);
index 3b62f45bf0ab624c09bffdc7c0da90cb7b100abc..b52622ec1b671605dc91d5e0330e2eb316cfdb8e 100644 (file)
@@ -132,7 +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 *,
+extern int sys_select (int, fd_set *, fd_set *, fd_set *,
                       struct timespec *, void *);
 #endif
 
@@ -280,7 +280,7 @@ static bool process_output_skip;
 
 static void create_process (Lisp_Object, char **, Lisp_Object);
 #ifdef USABLE_SIGIO
-static bool keyboard_bit_set (SELECT_TYPE *);
+static bool keyboard_bit_set (fd_set *);
 #endif
 static void deactivate_process (Lisp_Object);
 static void status_notify (struct Lisp_Process *);
@@ -299,26 +299,26 @@ static void exec_sentinel (Lisp_Object proc, Lisp_Object reason);
 
 /* Mask of bits indicating the descriptors that we wait for input on.  */
 
-static SELECT_TYPE input_wait_mask;
+static fd_set input_wait_mask;
 
 /* Mask that excludes keyboard input descriptor(s).  */
 
-static SELECT_TYPE non_keyboard_wait_mask;
+static fd_set non_keyboard_wait_mask;
 
 /* Mask that excludes process input descriptor(s).  */
 
-static SELECT_TYPE non_process_wait_mask;
+static fd_set non_process_wait_mask;
 
 /* Mask for selecting for write.  */
 
-static SELECT_TYPE write_mask;
+static fd_set write_mask;
 
 #ifdef NON_BLOCKING_CONNECT
 /* Mask of bits indicating the descriptors that we wait for connect to
    complete on.  Once they complete, they are removed from this mask
    and added to the input_wait_mask and non_keyboard_wait_mask.  */
 
-static SELECT_TYPE connect_wait_mask;
+static fd_set connect_wait_mask;
 
 /* Number of bits set in connect_wait_mask.  */
 static int num_pending_connects;
@@ -331,7 +331,7 @@ static int max_process_desc;
 static int max_input_desc;
 
 /* Indexed by descriptor, gives the process (if any) for that descriptor */
-static Lisp_Object chan_process[MAXDESC];
+static Lisp_Object chan_process[FD_SETSIZE];
 
 /* Alist of elements (NAME . PROCESS) */
 static Lisp_Object Vprocess_alist;
@@ -342,18 +342,18 @@ static Lisp_Object Vprocess_alist;
    output from the process is to read at least one char.
    Always -1 on systems that support FIONREAD.  */
 
-static int proc_buffered_char[MAXDESC];
+static int proc_buffered_char[FD_SETSIZE];
 
 /* Table of `struct coding-system' for each process.  */
-static struct coding_system *proc_decode_coding_system[MAXDESC];
-static struct coding_system *proc_encode_coding_system[MAXDESC];
+static struct coding_system *proc_decode_coding_system[FD_SETSIZE];
+static struct coding_system *proc_encode_coding_system[FD_SETSIZE];
 
 #ifdef DATAGRAM_SOCKETS
 /* Table of `partner address' for datagram sockets.  */
 static struct sockaddr_and_len {
   struct sockaddr *sa;
   int len;
-} datagram_address[MAXDESC];
+} datagram_address[FD_SETSIZE];
 #define DATAGRAM_CHAN_P(chan)  (datagram_address[chan].sa != 0)
 #define DATAGRAM_CONN_P(proc)  (PROCESSP (proc) && datagram_address[XPROCESS (proc)->infd].sa != 0)
 #else
@@ -458,7 +458,7 @@ static struct fd_callback_data
 #define FOR_READ  1
 #define FOR_WRITE 2
   int condition; /* mask of the defines above.  */
-} fd_callback_info[MAXDESC];
+} fd_callback_info[FD_SETSIZE];
 
 
 /* Add a file descriptor FD to be monitored for when read is possible.
@@ -467,7 +467,7 @@ static struct fd_callback_data
 void
 add_read_fd (int fd, fd_callback func, void *data)
 {
-  eassert (fd < MAXDESC);
+  eassert (fd < FD_SETSIZE);
   add_keyboard_wait_descriptor (fd);
 
   fd_callback_info[fd].func = func;
@@ -480,7 +480,7 @@ add_read_fd (int fd, fd_callback func, void *data)
 void
 delete_read_fd (int fd)
 {
-  eassert (fd < MAXDESC);
+  eassert (fd < FD_SETSIZE);
   delete_keyboard_wait_descriptor (fd);
 
   fd_callback_info[fd].condition &= ~FOR_READ;
@@ -497,7 +497,7 @@ delete_read_fd (int fd)
 void
 add_write_fd (int fd, fd_callback func, void *data)
 {
-  eassert (fd < MAXDESC);
+  eassert (fd < FD_SETSIZE);
   FD_SET (fd, &write_mask);
   if (fd > max_input_desc)
     max_input_desc = fd;
@@ -528,7 +528,7 @@ delete_input_desc (int fd)
 void
 delete_write_fd (int fd)
 {
-  eassert (fd < MAXDESC);
+  eassert (fd < FD_SETSIZE);
   FD_CLR (fd, &write_mask);
   fd_callback_info[fd].condition &= ~FOR_WRITE;
   if (fd_callback_info[fd].condition == 0)
@@ -3232,7 +3232,7 @@ usage: (make-network-process &rest ARGS)  */)
             wait for completion is pselect(). */
          int sc;
          socklen_t len;
-         SELECT_TYPE fdset;
+         fd_set fdset;
        retry_select:
          FD_ZERO (&fdset);
          FD_SET (s, &fdset);
@@ -4232,8 +4232,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
                             struct Lisp_Process *wait_proc, int just_wait_proc)
 {
   int channel, nfds;
-  SELECT_TYPE Available;
-  SELECT_TYPE Writeok;
+  fd_set Available;
+  fd_set Writeok;
   bool check_write;
   int check_delay;
   bool no_avail;
@@ -4387,8 +4387,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
         timeout to get our attention.  */
       if (update_tick != process_tick)
        {
-         SELECT_TYPE Atemp;
-         SELECT_TYPE Ctemp;
+         fd_set Atemp;
+         fd_set Ctemp;
 
           if (kbd_on_hold_p ())
             FD_ZERO (&Atemp);
@@ -4571,7 +4571,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
                     the gnutls library -- 2.12.14 has been confirmed
                     to need it.  See
                     http://comments.gmane.org/gmane.emacs.devel/145074 */
-                 for (channel = 0; channel < MAXDESC; ++channel)
+                 for (channel = 0; channel < FD_SETSIZE; ++channel)
                    if (! NILP (chan_process[channel]))
                      {
                        struct Lisp_Process *p =
@@ -6542,7 +6542,7 @@ keyboard_bit_set (fd_set *mask)
 #else  /* not subprocesses */
 
 /* Defined on msdos.c.  */
-extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
+extern int sys_select (int, fd_set *, fd_set *, fd_set *,
                       struct timespec *, void *);
 
 /* 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,
   while (1)
     {
       bool timeout_reduced_for_timers = 0;
-      SELECT_TYPE waitchannels;
+      fd_set waitchannels;
       int xerrno;
 
       /* If calling from keyboard input, do not quit
@@ -7072,7 +7072,7 @@ init_process_emacs (void)
 
   Vprocess_alist = Qnil;
   deleted_pid_list = Qnil;
-  for (i = 0; i < MAXDESC; i++)
+  for (i = 0; i < FD_SETSIZE; i++)
     {
       chan_process[i] = Qnil;
       proc_buffered_char[i] = -1;
index e43991f41ab0cf215a4d0d7a7e219bdd33433fd3..6439697501e022bcbf21180578d52ec08f0bf0b4 100644 (file)
@@ -588,7 +588,7 @@ restore_signal_handlers (struct save_signal *saved_handlers)
 }
 \f
 #ifdef USABLE_SIGIO
-static int old_fcntl_flags[MAXDESC];
+static int old_fcntl_flags[FD_SETSIZE];
 #endif
 
 void
@@ -817,7 +817,7 @@ emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp)
 \f
 
 #ifdef F_SETOWN
-static int old_fcntl_owner[MAXDESC];
+static int old_fcntl_owner[FD_SETSIZE];
 #endif /* F_SETOWN */
 
 /* This may also be defined in stdio,
index 0a4f7e3ad96cda918ca3a02a0d10b24cffe2c6cf..5df0af9ed37fb1f1ae23d53aa1a811308b4ada59 100644 (file)
@@ -25,15 +25,12 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    definitions in w32.h are incompatible with the below.  */
 #ifndef WINDOWSNT
 #ifdef FD_SET
-#ifdef FD_SETSIZE
-#define MAXDESC FD_SETSIZE
-#else
-#define MAXDESC 64
+#ifndef FD_SETSIZE
+#define FD_SETSIZE 64
 #endif
-#define SELECT_TYPE fd_set
 #else /* no FD_SET */
-#define MAXDESC 32
-#define SELECT_TYPE int
+#define FD_SETSIZE 32
+typedef int fd_set;
 
 /* Define the macros to access a single-int bitmap of descriptors.  */
 #define FD_SET(n, p) (*(p) |= (1 << (n)))
index 45a34f2e0a56c834d84e88e3342dde852e7c3722..7a754bd75c029be5535643060c14db7094c8ee73 100644 (file)
@@ -29,10 +29,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "frame.h"
 
 int
-xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
+xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds,
           struct timespec const *timeout, sigset_t const *sigmask)
 {
-  SELECT_TYPE all_rfds, all_wfds;
+  fd_set all_rfds, all_wfds;
   struct timespec tmo;
   struct timespec const *tmop = timeout;
 
index f85c17f71907e4b139bedb683109df2e2513560e..1f8555591d0ad9b1b3baeed6cf5244e6aa07499b 100644 (file)
@@ -25,9 +25,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "sysselect.h"
 
 extern int xg_select (int max_fds,
-                      SELECT_TYPE *rfds,
-                      SELECT_TYPE *wfds,
-                      SELECT_TYPE *efds,
+                     fd_set *rfds, fd_set *wfds, fd_set *efds,
                      struct timespec const *timeout,
                      sigset_t const *sigmask);
 
index 98473939373f4b024baffc6b5c4578b71d998277..823c63bfc6fb6e3b056cd1aecda5823c970544da 100644 (file)
@@ -378,7 +378,7 @@ x_menu_wait_for_event (void *data)
          )
     {
       struct timespec next_time = timer_check (), *ntp;
-      SELECT_TYPE read_fds;
+      fd_set read_fds;
       struct x_display_info *dpyinfo;
       int n = 0;
 
index 5a67c3b6f2f131c3efd5e4cc529f962fc828d277..777f13e431c6cdf1a03f86491ad1a077615af14c 100644 (file)
@@ -8676,7 +8676,7 @@ x_wait_for_event (struct frame *f, int eventtype)
 {
   int level = interrupt_input_blocked;
 
-  SELECT_TYPE fds;
+  fd_set fds;
   struct timespec tmo, tmo_at, time_now;
   int fd = ConnectionNumber (FRAME_X_DISPLAY (f));