diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/buffer.h | 6 | ||||
| -rw-r--r-- | src/lisp.h | 6 | ||||
| -rw-r--r-- | src/process.c | 47 |
4 files changed, 38 insertions, 30 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0d3982618b7..1ad3e1cff24 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,14 @@ | |||
| 1 | 2013-08-15 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2013-08-15 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | * lisp.h (FOR_EACH_ALIST_VALUE): New macro | ||
| 4 | to do `for' loops over alist values. | ||
| 5 | * buffer.h (FOR_EACH_BUFFER): | ||
| 6 | * process.c (FOR_EACH_PROCESS): Use it. | ||
| 7 | (handle_child_signal, status_notify, Fget_buffer_process) | ||
| 8 | (kill_buffer_processes): Use FOR_EACH_PROCESS. | ||
| 9 | |||
| 10 | 2013-08-15 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 11 | |||
| 3 | * term.c (get_named_tty, create_tty_output, tty_free_frame_resources) | 12 | * term.c (get_named_tty, create_tty_output, tty_free_frame_resources) |
| 4 | (tty_free_frame_resources, delete_tty): Prefer eassert to emacs_abort. | 13 | (tty_free_frame_resources, delete_tty): Prefer eassert to emacs_abort. |
| 5 | * image.c (make_image_cache): For struct image_cache, prefer xmalloc | 14 | * image.c (make_image_cache): For struct image_cache, prefer xmalloc |
diff --git a/src/buffer.h b/src/buffer.h index 221db39329a..55a9e8d2a1c 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -1132,10 +1132,8 @@ extern Lisp_Object Qpriority, Qbefore_string, Qafter_string; | |||
| 1132 | /* FOR_EACH_LIVE_BUFFER (LIST_VAR, BUF_VAR) followed by a statement is | 1132 | /* FOR_EACH_LIVE_BUFFER (LIST_VAR, BUF_VAR) followed by a statement is |
| 1133 | a `for' loop which iterates over the buffers from Vbuffer_alist. */ | 1133 | a `for' loop which iterates over the buffers from Vbuffer_alist. */ |
| 1134 | 1134 | ||
| 1135 | #define FOR_EACH_LIVE_BUFFER(list_var, buf_var) \ | 1135 | #define FOR_EACH_LIVE_BUFFER(list_var, buf_var) \ |
| 1136 | for (list_var = Vbuffer_alist; \ | 1136 | FOR_EACH_ALIST_VALUE (Vbuffer_alist, list_var, buf_var) |
| 1137 | (CONSP (list_var) && (buf_var = XCDR (XCAR (list_var)), 1)); \ | ||
| 1138 | list_var = XCDR (list_var)) | ||
| 1139 | 1137 | ||
| 1140 | /* Get text properties of B. */ | 1138 | /* Get text properties of B. */ |
| 1141 | 1139 | ||
diff --git a/src/lisp.h b/src/lisp.h index 6d79bb1d6a5..e6e90e1e968 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4342,6 +4342,12 @@ extern void *record_xmalloc (size_t); | |||
| 4342 | memory_full (SIZE_MAX); \ | 4342 | memory_full (SIZE_MAX); \ |
| 4343 | } while (0) | 4343 | } while (0) |
| 4344 | 4344 | ||
| 4345 | /* Do a `for' loop over alist values. */ | ||
| 4346 | |||
| 4347 | #define FOR_EACH_ALIST_VALUE(head_var, list_var, value_var) \ | ||
| 4348 | for (list_var = head_var; \ | ||
| 4349 | (CONSP (list_var) && (value_var = XCDR (XCAR (list_var)), 1)); \ | ||
| 4350 | list_var = XCDR (list_var)) | ||
| 4345 | 4351 | ||
| 4346 | /* Check whether it's time for GC, and run it if so. */ | 4352 | /* Check whether it's time for GC, and run it if so. */ |
| 4347 | 4353 | ||
diff --git a/src/process.c b/src/process.c index c803d69d6d8..892a5aa86c5 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -361,6 +361,12 @@ static struct sockaddr_and_len { | |||
| 361 | #define DATAGRAM_CONN_P(proc) (0) | 361 | #define DATAGRAM_CONN_P(proc) (0) |
| 362 | #endif | 362 | #endif |
| 363 | 363 | ||
| 364 | /* FOR_EACH_PROCESS (LIST_VAR, PROC_VAR) followed by a statement is | ||
| 365 | a `for' loop which iterates over processes from Vprocess_alist. */ | ||
| 366 | |||
| 367 | #define FOR_EACH_PROCESS(list_var, proc_var) \ | ||
| 368 | FOR_EACH_ALIST_VALUE (Vprocess_alist, list_var, proc_var) | ||
| 369 | |||
| 364 | /* These setters are used only in this file, so they can be private. */ | 370 | /* These setters are used only in this file, so they can be private. */ |
| 365 | static void | 371 | static void |
| 366 | pset_buffer (struct Lisp_Process *p, Lisp_Object val) | 372 | pset_buffer (struct Lisp_Process *p, Lisp_Object val) |
| @@ -6135,7 +6141,7 @@ static signal_handler_t volatile lib_child_handler; | |||
| 6135 | static void | 6141 | static void |
| 6136 | handle_child_signal (int sig) | 6142 | handle_child_signal (int sig) |
| 6137 | { | 6143 | { |
| 6138 | Lisp_Object tail; | 6144 | Lisp_Object tail, proc; |
| 6139 | 6145 | ||
| 6140 | /* Find the process that signaled us, and record its status. */ | 6146 | /* Find the process that signaled us, and record its status. */ |
| 6141 | 6147 | ||
| @@ -6165,9 +6171,8 @@ handle_child_signal (int sig) | |||
| 6165 | } | 6171 | } |
| 6166 | 6172 | ||
| 6167 | /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */ | 6173 | /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */ |
| 6168 | for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) | 6174 | FOR_EACH_PROCESS (tail, proc) |
| 6169 | { | 6175 | { |
| 6170 | Lisp_Object proc = XCDR (XCAR (tail)); | ||
| 6171 | struct Lisp_Process *p = XPROCESS (proc); | 6176 | struct Lisp_Process *p = XPROCESS (proc); |
| 6172 | int status; | 6177 | int status; |
| 6173 | 6178 | ||
| @@ -6322,13 +6327,10 @@ status_notify (struct Lisp_Process *deleting_process) | |||
| 6322 | that we run, we get called again to handle their status changes. */ | 6327 | that we run, we get called again to handle their status changes. */ |
| 6323 | update_tick = process_tick; | 6328 | update_tick = process_tick; |
| 6324 | 6329 | ||
| 6325 | for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) | 6330 | FOR_EACH_PROCESS (tail, proc) |
| 6326 | { | 6331 | { |
| 6327 | Lisp_Object symbol; | 6332 | Lisp_Object symbol; |
| 6328 | register struct Lisp_Process *p; | 6333 | register struct Lisp_Process *p = XPROCESS (proc); |
| 6329 | |||
| 6330 | proc = Fcdr (XCAR (tail)); | ||
| 6331 | p = XPROCESS (proc); | ||
| 6332 | 6334 | ||
| 6333 | if (p->tick != p->update_tick) | 6335 | if (p->tick != p->update_tick) |
| 6334 | { | 6336 | { |
| @@ -6851,12 +6853,9 @@ BUFFER may be a buffer or the name of one. */) | |||
| 6851 | buf = Fget_buffer (buffer); | 6853 | buf = Fget_buffer (buffer); |
| 6852 | if (NILP (buf)) return Qnil; | 6854 | if (NILP (buf)) return Qnil; |
| 6853 | 6855 | ||
| 6854 | for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) | 6856 | FOR_EACH_PROCESS (tail, proc) |
| 6855 | { | 6857 | if (EQ (XPROCESS (proc)->buffer, buf)) |
| 6856 | proc = Fcdr (XCAR (tail)); | 6858 | return proc; |
| 6857 | if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf)) | ||
| 6858 | return proc; | ||
| 6859 | } | ||
| 6860 | #endif /* subprocesses */ | 6859 | #endif /* subprocesses */ |
| 6861 | return Qnil; | 6860 | return Qnil; |
| 6862 | } | 6861 | } |
| @@ -6889,18 +6888,14 @@ kill_buffer_processes (Lisp_Object buffer) | |||
| 6889 | #ifdef subprocesses | 6888 | #ifdef subprocesses |
| 6890 | Lisp_Object tail, proc; | 6889 | Lisp_Object tail, proc; |
| 6891 | 6890 | ||
| 6892 | for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) | 6891 | FOR_EACH_PROCESS (tail, proc) |
| 6893 | { | 6892 | if (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer)) |
| 6894 | proc = XCDR (XCAR (tail)); | 6893 | { |
| 6895 | if (PROCESSP (proc) | 6894 | if (NETCONN_P (proc) || SERIALCONN_P (proc)) |
| 6896 | && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) | 6895 | Fdelete_process (proc); |
| 6897 | { | 6896 | else if (XPROCESS (proc)->infd >= 0) |
| 6898 | if (NETCONN_P (proc) || SERIALCONN_P (proc)) | 6897 | process_send_signal (proc, SIGHUP, Qnil, 1); |
| 6899 | Fdelete_process (proc); | 6898 | } |
| 6900 | else if (XPROCESS (proc)->infd >= 0) | ||
| 6901 | process_send_signal (proc, SIGHUP, Qnil, 1); | ||
| 6902 | } | ||
| 6903 | } | ||
| 6904 | #else /* subprocesses */ | 6899 | #else /* subprocesses */ |
| 6905 | /* Since we have no subprocesses, this does nothing. */ | 6900 | /* Since we have no subprocesses, this does nothing. */ |
| 6906 | #endif /* subprocesses */ | 6901 | #endif /* subprocesses */ |