aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-09-20 21:28:51 +0000
committerStefan Monnier2007-09-20 21:28:51 +0000
commit4a729fd84ef490b74100bec2405c76ddf461b766 (patch)
tree4750401a11ea5b20f049b131bc89d685119d44ff
parent59a7bc630dc4ed75fee06037afe86088afce21e5 (diff)
downloademacs-4a729fd84ef490b74100bec2405c76ddf461b766.tar.gz
emacs-4a729fd84ef490b74100bec2405c76ddf461b766.zip
(enum mem_type): New member for `terminal' objects.
(allocate_terminal): New function. (mark_maybe_pointer, valid_lisp_object_p, mark_object): Handle terminals. (mark_terminal): New fun. (mark_terminals): Move from terminal.c.
-rw-r--r--src/alloc.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c
index f1758158344..2599d5c8ad8 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -55,6 +55,7 @@ Boston, MA 02110-1301, USA. */
55#include "blockinput.h" 55#include "blockinput.h"
56#include "charset.h" 56#include "charset.h"
57#include "syssignal.h" 57#include "syssignal.h"
58#include "termhooks.h" /* For struct terminal. */
58#include <setjmp.h> 59#include <setjmp.h>
59 60
60/* GC_MALLOC_CHECK defined means perform validity checks of malloc'd 61/* GC_MALLOC_CHECK defined means perform validity checks of malloc'd
@@ -341,7 +342,8 @@ Lisp_Object Vgc_elapsed; /* accumulated elapsed time in GC */
341EMACS_INT gcs_done; /* accumulated GCs */ 342EMACS_INT gcs_done; /* accumulated GCs */
342 343
343static void mark_buffer P_ ((Lisp_Object)); 344static void mark_buffer P_ ((Lisp_Object));
344extern void mark_terminals P_ ((void)); 345static void mark_terminal P_((struct terminal *t));
346static void mark_terminals P_ ((void));
345extern void mark_kboards P_ ((void)); 347extern void mark_kboards P_ ((void));
346extern void mark_ttys P_ ((void)); 348extern void mark_ttys P_ ((void));
347extern void mark_backtrace P_ ((void)); 349extern void mark_backtrace P_ ((void));
@@ -382,6 +384,7 @@ enum mem_type
382 MEM_TYPE_PROCESS, 384 MEM_TYPE_PROCESS,
383 MEM_TYPE_HASH_TABLE, 385 MEM_TYPE_HASH_TABLE,
384 MEM_TYPE_FRAME, 386 MEM_TYPE_FRAME,
387 MEM_TYPE_TERMINAL,
385 MEM_TYPE_WINDOW 388 MEM_TYPE_WINDOW
386}; 389};
387 390
@@ -3017,6 +3020,22 @@ allocate_window ()
3017} 3020}
3018 3021
3019 3022
3023struct terminal *
3024allocate_terminal ()
3025{
3026 EMACS_INT len = VECSIZE (struct terminal);
3027 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_TERMINAL);
3028 EMACS_INT i;
3029 Lisp_Object tmp, zero = make_number (0);
3030
3031 for (i = 0; i < len; ++i)
3032 v->contents[i] = zero;
3033 v->size = len;
3034 XSETTERMINAL (tmp, v); /* Add the appropriate tag. */
3035
3036 return (struct terminal *) v;
3037}
3038
3020struct frame * 3039struct frame *
3021allocate_frame () 3040allocate_frame ()
3022{ 3041{
@@ -4320,6 +4339,7 @@ mark_maybe_pointer (p)
4320 case MEM_TYPE_PROCESS: 4339 case MEM_TYPE_PROCESS:
4321 case MEM_TYPE_HASH_TABLE: 4340 case MEM_TYPE_HASH_TABLE:
4322 case MEM_TYPE_FRAME: 4341 case MEM_TYPE_FRAME:
4342 case MEM_TYPE_TERMINAL:
4323 case MEM_TYPE_WINDOW: 4343 case MEM_TYPE_WINDOW:
4324 if (live_vector_p (m, p)) 4344 if (live_vector_p (m, p))
4325 { 4345 {
@@ -4724,6 +4744,7 @@ valid_lisp_object_p (obj)
4724 case MEM_TYPE_PROCESS: 4744 case MEM_TYPE_PROCESS:
4725 case MEM_TYPE_HASH_TABLE: 4745 case MEM_TYPE_HASH_TABLE:
4726 case MEM_TYPE_FRAME: 4746 case MEM_TYPE_FRAME:
4747 case MEM_TYPE_TERMINAL:
4727 case MEM_TYPE_WINDOW: 4748 case MEM_TYPE_WINDOW:
4728 return live_vector_p (m, p); 4749 return live_vector_p (m, p);
4729 4750
@@ -5662,6 +5683,11 @@ mark_object (arg)
5662 mark_glyph_matrix (w->desired_matrix); 5683 mark_glyph_matrix (w->desired_matrix);
5663 } 5684 }
5664 } 5685 }
5686 else if (GC_TERMINALP (obj))
5687 {
5688 CHECK_LIVE (live_vector_p);
5689 mark_terminal (XTERMINAL (obj));
5690 }
5665 else if (GC_HASH_TABLE_P (obj)) 5691 else if (GC_HASH_TABLE_P (obj))
5666 { 5692 {
5667 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); 5693 struct Lisp_Hash_Table *h = XHASH_TABLE (obj);
@@ -5905,6 +5931,28 @@ mark_buffer (buf)
5905 } 5931 }
5906} 5932}
5907 5933
5934/* Mark the Lisp pointers in the terminal objects.
5935 Called by the Fgarbage_collector. */
5936
5937static void
5938mark_terminal (struct terminal *t)
5939{
5940 VECTOR_MARK (t);
5941 mark_object (t->param_alist);
5942}
5943
5944static void
5945mark_terminals (void)
5946{
5947 struct terminal *t;
5948 for (t = terminal_list; t; t = t->next_terminal)
5949 {
5950 eassert (t->name != NULL);
5951 mark_terminal (t);
5952 }
5953}
5954
5955
5908 5956
5909/* Value is non-zero if OBJ will survive the current GC because it's 5957/* Value is non-zero if OBJ will survive the current GC because it's
5910 either marked or does not need to be marked to survive. */ 5958 either marked or does not need to be marked to survive. */