aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2007-09-20 21:32:12 +0000
committerStefan Monnier2007-09-20 21:32:12 +0000
commitd30a25b306ced73b560cb95ceb9ced5ee5a0fd30 (patch)
treed2ed57a296a1da98ea633c6a1d927e3c0bd839f0 /src
parent4a729fd84ef490b74100bec2405c76ddf461b766 (diff)
downloademacs-d30a25b306ced73b560cb95ceb9ced5ee5a0fd30.tar.gz
emacs-d30a25b306ced73b560cb95ceb9ced5ee5a0fd30.zip
(get_terminal): Handle terminals.
Make sure the terminal returned is live. (create_terminal): Use allocate_terminal. (mark_terminals): Move to alloc.c. (delete_terminal): Use terminal->name as liveness status. NULL out fields after freeing their contents. Don't deallocate the object. (Fframe_terminal): Use FRAME_TERMINAL. Return the terminal object rather than an int. (Fterminal_live_p): Accept non-integer arguments. (Fterminal_list): Return terminal objects rather than an ints.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog38
-rw-r--r--src/terminal.c78
2 files changed, 74 insertions, 42 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c74e872de70..44c04fcb940 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,41 @@
12007-09-20 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * terminal.c (get_terminal): Handle terminals.
4 Make sure the terminal returned is live.
5 (create_terminal): Use allocate_terminal.
6 (mark_terminals): Move to alloc.c.
7 (delete_terminal): Use terminal->name as liveness status.
8 NULL out fields after freeing their contents.
9 Don't deallocate the object.
10 (Fframe_terminal): Use FRAME_TERMINAL. Return the terminal object
11 rather than an int.
12 (Fterminal_live_p): Accept non-integer arguments.
13 (Fterminal_list): Return terminal objects rather than an ints.
14
15 * alloc.c (enum mem_type): New member for `terminal' objects.
16 (allocate_terminal): New function.
17 (mark_maybe_pointer, valid_lisp_object_p, mark_object): Handle terminals.
18 (mark_terminal): New fun.
19 (mark_terminals): Move from terminal.c.
20
21 * term.c (get_tty_terminal): Don't treat output_initial specially.
22 (Fsuspend_tty, Fresume_tty): Use terminal objects rather than ints.
23 (delete_tty): Use terminal->name as liveness status.
24
25 * termhooks.h (struct terminal): Make it into a pseudovector.
26 Remove `deleted' replaced by checking `name's nullness.
27
28 * print.c (print_object): Handle terminals.
29
30 * lisp.h (enum pvec_type): New `terminal' pseudovector.
31 (XTERMINAL, XSETTERMINAL, TERMINALP, GC_TERMINALP): New macros.
32
33 * frame.c (make_terminal_frame):
34 * keyboard.c (tty_read_avail_input):
35 * w32term.c (x_delete_terminal):
36 * xfns.c (Fx_create_frame, x_create_tip_frame):
37 * xterm.c (x_delete_terminal): Use terminal->name as liveness status.
38
12007-09-20 Glenn Morris <rgm@gnu.org> 392007-09-20 Glenn Morris <rgm@gnu.org>
2 40
3 * process.c (Fmake_network_process): Doc fix. 41 * process.c (Fmake_network_process): Doc fix.
diff --git a/src/terminal.c b/src/terminal.c
index c7d3da5d935..39407507108 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -205,8 +205,12 @@ get_terminal (Lisp_Object terminal, int throw)
205 if (NILP (terminal)) 205 if (NILP (terminal))
206 terminal = selected_frame; 206 terminal = selected_frame;
207 207
208 if (INTEGERP (terminal)) 208 if (TERMINALP (terminal))
209 result = XTERMINAL (terminal);
210
211 else if (INTEGERP (terminal))
209 { 212 {
213 /* FIXME: Get rid of the use of integers to represent terminals. */
210 struct terminal *t; 214 struct terminal *t;
211 215
212 for (t = terminal_list; t; t = t->next_terminal) 216 for (t = terminal_list; t; t = t->next_terminal)
@@ -214,6 +218,7 @@ get_terminal (Lisp_Object terminal, int throw)
214 if (t->id == XINT (terminal)) 218 if (t->id == XINT (terminal))
215 { 219 {
216 result = t; 220 result = t;
221 eassert (t->name != NULL);
217 break; 222 break;
218 } 223 }
219 } 224 }
@@ -223,6 +228,9 @@ get_terminal (Lisp_Object terminal, int throw)
223 result = FRAME_TERMINAL (XFRAME (terminal)); 228 result = FRAME_TERMINAL (XFRAME (terminal));
224 } 229 }
225 230
231 if (result && !result->name)
232 result = NULL;
233
226 if (result == NULL && throw) 234 if (result == NULL && throw)
227 wrong_type_argument (Qterminal_live_p, terminal); 235 wrong_type_argument (Qterminal_live_p, terminal);
228 236
@@ -236,9 +244,9 @@ get_terminal (Lisp_Object terminal, int throw)
236struct terminal * 244struct terminal *
237create_terminal (void) 245create_terminal (void)
238{ 246{
239 struct terminal *terminal = (struct terminal *) xmalloc (sizeof (struct terminal)); 247 struct terminal *terminal = allocate_terminal ();
240 248
241 bzero (terminal, sizeof (struct terminal)); 249 terminal->name = NULL;
242 terminal->next_terminal = terminal_list; 250 terminal->next_terminal = terminal_list;
243 terminal_list = terminal; 251 terminal_list = terminal;
244 252
@@ -256,20 +264,6 @@ create_terminal (void)
256 return terminal; 264 return terminal;
257} 265}
258 266
259/* Mark the Lisp pointers in the terminal objects.
260 Called by the Fgarbage_collector. */
261
262void
263mark_terminals (void)
264{
265 struct terminal *t;
266 for (t = terminal_list; t; t = t->next_terminal)
267 {
268 mark_object (t->param_alist);
269 }
270}
271
272
273/* Low-level function to close all frames on a terminal, remove it 267/* Low-level function to close all frames on a terminal, remove it
274 from the terminal list and free its memory. */ 268 from the terminal list and free its memory. */
275 269
@@ -281,9 +275,10 @@ delete_terminal (struct terminal *terminal)
281 275
282 /* Protect against recursive calls. Fdelete_frame calls the 276 /* Protect against recursive calls. Fdelete_frame calls the
283 delete_terminal_hook when we delete our last frame. */ 277 delete_terminal_hook when we delete our last frame. */
284 if (terminal->deleted) 278 if (!terminal->name)
285 return; 279 return;
286 terminal->deleted = 1; 280 xfree (terminal->name);
281 terminal->name = NULL;
287 282
288 /* Check for live frames that are still on this terminal. */ 283 /* Check for live frames that are still on this terminal. */
289 FOR_EACH_FRAME (tail, frame) 284 FOR_EACH_FRAME (tail, frame)
@@ -300,20 +295,18 @@ delete_terminal (struct terminal *terminal)
300 abort (); 295 abort ();
301 *tp = terminal->next_terminal; 296 *tp = terminal->next_terminal;
302 297
303 if (terminal->keyboard_coding) 298 xfree (terminal->keyboard_coding);
304 xfree (terminal->keyboard_coding); 299 terminal->keyboard_coding = NULL;
305 if (terminal->terminal_coding) 300 xfree (terminal->terminal_coding);
306 xfree (terminal->terminal_coding); 301 terminal->terminal_coding = NULL;
307 if (terminal->name)
308 xfree (terminal->name);
309 302
310#ifdef MULTI_KBOARD 303#ifdef MULTI_KBOARD
311 if (terminal->kboard && --terminal->kboard->reference_count == 0) 304 if (terminal->kboard && --terminal->kboard->reference_count == 0)
312 delete_kboard (terminal->kboard); 305 {
306 delete_kboard (terminal->kboard);
307 terminal->kboard = NULL;
308 }
313#endif 309#endif
314
315 bzero (terminal, sizeof (struct terminal));
316 xfree (terminal);
317} 310}
318 311
319DEFUN ("delete-terminal", Fdelete_terminal, Sdelete_terminal, 0, 2, 0, 312DEFUN ("delete-terminal", Fdelete_terminal, Sdelete_terminal, 0, 2, 0,
@@ -364,12 +357,16 @@ The terminal device is represented by its integer identifier. */)
364 357
365 CHECK_LIVE_FRAME (frame); 358 CHECK_LIVE_FRAME (frame);
366 359
367 t = get_terminal (frame, 0); 360 t = FRAME_TERMINAL (XFRAME (frame));
368 361
369 if (!t) 362 if (!t)
370 return Qnil; 363 return Qnil;
371 else 364 else
372 return make_number (t->id); 365 {
366 Lisp_Object terminal;
367 XSETTERMINAL (terminal, t);
368 return terminal;
369 }
373} 370}
374 371
375DEFUN ("terminal-live-p", Fterminal_live_p, Sterminal_live_p, 1, 1, 0, 372DEFUN ("terminal-live-p", Fterminal_live_p, Sterminal_live_p, 1, 1, 0,
@@ -377,17 +374,12 @@ DEFUN ("terminal-live-p", Fterminal_live_p, Sterminal_live_p, 1, 1, 0,
377Value is nil if OBJECT is not a live display terminal. 374Value is nil if OBJECT is not a live display terminal.
378If object is a live display terminal, the return value indicates what 375If object is a live display terminal, the return value indicates what
379sort of output terminal it uses. See the documentation of `framep' for 376sort of output terminal it uses. See the documentation of `framep' for
380possible return values. 377possible return values. */)
381
382Display terminals are represented by their integer identifiers. */)
383 (object) 378 (object)
384 Lisp_Object object; 379 Lisp_Object object;
385{ 380{
386 struct terminal *t; 381 struct terminal *t;
387 382
388 if (!INTEGERP (object))
389 return Qnil;
390
391 t = get_terminal (object, 0); 383 t = get_terminal (object, 0);
392 384
393 if (!t) 385 if (!t)
@@ -412,15 +404,17 @@ Display terminals are represented by their integer identifiers. */)
412} 404}
413 405
414DEFUN ("terminal-list", Fterminal_list, Sterminal_list, 0, 0, 0, 406DEFUN ("terminal-list", Fterminal_list, Sterminal_list, 0, 0, 0,
415 doc: /* Return a list of all terminal devices. 407 doc: /* Return a list of all terminal devices. */)
416Terminal devices are represented by their integer identifiers. */)
417 () 408 ()
418{ 409{
419 Lisp_Object terminals = Qnil; 410 Lisp_Object terminal, terminals = Qnil;
420 struct terminal *t; 411 struct terminal *t;
421 412
422 for (t = terminal_list; t; t = t->next_terminal) 413 for (t = terminal_list; t; t = t->next_terminal)
423 terminals = Fcons (make_number (t->id), terminals); 414 {
415 XSETTERMINAL (terminal, t);
416 terminals = Fcons (terminal, terminals);
417 }
424 418
425 return terminals; 419 return terminals;
426} 420}