From: Stefan Monnier Date: Thu, 12 Jul 2007 06:36:57 +0000 (+0000) Subject: (struct Lisp_Process): Turn slots infd, outfd, kill_without_query, pty_flag, X-Git-Tag: emacs-pretest-23.0.90~11947 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=60f0fb11dda9422e50dd58fb1e4dff76a960a107;p=emacs.git (struct Lisp_Process): Turn slots infd, outfd, kill_without_query, pty_flag, tick, update_tick, decoding_carryover, inherit_coding_system_flag, filter_multibyte, adaptive_read_buffering, read_output_delay, and read_output_skip from Lisp_Objects to ints. Remove unused encoding_carryover. --- diff --git a/src/ChangeLog b/src/ChangeLog index e920eb57437..80871a10449 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2007-07-12 Stefan Monnier + + * process.h (struct Lisp_Process): Turn slots infd, outfd, + kill_without_query, pty_flag, tick, update_tick, decoding_carryover, + inherit_coding_system_flag, filter_multibyte, adaptive_read_buffering, + read_output_delay, and read_output_skip from Lisp_Objects to ints. + Remove unused encoding_carryover. + * process.c: Adjust all functions accordingly. + 2007-07-12 Richard Stallman * term.c: Include unistd.h only if HAVE_UNISTD_H. diff --git a/src/process.c b/src/process.c index c248a8144db..90d0ee34024 100644 --- a/src/process.c +++ b/src/process.c @@ -393,7 +393,7 @@ struct sockaddr_and_len { int len; } datagram_address[MAXDESC]; #define DATAGRAM_CHAN_P(chan) (datagram_address[chan].sa != 0) -#define DATAGRAM_CONN_P(proc) (PROCESSP (proc) && datagram_address[XINT (XPROCESS (proc)->infd)].sa != 0) +#define DATAGRAM_CONN_P(proc) (PROCESSP (proc) && datagram_address[XPROCESS (proc)->infd].sa != 0) #else #define DATAGRAM_CHAN_P(chan) (0) #define DATAGRAM_CONN_P(proc) (0) @@ -628,19 +628,19 @@ make_process (name) p = allocate_process (); - XSETINT (p->infd, -1); - XSETINT (p->outfd, -1); - XSETFASTINT (p->tick, 0); - XSETFASTINT (p->update_tick, 0); + p->infd = -1; + p->outfd = -1; + p->tick = 0; + p->update_tick = 0; p->pid = 0; p->raw_status_new = 0; p->status = Qrun; p->mark = Fmake_marker (); #ifdef ADAPTIVE_READ_BUFFERING - p->adaptive_read_buffering = Qnil; - XSETFASTINT (p->read_output_delay, 0); - p->read_output_skip = Qnil; + p->adaptive_read_buffering = 0; + p->read_output_delay = 0; + p->read_output_skip = 0; #endif /* If name is already in use, modify it until it is unused. */ @@ -679,8 +679,8 @@ setup_process_coding_systems (process) Lisp_Object process; { struct Lisp_Process *p = XPROCESS (process); - int inch = XINT (p->infd); - int outch = XINT (p->outfd); + int inch = p->infd; + int outch = p->outfd; if (inch < 0 || outch < 0) return; @@ -692,7 +692,7 @@ setup_process_coding_systems (process) proc_decode_coding_system[inch]); if (! NILP (p->filter)) { - if (NILP (p->filter_multibyte)) + if (!p->filter_multibyte) setup_raw_text_coding_system (proc_decode_coding_system[inch]); } else if (BUFFERP (p->buffer)) @@ -815,10 +815,10 @@ nil, indicating the current buffer's process. */) if (NETCONN1_P (p)) { p->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); - XSETINT (p->tick, ++process_tick); + p->tick = ++process_tick; status_notify (p); } - else if (XINT (p->infd) >= 0) + else if (p->infd >= 0) { #ifdef SIGCHLD Lisp_Object symbol; @@ -846,7 +846,7 @@ nil, indicating the current buffer's process. */) /* Do this now, since remove_process will make sigchld_handler do nothing. */ p->status = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); - XSETINT (p->tick, ++process_tick); + p->tick = ++process_tick; status_notify (p); } } @@ -1038,18 +1038,18 @@ The string argument is normally a multibyte string, except: (debug) (set-process-filter process ...) */ - if (XINT (p->infd) >= 0) + if (p->infd >= 0) { if (EQ (filter, Qt) && !EQ (p->status, Qlisten)) { - FD_CLR (XINT (p->infd), &input_wait_mask); - FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); + FD_CLR (p->infd, &input_wait_mask); + FD_CLR (p->infd, &non_keyboard_wait_mask); } else if (EQ (p->filter, Qt) && !EQ (p->command, Qt)) /* Network process not stopped. */ { - FD_SET (XINT (p->infd), &input_wait_mask); - FD_SET (XINT (p->infd), &non_keyboard_wait_mask); + FD_SET (p->infd, &input_wait_mask); + FD_SET (p->infd, &non_keyboard_wait_mask); } } @@ -1111,8 +1111,8 @@ DEFUN ("set-process-window-size", Fset_process_window_size, CHECK_NATNUM (height); CHECK_NATNUM (width); - if (XINT (XPROCESS (process)->infd) < 0 - || set_window_size (XINT (XPROCESS (process)->infd), + if (XPROCESS (process)->infd < 0 + || set_window_size (XPROCESS (process)->infd, XINT (height), XINT (width)) <= 0) return Qnil; else @@ -1140,7 +1140,7 @@ for the process which will run. */) register Lisp_Object process, flag; { CHECK_PROCESS (process); - XPROCESS (process)->inherit_coding_system_flag = flag; + XPROCESS (process)->inherit_coding_system_flag = !NILP (flag); return flag; } @@ -1155,7 +1155,7 @@ the process output. */) register Lisp_Object process; { CHECK_PROCESS (process); - return XPROCESS (process)->inherit_coding_system_flag; + return XPROCESS (process)->inherit_coding_system_flag ? Qt : Qnil; } DEFUN ("set-process-query-on-exit-flag", @@ -1168,7 +1168,7 @@ exiting if PROCESS is running. */) register Lisp_Object process, flag; { CHECK_PROCESS (process); - XPROCESS (process)->kill_without_query = Fnull (flag); + XPROCESS (process)->kill_without_query = NILP (flag); return flag; } @@ -1180,7 +1180,7 @@ DEFUN ("process-query-on-exit-flag", register Lisp_Object process; { CHECK_PROCESS (process); - return Fnull (XPROCESS (process)->kill_without_query); + return (XPROCESS (process)->kill_without_query ? Qnil : Qt); } #ifdef DATAGRAM_SOCKETS @@ -1355,7 +1355,7 @@ list_processes_1 (query_only) p = XPROCESS (proc); if (NILP (p->childp)) continue; - if (!NILP (query_only) && !NILP (p->kill_without_query)) + if (!NILP (query_only) && p->kill_without_query) continue; if (STRINGP (p->name) && ( i = SCHARS (p->name), (i > w_proc))) @@ -1418,7 +1418,7 @@ list_processes_1 (query_only) p = XPROCESS (proc); if (NILP (p->childp)) continue; - if (!NILP (query_only) && !NILP (p->kill_without_query)) + if (!NILP (query_only) && p->kill_without_query) continue; Finsert (1, &p->name); @@ -1494,7 +1494,7 @@ list_processes_1 (query_only) if (NILP (port)) port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil); sprintf (tembuf, "(network %s server on %s)\n", - (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), + (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"), (STRINGP (port) ? (char *)SDATA (port) : "?")); insert_string (tembuf); } @@ -1512,7 +1512,7 @@ list_processes_1 (query_only) if (NILP (host)) host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil); sprintf (tembuf, "(network %s connection to %s)\n", - (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), + (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"), (STRINGP (host) ? (char *)SDATA (host) : "?")); insert_string (tembuf); } @@ -1643,11 +1643,13 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) XPROCESS (proc)->sentinel = Qnil; XPROCESS (proc)->filter = Qnil; XPROCESS (proc)->filter_multibyte - = buffer_defaults.enable_multibyte_characters; + = !NILP (buffer_defaults.enable_multibyte_characters); XPROCESS (proc)->command = Flist (nargs - 2, args + 2); #ifdef ADAPTIVE_READ_BUFFERING - XPROCESS (proc)->adaptive_read_buffering = Vprocess_adaptive_read_buffering; + XPROCESS (proc)->adaptive_read_buffering + = (NILP (Vprocess_adaptive_read_buffering) ? 0 + : EQ (Vprocess_adaptive_read_buffering, Qt) ? 1 : 2); #endif /* Make the process marker point into the process buffer (if any). */ @@ -1778,13 +1780,11 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) #endif /* not VMS */ XPROCESS (proc)->decoding_buf = make_uninit_string (0); - XPROCESS (proc)->decoding_carryover = make_number (0); + XPROCESS (proc)->decoding_carryover = 0; XPROCESS (proc)->encoding_buf = make_uninit_string (0); - XPROCESS (proc)->encoding_carryover = make_number (0); XPROCESS (proc)->inherit_coding_system_flag - = (NILP (buffer) || !inherit_process_coding_system - ? Qnil : Qt); + = (NILP (buffer) || !inherit_process_coding_system); create_process (proc, (char **) new_argv, current_dir); @@ -1956,15 +1956,15 @@ create_process (process, new_argv, current_dir) /* Record this as an active process, with its channels. As a result, child_setup will close Emacs's side of the pipes. */ chan_process[inchannel] = process; - XSETINT (XPROCESS (process)->infd, inchannel); - XSETINT (XPROCESS (process)->outfd, outchannel); + XPROCESS (process)->infd = inchannel; + XPROCESS (process)->outfd = outchannel; /* Previously we recorded the tty descriptor used in the subprocess. It was only used for getting the foreground tty process, so now we just reopen the device (see emacs_get_tty_pgrp) as this is more portable (see USG_SUBTTY_WORKS above). */ - XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil); + XPROCESS (process)->pty_flag = pty_flag; XPROCESS (process)->status = Qrun; setup_process_coding_systems (process); @@ -2481,7 +2481,7 @@ DEFUN ("process-datagram-address", Fprocess_datagram_address, Sprocess_datagram_ if (!DATAGRAM_CONN_P (process)) return Qnil; - channel = XINT (XPROCESS (process)->infd); + channel = XPROCESS (process)->infd; return conv_sockaddr_to_lisp (datagram_address[channel].sa, datagram_address[channel].len); } @@ -2501,7 +2501,7 @@ Returns nil upon error setting address, ADDRESS otherwise. */) if (!DATAGRAM_CONN_P (process)) return Qnil; - channel = XINT (XPROCESS (process)->infd); + channel = XPROCESS (process)->infd; len = get_lisp_to_sockaddr_size (address, &family); if (datagram_address[channel].len != len) @@ -2666,7 +2666,7 @@ OPTION is not a supported option, return nil instead; otherwise return t. */) if (!NETCONN1_P (p)) error ("Process is not a network process"); - s = XINT (p->infd); + s = p->infd; if (s < 0) error ("Process is not running"); @@ -3420,18 +3420,18 @@ usage: (make-network-process &rest ARGS) */) p->buffer = buffer; p->sentinel = sentinel; p->filter = filter; - p->filter_multibyte = buffer_defaults.enable_multibyte_characters; + p->filter_multibyte = !NILP (buffer_defaults.enable_multibyte_characters); /* Override the above only if :filter-multibyte is specified. */ if (! NILP (Fplist_member (contact, QCfilter_multibyte))) - p->filter_multibyte = Fplist_get (contact, QCfilter_multibyte); + p->filter_multibyte = !NILP (Fplist_get (contact, QCfilter_multibyte)); p->log = Fplist_get (contact, QClog); if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) - p->kill_without_query = Qt; + p->kill_without_query = 1; if ((tem = Fplist_get (contact, QCstop), !NILP (tem))) p->command = Qt; p->pid = 0; - XSETINT (p->infd, inch); - XSETINT (p->outfd, outch); + p->infd = inch; + p->outfd = outch; if (is_server && socktype == SOCK_STREAM) p->status = Qlisten; @@ -3552,13 +3552,11 @@ usage: (make-network-process &rest ARGS) */) setup_process_coding_systems (proc); p->decoding_buf = make_uninit_string (0); - p->decoding_carryover = make_number (0); + p->decoding_carryover = 0; p->encoding_buf = make_uninit_string (0); - p->encoding_carryover = make_number (0); p->inherit_coding_system_flag - = (!NILP (tem) || NILP (buffer) || !inherit_process_coding_system - ? Qnil : Qt); + = (!NILP (tem) || NILP (buffer) || !inherit_process_coding_system); UNGCPRO; return proc; @@ -3821,16 +3819,16 @@ deactivate_process (proc) register int inchannel, outchannel; register struct Lisp_Process *p = XPROCESS (proc); - inchannel = XINT (p->infd); - outchannel = XINT (p->outfd); + inchannel = p->infd; + outchannel = p->outfd; #ifdef ADAPTIVE_READ_BUFFERING - if (XINT (p->read_output_delay) > 0) + if (p->read_output_delay > 0) { if (--process_output_delay_count < 0) process_output_delay_count = 0; - XSETINT (p->read_output_delay, 0); - p->read_output_skip = Qnil; + p->read_output_delay = 0; + p->read_output_skip = 0; } #endif @@ -3852,8 +3850,8 @@ deactivate_process (proc) emacs_close (outchannel); #endif - XSETINT (p->infd, -1); - XSETINT (p->outfd, -1); + p->infd = -1; + p->outfd = -1; #ifdef DATAGRAM_SOCKETS if (DATAGRAM_CHAN_P (inchannel)) { @@ -3901,8 +3899,8 @@ close_process_descs () process = chan_process[i]; if (!NILP (process)) { - int in = XINT (XPROCESS (process)->infd); - int out = XINT (XPROCESS (process)->outfd); + int in = XPROCESS (process)->infd; + int out = XPROCESS (process)->outfd; if (in >= 0) emacs_close (in); if (out >= 0 && in != out) @@ -4146,8 +4144,8 @@ server_accept_connection (server, channel) p->filter = ps->filter; p->command = Qnil; p->pid = 0; - XSETINT (p->infd, s); - XSETINT (p->outfd, s); + p->infd = s; + p->outfd = s; p->status = Qrun; /* Client processes for accepted connections are not stopped initially. */ @@ -4170,12 +4168,11 @@ server_accept_connection (server, channel) setup_process_coding_systems (proc); p->decoding_buf = make_uninit_string (0); - p->decoding_carryover = make_number (0); + p->decoding_carryover = 0; p->encoding_buf = make_uninit_string (0); - p->encoding_carryover = make_number (0); p->inherit_coding_system_flag - = (NILP (buffer) ? Qnil : ps->inherit_coding_system_flag); + = (NILP (buffer) ? 0 : ps->inherit_coding_system_flag); if (!NILP (ps->log)) call3 (ps->log, server, proc, @@ -4300,7 +4297,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, /* If wait_proc is a process to watch, set wait_channel accordingly. */ if (wait_proc != NULL) - wait_channel = XINT (wait_proc->infd); + wait_channel = wait_proc->infd; record_unwind_protect (wait_reading_process_output_unwind, make_number (waiting_for_user_input_p)); @@ -4485,9 +4482,9 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, XSETPROCESS (proc, wait_proc); /* Read data from the process, until we exhaust it. */ - while (XINT (wait_proc->infd) >= 0) + while (wait_proc->infd >= 0) { - nread = read_process_output (proc, XINT (wait_proc->infd)); + nread = read_process_output (proc, wait_proc->infd); if (nread == 0) break; @@ -4517,9 +4514,9 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, if (wait_proc && just_wait_proc) { - if (XINT (wait_proc->infd) < 0) /* Terminated */ + if (wait_proc->infd < 0) /* Terminated */ break; - FD_SET (XINT (wait_proc->infd), &Available); + FD_SET (wait_proc->infd, &Available); check_delay = 0; IF_NON_BLOCKING_CONNECT (check_connect = 0); } @@ -4567,7 +4564,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, #ifdef ADAPTIVE_READ_BUFFERING /* Set the timeout for adaptive read buffering if any - process has non-nil read_output_skip and non-zero + process has non-zero read_output_skip and non-zero read_output_delay, and we are not reading output for a specific wait_channel. It is not executed if Vprocess_adaptive_read_buffering is nil. */ @@ -4582,16 +4579,16 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, if (NILP (proc)) continue; /* Find minimum non-zero read_output_delay among the - processes with non-nil read_output_skip. */ - if (XINT (XPROCESS (proc)->read_output_delay) > 0) + processes with non-zero read_output_skip. */ + if (XPROCESS (proc)->read_output_delay > 0) { check_delay--; - if (NILP (XPROCESS (proc)->read_output_skip)) + if (!XPROCESS (proc)->read_output_skip) continue; FD_CLR (channel, &Available); - XPROCESS (proc)->read_output_skip = Qnil; - if (XINT (XPROCESS (proc)->read_output_delay) < usecs) - usecs = XINT (XPROCESS (proc)->read_output_delay); + XPROCESS (proc)->read_output_skip = 0; + if (XPROCESS (proc)->read_output_delay < usecs) + usecs = XPROCESS (proc)->read_output_delay; } } EMACS_SET_SECS_USECS (timeout, 0, usecs); @@ -4864,7 +4861,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, else { /* Preserve status of processes already terminated. */ - XSETINT (XPROCESS (proc)->tick, ++process_tick); + XPROCESS (proc)->tick = ++process_tick; deactivate_process (proc); if (XPROCESS (proc)->raw_status_new) update_status (XPROCESS (proc)); @@ -4916,7 +4913,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, #endif if (xerrno) { - XSETINT (p->tick, ++process_tick); + p->tick = ++process_tick; p->status = Fcons (Qfailed, Fcons (make_number (xerrno), Qnil)); deactivate_process (proc); } @@ -4929,8 +4926,8 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, exec_sentinel (proc, build_string ("open\n")); if (!EQ (p->filter, Qt) && !EQ (p->command, Qt)) { - FD_SET (XINT (p->infd), &input_wait_mask); - FD_SET (XINT (p->infd), &non_keyboard_wait_mask); + FD_SET (p->infd, &input_wait_mask); + FD_SET (p->infd, &non_keyboard_wait_mask); } } } @@ -5004,7 +5001,7 @@ read_process_output (proc, channel) register struct Lisp_Process *p = XPROCESS (proc); register int opoint; struct coding_system *coding = proc_decode_coding_system[channel]; - int carryover = XINT (p->decoding_carryover); + int carryover = p->decoding_carryover; int readmax = 4096; #ifdef VMS @@ -5057,9 +5054,9 @@ read_process_output (proc, channel) { nbytes = emacs_read (channel, chars + carryover, readmax); #ifdef ADAPTIVE_READ_BUFFERING - if (nbytes > 0 && !NILP (p->adaptive_read_buffering)) + if (nbytes > 0 && p->adaptive_read_buffering) { - int delay = XINT (p->read_output_delay); + int delay = p->read_output_delay; if (nbytes < 256) { if (delay < READ_OUTPUT_DELAY_MAX_MAX) @@ -5075,10 +5072,10 @@ read_process_output (proc, channel) if (delay == 0) process_output_delay_count--; } - XSETINT (p->read_output_delay, delay); + p->read_output_delay = delay; if (delay) { - p->read_output_skip = Qt; + p->read_output_skip = 1; process_output_skip = 1; } } @@ -5096,7 +5093,7 @@ read_process_output (proc, channel) } #endif /* not VMS */ - XSETINT (p->decoding_carryover, 0); + p->decoding_carryover = 0; /* At this point, NBYTES holds number of bytes just received (including the one in proc_buffered_char[channel]). */ @@ -5170,14 +5167,14 @@ read_process_output (proc, channel) valid memory because p->outfd will be changed once EOF is sent to the process. */ if (NILP (p->encode_coding_system) - && proc_encode_coding_system[XINT (p->outfd)]) + && proc_encode_coding_system[p->outfd]) { p->encode_coding_system = coding->symbol; setup_coding_system (coding->symbol, - proc_encode_coding_system[XINT (p->outfd)]); - if (proc_encode_coding_system[XINT (p->outfd)]->eol_type + proc_encode_coding_system[p->outfd]); + if (proc_encode_coding_system[p->outfd]->eol_type == CODING_EOL_UNDECIDED) - proc_encode_coding_system[XINT (p->outfd)]->eol_type + proc_encode_coding_system[p->outfd]->eol_type = system_eol_type; } } @@ -5190,9 +5187,9 @@ read_process_output (proc, channel) p->decoding_buf = make_uninit_string (carryover); bcopy (chars + coding->consumed, SDATA (p->decoding_buf), carryover); - XSETINT (p->decoding_carryover, carryover); + p->decoding_carryover = carryover; /* Adjust the multibyteness of TEXT to that of the filter. */ - if (NILP (p->filter_multibyte) != ! STRING_MULTIBYTE (text)) + if (p->filter_multibyte != STRING_MULTIBYTE (text)) text = (STRING_MULTIBYTE (text) ? Fstring_as_unibyte (text) : Fstring_to_multibyte (text)); @@ -5284,14 +5281,14 @@ read_process_output (proc, channel) { p->decode_coding_system = coding->symbol; if (NILP (p->encode_coding_system) - && proc_encode_coding_system[XINT (p->outfd)]) + && proc_encode_coding_system[p->outfd]) { p->encode_coding_system = coding->symbol; setup_coding_system (coding->symbol, - proc_encode_coding_system[XINT (p->outfd)]); - if (proc_encode_coding_system[XINT (p->outfd)]->eol_type + proc_encode_coding_system[p->outfd]); + if (proc_encode_coding_system[p->outfd]->eol_type == CODING_EOL_UNDECIDED) - proc_encode_coding_system[XINT (p->outfd)]->eol_type + proc_encode_coding_system[p->outfd]->eol_type = system_eol_type; } } @@ -5303,7 +5300,7 @@ read_process_output (proc, channel) p->decoding_buf = make_uninit_string (carryover); bcopy (chars + coding->consumed, SDATA (p->decoding_buf), carryover); - XSETINT (p->decoding_carryover, carryover); + p->decoding_carryover = carryover; /* Adjust the multibyteness of TEXT to that of the buffer. */ if (NILP (current_buffer->enable_multibyte_characters) @@ -5422,10 +5419,10 @@ send_process (proc, buf, len, object) update_status (p); if (! EQ (p->status, Qrun)) error ("Process %s not running", SDATA (p->name)); - if (XINT (p->outfd) < 0) + if (p->outfd < 0) error ("Output file descriptor of %s is closed", SDATA (p->name)); - coding = proc_encode_coding_system[XINT (p->outfd)]; + coding = proc_encode_coding_system[p->outfd]; Vlast_coding_system_used = coding->symbol; if ((STRINGP (object) && STRING_MULTIBYTE (object)) @@ -5518,7 +5515,7 @@ send_process (proc, buf, len, object) if (pty_max_bytes == 0) { #if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON) - pty_max_bytes = fpathconf (XFASTINT (p->outfd), _PC_MAX_CANON); + pty_max_bytes = fpathconf (p->outfd, _PC_MAX_CANON); if (pty_max_bytes < 0) pty_max_bytes = 250; #else @@ -5540,7 +5537,7 @@ send_process (proc, buf, len, object) /* Decide how much data we can send in one batch. Long lines need to be split into multiple batches. */ - if (!NILP (p->pty_flag)) + if (p->pty_flag) { /* Starting this at zero is always correct when not the first iteration because the previous iteration ended by sending C-d. @@ -5569,7 +5566,7 @@ send_process (proc, buf, len, object) /* Send this batch, using one or more write calls. */ while (this > 0) { - int outfd = XINT (p->outfd); + int outfd = p->outfd; old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap); #ifdef DATAGRAM_SOCKETS if (DATAGRAM_CHAN_P (outfd)) @@ -5589,12 +5586,12 @@ send_process (proc, buf, len, object) { rv = emacs_write (outfd, (char *) buf, this); #ifdef ADAPTIVE_READ_BUFFERING - if (XINT (p->read_output_delay) > 0 - && EQ (p->adaptive_read_buffering, Qt)) + if (p->read_output_delay > 0 + && p->adaptive_read_buffering == 1) { - XSETFASTINT (p->read_output_delay, 0); + p->read_output_delay = 0; process_output_delay_count--; - p->read_output_skip = Qnil; + p->read_output_skip = 0; } #endif } @@ -5637,7 +5634,7 @@ send_process (proc, buf, len, object) if (errno == EAGAIN) { int flags = FWRITE; - ioctl (XINT (p->outfd), TIOCFLUSH, &flags); + ioctl (p->outfd, TIOCFLUSH, &flags); } #endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ @@ -5686,7 +5683,7 @@ send_process (proc, buf, len, object) #endif p->raw_status_new = 0; p->status = Fcons (Qexit, Fcons (make_number (256), Qnil)); - XSETINT (p->tick, ++process_tick); + p->tick = ++process_tick; deactivate_process (proc); #ifdef VMS error ("Error writing to process %s; closed it", SDATA (p->name)); @@ -5738,10 +5735,10 @@ send_process_object (proc, start, end) update_status (p); if (! EQ (p->status, Qrun)) error ("Process %s not running", SDATA (p->name)); - if (XINT (p->outfd) < 0) + if (p->outfd < 0) error ("Output file descriptor of %s is closed", SDATA (p->name)); - coding = proc_encode_coding_system[XINT (p->outfd)]; + coding = proc_encode_coding_system[p->outfd]; if (! EQ (coding->symbol, p->encode_coding_system)) /* The coding system for encoding was changed to raw-text because we sent a unibyte text previously. Now we are @@ -5830,7 +5827,7 @@ emacs_get_tty_pgrp (p) int gid = -1; #ifdef TIOCGPGRP - if (ioctl (XINT (p->infd), TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) + if (ioctl (p->infd, TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) { int fd; /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the @@ -5868,7 +5865,7 @@ return t unconditionally. */) if (!EQ (p->childp, Qt)) error ("Process %s is not a subprocess", SDATA (p->name)); - if (XINT (p->infd) < 0) + if (p->infd < 0) error ("Process %s is not active", SDATA (p->name)); @@ -5911,11 +5908,11 @@ process_send_signal (process, signo, current_group, nomsg) if (!EQ (p->childp, Qt)) error ("Process %s is not a subprocess", SDATA (p->name)); - if (XINT (p->infd) < 0) + if (p->infd < 0) error ("Process %s is not active", SDATA (p->name)); - if (NILP (p->pty_flag)) + if (!p->pty_flag) current_group = Qnil; /* If we are using pgrps, get a pgrp number and make it negative. */ @@ -5934,7 +5931,7 @@ process_send_signal (process, signo, current_group, nomsg) struct termios t; cc_t *sig_char = NULL; - tcgetattr (XINT (p->infd), &t); + tcgetattr (p->infd, &t); switch (signo) { @@ -5974,16 +5971,16 @@ process_send_signal (process, signo, current_group, nomsg) switch (signo) { case SIGINT: - ioctl (XINT (p->infd), TIOCGETC, &c); + ioctl (p->infd, TIOCGETC, &c); send_process (proc, &c.t_intrc, 1, Qnil); return; case SIGQUIT: - ioctl (XINT (p->infd), TIOCGETC, &c); + ioctl (p->infd, TIOCGETC, &c); send_process (proc, &c.t_quitc, 1, Qnil); return; #ifdef SIGTSTP case SIGTSTP: - ioctl (XINT (p->infd), TIOCGLTC, &lc); + ioctl (p->infd, TIOCGLTC, &lc); send_process (proc, &lc.t_suspc, 1, Qnil); return; #endif /* ! defined (SIGTSTP) */ @@ -5998,16 +5995,16 @@ process_send_signal (process, signo, current_group, nomsg) switch (signo) { case SIGINT: - ioctl (XINT (p->infd), TCGETA, &t); + ioctl (p->infd, TCGETA, &t); send_process (proc, &t.c_cc[VINTR], 1, Qnil); return; case SIGQUIT: - ioctl (XINT (p->infd), TCGETA, &t); + ioctl (p->infd, TCGETA, &t); send_process (proc, &t.c_cc[VQUIT], 1, Qnil); return; #ifdef SIGTSTP case SIGTSTP: - ioctl (XINT (p->infd), TCGETA, &t); + ioctl (p->infd, TCGETA, &t); send_process (proc, &t.c_cc[VSWTCH], 1, Qnil); return; #endif /* ! defined (SIGTSTP) */ @@ -6065,7 +6062,7 @@ process_send_signal (process, signo, current_group, nomsg) case SIGCONT: p->raw_status_new = 0; p->status = Qrun; - XSETINT (p->tick, ++process_tick); + p->tick = ++process_tick; if (!nomsg) status_notify (NULL); break; @@ -6085,7 +6082,7 @@ process_send_signal (process, signo, current_group, nomsg) sys$forcex (&(p->pid), 0, 1); whoosh: #endif - flush_pending_output (XINT (p->infd)); + flush_pending_output (p->infd); break; } @@ -6102,7 +6099,7 @@ process_send_signal (process, signo, current_group, nomsg) #ifdef TIOCSIGSEND if (!NILP (current_group)) { - if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1) + if (ioctl (p->infd, TIOCSIGSEND, signo) == -1) EMACS_KILLPG (gid, signo); } else @@ -6168,10 +6165,10 @@ If PROCESS is a network process, inhibit handling of incoming traffic. */) p = XPROCESS (process); if (NILP (p->command) - && XINT (p->infd) >= 0) + && p->infd >= 0) { - FD_CLR (XINT (p->infd), &input_wait_mask); - FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); + FD_CLR (p->infd, &input_wait_mask); + FD_CLR (p->infd, &non_keyboard_wait_mask); } p->command = Qt; return process; @@ -6199,11 +6196,11 @@ If PROCESS is a network process, resume handling of incoming traffic. */) p = XPROCESS (process); if (EQ (p->command, Qt) - && XINT (p->infd) >= 0 + && p->infd >= 0 && (!EQ (p->filter, Qt) || EQ (p->status, Qlisten))) { - FD_SET (XINT (p->infd), &input_wait_mask); - FD_SET (XINT (p->infd), &non_keyboard_wait_mask); + FD_SET (p->infd, &input_wait_mask); + FD_SET (p->infd, &non_keyboard_wait_mask); } p->command = Qnil; return process; @@ -6400,7 +6397,7 @@ text to PROCESS after you call this function. */) return process; proc = get_process (process); - coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; + coding = proc_encode_coding_system[XPROCESS (proc)->outfd]; /* Make sure the process is really alive. */ if (XPROCESS (proc)->raw_status_new) @@ -6417,7 +6414,7 @@ text to PROCESS after you call this function. */) #ifdef VMS send_process (proc, "\032", 1, Qnil); /* ^z */ #else - if (!NILP (XPROCESS (proc)->pty_flag)) + if (XPROCESS (proc)->pty_flag) send_process (proc, "\004", 1, Qnil); else { @@ -6429,18 +6426,18 @@ text to PROCESS after you call this function. */) (In some old system, shutdown to socketpair doesn't work. Then we just can't win.) */ if (XPROCESS (proc)->pid == 0 - || XINT (XPROCESS (proc)->outfd) == XINT (XPROCESS (proc)->infd)) - shutdown (XINT (XPROCESS (proc)->outfd), 1); + || XPROCESS (proc)->outfd == XPROCESS (proc)->infd) + shutdown (XPROCESS (proc)->outfd, 1); /* In case of socketpair, outfd == infd, so don't close it. */ - if (XINT (XPROCESS (proc)->outfd) != XINT (XPROCESS (proc)->infd)) - emacs_close (XINT (XPROCESS (proc)->outfd)); + if (XPROCESS (proc)->outfd != XPROCESS (proc)->infd) + emacs_close (XPROCESS (proc)->outfd); #else /* not HAVE_SHUTDOWN */ - emacs_close (XINT (XPROCESS (proc)->outfd)); + emacs_close (XPROCESS (proc)->outfd); #endif /* not HAVE_SHUTDOWN */ new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); if (new_outfd < 0) abort (); - old_outfd = XINT (XPROCESS (proc)->outfd); + old_outfd = XPROCESS (proc)->outfd; if (!proc_encode_coding_system[new_outfd]) proc_encode_coding_system[new_outfd] @@ -6451,7 +6448,7 @@ text to PROCESS after you call this function. */) bzero (proc_encode_coding_system[old_outfd], sizeof (struct coding_system)); - XSETINT (XPROCESS (proc)->outfd, new_outfd); + XPROCESS (proc)->outfd = new_outfd; } #endif /* VMS */ return process; @@ -6474,7 +6471,7 @@ kill_buffer_processes (buffer) { if (NETCONN_P (proc)) Fdelete_process (proc); - else if (XINT (XPROCESS (proc)->infd) >= 0) + else if (XPROCESS (proc)->infd >= 0) process_send_signal (proc, SIGHUP, Qnil, 1); } } @@ -6604,21 +6601,21 @@ sigchld_handler (signo) union { int i; WAITTYPE wt; } u; int clear_desc_flag = 0; - XSETINT (p->tick, ++process_tick); + p->tick = ++process_tick; u.wt = w; p->raw_status = u.i; p->raw_status_new = 1; /* If process has terminated, stop waiting for its output. */ if ((WIFSIGNALED (w) || WIFEXITED (w)) - && XINT (p->infd) >= 0) + && p->infd >= 0) clear_desc_flag = 1; /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */ if (clear_desc_flag) { - FD_CLR (XINT (p->infd), &input_wait_mask); - FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); + FD_CLR (p->infd, &input_wait_mask); + FD_CLR (p->infd, &non_keyboard_wait_mask); } /* Tell wait_reading_process_output that it needs to wake up and @@ -6795,18 +6792,18 @@ status_notify (deleting_process) proc = Fcdr (Fcar (tail)); p = XPROCESS (proc); - if (XINT (p->tick) != XINT (p->update_tick)) + if (p->tick != p->update_tick) { - XSETINT (p->update_tick, XINT (p->tick)); + p->update_tick = p->tick; /* If process is still active, read any output that remains. */ while (! EQ (p->filter, Qt) && ! EQ (p->status, Qconnect) && ! EQ (p->status, Qlisten) && ! EQ (p->command, Qt) /* Network process not stopped. */ - && XINT (p->infd) >= 0 + && p->infd >= 0 && p != deleting_process - && read_process_output (proc, XINT (p->infd)) > 0); + && read_process_output (proc, p->infd) > 0); buffer = p->buffer; @@ -6833,7 +6830,7 @@ status_notify (deleting_process) So set p->update_tick again so that an error in the sentinel will not cause this code to be run again. */ - XSETINT (p->update_tick, XINT (p->tick)); + p->update_tick = p->tick; /* Now output the message suitably. */ if (!NILP (p->sentinel)) exec_sentinel (proc, msg); @@ -6906,9 +6903,9 @@ encode subprocess input. */) CHECK_PROCESS (process); p = XPROCESS (process); - if (XINT (p->infd) < 0) + if (p->infd < 0) error ("Input file descriptor of %s closed", SDATA (p->name)); - if (XINT (p->outfd) < 0) + if (p->outfd < 0) error ("Output file descriptor of %s closed", SDATA (p->name)); Fcheck_coding_system (decoding); Fcheck_coding_system (encoding); @@ -6945,7 +6942,7 @@ suppressed. */) CHECK_PROCESS (process); p = XPROCESS (process); - p->filter_multibyte = flag; + p->filter_multibyte = !NILP (flag); setup_process_coding_systems (process); return Qnil; @@ -6962,7 +6959,7 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p, CHECK_PROCESS (process); p = XPROCESS (process); - return (NILP (p->filter_multibyte) ? Qnil : Qt); + return (p->filter_multibyte ? Qt : Qnil); } diff --git a/src/process.h b/src/process.h index 718d2a70ea8..fd7847b5e29 100644 --- a/src/process.h +++ b/src/process.h @@ -36,10 +36,6 @@ struct Lisp_Process { EMACS_INT size; struct Lisp_Vector *v_next; - /* Descriptor by which we read from this process */ - Lisp_Object infd; - /* Descriptor by which we write to this process */ - Lisp_Object outfd; /* Name of subprocess terminal. */ Lisp_Object tty_name; /* Name of this process */ @@ -64,61 +60,65 @@ struct Lisp_Process Lisp_Object plist; /* Marker set to end of last buffer-inserted output from this process */ Lisp_Object mark; - /* Non-nil means kill silently if Emacs is exited. - This is the inverse of the `query-on-exit' flag. */ - Lisp_Object kill_without_query; /* Symbol indicating status of process. This may be a symbol: run, open, or closed. Or it may be a list, whose car is stop, exit or signal and whose cdr is a pair (EXIT_CODE . COREDUMP_FLAG) or (SIGNAL_NUMBER . COREDUMP_FLAG). */ Lisp_Object status; - /* Non-nil if communicating through a pty. */ - Lisp_Object pty_flag; - /* Event-count of last event in which this process changed status. */ - Lisp_Object tick; - /* Event-count of last such event reported. */ - Lisp_Object update_tick; /* Coding-system for decoding the input from this process. */ Lisp_Object decode_coding_system; /* Working buffer for decoding. */ Lisp_Object decoding_buf; - /* Size of carryover in decoding. */ - Lisp_Object decoding_carryover; /* Coding-system for encoding the output to this process. */ Lisp_Object encode_coding_system; /* Working buffer for encoding. */ Lisp_Object encoding_buf; - /* Size of carryover in encoding. */ - Lisp_Object encoding_carryover; - /* Flag to set coding-system of the process buffer from the - coding_system used to decode process output. */ - Lisp_Object inherit_coding_system_flag; - /* Flat to decide the multibyteness of a string given to the - filter (if any). It is initialized to the value of - `default-enable-multibyte-characters' when the process is - generated, and can be changed by the function - `set-process-fileter-multibyte'. */ - Lisp_Object filter_multibyte; - /* Should we delay reading output from this process. - Initialized from `Vprocess_adaptive_read_buffering'. */ - Lisp_Object adaptive_read_buffering; - /* Hysteresis to try to read process output in larger blocks. - On some systems, e.g. GNU/Linux, Emacs is seen as - an interactive app also when reading process output, meaning - that process output can be read in as little as 1 byte at a - time. Value is micro-seconds to delay reading output from - this process. Range is 0 .. 50000. */ - Lisp_Object read_output_delay; - /* Skip reading this process on next read. */ - Lisp_Object read_output_skip; /* After this point, there are no Lisp_Objects any more. */ + /* alloc.c assumes that `pid' is the first such non-Lisp slot. */ /* Number of this process. allocate_process assumes this is the first non-Lisp_Object field. A value 0 is used for pseudo-processes such as network connections. */ pid_t pid; + /* Descriptor by which we read from this process */ + int infd; + /* Descriptor by which we write to this process */ + int outfd; + /* Event-count of last event in which this process changed status. */ + int tick; + /* Event-count of last such event reported. */ + int update_tick; + /* Size of carryover in decoding. */ + int decoding_carryover; + /* Hysteresis to try to read process output in larger blocks. + On some systems, e.g. GNU/Linux, Emacs is seen as + an interactive app also when reading process output, meaning + that process output can be read in as little as 1 byte at a + time. Value is micro-seconds to delay reading output from + this process. Range is 0 .. 50000. */ + int read_output_delay; + /* Should we delay reading output from this process. + Initialized from `Vprocess_adaptive_read_buffering'. + 0 = nil, 1 = t, 2 = other. */ + int adaptive_read_buffering : 2; + /* Skip reading this process on next read. */ + int read_output_skip : 1; + /* Non-nil means kill silently if Emacs is exited. + This is the inverse of the `query-on-exit' flag. */ + int kill_without_query : 1; + /* Non-nil if communicating through a pty. */ + int pty_flag : 1; + /* Flag to set coding-system of the process buffer from the + coding_system used to decode process output. */ + int inherit_coding_system_flag : 1; + /* Flag to decide the multibyteness of a string given to the + filter (if any). It is initialized to the value of + `default-enable-multibyte-characters' when the process is + generated, and can be changed by the function + `set-process-filter-multibyte'. */ + int filter_multibyte : 1; /* Record the process status in the raw form in which it comes from `wait'. This is to avoid consing in a signal handler. The `raw_status_new' flag indicates that `raw_status' contains a new status that still