* alloc.c (make_pure_float): Align pureptr on a sizeof (double)
[bpt/emacs.git] / src / alloc.c
CommitLineData
7146af97 1/* Storage allocation and gc for GNU Emacs Lisp interpreter.
7c299e7a 2 Copyright (C) 1985, 1986, 1988, 1992, 1993 Free Software Foundation, Inc.
7146af97
JB
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
7c299e7a 8the Free Software Foundation; either version 2, or (at your option)
7146af97
JB
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21#include "config.h"
22#include "lisp.h"
d5e35230 23#include "intervals.h"
4c0be5f4 24#include "puresize.h"
7146af97
JB
25#ifndef standalone
26#include "buffer.h"
27#include "window.h"
502b9b64 28#include "frame.h"
7146af97
JB
29#endif
30
e065a56e
JB
31#include "syssignal.h"
32
7146af97
JB
33#define max(A,B) ((A) > (B) ? (A) : (B))
34
35/* Macro to verify that storage intended for Lisp objects is not
36 out of range to fit in the space for a pointer.
37 ADDRESS is the start of the block, and SIZE
38 is the amount of space within which objects can start. */
39#define VALIDATE_LISP_STORAGE(address, size) \
40do \
41 { \
42 Lisp_Object val; \
43 XSET (val, Lisp_Cons, (char *) address + size); \
44 if ((char *) XCONS (val) != (char *) address + size) \
45 { \
46 free (address); \
47 memory_full (); \
48 } \
49 } while (0)
50
51/* Number of bytes of consing done since the last gc */
52int consing_since_gc;
53
54/* Number of bytes of consing since gc before another gc should be done. */
55int gc_cons_threshold;
56
57/* Nonzero during gc */
58int gc_in_progress;
59
60#ifndef VIRT_ADDR_VARIES
61extern
62#endif /* VIRT_ADDR_VARIES */
63 int malloc_sbrk_used;
64
65#ifndef VIRT_ADDR_VARIES
66extern
67#endif /* VIRT_ADDR_VARIES */
68 int malloc_sbrk_unused;
69
502b9b64
JB
70/* Two limits controlling how much undo information to keep. */
71int undo_limit;
72int undo_strong_limit;
7146af97
JB
73
74/* Non-nil means defun should do purecopy on the function definition */
75Lisp_Object Vpurify_flag;
76
77#ifndef HAVE_SHM
78int pure[PURESIZE / sizeof (int)] = {0,}; /* Force it into data space! */
79#define PUREBEG (char *) pure
80#else
81#define pure PURE_SEG_BITS /* Use shared memory segment */
82#define PUREBEG (char *)PURE_SEG_BITS
4c0be5f4
JB
83
84/* This variable is used only by the XPNTR macro when HAVE_SHM is
85 defined. If we used the PURESIZE macro directly there, that would
86 make most of emacs dependent on puresize.h, which we don't want -
87 you should be able to change that without too much recompilation.
88 So map_in_data initializes pure_size, and the dependencies work
89 out. */
90int pure_size;
7146af97
JB
91#endif /* not HAVE_SHM */
92
93/* Index in pure at which next pure object will be allocated. */
94int pureptr;
95
96/* If nonzero, this is a warning delivered by malloc and not yet displayed. */
97char *pending_malloc_warning;
98
99/* Maximum amount of C stack to save when a GC happens. */
100
101#ifndef MAX_SAVE_STACK
102#define MAX_SAVE_STACK 16000
103#endif
104
105/* Buffer in which we save a copy of the C stack at each GC. */
106
107char *stack_copy;
108int stack_copy_size;
109
110/* Non-zero means ignore malloc warnings. Set during initialization. */
111int ignore_warnings;
350273a4
JA
112
113static void mark_object (), mark_buffer ();
114static void clear_marks (), gc_sweep ();
115static void compact_strings ();
7146af97 116\f
1a4f1e2c
JB
117/* Versions of malloc and realloc that print warnings as memory gets full. */
118
7146af97
JB
119Lisp_Object
120malloc_warning_1 (str)
121 Lisp_Object str;
122{
123 Fprinc (str, Vstandard_output);
124 write_string ("\nKilling some buffers may delay running out of memory.\n", -1);
125 write_string ("However, certainly by the time you receive the 95% warning,\n", -1);
126 write_string ("you should clean up, kill this Emacs, and start a new one.", -1);
127 return Qnil;
128}
129
130/* malloc calls this if it finds we are near exhausting storage */
131malloc_warning (str)
132 char *str;
133{
134 pending_malloc_warning = str;
135}
136
137display_malloc_warning ()
138{
139 register Lisp_Object val;
140
141 val = build_string (pending_malloc_warning);
142 pending_malloc_warning = 0;
143 internal_with_output_to_temp_buffer (" *Danger*", malloc_warning_1, val);
144}
145
146/* Called if malloc returns zero */
147memory_full ()
148{
149 error ("Memory exhausted");
150}
151
152/* like malloc and realloc but check for no memory left */
153
154long *
155xmalloc (size)
156 int size;
157{
158 register long *val;
159
160 val = (long *) malloc (size);
161
162 if (!val && size) memory_full ();
163 return val;
164}
165
166long *
167xrealloc (block, size)
168 long *block;
169 int size;
170{
171 register long *val;
172
56d2031b
JB
173 /* We must call malloc explicitly when BLOCK is 0, since some
174 reallocs don't do this. */
175 if (! block)
176 val = (long *) malloc (size);
f048679d 177 else
56d2031b 178 val = (long *) realloc (block, size);
7146af97
JB
179
180 if (!val && size) memory_full ();
181 return val;
182}
183\f
1a4f1e2c
JB
184/* Interval allocation. */
185
d5e35230
JA
186#ifdef USE_TEXT_PROPERTIES
187#define INTERVAL_BLOCK_SIZE \
188 ((1020 - sizeof (struct interval_block *)) / sizeof (struct interval))
189
190struct interval_block
191 {
192 struct interval_block *next;
193 struct interval intervals[INTERVAL_BLOCK_SIZE];
194 };
195
196struct interval_block *interval_block;
197static int interval_block_index;
198
199INTERVAL interval_free_list;
200
201static void
202init_intervals ()
203{
204 interval_block
205 = (struct interval_block *) malloc (sizeof (struct interval_block));
206 interval_block->next = 0;
207 bzero (interval_block->intervals, sizeof interval_block->intervals);
208 interval_block_index = 0;
209 interval_free_list = 0;
210}
211
212#define INIT_INTERVALS init_intervals ()
213
214INTERVAL
215make_interval ()
216{
217 INTERVAL val;
218
219 if (interval_free_list)
220 {
221 val = interval_free_list;
222 interval_free_list = interval_free_list->parent;
223 }
224 else
225 {
226 if (interval_block_index == INTERVAL_BLOCK_SIZE)
227 {
228 register struct interval_block *newi
229 = (struct interval_block *) malloc (sizeof (struct interval_block));
230
231 if (!newi)
232 memory_full ();
233
234 VALIDATE_LISP_STORAGE (newi, sizeof *newi);
235 newi->next = interval_block;
236 interval_block = newi;
237 interval_block_index = 0;
238 }
239 val = &interval_block->intervals[interval_block_index++];
240 }
241 consing_since_gc += sizeof (struct interval);
242 RESET_INTERVAL (val);
243 return val;
244}
245
246static int total_free_intervals, total_intervals;
247
248/* Mark the pointers of one interval. */
249
250static void
251mark_interval (i)
252 register INTERVAL i;
253{
254 if (XMARKBIT (i->plist))
255 abort ();
256 mark_object (&i->plist);
257 XMARK (i->plist);
258}
259
260static void
261mark_interval_tree (tree)
262 register INTERVAL tree;
263{
264 if (XMARKBIT (tree->plist))
265 return;
266
1a4f1e2c 267 traverse_intervals (tree, 1, 0, mark_interval);
d5e35230
JA
268}
269
270#define MARK_INTERVAL_TREE(i) \
271 { if (!NULL_INTERVAL_P (i)) mark_interval_tree (i); }
272
1a4f1e2c
JB
273/* The oddity in the call to XUNMARK is necessary because XUNMARK
274 expands to an assigment to its argument, and most C compilers don't
275 support casts on the left operand of `='. */
276#define UNMARK_BALANCE_INTERVALS(i) \
277{ \
278 if (! NULL_INTERVAL_P (i)) \
279 { \
280 XUNMARK (* (Lisp_Object *) (&(i)->parent)); \
281 (i) = balance_intervals (i); \
282 } \
d5e35230
JA
283}
284
285#else /* no interval use */
286
287#define INIT_INTERVALS
288
289#define UNMARK_BALANCE_INTERVALS(i)
290#define MARK_INTERVAL_TREE(i)
291
292#endif /* no interval use */
293\f
1a4f1e2c
JB
294/* Floating point allocation. */
295
7146af97
JB
296#ifdef LISP_FLOAT_TYPE
297/* Allocation of float cells, just like conses */
298/* We store float cells inside of float_blocks, allocating a new
299 float_block with malloc whenever necessary. Float cells reclaimed by
300 GC are put on a free list to be reallocated before allocating
301 any new float cells from the latest float_block.
302
303 Each float_block is just under 1020 bytes long,
304 since malloc really allocates in units of powers of two
305 and uses 4 bytes for its own overhead. */
306
307#define FLOAT_BLOCK_SIZE \
308 ((1020 - sizeof (struct float_block *)) / sizeof (struct Lisp_Float))
309
310struct float_block
311 {
312 struct float_block *next;
313 struct Lisp_Float floats[FLOAT_BLOCK_SIZE];
314 };
315
316struct float_block *float_block;
317int float_block_index;
318
319struct Lisp_Float *float_free_list;
320
321void
322init_float ()
323{
324 float_block = (struct float_block *) malloc (sizeof (struct float_block));
325 float_block->next = 0;
326 bzero (float_block->floats, sizeof float_block->floats);
327 float_block_index = 0;
328 float_free_list = 0;
329}
330
331/* Explicitly free a float cell. */
332free_float (ptr)
333 struct Lisp_Float *ptr;
334{
335 XFASTINT (ptr->type) = (int) float_free_list;
336 float_free_list = ptr;
337}
338
339Lisp_Object
340make_float (float_value)
341 double float_value;
342{
343 register Lisp_Object val;
344
345 if (float_free_list)
346 {
347 XSET (val, Lisp_Float, float_free_list);
348 float_free_list = (struct Lisp_Float *) XFASTINT (float_free_list->type);
349 }
350 else
351 {
352 if (float_block_index == FLOAT_BLOCK_SIZE)
353 {
354 register struct float_block *new = (struct float_block *) malloc (sizeof (struct float_block));
355 if (!new) memory_full ();
356 VALIDATE_LISP_STORAGE (new, sizeof *new);
357 new->next = float_block;
358 float_block = new;
359 float_block_index = 0;
360 }
361 XSET (val, Lisp_Float, &float_block->floats[float_block_index++]);
362 }
363 XFLOAT (val)->data = float_value;
364 XFLOAT (val)->type = 0; /* bug chasing -wsr */
365 consing_since_gc += sizeof (struct Lisp_Float);
366 return val;
367}
368
369#endif /* LISP_FLOAT_TYPE */
370\f
371/* Allocation of cons cells */
372/* We store cons cells inside of cons_blocks, allocating a new
373 cons_block with malloc whenever necessary. Cons cells reclaimed by
374 GC are put on a free list to be reallocated before allocating
375 any new cons cells from the latest cons_block.
376
377 Each cons_block is just under 1020 bytes long,
378 since malloc really allocates in units of powers of two
379 and uses 4 bytes for its own overhead. */
380
381#define CONS_BLOCK_SIZE \
382 ((1020 - sizeof (struct cons_block *)) / sizeof (struct Lisp_Cons))
383
384struct cons_block
385 {
386 struct cons_block *next;
387 struct Lisp_Cons conses[CONS_BLOCK_SIZE];
388 };
389
390struct cons_block *cons_block;
391int cons_block_index;
392
393struct Lisp_Cons *cons_free_list;
394
395void
396init_cons ()
397{
398 cons_block = (struct cons_block *) malloc (sizeof (struct cons_block));
399 cons_block->next = 0;
400 bzero (cons_block->conses, sizeof cons_block->conses);
401 cons_block_index = 0;
402 cons_free_list = 0;
403}
404
405/* Explicitly free a cons cell. */
406free_cons (ptr)
407 struct Lisp_Cons *ptr;
408{
409 XFASTINT (ptr->car) = (int) cons_free_list;
410 cons_free_list = ptr;
411}
412
413DEFUN ("cons", Fcons, Scons, 2, 2, 0,
414 "Create a new cons, give it CAR and CDR as components, and return it.")
415 (car, cdr)
416 Lisp_Object car, cdr;
417{
418 register Lisp_Object val;
419
420 if (cons_free_list)
421 {
422 XSET (val, Lisp_Cons, cons_free_list);
423 cons_free_list = (struct Lisp_Cons *) XFASTINT (cons_free_list->car);
424 }
425 else
426 {
427 if (cons_block_index == CONS_BLOCK_SIZE)
428 {
429 register struct cons_block *new = (struct cons_block *) malloc (sizeof (struct cons_block));
430 if (!new) memory_full ();
431 VALIDATE_LISP_STORAGE (new, sizeof *new);
432 new->next = cons_block;
433 cons_block = new;
434 cons_block_index = 0;
435 }
436 XSET (val, Lisp_Cons, &cons_block->conses[cons_block_index++]);
437 }
438 XCONS (val)->car = car;
439 XCONS (val)->cdr = cdr;
440 consing_since_gc += sizeof (struct Lisp_Cons);
441 return val;
442}
443
444DEFUN ("list", Flist, Slist, 0, MANY, 0,
445 "Return a newly created list with specified arguments as elements.\n\
446Any number of arguments, even zero arguments, are allowed.")
447 (nargs, args)
448 int nargs;
449 register Lisp_Object *args;
450{
451 register Lisp_Object len, val, val_tail;
452
453 XFASTINT (len) = nargs;
454 val = Fmake_list (len, Qnil);
455 val_tail = val;
265a9e55 456 while (!NILP (val_tail))
7146af97
JB
457 {
458 XCONS (val_tail)->car = *args++;
459 val_tail = XCONS (val_tail)->cdr;
460 }
461 return val;
462}
463
464DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
465 "Return a newly created list of length LENGTH, with each element being INIT.")
466 (length, init)
467 register Lisp_Object length, init;
468{
469 register Lisp_Object val;
470 register int size;
471
472 if (XTYPE (length) != Lisp_Int || XINT (length) < 0)
473 length = wrong_type_argument (Qnatnump, length);
474 size = XINT (length);
475
476 val = Qnil;
477 while (size-- > 0)
478 val = Fcons (init, val);
479 return val;
480}
481\f
482/* Allocation of vectors */
483
484struct Lisp_Vector *all_vectors;
485
486DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0,
487 "Return a newly created vector of length LENGTH, with each element being INIT.\n\
488See also the function `vector'.")
489 (length, init)
490 register Lisp_Object length, init;
491{
492 register int sizei, index;
493 register Lisp_Object vector;
494 register struct Lisp_Vector *p;
495
496 if (XTYPE (length) != Lisp_Int || XINT (length) < 0)
497 length = wrong_type_argument (Qnatnump, length);
498 sizei = XINT (length);
499
500 p = (struct Lisp_Vector *) malloc (sizeof (struct Lisp_Vector) + (sizei - 1) * sizeof (Lisp_Object));
501 if (p == 0)
502 memory_full ();
503 VALIDATE_LISP_STORAGE (p, 0);
504
505 XSET (vector, Lisp_Vector, p);
506 consing_since_gc += sizeof (struct Lisp_Vector) + (sizei - 1) * sizeof (Lisp_Object);
507
508 p->size = sizei;
509 p->next = all_vectors;
510 all_vectors = p;
511
512 for (index = 0; index < sizei; index++)
513 p->contents[index] = init;
514
515 return vector;
516}
517
518DEFUN ("vector", Fvector, Svector, 0, MANY, 0,
519 "Return a newly created vector with specified arguments as elements.\n\
520Any number of arguments, even zero arguments, are allowed.")
521 (nargs, args)
522 register int nargs;
523 Lisp_Object *args;
524{
525 register Lisp_Object len, val;
526 register int index;
527 register struct Lisp_Vector *p;
528
529 XFASTINT (len) = nargs;
530 val = Fmake_vector (len, Qnil);
531 p = XVECTOR (val);
532 for (index = 0; index < nargs; index++)
533 p->contents[index] = args[index];
534 return val;
535}
536
537DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0,
538 "Create a byte-code object with specified arguments as elements.\n\
539The arguments should be the arglist, bytecode-string, constant vector,\n\
540stack size, (optional) doc string, and (optional) interactive spec.\n\
541The first four arguments are required; at most six have any\n\
542significance.")
543 (nargs, args)
544 register int nargs;
545 Lisp_Object *args;
546{
547 register Lisp_Object len, val;
548 register int index;
549 register struct Lisp_Vector *p;
550
551 XFASTINT (len) = nargs;
265a9e55 552 if (!NILP (Vpurify_flag))
7146af97
JB
553 val = make_pure_vector (len);
554 else
555 val = Fmake_vector (len, Qnil);
556 p = XVECTOR (val);
557 for (index = 0; index < nargs; index++)
558 {
265a9e55 559 if (!NILP (Vpurify_flag))
7146af97
JB
560 args[index] = Fpurecopy (args[index]);
561 p->contents[index] = args[index];
562 }
563 XSETTYPE (val, Lisp_Compiled);
564 return val;
565}
566\f
567/* Allocation of symbols.
568 Just like allocation of conses!
569
570 Each symbol_block is just under 1020 bytes long,
571 since malloc really allocates in units of powers of two
572 and uses 4 bytes for its own overhead. */
573
574#define SYMBOL_BLOCK_SIZE \
575 ((1020 - sizeof (struct symbol_block *)) / sizeof (struct Lisp_Symbol))
576
577struct symbol_block
578 {
579 struct symbol_block *next;
580 struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE];
581 };
582
583struct symbol_block *symbol_block;
584int symbol_block_index;
585
586struct Lisp_Symbol *symbol_free_list;
587
588void
589init_symbol ()
590{
591 symbol_block = (struct symbol_block *) malloc (sizeof (struct symbol_block));
592 symbol_block->next = 0;
593 bzero (symbol_block->symbols, sizeof symbol_block->symbols);
594 symbol_block_index = 0;
595 symbol_free_list = 0;
596}
597
598DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0,
599 "Return a newly allocated uninterned symbol whose name is NAME.\n\
600Its value and function definition are void, and its property list is nil.")
601 (str)
602 Lisp_Object str;
603{
604 register Lisp_Object val;
605 register struct Lisp_Symbol *p;
606
607 CHECK_STRING (str, 0);
608
609 if (symbol_free_list)
610 {
611 XSET (val, Lisp_Symbol, symbol_free_list);
612 symbol_free_list
613 = (struct Lisp_Symbol *) XFASTINT (symbol_free_list->value);
614 }
615 else
616 {
617 if (symbol_block_index == SYMBOL_BLOCK_SIZE)
618 {
619 struct symbol_block *new = (struct symbol_block *) malloc (sizeof (struct symbol_block));
620 if (!new) memory_full ();
621 VALIDATE_LISP_STORAGE (new, sizeof *new);
622 new->next = symbol_block;
623 symbol_block = new;
624 symbol_block_index = 0;
625 }
626 XSET (val, Lisp_Symbol, &symbol_block->symbols[symbol_block_index++]);
627 }
628 p = XSYMBOL (val);
629 p->name = XSTRING (str);
630 p->plist = Qnil;
631 p->value = Qunbound;
632 p->function = Qunbound;
633 p->next = 0;
634 consing_since_gc += sizeof (struct Lisp_Symbol);
635 return val;
636}
637\f
638/* Allocation of markers.
639 Works like allocation of conses. */
640
641#define MARKER_BLOCK_SIZE \
642 ((1020 - sizeof (struct marker_block *)) / sizeof (struct Lisp_Marker))
643
644struct marker_block
645 {
646 struct marker_block *next;
647 struct Lisp_Marker markers[MARKER_BLOCK_SIZE];
648 };
649
650struct marker_block *marker_block;
651int marker_block_index;
652
653struct Lisp_Marker *marker_free_list;
654
655void
656init_marker ()
657{
658 marker_block = (struct marker_block *) malloc (sizeof (struct marker_block));
659 marker_block->next = 0;
660 bzero (marker_block->markers, sizeof marker_block->markers);
661 marker_block_index = 0;
662 marker_free_list = 0;
663}
664
665DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
666 "Return a newly allocated marker which does not point at any place.")
667 ()
668{
669 register Lisp_Object val;
670 register struct Lisp_Marker *p;
e065a56e 671
7146af97
JB
672 if (marker_free_list)
673 {
674 XSET (val, Lisp_Marker, marker_free_list);
675 marker_free_list
676 = (struct Lisp_Marker *) XFASTINT (marker_free_list->chain);
677 }
678 else
679 {
680 if (marker_block_index == MARKER_BLOCK_SIZE)
681 {
682 struct marker_block *new = (struct marker_block *) malloc (sizeof (struct marker_block));
683 if (!new) memory_full ();
684 VALIDATE_LISP_STORAGE (new, sizeof *new);
685 new->next = marker_block;
686 marker_block = new;
687 marker_block_index = 0;
688 }
689 XSET (val, Lisp_Marker, &marker_block->markers[marker_block_index++]);
690 }
691 p = XMARKER (val);
692 p->buffer = 0;
693 p->bufpos = 0;
694 p->chain = Qnil;
695 consing_since_gc += sizeof (struct Lisp_Marker);
696 return val;
697}
698\f
699/* Allocation of strings */
700
701/* Strings reside inside of string_blocks. The entire data of the string,
702 both the size and the contents, live in part of the `chars' component of a string_block.
703 The `pos' component is the index within `chars' of the first free byte.
704
705 first_string_block points to the first string_block ever allocated.
706 Each block points to the next one with its `next' field.
707 The `prev' fields chain in reverse order.
708 The last one allocated is the one currently being filled.
709 current_string_block points to it.
710
711 The string_blocks that hold individual large strings
712 go in a separate chain, started by large_string_blocks. */
713
714
715/* String blocks contain this many useful bytes.
716 8188 is power of 2, minus 4 for malloc overhead. */
717#define STRING_BLOCK_SIZE (8188 - sizeof (struct string_block_head))
718
719/* A string bigger than this gets its own specially-made string block
720 if it doesn't fit in the current one. */
721#define STRING_BLOCK_OUTSIZE 1024
722
723struct string_block_head
724 {
725 struct string_block *next, *prev;
726 int pos;
727 };
728
729struct string_block
730 {
731 struct string_block *next, *prev;
732 int pos;
733 char chars[STRING_BLOCK_SIZE];
734 };
735
736/* This points to the string block we are now allocating strings. */
737
738struct string_block *current_string_block;
739
740/* This points to the oldest string block, the one that starts the chain. */
741
742struct string_block *first_string_block;
743
744/* Last string block in chain of those made for individual large strings. */
745
746struct string_block *large_string_blocks;
747
748/* If SIZE is the length of a string, this returns how many bytes
749 the string occupies in a string_block (including padding). */
750
751#define STRING_FULLSIZE(size) (((size) + sizeof (struct Lisp_String) + PAD) \
752 & ~(PAD - 1))
753#define PAD (sizeof (int))
754
755#if 0
756#define STRING_FULLSIZE(SIZE) \
757(((SIZE) + 2 * sizeof (int)) & ~(sizeof (int) - 1))
758#endif
759
760void
761init_strings ()
762{
763 current_string_block = (struct string_block *) malloc (sizeof (struct string_block));
764 first_string_block = current_string_block;
765 consing_since_gc += sizeof (struct string_block);
766 current_string_block->next = 0;
767 current_string_block->prev = 0;
768 current_string_block->pos = 0;
769 large_string_blocks = 0;
770}
771
772DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0,
773 "Return a newly created string of length LENGTH, with each element being INIT.\n\
774Both LENGTH and INIT must be numbers.")
775 (length, init)
776 Lisp_Object length, init;
777{
778 register Lisp_Object val;
779 register unsigned char *p, *end, c;
780
781 if (XTYPE (length) != Lisp_Int || XINT (length) < 0)
782 length = wrong_type_argument (Qnatnump, length);
783 CHECK_NUMBER (init, 1);
784 val = make_uninit_string (XINT (length));
785 c = XINT (init);
786 p = XSTRING (val)->data;
787 end = p + XSTRING (val)->size;
788 while (p != end)
789 *p++ = c;
790 *p = 0;
791 return val;
792}
793
794Lisp_Object
795make_string (contents, length)
796 char *contents;
797 int length;
798{
799 register Lisp_Object val;
800 val = make_uninit_string (length);
801 bcopy (contents, XSTRING (val)->data, length);
802 return val;
803}
804
805Lisp_Object
806build_string (str)
807 char *str;
808{
809 return make_string (str, strlen (str));
810}
811
812Lisp_Object
813make_uninit_string (length)
814 int length;
815{
816 register Lisp_Object val;
817 register int fullsize = STRING_FULLSIZE (length);
818
819 if (length < 0) abort ();
820
821 if (fullsize <= STRING_BLOCK_SIZE - current_string_block->pos)
822 /* This string can fit in the current string block */
823 {
824 XSET (val, Lisp_String,
825 (struct Lisp_String *) (current_string_block->chars + current_string_block->pos));
826 current_string_block->pos += fullsize;
827 }
828 else if (fullsize > STRING_BLOCK_OUTSIZE)
829 /* This string gets its own string block */
830 {
831 register struct string_block *new
832 = (struct string_block *) malloc (sizeof (struct string_block_head) + fullsize);
833 VALIDATE_LISP_STORAGE (new, 0);
834 if (!new) memory_full ();
835 consing_since_gc += sizeof (struct string_block_head) + fullsize;
836 new->pos = fullsize;
837 new->next = large_string_blocks;
838 large_string_blocks = new;
839 XSET (val, Lisp_String,
840 (struct Lisp_String *) ((struct string_block_head *)new + 1));
841 }
842 else
843 /* Make a new current string block and start it off with this string */
844 {
845 register struct string_block *new
846 = (struct string_block *) malloc (sizeof (struct string_block));
847 if (!new) memory_full ();
848 VALIDATE_LISP_STORAGE (new, sizeof *new);
849 consing_since_gc += sizeof (struct string_block);
850 current_string_block->next = new;
851 new->prev = current_string_block;
852 new->next = 0;
853 current_string_block = new;
854 new->pos = fullsize;
855 XSET (val, Lisp_String,
856 (struct Lisp_String *) current_string_block->chars);
857 }
858
859 XSTRING (val)->size = length;
860 XSTRING (val)->data[length] = 0;
d5e35230 861 INITIALIZE_INTERVAL (XSTRING (val), NULL_INTERVAL);
7146af97
JB
862
863 return val;
864}
865
866/* Return a newly created vector or string with specified arguments as
867 elements. If all the arguments are characters, make a string;
868 otherwise, make a vector. Any number of arguments, even zero
869 arguments, are allowed. */
870
871Lisp_Object
0feac52d 872make_array (nargs, args)
7146af97
JB
873 register int nargs;
874 Lisp_Object *args;
875{
876 int i;
877
878 for (i = 0; i < nargs; i++)
879 if (XTYPE (args[i]) != Lisp_Int
880 || (unsigned) XINT (args[i]) >= 0400)
881 return Fvector (nargs, args);
882
883 /* Since the loop exited, we know that all the things in it are
884 characters, so we can make a string. */
885 {
886 Lisp_Object result = Fmake_string (nargs, make_number (0));
887
888 for (i = 0; i < nargs; i++)
889 XSTRING (result)->data[i] = XINT (args[i]);
890
891 return result;
892 }
893}
894\f
1a4f1e2c
JB
895/* Allocation of ropes. */
896
7146af97
JB
897/* Note: the user cannot manipulate ropes portably by referring
898 to the chars of the string, because combining two chars to make a GLYPH
899 depends on endianness. */
900
901DEFUN ("make-rope", Fmake_rope, Smake_rope, 0, MANY, 0,
d5e7c279 902 "Return a newly created rope containing the arguments of this function.\n\
7146af97
JB
903A rope is a string, except that its contents will be treated as an\n\
904array of glyphs, where a glyph is an integer type that may be larger\n\
905than a character. Emacs is normally configured to use 8-bit glyphs,\n\
906so ropes are normally no different from strings. But Emacs may be\n\
907configured to use 16-bit glyphs, to allow the use of larger fonts.\n\
908\n\
909Each argument (which must be an integer) specifies one glyph, whatever\n\
910size glyphs may be.\n\
911\n\
912See variable `buffer-display-table' for the uses of ropes.")
913 (nargs, args)
914 register int nargs;
915 Lisp_Object *args;
916{
917 register int i;
918 register Lisp_Object val;
919 register GLYPH *p;
920
921 val = make_uninit_string (nargs * sizeof (GLYPH));
922
923 p = (GLYPH *) XSTRING (val)->data;
924 for (i = 0; i < nargs; i++)
925 {
926 CHECK_NUMBER (args[i], i);
927 p[i] = XFASTINT (args[i]);
928 }
929 return val;
930}
931
932DEFUN ("rope-elt", Frope_elt, Srope_elt, 2, 2, 0,
933 "Return an element of rope R at index N.\n\
934A rope is a string in which each pair of bytes is considered an element.\n\
935See variable `buffer-display-table' for the uses of ropes.")
936 (r, n)
5bc1518a 937 Lisp_Object r, n;
7146af97
JB
938{
939 CHECK_STRING (r, 0);
940 CHECK_NUMBER (n, 1);
941 if ((XSTRING (r)->size / sizeof (GLYPH)) <= XINT (n) || XINT (n) < 0)
942 args_out_of_range (r, n);
943 return ((GLYPH *) XSTRING (r)->data)[XFASTINT (n)];
944}
945\f
1a4f1e2c
JB
946/* Pure storage management. */
947
7146af97
JB
948/* Must get an error if pure storage is full,
949 since if it cannot hold a large string
950 it may be able to hold conses that point to that string;
951 then the string is not protected from gc. */
952
953Lisp_Object
954make_pure_string (data, length)
955 char *data;
956 int length;
957{
958 register Lisp_Object new;
d5e35230 959 register int size = sizeof (int) + INTERVAL_PTR_SIZE + length + 1;
7146af97
JB
960
961 if (pureptr + size > PURESIZE)
962 error ("Pure Lisp storage exhausted");
963 XSET (new, Lisp_String, PUREBEG + pureptr);
964 XSTRING (new)->size = length;
965 bcopy (data, XSTRING (new)->data, length);
966 XSTRING (new)->data[length] = 0;
967 pureptr += (size + sizeof (int) - 1)
968 / sizeof (int) * sizeof (int);
969 return new;
970}
971
972Lisp_Object
973pure_cons (car, cdr)
974 Lisp_Object car, cdr;
975{
976 register Lisp_Object new;
977
978 if (pureptr + sizeof (struct Lisp_Cons) > PURESIZE)
979 error ("Pure Lisp storage exhausted");
980 XSET (new, Lisp_Cons, PUREBEG + pureptr);
981 pureptr += sizeof (struct Lisp_Cons);
982 XCONS (new)->car = Fpurecopy (car);
983 XCONS (new)->cdr = Fpurecopy (cdr);
984 return new;
985}
986
987#ifdef LISP_FLOAT_TYPE
988
989Lisp_Object
990make_pure_float (num)
991 double num;
992{
993 register Lisp_Object new;
994
1a4f1e2c
JB
995 /* Make sure that pureptr is aligned on at least a sizeof (double)
996 boundary. Some architectures (like the sparc) require this, and
997 I suspect that floats are rare enough that it's no tragedy for
998 those that do. */
999 pureptr = (pureptr + sizeof (num) - 1) & - sizeof (num);
1000
7146af97
JB
1001 if (pureptr + sizeof (struct Lisp_Float) > PURESIZE)
1002 error ("Pure Lisp storage exhausted");
1003 XSET (new, Lisp_Float, PUREBEG + pureptr);
1004 pureptr += sizeof (struct Lisp_Float);
1005 XFLOAT (new)->data = num;
1006 XFLOAT (new)->type = 0; /* bug chasing -wsr */
1007 return new;
1008}
1009
1010#endif /* LISP_FLOAT_TYPE */
1011
1012Lisp_Object
1013make_pure_vector (len)
1014 int len;
1015{
1016 register Lisp_Object new;
1017 register int size = sizeof (struct Lisp_Vector) + (len - 1) * sizeof (Lisp_Object);
1018
1019 if (pureptr + size > PURESIZE)
1020 error ("Pure Lisp storage exhausted");
1021
1022 XSET (new, Lisp_Vector, PUREBEG + pureptr);
1023 pureptr += size;
1024 XVECTOR (new)->size = len;
1025 return new;
1026}
1027
1028DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0,
1029 "Make a copy of OBJECT in pure storage.\n\
1030Recursively copies contents of vectors and cons cells.\n\
1031Does not copy symbols.")
1032 (obj)
1033 register Lisp_Object obj;
1034{
1035 register Lisp_Object new, tem;
1036 register int i;
1037
265a9e55 1038 if (NILP (Vpurify_flag))
7146af97
JB
1039 return obj;
1040
1041 if ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE)
1042 && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure)
1043 return obj;
1044
1045#ifdef SWITCH_ENUM_BUG
1046 switch ((int) XTYPE (obj))
1047#else
1048 switch (XTYPE (obj))
1049#endif
1050 {
1051 case Lisp_Marker:
1052 error ("Attempt to copy a marker to pure storage");
1053
1054 case Lisp_Cons:
1055 return pure_cons (XCONS (obj)->car, XCONS (obj)->cdr);
1056
1057#ifdef LISP_FLOAT_TYPE
1058 case Lisp_Float:
1059 return make_pure_float (XFLOAT (obj)->data);
1060#endif /* LISP_FLOAT_TYPE */
1061
1062 case Lisp_String:
1063 return make_pure_string (XSTRING (obj)->data, XSTRING (obj)->size);
1064
1065 case Lisp_Compiled:
1066 case Lisp_Vector:
1067 new = make_pure_vector (XVECTOR (obj)->size);
1068 for (i = 0; i < XVECTOR (obj)->size; i++)
1069 {
1070 tem = XVECTOR (obj)->contents[i];
1071 XVECTOR (new)->contents[i] = Fpurecopy (tem);
1072 }
1073 XSETTYPE (new, XTYPE (obj));
1074 return new;
1075
1076 default:
1077 return obj;
1078 }
1079}
1080\f
1081/* Recording what needs to be marked for gc. */
1082
1083struct gcpro *gcprolist;
1084
daa37602 1085#define NSTATICS 512
7146af97
JB
1086
1087Lisp_Object *staticvec[NSTATICS] = {0};
1088
1089int staticidx = 0;
1090
1091/* Put an entry in staticvec, pointing at the variable whose address is given */
1092
1093void
1094staticpro (varaddress)
1095 Lisp_Object *varaddress;
1096{
1097 staticvec[staticidx++] = varaddress;
1098 if (staticidx >= NSTATICS)
1099 abort ();
1100}
1101
1102struct catchtag
1103 {
1104 Lisp_Object tag;
1105 Lisp_Object val;
1106 struct catchtag *next;
1107/* jmp_buf jmp; /* We don't need this for GC purposes */
1108 };
1109
1110struct backtrace
1111 {
1112 struct backtrace *next;
1113 Lisp_Object *function;
1114 Lisp_Object *args; /* Points to vector of args. */
1115 int nargs; /* length of vector */
1116 /* if nargs is UNEVALLED, args points to slot holding list of unevalled args */
1117 char evalargs;
1118 };
1119
1120/* Two flags that are set during GC in the `size' component
1121 of a string or vector. On some machines, these flags
1122 are defined by the m- file to be different bits. */
1123
1124/* On vector, means it has been marked.
1125 On string size field or a reference to a string,
1126 means not the last reference in the chain. */
1127
1128#ifndef ARRAY_MARK_FLAG
1129#define ARRAY_MARK_FLAG ((MARKBIT >> 1) & ~MARKBIT)
1130#endif /* no ARRAY_MARK_FLAG */
1131
1132/* Any slot that is a Lisp_Object can point to a string
1133 and thus can be put on a string's reference-chain
1134 and thus may need to have its ARRAY_MARK_FLAG set.
1135 This includes the slots whose markbits are used to mark
1136 the containing objects. */
1137
1138#if ARRAY_MARK_FLAG == MARKBIT
1139you lose
1140#endif
1141\f
1a4f1e2c
JB
1142/* Garbage collection! */
1143
7146af97
JB
1144int total_conses, total_markers, total_symbols, total_string_size, total_vector_size;
1145int total_free_conses, total_free_markers, total_free_symbols;
1146#ifdef LISP_FLOAT_TYPE
1147int total_free_floats, total_floats;
1148#endif /* LISP_FLOAT_TYPE */
1149
7146af97
JB
1150DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",
1151 "Reclaim storage for Lisp objects no longer needed.\n\
1152Returns info on amount of space in use:\n\
1153 ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)\n\
1154 (USED-MARKERS . FREE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS\n\
1155 (USED-FLOATS . FREE-FLOATS))\n\
1156Garbage collection happens automatically if you cons more than\n\
1157`gc-cons-threshold' bytes of Lisp data since previous garbage collection.")
1158 ()
1159{
1160 register struct gcpro *tail;
1161 register struct specbinding *bind;
1162 struct catchtag *catch;
1163 struct handler *handler;
1164 register struct backtrace *backlist;
1165 register Lisp_Object tem;
1166 char *omessage = echo_area_glyphs;
1167 char stack_top_variable;
1168 register int i;
1169
7146af97
JB
1170 /* Save a copy of the contents of the stack, for debugging. */
1171#if MAX_SAVE_STACK > 0
265a9e55 1172 if (NILP (Vpurify_flag))
7146af97
JB
1173 {
1174 i = &stack_top_variable - stack_bottom;
1175 if (i < 0) i = -i;
1176 if (i < MAX_SAVE_STACK)
1177 {
1178 if (stack_copy == 0)
1179 stack_copy = (char *) malloc (stack_copy_size = i);
1180 else if (stack_copy_size < i)
1181 stack_copy = (char *) realloc (stack_copy, (stack_copy_size = i));
1182 if (stack_copy)
1183 {
1184 if ((int) (&stack_top_variable - stack_bottom) > 0)
1185 bcopy (stack_bottom, stack_copy, i);
1186 else
1187 bcopy (&stack_top_variable, stack_copy, i);
1188 }
1189 }
1190 }
1191#endif /* MAX_SAVE_STACK > 0 */
1192
1193 if (!noninteractive)
1194 message1 ("Garbage collecting...");
1195
1196 /* Don't keep command history around forever */
1197 tem = Fnthcdr (make_number (30), Vcommand_history);
1198 if (CONSP (tem))
1199 XCONS (tem)->cdr = Qnil;
ffd56f97 1200
7146af97
JB
1201 /* Likewise for undo information. */
1202 {
1203 register struct buffer *nextb = all_buffers;
1204
1205 while (nextb)
1206 {
ffd56f97
JB
1207 /* If a buffer's undo list is Qt, that means that undo is
1208 turned off in that buffer. Calling truncate_undo_list on
1209 Qt tends to return NULL, which effectively turns undo back on.
1210 So don't call truncate_undo_list if undo_list is Qt. */
1211 if (! EQ (nextb->undo_list, Qt))
1212 nextb->undo_list
502b9b64
JB
1213 = truncate_undo_list (nextb->undo_list, undo_limit,
1214 undo_strong_limit);
7146af97
JB
1215 nextb = nextb->next;
1216 }
1217 }
1218
1219 gc_in_progress = 1;
1220
1221/* clear_marks (); */
1222
1223 /* In each "large string", set the MARKBIT of the size field.
1224 That enables mark_object to recognize them. */
1225 {
1226 register struct string_block *b;
1227 for (b = large_string_blocks; b; b = b->next)
1228 ((struct Lisp_String *)(&b->chars[0]))->size |= MARKBIT;
1229 }
1230
1231 /* Mark all the special slots that serve as the roots of accessibility.
1232
1233 Usually the special slots to mark are contained in particular structures.
1234 Then we know no slot is marked twice because the structures don't overlap.
1235 In some cases, the structures point to the slots to be marked.
1236 For these, we use MARKBIT to avoid double marking of the slot. */
1237
1238 for (i = 0; i < staticidx; i++)
1239 mark_object (staticvec[i]);
1240 for (tail = gcprolist; tail; tail = tail->next)
1241 for (i = 0; i < tail->nvars; i++)
1242 if (!XMARKBIT (tail->var[i]))
1243 {
1244 mark_object (&tail->var[i]);
1245 XMARK (tail->var[i]);
1246 }
1247 for (bind = specpdl; bind != specpdl_ptr; bind++)
1248 {
1249 mark_object (&bind->symbol);
1250 mark_object (&bind->old_value);
1251 }
1252 for (catch = catchlist; catch; catch = catch->next)
1253 {
1254 mark_object (&catch->tag);
1255 mark_object (&catch->val);
1256 }
1257 for (handler = handlerlist; handler; handler = handler->next)
1258 {
1259 mark_object (&handler->handler);
1260 mark_object (&handler->var);
1261 }
1262 for (backlist = backtrace_list; backlist; backlist = backlist->next)
1263 {
1264 if (!XMARKBIT (*backlist->function))
1265 {
1266 mark_object (backlist->function);
1267 XMARK (*backlist->function);
1268 }
1269 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY)
1270 i = 0;
1271 else
1272 i = backlist->nargs - 1;
1273 for (; i >= 0; i--)
1274 if (!XMARKBIT (backlist->args[i]))
1275 {
1276 mark_object (&backlist->args[i]);
1277 XMARK (backlist->args[i]);
1278 }
1279 }
1280
1281 gc_sweep ();
1282
1283 /* Clear the mark bits that we set in certain root slots. */
1284
1285 for (tail = gcprolist; tail; tail = tail->next)
1286 for (i = 0; i < tail->nvars; i++)
1287 XUNMARK (tail->var[i]);
1288 for (backlist = backtrace_list; backlist; backlist = backlist->next)
1289 {
1290 XUNMARK (*backlist->function);
1291 if (backlist->nargs == UNEVALLED || backlist->nargs == MANY)
1292 i = 0;
1293 else
1294 i = backlist->nargs - 1;
1295 for (; i >= 0; i--)
1296 XUNMARK (backlist->args[i]);
1297 }
1298 XUNMARK (buffer_defaults.name);
1299 XUNMARK (buffer_local_symbols.name);
1300
1301/* clear_marks (); */
1302 gc_in_progress = 0;
1303
1304 consing_since_gc = 0;
1305 if (gc_cons_threshold < 10000)
1306 gc_cons_threshold = 10000;
1307
1308 if (omessage)
1309 message1 (omessage);
1310 else if (!noninteractive)
1311 message1 ("Garbage collecting...done");
1312
7146af97
JB
1313 return Fcons (Fcons (make_number (total_conses),
1314 make_number (total_free_conses)),
1315 Fcons (Fcons (make_number (total_symbols),
1316 make_number (total_free_symbols)),
1317 Fcons (Fcons (make_number (total_markers),
1318 make_number (total_free_markers)),
1319 Fcons (make_number (total_string_size),
1320 Fcons (make_number (total_vector_size),
1321
1322#ifdef LISP_FLOAT_TYPE
1323 Fcons (Fcons (make_number (total_floats),
1324 make_number (total_free_floats)),
1325 Qnil)
1326#else /* not LISP_FLOAT_TYPE */
1327 Qnil
1328#endif /* not LISP_FLOAT_TYPE */
1329 )))));
1330}
1331\f
1332#if 0
1333static void
1334clear_marks ()
1335{
1336 /* Clear marks on all conses */
1337 {
1338 register struct cons_block *cblk;
1339 register int lim = cons_block_index;
1340
1341 for (cblk = cons_block; cblk; cblk = cblk->next)
1342 {
1343 register int i;
1344 for (i = 0; i < lim; i++)
1345 XUNMARK (cblk->conses[i].car);
1346 lim = CONS_BLOCK_SIZE;
1347 }
1348 }
1349 /* Clear marks on all symbols */
1350 {
1351 register struct symbol_block *sblk;
1352 register int lim = symbol_block_index;
1353
1354 for (sblk = symbol_block; sblk; sblk = sblk->next)
1355 {
1356 register int i;
1357 for (i = 0; i < lim; i++)
1358 {
1359 XUNMARK (sblk->symbols[i].plist);
1360 }
1361 lim = SYMBOL_BLOCK_SIZE;
1362 }
1363 }
1364 /* Clear marks on all markers */
1365 {
1366 register struct marker_block *sblk;
1367 register int lim = marker_block_index;
1368
1369 for (sblk = marker_block; sblk; sblk = sblk->next)
1370 {
1371 register int i;
1372 for (i = 0; i < lim; i++)
1373 XUNMARK (sblk->markers[i].chain);
1374 lim = MARKER_BLOCK_SIZE;
1375 }
1376 }
1377 /* Clear mark bits on all buffers */
1378 {
1379 register struct buffer *nextb = all_buffers;
1380
1381 while (nextb)
1382 {
1383 XUNMARK (nextb->name);
1384 nextb = nextb->next;
1385 }
1386 }
1387}
1388#endif
1389\f
1a4f1e2c
JB
1390/* Mark reference to a Lisp_Object.
1391 If the object referred to has not been seen yet, recursively mark
1392 all the references contained in it.
7146af97
JB
1393
1394 If the object referenced is a short string, the referrencing slot
1395 is threaded into a chain of such slots, pointed to from
1396 the `size' field of the string. The actual string size
1397 lives in the last slot in the chain. We recognize the end
1398 because it is < (unsigned) STRING_BLOCK_SIZE. */
1399
785cd37f
RS
1400#define LAST_MARKED_SIZE 500
1401Lisp_Object *last_marked[LAST_MARKED_SIZE];
1402int last_marked_index;
1403
7146af97
JB
1404static void
1405mark_object (objptr)
1406 Lisp_Object *objptr;
1407{
1408 register Lisp_Object obj;
1409
1410 obj = *objptr;
1411 XUNMARK (obj);
1412
1413 loop:
1414
1415 if ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE)
1416 && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure)
1417 return;
1418
785cd37f
RS
1419 last_marked[last_marked_index++] = objptr;
1420 if (last_marked_index == LAST_MARKED_SIZE)
1421 last_marked_index = 0;
1422
7146af97
JB
1423#ifdef SWITCH_ENUM_BUG
1424 switch ((int) XGCTYPE (obj))
1425#else
1426 switch (XGCTYPE (obj))
1427#endif
1428 {
1429 case Lisp_String:
1430 {
1431 register struct Lisp_String *ptr = XSTRING (obj);
1432
d5e35230 1433 MARK_INTERVAL_TREE (ptr->intervals);
7146af97
JB
1434 if (ptr->size & MARKBIT)
1435 /* A large string. Just set ARRAY_MARK_FLAG. */
1436 ptr->size |= ARRAY_MARK_FLAG;
1437 else
1438 {
1439 /* A small string. Put this reference
1440 into the chain of references to it.
1441 The address OBJPTR is even, so if the address
1442 includes MARKBIT, put it in the low bit
1443 when we store OBJPTR into the size field. */
1444
1445 if (XMARKBIT (*objptr))
1446 {
1447 XFASTINT (*objptr) = ptr->size;
1448 XMARK (*objptr);
1449 }
1450 else
1451 XFASTINT (*objptr) = ptr->size;
1452 if ((int)objptr & 1) abort ();
1453 ptr->size = (int) objptr & ~MARKBIT;
1454 if ((int) objptr & MARKBIT)
1455 ptr->size ++;
1456 }
1457 }
1458 break;
1459
1460 case Lisp_Vector:
1461 case Lisp_Window:
1462 case Lisp_Process:
1463 case Lisp_Window_Configuration:
7146af97
JB
1464 {
1465 register struct Lisp_Vector *ptr = XVECTOR (obj);
1466 register int size = ptr->size;
785cd37f 1467 struct Lisp_Vector *volatile ptr1 = ptr;
7146af97
JB
1468 register int i;
1469
1470 if (size & ARRAY_MARK_FLAG) break; /* Already marked */
1471 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */
1472 for (i = 0; i < size; i++) /* and then mark its elements */
785cd37f
RS
1473 {
1474 if (ptr != ptr1)
1475 abort ();
1476 mark_object (&ptr->contents[i]);
1477 }
7146af97
JB
1478 }
1479 break;
1480
c54ca951
RS
1481 case Lisp_Compiled:
1482 /* We could treat this just like a vector, but it is better
1483 to save the COMPILED_CONSTANTS element for last and avoid recursion
1484 there. */
1485 {
1486 register struct Lisp_Vector *ptr = XVECTOR (obj);
1487 register int size = ptr->size;
1488 struct Lisp_Vector *volatile ptr1 = ptr;
1489 register int i;
1490
1491 if (size & ARRAY_MARK_FLAG) break; /* Already marked */
1492 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */
1493 for (i = 0; i < size; i++) /* and then mark its elements */
1494 {
1495 if (ptr != ptr1)
1496 abort ();
1497 if (i != COMPILED_CONSTANTS)
1498 mark_object (&ptr->contents[i]);
1499 }
1500 objptr = &ptr->contents[COMPILED_CONSTANTS];
1501 obj = *objptr;
1502 goto loop;
1503 }
1504
502b9b64
JB
1505#ifdef MULTI_FRAME
1506 case Lisp_Frame:
7146af97 1507 {
502b9b64 1508 register struct frame *ptr = XFRAME (obj);
7146af97 1509 register int size = ptr->size;
7146af97
JB
1510
1511 if (size & ARRAY_MARK_FLAG) break; /* Already marked */
1512 ptr->size |= ARRAY_MARK_FLAG; /* Else mark it */
1513
1514 mark_object (&ptr->name);
502b9b64 1515 mark_object (&ptr->focus_frame);
7146af97
JB
1516 mark_object (&ptr->width);
1517 mark_object (&ptr->height);
1518 mark_object (&ptr->selected_window);
1519 mark_object (&ptr->minibuffer_window);
1520 mark_object (&ptr->param_alist);
7c299e7a
JB
1521 mark_object (&ptr->scrollbars);
1522 mark_object (&ptr->condemned_scrollbars);
7146af97
JB
1523 }
1524 break;
42a9cd6a 1525#endif /* not MULTI_FRAME */
7146af97 1526
7146af97
JB
1527 case Lisp_Symbol:
1528 {
1529 register struct Lisp_Symbol *ptr = XSYMBOL (obj);
1530 struct Lisp_Symbol *ptrx;
1531
1532 if (XMARKBIT (ptr->plist)) break;
1533 XMARK (ptr->plist);
7146af97
JB
1534 mark_object ((Lisp_Object *) &ptr->value);
1535 mark_object (&ptr->function);
1536 mark_object (&ptr->plist);
8aaa7c8a
JB
1537 XSETTYPE (*(Lisp_Object *) &ptr->name, Lisp_String);
1538 mark_object (&ptr->name);
7146af97
JB
1539 ptr = ptr->next;
1540 if (ptr)
1541 {
1542 ptrx = ptr; /* Use pf ptrx avoids compiler bug on Sun */
1543 XSETSYMBOL (obj, ptrx);
1544 goto loop;
1545 }
1546 }
1547 break;
1548
1549 case Lisp_Marker:
1550 XMARK (XMARKER (obj)->chain);
1551 /* DO NOT mark thru the marker's chain.
1552 The buffer's markers chain does not preserve markers from gc;
c54ca951 1553 instead, markers are removed from the chain when freed by gc. */
7146af97
JB
1554 break;
1555
1556 case Lisp_Cons:
1557 case Lisp_Buffer_Local_Value:
1558 case Lisp_Some_Buffer_Local_Value:
1559 {
1560 register struct Lisp_Cons *ptr = XCONS (obj);
1561 if (XMARKBIT (ptr->car)) break;
1562 XMARK (ptr->car);
c54ca951
RS
1563 /* If the cdr is nil, avoid recursion for the car. */
1564 if (EQ (ptr->cdr, Qnil))
1565 {
1566 objptr = &ptr->car;
1567 obj = ptr->car;
1568 XUNMARK (obj);
1569 goto loop;
1570 }
7146af97
JB
1571 mark_object (&ptr->car);
1572 objptr = &ptr->cdr;
1573 obj = ptr->cdr;
1574 goto loop;
1575 }
1576
1577#ifdef LISP_FLOAT_TYPE
1578 case Lisp_Float:
1579 XMARK (XFLOAT (obj)->type);
1580 break;
1581#endif /* LISP_FLOAT_TYPE */
1582
1583 case Lisp_Buffer:
1584 if (!XMARKBIT (XBUFFER (obj)->name))
1585 mark_buffer (obj);
1586 break;
1587
1588 case Lisp_Int:
1589 case Lisp_Void:
1590 case Lisp_Subr:
1591 case Lisp_Intfwd:
1592 case Lisp_Boolfwd:
1593 case Lisp_Objfwd:
1594 case Lisp_Buffer_Objfwd:
1595 case Lisp_Internal_Stream:
1596 /* Don't bother with Lisp_Buffer_Objfwd,
1597 since all markable slots in current buffer marked anyway. */
1598 /* Don't need to do Lisp_Objfwd, since the places they point
1599 are protected with staticpro. */
1600 break;
1601
1602 default:
1603 abort ();
1604 }
1605}
1606
1607/* Mark the pointers in a buffer structure. */
1608
1609static void
1610mark_buffer (buf)
1611 Lisp_Object buf;
1612{
7146af97
JB
1613 register struct buffer *buffer = XBUFFER (buf);
1614 register Lisp_Object *ptr;
1615
1616 /* This is the buffer's markbit */
1617 mark_object (&buffer->name);
1618 XMARK (buffer->name);
1619
d5e35230
JA
1620 MARK_INTERVAL_TREE (buffer->intervals);
1621
7146af97
JB
1622#if 0
1623 mark_object (buffer->syntax_table);
1624
1625 /* Mark the various string-pointers in the buffer object.
1626 Since the strings may be relocated, we must mark them
1627 in their actual slots. So gc_sweep must convert each slot
1628 back to an ordinary C pointer. */
1629 XSET (*(Lisp_Object *)&buffer->upcase_table,
1630 Lisp_String, buffer->upcase_table);
1631 mark_object ((Lisp_Object *)&buffer->upcase_table);
1632 XSET (*(Lisp_Object *)&buffer->downcase_table,
1633 Lisp_String, buffer->downcase_table);
1634 mark_object ((Lisp_Object *)&buffer->downcase_table);
1635
1636 XSET (*(Lisp_Object *)&buffer->sort_table,
1637 Lisp_String, buffer->sort_table);
1638 mark_object ((Lisp_Object *)&buffer->sort_table);
1639 XSET (*(Lisp_Object *)&buffer->folding_sort_table,
1640 Lisp_String, buffer->folding_sort_table);
1641 mark_object ((Lisp_Object *)&buffer->folding_sort_table);
1642#endif
1643
1644 for (ptr = &buffer->name + 1;
1645 (char *)ptr < (char *)buffer + sizeof (struct buffer);
1646 ptr++)
1647 mark_object (ptr);
1648}
1649\f
1a4f1e2c 1650/* Sweep: find all structures not marked, and free them. */
7146af97
JB
1651
1652static void
1653gc_sweep ()
1654{
1655 total_string_size = 0;
1656 compact_strings ();
1657
1658 /* Put all unmarked conses on free list */
1659 {
1660 register struct cons_block *cblk;
1661 register int lim = cons_block_index;
1662 register int num_free = 0, num_used = 0;
1663
1664 cons_free_list = 0;
1665
1666 for (cblk = cons_block; cblk; cblk = cblk->next)
1667 {
1668 register int i;
1669 for (i = 0; i < lim; i++)
1670 if (!XMARKBIT (cblk->conses[i].car))
1671 {
1672 XFASTINT (cblk->conses[i].car) = (int) cons_free_list;
1673 num_free++;
1674 cons_free_list = &cblk->conses[i];
1675 }
1676 else
1677 {
1678 num_used++;
1679 XUNMARK (cblk->conses[i].car);
1680 }
1681 lim = CONS_BLOCK_SIZE;
1682 }
1683 total_conses = num_used;
1684 total_free_conses = num_free;
1685 }
1686
1687#ifdef LISP_FLOAT_TYPE
1688 /* Put all unmarked floats on free list */
1689 {
1690 register struct float_block *fblk;
1691 register int lim = float_block_index;
1692 register int num_free = 0, num_used = 0;
1693
1694 float_free_list = 0;
1695
1696 for (fblk = float_block; fblk; fblk = fblk->next)
1697 {
1698 register int i;
1699 for (i = 0; i < lim; i++)
1700 if (!XMARKBIT (fblk->floats[i].type))
1701 {
1702 XFASTINT (fblk->floats[i].type) = (int) float_free_list;
1703 num_free++;
1704 float_free_list = &fblk->floats[i];
1705 }
1706 else
1707 {
1708 num_used++;
1709 XUNMARK (fblk->floats[i].type);
1710 }
1711 lim = FLOAT_BLOCK_SIZE;
1712 }
1713 total_floats = num_used;
1714 total_free_floats = num_free;
1715 }
1716#endif /* LISP_FLOAT_TYPE */
1717
d5e35230
JA
1718#ifdef USE_TEXT_PROPERTIES
1719 /* Put all unmarked intervals on free list */
1720 {
1721 register struct interval_block *iblk;
1722 register int lim = interval_block_index;
1723 register int num_free = 0, num_used = 0;
1724
1725 interval_free_list = 0;
1726
1727 for (iblk = interval_block; iblk; iblk = iblk->next)
1728 {
1729 register int i;
1730
1731 for (i = 0; i < lim; i++)
1732 {
1733 if (! XMARKBIT (iblk->intervals[i].plist))
1734 {
1735 iblk->intervals[i].parent = interval_free_list;
1736 interval_free_list = &iblk->intervals[i];
1737 num_free++;
1738 }
1739 else
1740 {
1741 num_used++;
1742 XUNMARK (iblk->intervals[i].plist);
1743 }
1744 }
1745 lim = INTERVAL_BLOCK_SIZE;
1746 }
1747 total_intervals = num_used;
1748 total_free_intervals = num_free;
1749 }
1750#endif /* USE_TEXT_PROPERTIES */
1751
7146af97
JB
1752 /* Put all unmarked symbols on free list */
1753 {
1754 register struct symbol_block *sblk;
1755 register int lim = symbol_block_index;
1756 register int num_free = 0, num_used = 0;
1757
1758 symbol_free_list = 0;
1759
1760 for (sblk = symbol_block; sblk; sblk = sblk->next)
1761 {
1762 register int i;
1763 for (i = 0; i < lim; i++)
1764 if (!XMARKBIT (sblk->symbols[i].plist))
1765 {
1766 XFASTINT (sblk->symbols[i].value) = (int) symbol_free_list;
1767 symbol_free_list = &sblk->symbols[i];
1768 num_free++;
1769 }
1770 else
1771 {
1772 num_used++;
1773 sblk->symbols[i].name
1774 = XSTRING (*(Lisp_Object *) &sblk->symbols[i].name);
1775 XUNMARK (sblk->symbols[i].plist);
1776 }
1777 lim = SYMBOL_BLOCK_SIZE;
1778 }
1779 total_symbols = num_used;
1780 total_free_symbols = num_free;
1781 }
1782
1783#ifndef standalone
1784 /* Put all unmarked markers on free list.
1785 Dechain each one first from the buffer it points into. */
1786 {
1787 register struct marker_block *mblk;
1788 struct Lisp_Marker *tem1;
1789 register int lim = marker_block_index;
1790 register int num_free = 0, num_used = 0;
1791
1792 marker_free_list = 0;
1793
1794 for (mblk = marker_block; mblk; mblk = mblk->next)
1795 {
1796 register int i;
1797 for (i = 0; i < lim; i++)
1798 if (!XMARKBIT (mblk->markers[i].chain))
1799 {
1800 Lisp_Object tem;
1801 tem1 = &mblk->markers[i]; /* tem1 avoids Sun compiler bug */
1802 XSET (tem, Lisp_Marker, tem1);
1803 unchain_marker (tem);
1804 XFASTINT (mblk->markers[i].chain) = (int) marker_free_list;
1805 marker_free_list = &mblk->markers[i];
1806 num_free++;
1807 }
1808 else
1809 {
1810 num_used++;
1811 XUNMARK (mblk->markers[i].chain);
1812 }
1813 lim = MARKER_BLOCK_SIZE;
1814 }
1815
1816 total_markers = num_used;
1817 total_free_markers = num_free;
1818 }
1819
1820 /* Free all unmarked buffers */
1821 {
1822 register struct buffer *buffer = all_buffers, *prev = 0, *next;
1823
1824 while (buffer)
1825 if (!XMARKBIT (buffer->name))
1826 {
1827 if (prev)
1828 prev->next = buffer->next;
1829 else
1830 all_buffers = buffer->next;
1831 next = buffer->next;
1832 free (buffer);
1833 buffer = next;
1834 }
1835 else
1836 {
1837 XUNMARK (buffer->name);
d5e35230 1838 UNMARK_BALANCE_INTERVALS (buffer->intervals);
7146af97
JB
1839
1840#if 0
1841 /* Each `struct Lisp_String *' was turned into a Lisp_Object
1842 for purposes of marking and relocation.
1843 Turn them back into C pointers now. */
1844 buffer->upcase_table
1845 = XSTRING (*(Lisp_Object *)&buffer->upcase_table);
1846 buffer->downcase_table
1847 = XSTRING (*(Lisp_Object *)&buffer->downcase_table);
1848 buffer->sort_table
1849 = XSTRING (*(Lisp_Object *)&buffer->sort_table);
1850 buffer->folding_sort_table
1851 = XSTRING (*(Lisp_Object *)&buffer->folding_sort_table);
1852#endif
1853
1854 prev = buffer, buffer = buffer->next;
1855 }
1856 }
1857
1858#endif /* standalone */
1859
1860 /* Free all unmarked vectors */
1861 {
1862 register struct Lisp_Vector *vector = all_vectors, *prev = 0, *next;
1863 total_vector_size = 0;
1864
1865 while (vector)
1866 if (!(vector->size & ARRAY_MARK_FLAG))
1867 {
1868 if (prev)
1869 prev->next = vector->next;
1870 else
1871 all_vectors = vector->next;
1872 next = vector->next;
1873 free (vector);
1874 vector = next;
1875 }
1876 else
1877 {
1878 vector->size &= ~ARRAY_MARK_FLAG;
1879 total_vector_size += vector->size;
1880 prev = vector, vector = vector->next;
1881 }
1882 }
1883
1884 /* Free all "large strings" not marked with ARRAY_MARK_FLAG. */
1885 {
1886 register struct string_block *sb = large_string_blocks, *prev = 0, *next;
1887
1888 while (sb)
1889 if (!(((struct Lisp_String *)(&sb->chars[0]))->size & ARRAY_MARK_FLAG))
1890 {
1891 if (prev)
1892 prev->next = sb->next;
1893 else
1894 large_string_blocks = sb->next;
1895 next = sb->next;
1896 free (sb);
1897 sb = next;
1898 }
1899 else
1900 {
1901 ((struct Lisp_String *)(&sb->chars[0]))->size
1902 &= ~ARRAY_MARK_FLAG & ~MARKBIT;
1903 total_string_size += ((struct Lisp_String *)(&sb->chars[0]))->size;
1904 prev = sb, sb = sb->next;
1905 }
1906 }
1907}
1908\f
1a4f1e2c 1909/* Compactify strings, relocate references, and free empty string blocks. */
7146af97
JB
1910
1911static void
1912compact_strings ()
1913{
1914 /* String block of old strings we are scanning. */
1915 register struct string_block *from_sb;
1916 /* A preceding string block (or maybe the same one)
1917 where we are copying the still-live strings to. */
1918 register struct string_block *to_sb;
1919 int pos;
1920 int to_pos;
1921
1922 to_sb = first_string_block;
1923 to_pos = 0;
1924
1925 /* Scan each existing string block sequentially, string by string. */
1926 for (from_sb = first_string_block; from_sb; from_sb = from_sb->next)
1927 {
1928 pos = 0;
1929 /* POS is the index of the next string in the block. */
1930 while (pos < from_sb->pos)
1931 {
1932 register struct Lisp_String *nextstr
1933 = (struct Lisp_String *) &from_sb->chars[pos];
1934
1935 register struct Lisp_String *newaddr;
1936 register int size = nextstr->size;
1937
1938 /* NEXTSTR is the old address of the next string.
1939 Just skip it if it isn't marked. */
1940 if ((unsigned) size > STRING_BLOCK_SIZE)
1941 {
1942 /* It is marked, so its size field is really a chain of refs.
1943 Find the end of the chain, where the actual size lives. */
1944 while ((unsigned) size > STRING_BLOCK_SIZE)
1945 {
1946 if (size & 1) size ^= MARKBIT | 1;
1947 size = *(int *)size & ~MARKBIT;
1948 }
1949
1950 total_string_size += size;
1951
1952 /* If it won't fit in TO_SB, close it out,
1953 and move to the next sb. Keep doing so until
1954 TO_SB reaches a large enough, empty enough string block.
1955 We know that TO_SB cannot advance past FROM_SB here
1956 since FROM_SB is large enough to contain this string.
1957 Any string blocks skipped here
1958 will be patched out and freed later. */
1959 while (to_pos + STRING_FULLSIZE (size)
1960 > max (to_sb->pos, STRING_BLOCK_SIZE))
1961 {
1962 to_sb->pos = to_pos;
1963 to_sb = to_sb->next;
1964 to_pos = 0;
1965 }
1966 /* Compute new address of this string
1967 and update TO_POS for the space being used. */
1968 newaddr = (struct Lisp_String *) &to_sb->chars[to_pos];
1969 to_pos += STRING_FULLSIZE (size);
1970
1971 /* Copy the string itself to the new place. */
1972 if (nextstr != newaddr)
d5e35230
JA
1973 bcopy (nextstr, newaddr, size + 1 + sizeof (int)
1974 + INTERVAL_PTR_SIZE);
7146af97
JB
1975
1976 /* Go through NEXTSTR's chain of references
1977 and make each slot in the chain point to
1978 the new address of this string. */
1979 size = newaddr->size;
1980 while ((unsigned) size > STRING_BLOCK_SIZE)
1981 {
1982 register Lisp_Object *objptr;
1983 if (size & 1) size ^= MARKBIT | 1;
1984 objptr = (Lisp_Object *)size;
1985
1986 size = XFASTINT (*objptr) & ~MARKBIT;
1987 if (XMARKBIT (*objptr))
1988 {
1989 XSET (*objptr, Lisp_String, newaddr);
1990 XMARK (*objptr);
1991 }
1992 else
1993 XSET (*objptr, Lisp_String, newaddr);
1994 }
1995 /* Store the actual size in the size field. */
1996 newaddr->size = size;
1997 }
1998 pos += STRING_FULLSIZE (size);
1999 }
2000 }
2001
2002 /* Close out the last string block still used and free any that follow. */
2003 to_sb->pos = to_pos;
2004 current_string_block = to_sb;
2005
2006 from_sb = to_sb->next;
2007 to_sb->next = 0;
2008 while (from_sb)
2009 {
2010 to_sb = from_sb->next;
2011 free (from_sb);
2012 from_sb = to_sb;
2013 }
2014
2015 /* Free any empty string blocks further back in the chain.
2016 This loop will never free first_string_block, but it is very
2017 unlikely that that one will become empty, so why bother checking? */
2018
2019 from_sb = first_string_block;
2020 while (to_sb = from_sb->next)
2021 {
2022 if (to_sb->pos == 0)
2023 {
2024 if (from_sb->next = to_sb->next)
2025 from_sb->next->prev = from_sb;
2026 free (to_sb);
2027 }
2028 else
2029 from_sb = to_sb;
2030 }
2031}
2032\f
20d24714
JB
2033/* Debugging aids. */
2034
2035DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, "",
2036 "Return the address of the last byte Emacs has allocated, divided by 1024.\n\
2037This may be helpful in debugging Emacs's memory usage.\n\
e41ae81f 2038We divide the value by 1024 to make sure it fits in a Lisp integer.")
20d24714
JB
2039 ()
2040{
2041 Lisp_Object end;
2042
0d73ca81 2043 XSET (end, Lisp_Int, (int) sbrk (0) / 1024);
20d24714
JB
2044
2045 return end;
2046}
2047
2048\f
7146af97
JB
2049/* Initialization */
2050
2051init_alloc_once ()
2052{
2053 /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */
2054 pureptr = 0;
4c0be5f4
JB
2055#ifdef HAVE_SHM
2056 pure_size = PURESIZE;
2057#endif
7146af97
JB
2058 all_vectors = 0;
2059 ignore_warnings = 1;
2060 init_strings ();
2061 init_cons ();
2062 init_symbol ();
2063 init_marker ();
2064#ifdef LISP_FLOAT_TYPE
2065 init_float ();
2066#endif /* LISP_FLOAT_TYPE */
d5e35230
JA
2067 INIT_INTERVALS;
2068
7146af97
JB
2069 ignore_warnings = 0;
2070 gcprolist = 0;
2071 staticidx = 0;
2072 consing_since_gc = 0;
2073 gc_cons_threshold = 100000;
2074#ifdef VIRT_ADDR_VARIES
2075 malloc_sbrk_unused = 1<<22; /* A large number */
2076 malloc_sbrk_used = 100000; /* as reasonable as any number */
2077#endif /* VIRT_ADDR_VARIES */
2078}
2079
2080init_alloc ()
2081{
2082 gcprolist = 0;
2083}
2084
2085void
2086syms_of_alloc ()
2087{
2088 DEFVAR_INT ("gc-cons-threshold", &gc_cons_threshold,
2089 "*Number of bytes of consing between garbage collections.\n\
2090Garbage collection can happen automatically once this many bytes have been\n\
2091allocated since the last garbage collection. All data types count.\n\n\
2092Garbage collection happens automatically only when `eval' is called.\n\n\
2093By binding this temporarily to a large number, you can effectively\n\
2094prevent garbage collection during a part of the program.");
2095
2096 DEFVAR_INT ("pure-bytes-used", &pureptr,
2097 "Number of bytes of sharable Lisp data allocated so far.");
2098
2099#if 0
2100 DEFVAR_INT ("data-bytes-used", &malloc_sbrk_used,
2101 "Number of bytes of unshared memory allocated in this session.");
2102
2103 DEFVAR_INT ("data-bytes-free", &malloc_sbrk_unused,
2104 "Number of bytes of unshared memory remaining available in this session.");
2105#endif
2106
2107 DEFVAR_LISP ("purify-flag", &Vpurify_flag,
2108 "Non-nil means loading Lisp code in order to dump an executable.\n\
2109This means that certain objects should be allocated in shared (pure) space.");
2110
502b9b64 2111 DEFVAR_INT ("undo-limit", &undo_limit,
7146af97 2112 "Keep no more undo information once it exceeds this size.\n\
502b9b64 2113This limit is applied when garbage collection happens.\n\
7146af97
JB
2114The size is counted as the number of bytes occupied,\n\
2115which includes both saved text and other data.");
502b9b64 2116 undo_limit = 20000;
7146af97 2117
502b9b64 2118 DEFVAR_INT ("undo-strong-limit", &undo_strong_limit,
7146af97
JB
2119 "Don't keep more than this much size of undo information.\n\
2120A command which pushes past this size is itself forgotten.\n\
502b9b64 2121This limit is applied when garbage collection happens.\n\
7146af97
JB
2122The size is counted as the number of bytes occupied,\n\
2123which includes both saved text and other data.");
502b9b64 2124 undo_strong_limit = 30000;
7146af97
JB
2125
2126 defsubr (&Scons);
2127 defsubr (&Slist);
2128 defsubr (&Svector);
2129 defsubr (&Smake_byte_code);
2130 defsubr (&Smake_list);
2131 defsubr (&Smake_vector);
2132 defsubr (&Smake_string);
2133 defsubr (&Smake_rope);
2134 defsubr (&Srope_elt);
2135 defsubr (&Smake_symbol);
2136 defsubr (&Smake_marker);
2137 defsubr (&Spurecopy);
2138 defsubr (&Sgarbage_collect);
20d24714 2139 defsubr (&Smemory_limit);
7146af97 2140}