mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
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.
This commit is contained in:
parent
b73517d9ec
commit
d486344e6f
9 changed files with 46 additions and 44 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -4686,7 +4686,7 @@ - (void)fd_handler:(id)unused
|
|||
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 @@ - (void)fd_handler:(id)unused
|
|||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -588,7 +588,7 @@ restore_signal_handlers (struct save_signal *saved_handlers)
|
|||
}
|
||||
|
||||
#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)
|
|||
|
||||
|
||||
#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,
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue