#define process_output_delay_count 0
#endif
-static Lisp_Object Fget_process (Lisp_Object);
static void create_process (Lisp_Object, char **, Lisp_Object);
#ifdef SIGIO
static int keyboard_bit_set (SELECT_TYPE *);
void
add_read_fd (int fd, fd_callback func, void *data)
{
- xassert (fd < MAXDESC);
+ eassert (fd < MAXDESC);
add_keyboard_wait_descriptor (fd);
fd_callback_info[fd].func = func;
void
delete_read_fd (int fd)
{
- xassert (fd < MAXDESC);
+ eassert (fd < MAXDESC);
delete_keyboard_wait_descriptor (fd);
fd_callback_info[fd].condition &= ~FOR_READ;
void
add_write_fd (int fd, fd_callback func, void *data)
{
- xassert (fd < MAXDESC);
+ eassert (fd < MAXDESC);
FD_SET (fd, &write_mask);
if (fd > max_input_desc)
max_input_desc = fd;
{
int lim = max_input_desc;
- xassert (fd < MAXDESC);
+ eassert (fd < MAXDESC);
FD_CLR (fd, &write_mask);
fd_callback_info[fd].condition &= ~FOR_WRITE;
if (fd_callback_info[fd].condition == 0)
{
tem = Fget_process (name1);
if (NILP (tem)) break;
- sprintf (suffix, "<%"pMd">", i);
- name1 = concat2 (name, build_string (suffix));
+ name1 = concat2 (name, make_formatted_string (suffix, "<%"pMd">", i));
}
name = name1;
p->name = name;
(register Lisp_Object process, Lisp_Object height, Lisp_Object width)
{
CHECK_PROCESS (process);
- CHECK_RANGED_INTEGER (0, height, INT_MAX);
- CHECK_RANGED_INTEGER (0, width, INT_MAX);
+ CHECK_RANGED_INTEGER (height, 0, INT_MAX);
+ CHECK_RANGED_INTEGER (width, 0, INT_MAX);
if (XPROCESS (process)->infd < 0
|| set_window_size (XPROCESS (process)->infd,
return (XPROCESS (process)->kill_without_query ? Qnil : Qt);
}
-#ifdef DATAGRAM_SOCKETS
-static Lisp_Object Fprocess_datagram_address (Lisp_Object);
-#endif
-
DEFUN ("process-contact", Fprocess_contact, Sprocess_contact,
1, 2, 0,
doc: /* Return the contact info of PROCESS; t for a real child.
val = Vcoding_system_for_read;
if (NILP (val))
{
- args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2);
+ args2 = alloca ((nargs + 1) * sizeof *args2);
args2[0] = Qstart_process;
for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
GCPRO2 (proc, current_dir);
{
if (EQ (coding_systems, Qt))
{
- args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2);
+ args2 = alloca ((nargs + 1) * sizeof *args2);
args2[0] = Qstart_process;
for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
GCPRO2 (proc, current_dir);
/* Now that everything is encoded we can collect the strings into
NEW_ARGV. */
- new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
+ new_argv = alloca ((nargs - 1) * sizeof *new_argv);
new_argv[nargs - 2] = 0;
for (i = nargs - 2; i-- != 0; )
So have an interrupt jar it loose. */
{
struct atimer *timer;
- EMACS_TIME offset;
+ EMACS_TIME offset = make_emacs_time (1, 0);
stop_polling ();
- EMACS_SET_SECS_USECS (offset, 1, 0);
timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0);
if (forkin >= 0)
CHECK_STRING (service);
memset (&address_un, 0, sizeof address_un);
address_un.sun_family = AF_LOCAL;
- strncpy (address_un.sun_path, SSDATA (service), sizeof address_un.sun_path);
+ if (sizeof address_un.sun_path <= SBYTES (service))
+ error ("Service name too long");
+ strcpy (address_un.sun_path, SSDATA (service));
ai.ai_addr = (struct sockaddr *) &address_un;
ai.ai_addrlen = sizeof address_un;
goto open_socket;
{
if (datagram_address[s].sa)
abort ();
- datagram_address[s].sa = (struct sockaddr *) xmalloc (lres->ai_addrlen);
+ datagram_address[s].sa = xmalloc (lres->ai_addrlen);
datagram_address[s].len = lres->ai_addrlen;
if (is_server)
{
CHECK_STRING (ifname);
- memset (rq.ifr_name, 0, sizeof rq.ifr_name);
- strncpy (rq.ifr_name, SSDATA (ifname), sizeof (rq.ifr_name));
+ if (sizeof rq.ifr_name <= SBYTES (ifname))
+ error ("interface name too long");
+ strcpy (rq.ifr_name, SSDATA (ifname));
s = socket (AF_INET, SOCK_STREAM, 0);
if (s < 0)
If NSECS > 0, the timeout consists of NSECS only.
If NSECS < 0, gobble data immediately, as if TIME_LIMIT were negative.
- READ_KBD is a lisp value:
+ READ_KBD is:
0 to ignore keyboard input, or
1 to return when input is available, or
-1 meaning caller will actually read the input, so don't throw to
/* Since we may need to wait several times,
compute the absolute time to return at. */
- if (time_limit || nsecs) /* FIXME neither should be negative, no? */
+ if (time_limit || 0 < nsecs)
{
- EMACS_GET_TIME (end_time);
- EMACS_SET_SECS_NSECS (timeout, time_limit, nsecs);
- EMACS_ADD_TIME (end_time, end_time, timeout);
+ timeout = make_emacs_time (time_limit, nsecs);
+ end_time = add_emacs_time (current_emacs_time (), timeout);
}
while (1)
/* Exit if already run out */
if (nsecs < 0)
{
- /* -1 specified for timeout means
+ /* A negative timeout means
gobble output available now
but don't wait at all. */
- EMACS_SET_SECS_USECS (timeout, 0, 0);
+ timeout = make_emacs_time (0, 0);
}
- else if (time_limit || nsecs)
+ else if (time_limit || 0 < nsecs)
{
- EMACS_GET_TIME (timeout);
- if (EMACS_TIME_LE (end_time, timeout))
+ EMACS_TIME now = current_emacs_time ();
+ if (EMACS_TIME_LE (end_time, now))
break;
- EMACS_SUB_TIME (timeout, end_time, timeout);
+ timeout = sub_emacs_time (end_time, now);
}
else
{
- EMACS_SET_SECS_USECS (timeout, 100000, 0);
+ timeout = make_emacs_time (100000, 0);
}
/* Normally we run timers here.
&& requeued_events_pending_p ())
break;
- /* If time_limit is negative, we are not going to wait at all. */
+ /* A negative timeout means do not wait at all. */
if (0 <= nsecs)
{
if (EMACS_TIME_VALID_P (timer_delay))
Atemp = input_wait_mask;
Ctemp = write_mask;
- EMACS_SET_SECS_USECS (timeout, 0, 0);
+ timeout = make_emacs_time (0, 0);
if ((pselect (max (max_process_desc, max_input_desc) + 1,
&Atemp,
#ifdef NON_BLOCKING_CONNECT
nsecs = XPROCESS (proc)->read_output_delay;
}
}
- EMACS_SET_SECS_NSECS (timeout, 0, nsecs);
+ timeout = make_emacs_time (0, nsecs);
process_output_skip = 0;
}
#endif
do_pending_window_change (0);
if ((time_limit || nsecs) && nfds == 0 && ! timeout_reduced_for_timers)
- /* We wanted the full specified time, so return now. */
+ /* We waited the full specified time, so return now. */
break;
if (nfds < 0)
{
ptrdiff_t count = SPECPDL_INDEX ();
Lisp_Object odeactivate;
- chars = (char *) alloca (carryover + readmax);
+ chars = alloca (carryover + readmax);
if (carryover)
/* See the comment above. */
memcpy (chars, SDATA (p->decoding_buf), carryover);
if (!proc_encode_coding_system[new_outfd])
proc_encode_coding_system[new_outfd]
- = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+ = xmalloc (sizeof (struct coding_system));
memcpy (proc_encode_coding_system[new_outfd],
proc_encode_coding_system[old_outfd],
sizeof (struct coding_system));
/* Tell wait_reading_process_output that it needs to wake up and
look around. */
if (input_available_clear_time)
- EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
+ *input_available_clear_time = make_emacs_time (0, 0);
}
/* There was no asynchronous process found for that pid: we have
/* Tell wait_reading_process_output that it needs to wake up and
look around. */
if (input_available_clear_time)
- EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
+ *input_available_clear_time = make_emacs_time (0, 0);
}
sigchld_end_of_loop:
/* Defined on msdos.c. */
extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
- EMACS_TIME *);
+ EMACS_TIME *, void *);
/* Implementation of wait_reading_process_output, assuming that there
are no subprocesses. Used only by the MS-DOS build.
If NSECS > 0, the timeout consists of NSECS only.
If NSECS < 0, gobble data immediately, as if TIME_LIMIT were negative.
- READ_KBD is a Lisp_Object:
+ READ_KBD is:
0 to ignore keyboard input, or
1 to return when input is available, or
-1 means caller will actually read the input, so don't throw to
{
register int nfds;
EMACS_TIME end_time, timeout;
- SELECT_TYPE waitchannels;
- int xerrno;
if (time_limit < 0)
{
time_limit = TYPE_MAXIMUM (time_t);
/* What does time_limit really mean? */
- if (time_limit || nsecs) /* FIXME: what if negative? */
+ if (time_limit || 0 < nsecs)
{
- EMACS_GET_TIME (end_time);
- EMACS_SET_SECS_NSECS (timeout, time_limit, nsecs);
- EMACS_ADD_TIME (end_time, end_time, timeout);
+ timeout = make_emacs_time (time_limit, nsecs);
+ end_time = add_emacs_time (current_emacs_time (), timeout);
}
/* Turn off periodic alarms (in case they are in use)
while (1)
{
int timeout_reduced_for_timers = 0;
+ SELECT_TYPE waitchannels;
+ int xerrno;
/* If calling from keyboard input, do not quit
since we want to return C-g as an input character.
/* Exit if already run out */
if (nsecs < 0)
{
- /* -1 specified for timeout means
+ /* A negative timeout means
gobble output available now
but don't wait at all. */
- EMACS_SET_SECS_USECS (timeout, 0, 0);
+ timeout = make_emacs_time (0, 0);
}
- else if (time_limit || nsecs)
+ else if (time_limit || 0 < nsecs)
{
- EMACS_GET_TIME (timeout);
- if (EMACS_TIME_LE (end_time, timeout))
+ EMACS_TIME now = current_emacs_time ();
+ if (EMACS_TIME_LE (end_time, now))
break;
- EMACS_SUB_TIME (timeout, end_time, timeout);
+ timeout = sub_emacs_time (end_time, now);
}
else
{
- EMACS_SET_SECS_USECS (timeout, 100000, 0);
+ timeout = make_emacs_time (100000, 0);
}
/* If our caller will not immediately handle keyboard events,
if (read_kbd < 0)
set_waiting_for_input (&timeout);
- /* Wait till there is something to do. */
-
- if (! read_kbd && NILP (wait_for_cell))
- FD_ZERO (&waitchannels);
- else
- FD_SET (0, &waitchannels);
-
/* If a frame has been newly mapped and needs updating,
reprocess its display stuff. */
if (frame_garbaged && do_display)
set_waiting_for_input (&timeout);
}
+ /* Wait till there is something to do. */
+ FD_ZERO (&waitchannels);
if (read_kbd && detect_input_pending ())
+ nfds = 0;
+ else
{
- nfds = 0;
- FD_ZERO (&waitchannels);
+ if (read_kbd || !NILP (wait_for_cell))
+ FD_SET (0, &waitchannels);
+ nfds = pselect (1, &waitchannels, NULL, NULL, &timeout, NULL);
}
- else
- nfds = pselect (1, &waitchannels, NULL, NULL, &timeout, NULL);
xerrno = errno;
return;
if (!proc_decode_coding_system[inch])
- proc_decode_coding_system[inch]
- = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+ proc_decode_coding_system[inch] = xmalloc (sizeof (struct coding_system));
coding_system = p->decode_coding_system;
if (! NILP (p->filter))
;
setup_coding_system (coding_system, proc_decode_coding_system[inch]);
if (!proc_encode_coding_system[outch])
- proc_encode_coding_system[outch]
- = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+ proc_encode_coding_system[outch] = xmalloc (sizeof (struct coding_system));
setup_coding_system (p->encode_coding_system,
proc_encode_coding_system[outch]);
#endif
}
\f
+/* This is not called "init_process" because that is the name of a
+ Mach system call, so it would cause problems on Darwin systems. */
void
-init_process (void)
+init_process_emacs (void)
{
#ifdef subprocesses
register int i;
char const *release = (STRINGP (Voperating_system_release)
? SSDATA (Voperating_system_release)
: 0);
- if (!release || !release[0] || (release[0] < MIN_PTY_KERNEL_VERSION
- && release[1] == '.')) {
+ if (!release || !release[0] || (release[0] < '7' && release[1] == '.')) {
Vprocess_connection_type = Qnil;
}
}