summaryrefslogtreecommitdiff
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c354
1 files changed, 177 insertions, 177 deletions
diff --git a/src/process.c b/src/process.c
index b0a327229c6..a9638dfc2df 100644
--- a/src/process.c
+++ b/src/process.c
@@ -160,6 +160,18 @@ static bool kbd_is_on_hold;
when exiting. */
bool inhibit_sentinels;
+union u_sockaddr
+{
+ struct sockaddr sa;
+ struct sockaddr_in in;
+#ifdef AF_INET6
+ struct sockaddr_in6 in6;
+#endif
+#ifdef HAVE_LOCAL_SOCKETS
+ struct sockaddr_un un;
+#endif
+};
+
#ifdef subprocesses
#ifndef SOCK_CLOEXEC
@@ -240,7 +252,7 @@ static EMACS_INT update_tick;
# define HAVE_SEQPACKET
#endif
-#define READ_OUTPUT_DELAY_INCREMENT (TIMESPEC_RESOLUTION / 100)
+#define READ_OUTPUT_DELAY_INCREMENT (TIMESPEC_HZ / 100)
#define READ_OUTPUT_DELAY_MAX (READ_OUTPUT_DELAY_INCREMENT * 5)
#define READ_OUTPUT_DELAY_MAX_MAX (READ_OUTPUT_DELAY_INCREMENT * 7)
@@ -672,12 +684,12 @@ static Lisp_Object
status_convert (int w)
{
if (WIFSTOPPED (w))
- return Fcons (Qstop, Fcons (make_number (WSTOPSIG (w)), Qnil));
+ return Fcons (Qstop, Fcons (make_fixnum (WSTOPSIG (w)), Qnil));
else if (WIFEXITED (w))
- return Fcons (Qexit, Fcons (make_number (WEXITSTATUS (w)),
+ return Fcons (Qexit, Fcons (make_fixnum (WEXITSTATUS (w)),
WCOREDUMP (w) ? Qt : Qnil));
else if (WIFSIGNALED (w))
- return Fcons (Qsignal, Fcons (make_number (WTERMSIG (w)),
+ return Fcons (Qsignal, Fcons (make_fixnum (WTERMSIG (w)),
WCOREDUMP (w) ? Qt : Qnil));
else
return Qrun;
@@ -706,7 +718,7 @@ decode_status (Lisp_Object l, Lisp_Object *symbol, Lisp_Object *code,
if (SYMBOLP (l))
{
*symbol = l;
- *code = make_number (0);
+ *code = make_fixnum (0);
*coredump = 0;
}
else
@@ -735,7 +747,7 @@ status_message (struct Lisp_Process *p)
{
char const *signame;
synchronize_system_messages_locale ();
- signame = strsignal (XFASTINT (code));
+ signame = strsignal (XFIXNAT (code));
if (signame == 0)
string = build_string ("unknown");
else
@@ -749,7 +761,7 @@ status_message (struct Lisp_Process *p)
c1 = STRING_CHAR (SDATA (string));
c2 = downcase (c1);
if (c1 != c2)
- Faset (string, make_number (0), make_number (c2));
+ Faset (string, make_fixnum (0), make_fixnum (c2));
}
AUTO_STRING (suffix, coredump ? " (core dumped)\n" : "\n");
return concat2 (string, suffix);
@@ -757,10 +769,10 @@ status_message (struct Lisp_Process *p)
else if (EQ (symbol, Qexit))
{
if (NETCONN1_P (p))
- return build_string (XFASTINT (code) == 0
+ return build_string (XFIXNAT (code) == 0
? "deleted\n"
: "connection broken by remote peer\n");
- if (XFASTINT (code) == 0)
+ if (XFIXNAT (code) == 0)
return build_string ("finished\n");
AUTO_STRING (prefix, "exited abnormally with code ");
string = Fnumber_to_string (code);
@@ -1013,7 +1025,7 @@ static Lisp_Object deleted_pid_list;
void
record_deleted_pid (pid_t pid, Lisp_Object filename)
{
- deleted_pid_list = Fcons (Fcons (make_fixnum_or_float (pid), filename),
+ deleted_pid_list = Fcons (Fcons (INT_TO_INTEGER (pid), filename),
/* GC treated elements set to nil. */
Fdelq (Qnil, deleted_pid_list));
@@ -1052,7 +1064,7 @@ nil, indicating the current buffer's process. */)
p->raw_status_new = 0;
if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p))
{
- pset_status (p, list2 (Qexit, make_number (0)));
+ pset_status (p, list2 (Qexit, make_fixnum (0)));
p->tick = ++process_tick;
status_notify (p, NULL);
redisplay_preserve_echo_area (13);
@@ -1071,7 +1083,7 @@ nil, indicating the current buffer's process. */)
update_status (p);
symbol = CONSP (p->status) ? XCAR (p->status) : p->status;
if (! (EQ (symbol, Qsignal) || EQ (symbol, Qexit)))
- pset_status (p, list2 (Qsignal, make_number (SIGKILL)));
+ pset_status (p, list2 (Qsignal, make_fixnum (SIGKILL)));
p->tick = ++process_tick;
status_notify (p, NULL);
@@ -1139,12 +1151,13 @@ If PROCESS has not yet exited or died, return 0. */)
update_status (XPROCESS (process));
if (CONSP (XPROCESS (process)->status))
return XCAR (XCDR (XPROCESS (process)->status));
- return make_number (0);
+ return make_fixnum (0);
}
DEFUN ("process-id", Fprocess_id, Sprocess_id, 1, 1, 0,
doc: /* Return the process id of PROCESS.
This is the pid of the external process which PROCESS uses or talks to.
+It is a fixnum if the value is small enough, otherwise a bignum.
For a network, serial, and pipe connections, this value is nil. */)
(register Lisp_Object process)
{
@@ -1152,7 +1165,7 @@ For a network, serial, and pipe connections, this value is nil. */)
CHECK_PROCESS (process);
pid = XPROCESS (process)->pid;
- return (pid ? make_fixnum_or_float (pid) : Qnil);
+ return pid ? INT_TO_INTEGER (pid) : Qnil;
}
DEFUN ("process-name", Fprocess_name, Sprocess_name, 1, 1, 0,
@@ -1248,10 +1261,7 @@ passed to the filter.
The filter gets two arguments: the process and the string of output.
The string argument is normally a multibyte string, except:
- if the process's input coding system is no-conversion or raw-text,
- it is a unibyte string (the non-converted input), or else
-- if `default-enable-multibyte-characters' is nil, it is a unibyte
- string (the result of converting the decoded input multibyte
- string to unibyte with `string-make-unibyte'). */)
+ it is a unibyte string (the non-converted input). */)
(Lisp_Object process, Lisp_Object filter)
{
CHECK_PROCESS (process);
@@ -1374,7 +1384,7 @@ nil otherwise. */)
if (NETCONN_P (process)
|| XPROCESS (process)->infd < 0
|| (set_window_size (XPROCESS (process)->infd,
- XINT (height), XINT (width))
+ XFIXNUM (height), XFIXNUM (width))
< 0))
return Qnil;
else
@@ -1575,12 +1585,12 @@ Return nil if format of ADDRESS is invalid. */)
for (i = 0; i < nargs; i++)
{
- if (! RANGED_INTEGERP (0, p->contents[i], 65535))
+ if (! RANGED_FIXNUMP (0, p->contents[i], 65535))
return Qnil;
if (nargs <= 5 /* IPv4 */
&& i < 4 /* host, not port */
- && XINT (p->contents[i]) > 255)
+ && XFIXNUM (p->contents[i]) > 255)
return Qnil;
args[i + 1] = p->contents[i];
@@ -1648,7 +1658,8 @@ to use a pty, or nil to use the default specified through
:stderr STDERR -- STDERR is either a buffer or a pipe process attached
to the standard error of subprocess. Specifying this implies
-`:connection-type' is set to `pipe'.
+`:connection-type' is set to `pipe'. If STDERR is nil, standard error
+is mixed with standard output and sent to BUFFER or FILTER.
usage: (make-process &rest ARGS) */)
(ptrdiff_t nargs, Lisp_Object *args)
@@ -1779,7 +1790,7 @@ usage: (make-process &rest ARGS) */)
val = Vcoding_system_for_read;
if (NILP (val))
{
- ptrdiff_t nargs2 = 3 + XINT (Flength (command));
+ ptrdiff_t nargs2 = 3 + XFIXNUM (Flength (command));
Lisp_Object tem2;
SAFE_ALLOCA_LISP (args2, nargs2);
ptrdiff_t i = 0;
@@ -1809,7 +1820,7 @@ usage: (make-process &rest ARGS) */)
{
if (EQ (coding_systems, Qt))
{
- ptrdiff_t nargs2 = 3 + XINT (Flength (command));
+ ptrdiff_t nargs2 = 3 + XFIXNUM (Flength (command));
Lisp_Object tem2;
SAFE_ALLOCA_LISP (args2, nargs2);
ptrdiff_t i = 0;
@@ -1854,7 +1865,7 @@ usage: (make-process &rest ARGS) */)
{
tem = Qnil;
openp (Vexec_path, program, Vexec_suffixes, &tem,
- make_number (X_OK), false);
+ make_fixnum (X_OK), false);
if (NILP (tem))
report_file_error ("Searching for program", program);
tem = Fexpand_file_name (tem, Qnil);
@@ -1913,8 +1924,7 @@ usage: (make-process &rest ARGS) */)
else
create_pty (proc);
- SAFE_FREE ();
- return unbind_to (count, proc);
+ return SAFE_FREE_UNBIND_TO (count, proc);
}
/* If PROC doesn't have its pid set, then an error was signaled and
@@ -2494,9 +2504,9 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len)
{
DECLARE_POINTER_ALIAS (sin, struct sockaddr_in, sa);
len = sizeof (sin->sin_addr) + 1;
- address = Fmake_vector (make_number (len), Qnil);
+ address = Fmake_vector (make_fixnum (len), Qnil);
p = XVECTOR (address);
- p->contents[--len] = make_number (ntohs (sin->sin_port));
+ p->contents[--len] = make_fixnum (ntohs (sin->sin_port));
cp = (unsigned char *) &sin->sin_addr;
break;
}
@@ -2506,11 +2516,11 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len)
DECLARE_POINTER_ALIAS (sin6, struct sockaddr_in6, sa);
DECLARE_POINTER_ALIAS (ip6, uint16_t, &sin6->sin6_addr);
len = sizeof (sin6->sin6_addr) / 2 + 1;
- address = Fmake_vector (make_number (len), Qnil);
+ address = Fmake_vector (make_fixnum (len), Qnil);
p = XVECTOR (address);
- p->contents[--len] = make_number (ntohs (sin6->sin6_port));
+ p->contents[--len] = make_fixnum (ntohs (sin6->sin6_port));
for (i = 0; i < len; i++)
- p->contents[i] = make_number (ntohs (ip6[i]));
+ p->contents[i] = make_fixnum (ntohs (ip6[i]));
return address;
}
#endif
@@ -2538,8 +2548,8 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len)
#endif
default:
len -= offsetof (struct sockaddr, sa_family) + sizeof (sa->sa_family);
- address = Fcons (make_number (sa->sa_family),
- Fmake_vector (make_number (len), Qnil));
+ address = Fcons (make_fixnum (sa->sa_family),
+ Fmake_vector (make_fixnum (len), Qnil));
p = XVECTOR (XCDR (address));
cp = (unsigned char *) &sa->sa_family + sizeof (sa->sa_family);
break;
@@ -2547,7 +2557,7 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len)
i = 0;
while (i < len)
- p->contents[i++] = make_number (*cp++);
+ p->contents[i++] = make_fixnum (*cp++);
return address;
}
@@ -2557,8 +2567,8 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len)
static Lisp_Object
conv_addrinfo_to_lisp (struct addrinfo *res)
{
- Lisp_Object protocol = make_number (res->ai_protocol);
- eassert (XINT (protocol) == res->ai_protocol);
+ Lisp_Object protocol = make_fixnum (res->ai_protocol);
+ eassert (XFIXNUM (protocol) == res->ai_protocol);
return Fcons (protocol, conv_sockaddr_to_lisp (res->ai_addr, res->ai_addrlen));
}
@@ -2593,14 +2603,14 @@ get_lisp_to_sockaddr_size (Lisp_Object address, int *familyp)
return sizeof (struct sockaddr_un);
}
#endif
- else if (CONSP (address) && TYPE_RANGED_INTEGERP (int, XCAR (address))
+ else if (CONSP (address) && TYPE_RANGED_FIXNUMP (int, XCAR (address))
&& VECTORP (XCDR (address)))
{
struct sockaddr *sa;
p = XVECTOR (XCDR (address));
if (MAX_ALLOCA - sizeof sa->sa_family < p->header.size)
return 0;
- *familyp = XINT (XCAR (address));
+ *familyp = XFIXNUM (XCAR (address));
return p->header.size + sizeof (sa->sa_family);
}
return 0;
@@ -2630,7 +2640,7 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int
{
DECLARE_POINTER_ALIAS (sin, struct sockaddr_in, sa);
len = sizeof (sin->sin_addr) + 1;
- hostport = XINT (p->contents[--len]);
+ hostport = XFIXNUM (p->contents[--len]);
sin->sin_port = htons (hostport);
cp = (unsigned char *)&sin->sin_addr;
sa->sa_family = family;
@@ -2641,12 +2651,12 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int
DECLARE_POINTER_ALIAS (sin6, struct sockaddr_in6, sa);
DECLARE_POINTER_ALIAS (ip6, uint16_t, &sin6->sin6_addr);
len = sizeof (sin6->sin6_addr) / 2 + 1;
- hostport = XINT (p->contents[--len]);
+ hostport = XFIXNUM (p->contents[--len]);
sin6->sin6_port = htons (hostport);
for (i = 0; i < len; i++)
- if (INTEGERP (p->contents[i]))
+ if (FIXNUMP (p->contents[i]))
{
- int j = XFASTINT (p->contents[i]) & 0xffff;
+ int j = XFIXNAT (p->contents[i]) & 0xffff;
ip6[i] = ntohs (j);
}
sa->sa_family = family;
@@ -2677,8 +2687,8 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int
}
for (i = 0; i < len; i++)
- if (INTEGERP (p->contents[i]))
- *cp++ = XFASTINT (p->contents[i]) & 0xff;
+ if (FIXNUMP (p->contents[i]))
+ *cp++ = XFIXNAT (p->contents[i]) & 0xff;
}
#ifdef DATAGRAM_SOCKETS
@@ -2809,8 +2819,8 @@ set_socket_option (int s, Lisp_Object opt, Lisp_Object val)
case SOPT_INT:
{
int optval;
- if (TYPE_RANGED_INTEGERP (int, val))
- optval = XINT (val);
+ if (TYPE_RANGED_FIXNUMP (int, val))
+ optval = XFIXNUM (val);
else
error ("Bad option value for %s", name);
ret = setsockopt (s, sopt->optlevel, sopt->optnum,
@@ -2848,8 +2858,8 @@ set_socket_option (int s, Lisp_Object opt, Lisp_Object val)
linger.l_onoff = 1;
linger.l_linger = 0;
- if (TYPE_RANGED_INTEGERP (int, val))
- linger.l_linger = XINT (val);
+ if (TYPE_RANGED_FIXNUMP (int, val))
+ linger.l_linger = XFIXNUM (val);
else
linger.l_onoff = NILP (val) ? 0 : 1;
ret = setsockopt (s, sopt->optlevel, sopt->optnum,
@@ -3093,7 +3103,7 @@ usage: (make-serial-process &rest ARGS) */)
if (NILP (Fplist_member (contact, QCspeed)))
error (":speed not specified");
if (!NILP (Fplist_get (contact, QCspeed)))
- CHECK_NUMBER (Fplist_get (contact, QCspeed));
+ CHECK_FIXNUM (Fplist_get (contact, QCspeed));
name = Fplist_get (contact, QCname);
if (NILP (name))
@@ -3325,7 +3335,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
int xerrno = 0;
int family;
int ret;
- ptrdiff_t addrlen;
+ ptrdiff_t addrlen UNINIT;
struct Lisp_Process *p = XPROCESS (proc);
Lisp_Object contact = p->childp;
int optbits = 0;
@@ -3351,7 +3361,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
{
Lisp_Object addrinfo = XCAR (addrinfos);
addrinfos = XCDR (addrinfos);
- int protocol = XINT (XCAR (addrinfo));
+ int protocol = XFIXNUM (XCAR (addrinfo));
Lisp_Object ip_address = XCDR (addrinfo);
#ifdef WINDOWSNT
@@ -3457,7 +3467,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
DECLARE_POINTER_ALIAS (psa1, struct sockaddr, &sa1);
if (getsockname (s, psa1, &len1) == 0)
{
- Lisp_Object service = make_number (ntohs (sa1.sin_port));
+ Lisp_Object service = make_fixnum (ntohs (sa1.sin_port));
contact = Fplist_put (contact, QCservice, service);
/* Save the port number so that we can stash it in
the process object later. */
@@ -3773,8 +3783,7 @@ The stopped state is cleared by `continue-process' and set by
:filter-multibyte BOOL -- If BOOL is non-nil, strings given to the
process filter are multibyte, otherwise they are unibyte.
-If this keyword is not specified, the strings are multibyte if
-the default value of `enable-multibyte-characters' is non-nil.
+If this keyword is not specified, the strings are multibyte.
:sentinel SENTINEL -- Install SENTINEL as the process sentinel.
@@ -3851,7 +3860,6 @@ usage: (make-network-process &rest ARGS) */)
Lisp_Object contact;
struct Lisp_Process *p;
const char *portstring UNINIT;
- ptrdiff_t portstringlen ATTRIBUTE_UNUSED;
char portbuf[INT_BUFSIZE_BOUND (EMACS_INT)];
#ifdef HAVE_LOCAL_SOCKETS
struct sockaddr_un address_un;
@@ -3919,7 +3927,7 @@ usage: (make-network-process &rest ARGS) */)
if (!get_lisp_to_sockaddr_size (address, &family))
error ("Malformed :address");
- addrinfos = list1 (Fcons (make_number (any_protocol), address));
+ addrinfos = list1 (Fcons (make_fixnum (any_protocol), address));
goto open_socket;
}
@@ -3943,8 +3951,8 @@ usage: (make-network-process &rest ARGS) */)
#endif
else if (EQ (tem, Qipv4))
family = AF_INET;
- else if (TYPE_RANGED_INTEGERP (int, tem))
- family = XINT (tem);
+ else if (TYPE_RANGED_FIXNUMP (int, tem))
+ family = XFIXNUM (tem);
else
error ("Unknown address family");
@@ -3983,7 +3991,7 @@ usage: (make-network-process &rest ARGS) */)
CHECK_STRING (service);
if (sizeof address_un.sun_path <= SBYTES (service))
error ("Service name too long");
- addrinfos = list1 (Fcons (make_number (any_protocol), service));
+ addrinfos = list1 (Fcons (make_fixnum (any_protocol), service));
goto open_socket;
}
#endif
@@ -4001,6 +4009,8 @@ usage: (make-network-process &rest ARGS) */)
if (!NILP (host))
{
+ ptrdiff_t portstringlen ATTRIBUTE_UNUSED;
+
/* SERVICE can either be a string or int.
Convert to a C string for later use by getaddrinfo. */
if (EQ (service, Qt))
@@ -4008,10 +4018,10 @@ usage: (make-network-process &rest ARGS) */)
portstring = "0";
portstringlen = 1;
}
- else if (INTEGERP (service))
+ else if (FIXNUMP (service))
{
portstring = portbuf;
- portstringlen = sprintf (portbuf, "%"pI"d", XINT (service));
+ portstringlen = sprintf (portbuf, "%"pI"d", XFIXNUM (service));
}
else
{
@@ -4019,37 +4029,38 @@ usage: (make-network-process &rest ARGS) */)
portstring = SSDATA (service);
portstringlen = SBYTES (service);
}
- }
#ifdef HAVE_GETADDRINFO_A
- if (!NILP (host) && nowait)
- {
- ptrdiff_t hostlen = SBYTES (host);
- struct req
- {
- struct gaicb gaicb;
- struct addrinfo hints;
- char str[FLEXIBLE_ARRAY_MEMBER];
- } *req = xmalloc (FLEXSIZEOF (struct req, str,
- hostlen + 1 + portstringlen + 1));
- dns_request = &req->gaicb;
- dns_request->ar_name = req->str;
- dns_request->ar_service = req->str + hostlen + 1;
- dns_request->ar_request = &req->hints;
- dns_request->ar_result = NULL;
- memset (&req->hints, 0, sizeof req->hints);
- req->hints.ai_family = family;
- req->hints.ai_socktype = socktype;
- strcpy (req->str, SSDATA (host));
- strcpy (req->str + hostlen + 1, portstring);
-
- int ret = getaddrinfo_a (GAI_NOWAIT, &dns_request, 1, NULL);
- if (ret)
- error ("%s/%s getaddrinfo_a error %d", SSDATA (host), portstring, ret);
-
- goto open_socket;
- }
+ if (nowait)
+ {
+ ptrdiff_t hostlen = SBYTES (host);
+ struct req
+ {
+ struct gaicb gaicb;
+ struct addrinfo hints;
+ char str[FLEXIBLE_ARRAY_MEMBER];
+ } *req = xmalloc (FLEXSIZEOF (struct req, str,
+ hostlen + 1 + portstringlen + 1));
+ dns_request = &req->gaicb;
+ dns_request->ar_name = req->str;
+ dns_request->ar_service = req->str + hostlen + 1;
+ dns_request->ar_request = &req->hints;
+ dns_request->ar_result = NULL;
+ memset (&req->hints, 0, sizeof req->hints);
+ req->hints.ai_family = family;
+ req->hints.ai_socktype = socktype;
+ strcpy (req->str, SSDATA (host));
+ strcpy (req->str + hostlen + 1, portstring);
+
+ int ret = getaddrinfo_a (GAI_NOWAIT, &dns_request, 1, NULL);
+ if (ret)
+ error ("%s/%s getaddrinfo_a error %d",
+ SSDATA (host), portstring, ret);
+
+ goto open_socket;
+ }
#endif /* HAVE_GETADDRINFO_A */
+ }
/* If we have a host, use getaddrinfo to resolve both host and service.
Otherwise, use getservbyname to lookup the service. */
@@ -4095,8 +4106,8 @@ usage: (make-network-process &rest ARGS) */)
if (EQ (service, Qt))
port = 0;
- else if (INTEGERP (service))
- port = XINT (service);
+ else if (FIXNUMP (service))
+ port = XFIXNUM (service);
else
{
CHECK_STRING (service);
@@ -4169,8 +4180,8 @@ usage: (make-network-process &rest ARGS) */)
/* :server QLEN */
p->is_server = !NILP (server);
- if (TYPE_RANGED_INTEGERP (int, server))
- p->backlog = XINT (server);
+ if (TYPE_RANGED_FIXNUMP (int, server))
+ p->backlog = XFIXNUM (server);
/* :nowait BOOL */
if (!p->is_server && socktype != SOCK_DGRAM && nowait)
@@ -4394,7 +4405,7 @@ network_interface_info (Lisp_Object ifname)
{
if (flags & 1)
{
- elt = Fcons (make_number (fnum), elt);
+ elt = Fcons (make_fixnum (fnum), elt);
}
}
}
@@ -4405,21 +4416,21 @@ network_interface_info (Lisp_Object ifname)
#if defined (SIOCGIFHWADDR) && defined (HAVE_STRUCT_IFREQ_IFR_HWADDR)
if (ioctl (s, SIOCGIFHWADDR, &rq) == 0)
{
- Lisp_Object hwaddr = Fmake_vector (make_number (6), Qnil);
+ Lisp_Object hwaddr = Fmake_vector (make_fixnum (6), Qnil);
register struct Lisp_Vector *p = XVECTOR (hwaddr);
int n;
any = 1;
for (n = 0; n < 6; n++)
- p->contents[n] = make_number (((unsigned char *)
+ p->contents[n] = make_fixnum (((unsigned char *)
&rq.ifr_hwaddr.sa_data[0])
[n]);
- elt = Fcons (make_number (rq.ifr_hwaddr.sa_family), hwaddr);
+ elt = Fcons (make_fixnum (rq.ifr_hwaddr.sa_family), hwaddr);
}
#elif defined (HAVE_GETIFADDRS) && defined (LLADDR)
if (getifaddrs (&ifap) != -1)
{
- Lisp_Object hwaddr = Fmake_vector (make_number (6), Qnil);
+ Lisp_Object hwaddr = Fmake_vector (make_fixnum (6), Qnil);
register struct Lisp_Vector *p = XVECTOR (hwaddr);
struct ifaddrs *it;
@@ -4436,9 +4447,9 @@ network_interface_info (Lisp_Object ifname)
memcpy (linkaddr, LLADDR (sdl), sdl->sdl_alen);
for (n = 0; n < 6; n++)
- p->contents[n] = make_number (linkaddr[n]);
+ p->contents[n] = make_fixnum (linkaddr[n]);
- elt = Fcons (make_number (it->ifa_addr->sa_family), hwaddr);
+ elt = Fcons (make_fixnum (it->ifa_addr->sa_family), hwaddr);
break;
}
}
@@ -4608,7 +4619,7 @@ is nil, from any process) before the timeout expired. */)
/* Can't wait for a process that is dedicated to a different
thread. */
- if (!EQ (proc->thread, Qnil) && !EQ (proc->thread, Fcurrent_thread ()))
+ if (!NILP (proc->thread) && !EQ (proc->thread, Fcurrent_thread ()))
{
Lisp_Object proc_thread_name = XTHREAD (proc->thread)->name;
@@ -4624,13 +4635,13 @@ is nil, from any process) before the timeout expired. */)
if (!NILP (millisec))
{ /* Obsolete calling convention using integers rather than floats. */
- CHECK_NUMBER (millisec);
+ CHECK_FIXNUM (millisec);
if (NILP (seconds))
- seconds = make_float (XINT (millisec) / 1000.0);
+ seconds = make_float (XFIXNUM (millisec) / 1000.0);
else
{
- CHECK_NUMBER (seconds);
- seconds = make_float (XINT (millisec) / 1000.0 + XINT (seconds));
+ CHECK_FIXNUM (seconds);
+ seconds = make_float (XFIXNUM (millisec) / 1000.0 + XFIXNUM (seconds));
}
}
@@ -4639,11 +4650,11 @@ is nil, from any process) before the timeout expired. */)
if (!NILP (seconds))
{
- if (INTEGERP (seconds))
+ if (FIXNUMP (seconds))
{
- if (XINT (seconds) > 0)
+ if (XFIXNUM (seconds) > 0)
{
- secs = XINT (seconds);
+ secs = XFIXNUM (seconds);
nsecs = 0;
}
}
@@ -4667,7 +4678,7 @@ is nil, from any process) before the timeout expired. */)
Qnil,
!NILP (process) ? XPROCESS (process) : NULL,
(NILP (just_this_one) ? 0
- : !INTEGERP (just_this_one) ? 1 : -1))
+ : !FIXNUMP (just_this_one) ? 1 : -1))
<= 0)
? Qnil : Qt);
}
@@ -4684,16 +4695,7 @@ server_accept_connection (Lisp_Object server, int channel)
struct Lisp_Process *ps = XPROCESS (server);
struct Lisp_Process *p;
int s;
- union u_sockaddr {
- struct sockaddr sa;
- struct sockaddr_in in;
-#ifdef AF_INET6
- struct sockaddr_in6 in6;
-#endif
-#ifdef HAVE_LOCAL_SOCKETS
- struct sockaddr_un un;
-#endif
- } saddr;
+ union u_sockaddr saddr;
socklen_t len = sizeof saddr;
ptrdiff_t count;
@@ -4705,7 +4707,7 @@ server_accept_connection (Lisp_Object server, int channel)
if (!would_block (code) && !NILP (ps->log))
call3 (ps->log, server, Qnil,
concat3 (build_string ("accept failed with code"),
- Fnumber_to_string (make_number (code)),
+ Fnumber_to_string (make_fixnum (code)),
build_string ("\n")));
return;
}
@@ -4733,9 +4735,9 @@ server_accept_connection (Lisp_Object server, int channel)
args[nargs++] = procname_format_in;
nargs++;
unsigned char *ip = (unsigned char *)&saddr.in.sin_addr.s_addr;
- service = make_number (ntohs (saddr.in.sin_port));
+ service = make_fixnum (ntohs (saddr.in.sin_port));
for (int i = 0; i < 4; i++)
- args[nargs++] = make_number (ip[i]);
+ args[nargs++] = make_fixnum (ip[i]);
args[nargs++] = service;
}
break;
@@ -4746,9 +4748,9 @@ server_accept_connection (Lisp_Object server, int channel)
args[nargs++] = procname_format_in6;
nargs++;
DECLARE_POINTER_ALIAS (ip6, uint16_t, &saddr.in6.sin6_addr);
- service = make_number (ntohs (saddr.in.sin_port));
+ service = make_fixnum (ntohs (saddr.in.sin_port));
for (int i = 0; i < 8; i++)
- args[nargs++] = make_number (ip6[i]);
+ args[nargs++] = make_fixnum (ip6[i]);
args[nargs++] = service;
}
break;
@@ -4757,7 +4759,7 @@ server_accept_connection (Lisp_Object server, int channel)
default:
args[nargs++] = procname_format_default;
nargs++;
- args[nargs++] = make_number (connect_counter);
+ args[nargs++] = make_fixnum (connect_counter);
break;
}
@@ -5012,7 +5014,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
Lisp_Object proc;
struct timespec timeout, end_time, timer_delay;
struct timespec got_output_end_time = invalid_timespec ();
- enum { MINIMUM = -1, TIMEOUT, INFINITY } wait;
+ enum { MINIMUM = -1, TIMEOUT, FOREVER } wait;
int got_some_output = -1;
uintmax_t prev_wait_proc_nbytes_read = wait_proc ? wait_proc->nbytes_read : 0;
#if defined HAVE_GETADDRINFO_A || defined HAVE_GNUTLS
@@ -5024,7 +5026,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
struct timespec now = invalid_timespec ();
eassert (wait_proc == NULL
- || EQ (wait_proc->thread, Qnil)
+ || NILP (wait_proc->thread)
|| XTHREAD (wait_proc->thread) == current_thread);
FD_ZERO (&Available);
@@ -5051,7 +5053,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
end_time = timespec_add (now, make_timespec (time_limit, nsecs));
}
else
- wait = INFINITY;
+ wait = FOREVER;
while (1)
{
@@ -5476,7 +5478,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
have waited a long amount of time due to repeated
timers. */
struct timespec huge_timespec
- = make_timespec (TYPE_MAXIMUM (time_t), 2 * TIMESPEC_RESOLUTION);
+ = make_timespec (TYPE_MAXIMUM (time_t), 2 * TIMESPEC_HZ);
struct timespec cmp_time = huge_timespec;
if (wait < TIMEOUT
|| (wait_proc
@@ -5641,16 +5643,6 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
}
else if (nread == -1 && would_block (errno))
;
-#ifdef WINDOWSNT
- /* FIXME: Is this special case still needed? */
- /* Note that we cannot distinguish between no input
- available now and a closed pipe.
- With luck, a closed pipe will be accompanied by
- subprocess termination and SIGCHLD. */
- else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)
- && !PIPECONN_P (proc))
- ;
-#endif
#ifdef HAVE_PTYS
/* On some OSs with ptys, when the process on one end of
a pty exits, the other end gets an error reading with
@@ -5689,7 +5681,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
deactivate_process (proc);
if (EQ (XPROCESS (proc)->status, Qrun))
pset_status (XPROCESS (proc),
- list2 (Qexit, make_number (0)));
+ list2 (Qexit, make_fixnum (0)));
}
else
{
@@ -5700,7 +5692,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
update_status (XPROCESS (proc));
if (EQ (XPROCESS (proc)->status, Qrun))
pset_status (XPROCESS (proc),
- list2 (Qexit, make_number (256)));
+ list2 (Qexit, make_fixnum (256)));
}
}
if (FD_ISSET (channel, &Writeok)
@@ -5752,7 +5744,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
else
{
p->tick = ++process_tick;
- pset_status (p, list2 (Qfailed, make_number (xerrno)));
+ pset_status (p, list2 (Qfailed, make_fixnum (xerrno)));
}
deactivate_process (proc);
if (!NILP (addrinfos))
@@ -5821,7 +5813,7 @@ read_process_output_error_handler (Lisp_Object error_val)
cmd_error_internal (error_val, "error in process filter: ");
Vinhibit_quit = Qt;
update_echo_area ();
- Fsleep_for (make_number (2), Qnil);
+ Fsleep_for (make_fixnum (2), Qnil);
return Qt;
}
@@ -6139,7 +6131,7 @@ Otherwise it discards the output. */)
/* If the restriction isn't what it should be, set it. */
if (old_begv != BEGV || old_zv != ZV)
- Fnarrow_to_region (make_number (old_begv), make_number (old_zv));
+ Fnarrow_to_region (make_fixnum (old_begv), make_fixnum (old_zv));
bset_read_only (current_buffer, old_read_only);
SET_PT_BOTH (opoint, opoint_byte);
@@ -6186,7 +6178,7 @@ write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj,
obj = make_unibyte_string (buf, len);
}
- entry = Fcons (obj, Fcons (make_number (offset), make_number (len)));
+ entry = Fcons (obj, Fcons (make_fixnum (offset), make_fixnum (len)));
if (front)
pset_write_queue (p, Fcons (entry, p->write_queue));
@@ -6214,8 +6206,8 @@ write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj,
*obj = XCAR (entry);
offset_length = XCDR (entry);
- *len = XINT (XCDR (offset_length));
- offset = XINT (XCAR (offset_length));
+ *len = XFIXNUM (XCDR (offset_length));
+ offset = XFIXNUM (XCAR (offset_length));
*buf = SSDATA (*obj) + offset;
return 1;
@@ -6423,7 +6415,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
}
#endif /* BROKEN_PTY_READ_AFTER_EAGAIN */
- /* Put what we should have written in wait_queue. */
+ /* Put what we should have written in write_queue. */
write_queue_push (p, cur_object, cur_buf, cur_len, 1);
wait_reading_process_output (0, 20 * 1000 * 1000,
0, 0, Qnil, NULL, 0);
@@ -6433,7 +6425,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
else if (errno == EPIPE)
{
p->raw_status_new = 0;
- pset_status (p, list2 (Qexit, make_number (256)));
+ pset_status (p, list2 (Qexit, make_fixnum (256)));
p->tick = ++process_tick;
deactivate_process (proc);
error ("process %s no longer connected to pipe; closed it",
@@ -6469,11 +6461,11 @@ set up yet, this function will block until socket setup has completed. */)
validate_region (&start, &end);
- start_byte = CHAR_TO_BYTE (XINT (start));
- end_byte = CHAR_TO_BYTE (XINT (end));
+ start_byte = CHAR_TO_BYTE (XFIXNUM (start));
+ end_byte = CHAR_TO_BYTE (XFIXNUM (end));
- if (XINT (start) < GPT && XINT (end) > GPT)
- move_gap_both (XINT (start), start_byte);
+ if (XFIXNUM (start) < GPT && XFIXNUM (end) > GPT)
+ move_gap_both (XFIXNUM (start), start_byte);
if (NETCONN_P (proc))
wait_while_connecting (proc);
@@ -6555,7 +6547,7 @@ process group. */)
if (gid == p->pid)
return Qnil;
if (gid != -1)
- return make_number (gid);
+ return make_fixnum (gid);
return Qt;
}
@@ -6860,12 +6852,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
{
Lisp_Object tem = Fget_process (process);
if (NILP (tem))
- {
- Lisp_Object process_number
- = string_to_number (SSDATA (process), 10, 1);
- if (NUMBERP (process_number))
- tem = process_number;
- }
+ tem = string_to_number (SSDATA (process), 10, 0);
process = tem;
}
else if (!NUMBERP (process))
@@ -6884,10 +6871,10 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
error ("Cannot signal process %s", SDATA (XPROCESS (process)->name));
}
- if (INTEGERP (sigcode))
+ if (FIXNUMP (sigcode))
{
CHECK_TYPE_RANGED_INTEGER (int, sigcode);
- signo = XINT (sigcode);
+ signo = XFIXNUM (sigcode);
}
else
{
@@ -6901,7 +6888,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
error ("Undefined signal name %s", name);
}
- return make_number (kill (pid, signo));
+ return make_fixnum (kill (pid, signo));
}
DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0,
@@ -7071,13 +7058,11 @@ handle_child_signal (int sig)
if (! CONSP (head))
continue;
xpid = XCAR (head);
- if (all_pids_are_fixnums ? INTEGERP (xpid) : NUMBERP (xpid))
+ if (all_pids_are_fixnums ? FIXNUMP (xpid) : INTEGERP (xpid))
{
- pid_t deleted_pid;
- if (INTEGERP (xpid))
- deleted_pid = XINT (xpid);
- else
- deleted_pid = XFLOAT_DATA (xpid);
+ intmax_t deleted_pid;
+ bool ok = integer_to_intmax (xpid, &deleted_pid);
+ eassert (ok);
if (child_status_changed (deleted_pid, 0, 0))
{
if (STRINGP (XCDR (head)))
@@ -7141,7 +7126,7 @@ exec_sentinel_error_handler (Lisp_Object error_val)
cmd_error_internal (error_val, "error in process sentinel: ");
Vinhibit_quit = Qt;
update_echo_area ();
- Fsleep_for (make_number (2), Qnil);
+ Fsleep_for (make_fixnum (2), Qnil);
return Qt;
}
@@ -7536,7 +7521,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
{
register int nfds;
struct timespec end_time, timeout;
- enum { MINIMUM = -1, TIMEOUT, INFINITY } wait;
+ enum { MINIMUM = -1, TIMEOUT, FOREVER } wait;
if (TYPE_MAXIMUM (time_t) < time_limit)
time_limit = TYPE_MAXIMUM (time_t);
@@ -7550,7 +7535,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
make_timespec (time_limit, nsecs));
}
else
- wait = INFINITY;
+ wait = FOREVER;
/* Turn off periodic alarms (in case they are in use)
and then turn off any other atimers,
@@ -7656,7 +7641,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
/* If we woke up due to SIGWINCH, actually change size now. */
do_pending_window_change (0);
- if (wait < INFINITY && nfds == 0 && ! timeout_reduced_for_timers)
+ if (wait < FOREVER && nfds == 0 && ! timeout_reduced_for_timers)
/* We waited the full specified time, so return now. */
break;
@@ -7949,8 +7934,7 @@ integer or floating point values.
majflt -- number of major page faults (number)
cminflt -- cumulative number of minor page faults (number)
cmajflt -- cumulative number of major page faults (number)
- utime -- user time used by the process, in (current-time) format,
- which is a list of integers (HIGH LOW USEC PSEC)
+ utime -- user time used by the process, in `current-time' format
stime -- system time used by the process (current-time)
time -- sum of utime and stime (current-time)
cutime -- user time used by the process and its children (current-time)
@@ -7962,7 +7946,7 @@ integer or floating point values.
start -- time the process started (current-time)
vsize -- virtual memory size of the process in KB's (number)
rss -- resident set size of the process in KB's (number)
- etime -- elapsed time the process is running, in (HIGH LOW USEC PSEC) format
+ etime -- elapsed time the process is running (current-time)
pcpu -- percents of CPU time used by the process (floating-point number)
pmem -- percents of total physical memory used by process's resident set
(floating-point number)
@@ -8048,6 +8032,18 @@ init_process_emacs (int sockfd)
#endif
external_sock_fd = sockfd;
+ Lisp_Object sockname = Qnil;
+# if HAVE_GETSOCKNAME
+ if (0 <= sockfd)
+ {
+ union u_sockaddr sa;
+ socklen_t salen = sizeof sa;
+ if (getsockname (sockfd, &sa.sa, &salen) == 0)
+ sockname = conv_sockaddr_to_lisp (&sa.sa, salen);
+ }
+# endif
+ Vinternal__daemon_sockname = sockname;
+
max_desc = -1;
memset (fd_callback_info, 0, sizeof (fd_callback_info));
@@ -8240,6 +8236,10 @@ These functions are called in the order of the list, until one of them
returns non-`nil'. */);
Vinterrupt_process_functions = list1 (Qinternal_default_interrupt_process);
+ DEFVAR_LISP ("internal--daemon-sockname", Vinternal__daemon_sockname,
+ doc: /* Name of external socket passed to Emacs, or nil if none. */);
+ Vinternal__daemon_sockname = Qnil;
+
DEFSYM (Qinternal_default_interrupt_process,
"internal-default-interrupt-process");
DEFSYM (Qinterrupt_process_functions, "interrupt-process-functions");