Mercurial > hg > xemacs-beta
comparison src/alloc.c @ 173:8eaf7971accc r20-3b13
Import from CVS: tag r20-3b13
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:49:09 +0200 |
parents | 929b76928fce |
children | 2d532a89d707 |
comparison
equal
deleted
inserted
replaced
172:a38aed19690b | 173:8eaf7971accc |
---|---|
195 #endif | 195 #endif |
196 | 196 |
197 int | 197 int |
198 purified (Lisp_Object obj) | 198 purified (Lisp_Object obj) |
199 { | 199 { |
200 if (!POINTER_TYPE_P (XGCTYPE (obj))) | 200 return !POINTER_TYPE_P (XGCTYPE (obj)) ? 0 : PURIFIED (XPNTR (obj)); |
201 return (0); | |
202 return (PURIFIED (XPNTR (obj))); | |
203 } | 201 } |
204 | 202 |
205 int | 203 int |
206 purespace_usage (void) | 204 purespace_usage (void) |
207 { | 205 { |
212 check_purespace (EMACS_INT size) | 210 check_purespace (EMACS_INT size) |
213 { | 211 { |
214 if (pure_lossage) | 212 if (pure_lossage) |
215 { | 213 { |
216 pure_lossage += size; | 214 pure_lossage += size; |
217 return (0); | 215 return 0; |
218 } | 216 } |
219 else if (pureptr + size > get_PURESIZE()) | 217 else if (pureptr + size > get_PURESIZE()) |
220 { | 218 { |
221 /* This can cause recursive bad behavior, we'll yell at the end */ | 219 /* This can cause recursive bad behavior, we'll yell at the end */ |
222 /* when we're done. */ | 220 /* when we're done. */ |
223 /* message ("\nERROR: Pure Lisp storage exhausted!\n"); */ | 221 /* message ("\nERROR: Pure Lisp storage exhausted!\n"); */ |
224 pure_lossage = size; | 222 pure_lossage = size; |
225 return (0); | 223 return 0; |
226 } | 224 } |
227 else | 225 else |
228 return (1); | 226 return 1; |
229 } | 227 } |
230 | 228 |
231 | 229 |
232 | 230 |
233 #ifndef PURESTAT | 231 #ifndef PURESTAT |
462 int len = strlen (str) + 1; /* for stupid terminating 0 */ | 460 int len = strlen (str) + 1; /* for stupid terminating 0 */ |
463 | 461 |
464 val = xmalloc (len); | 462 val = xmalloc (len); |
465 if (val == 0) return 0; | 463 if (val == 0) return 0; |
466 memcpy (val, str, len); | 464 memcpy (val, str, len); |
467 return (val); | 465 return val; |
468 } | 466 } |
469 | 467 |
470 #ifdef NEED_STRDUP | 468 #ifdef NEED_STRDUP |
471 char * | 469 char * |
472 strdup (CONST char *s) | 470 strdup (CONST char *s) |
487 if ((char *) XCONS (val) != lim) | 485 if ((char *) XCONS (val) != lim) |
488 { | 486 { |
489 xfree (p); | 487 xfree (p); |
490 memory_full (); | 488 memory_full (); |
491 } | 489 } |
492 return (p); | 490 return p; |
493 } | 491 } |
494 | 492 |
495 | 493 |
496 #define MARKED_RECORD_HEADER_P(lheader) \ | 494 #define MARKED_RECORD_HEADER_P(lheader) \ |
497 (((lheader)->implementation->finalizer) == this_marks_a_marked_record) | 495 (((lheader)->implementation->finalizer) == this_marks_a_marked_record) |
532 lcheader->uid = (int) &lcheader; | 530 lcheader->uid = (int) &lcheader; |
533 #endif | 531 #endif |
534 lcheader->free = 0; | 532 lcheader->free = 0; |
535 all_lcrecords = lcheader; | 533 all_lcrecords = lcheader; |
536 INCREMENT_CONS_COUNTER (size, implementation->name); | 534 INCREMENT_CONS_COUNTER (size, implementation->name); |
537 return (lcheader); | 535 return lcheader; |
538 } | 536 } |
539 | 537 |
540 #if 0 /* Presently unused */ | 538 #if 0 /* Presently unused */ |
541 /* Very, very poor man's EGC? | 539 /* Very, very poor man's EGC? |
542 * This may be slow and thrash pages all over the place. | 540 * This may be slow and thrash pages all over the place. |
1036 | 1034 |
1037 Lisp_Object | 1035 Lisp_Object |
1038 list1 (Lisp_Object obj0) | 1036 list1 (Lisp_Object obj0) |
1039 { | 1037 { |
1040 /* This cannot GC. */ | 1038 /* This cannot GC. */ |
1041 return (Fcons (obj0, Qnil)); | 1039 return Fcons (obj0, Qnil); |
1042 } | 1040 } |
1043 | 1041 |
1044 Lisp_Object | 1042 Lisp_Object |
1045 list2 (Lisp_Object obj0, Lisp_Object obj1) | 1043 list2 (Lisp_Object obj0, Lisp_Object obj1) |
1046 { | 1044 { |
1121 ALLOCATE_FIXED_TYPE (float, struct Lisp_Float, f); | 1119 ALLOCATE_FIXED_TYPE (float, struct Lisp_Float, f); |
1122 f->lheader.implementation = lrecord_float; | 1120 f->lheader.implementation = lrecord_float; |
1123 float_next (f) = ((struct Lisp_Float *) -1); | 1121 float_next (f) = ((struct Lisp_Float *) -1); |
1124 float_data (f) = float_value; | 1122 float_data (f) = float_value; |
1125 XSETFLOAT (val, f); | 1123 XSETFLOAT (val, f); |
1126 return (val); | 1124 return val; |
1127 } | 1125 } |
1128 | 1126 |
1129 #endif /* LISP_FLOAT_TYPE */ | 1127 #endif /* LISP_FLOAT_TYPE */ |
1130 | 1128 |
1131 | 1129 |
1152 INCREMENT_CONS_COUNTER (sizem, "vector"); | 1150 INCREMENT_CONS_COUNTER (sizem, "vector"); |
1153 | 1151 |
1154 p->size = sizei; | 1152 p->size = sizei; |
1155 vector_next (p) = all_vectors; | 1153 vector_next (p) = all_vectors; |
1156 XSETVECTOR (all_vectors, p); | 1154 XSETVECTOR (all_vectors, p); |
1157 return (p); | 1155 return p; |
1158 } | 1156 } |
1159 | 1157 |
1160 Lisp_Object | 1158 Lisp_Object |
1161 make_vector (EMACS_INT length, Lisp_Object init) | 1159 make_vector (EMACS_INT length, Lisp_Object init) |
1162 { | 1160 { |
1178 { | 1176 { |
1179 if (travesty[i] != travesty[0]) | 1177 if (travesty[i] != travesty[0]) |
1180 goto fill; | 1178 goto fill; |
1181 } | 1179 } |
1182 memset (vector_data (p), travesty[0], length * sizeof (Lisp_Object)); | 1180 memset (vector_data (p), travesty[0], length * sizeof (Lisp_Object)); |
1183 return (vector); | 1181 return vector; |
1184 } | 1182 } |
1185 fill: | 1183 fill: |
1186 #endif | 1184 #endif |
1187 for (elt = 0; elt < length; elt++) | 1185 for (elt = 0; elt < length; elt++) |
1188 vector_data(p)[elt] = init; | 1186 vector_data(p)[elt] = init; |
1189 | 1187 |
1190 return (vector); | 1188 return vector; |
1191 } | 1189 } |
1192 | 1190 |
1193 DEFUN ("make-vector", Fmake_vector, 2, 2, 0, /* | 1191 DEFUN ("make-vector", Fmake_vector, 2, 2, 0, /* |
1194 Return a newly created vector of length LENGTH, with each element being INIT. | 1192 Return a newly created vector of length LENGTH, with each element being INIT. |
1195 See also the function `vector'. | 1193 See also the function `vector'. |
1197 (length, init)) | 1195 (length, init)) |
1198 { | 1196 { |
1199 if (!INTP (length) || XINT (length) < 0) | 1197 if (!INTP (length) || XINT (length) < 0) |
1200 length = wrong_type_argument (Qnatnump, length); | 1198 length = wrong_type_argument (Qnatnump, length); |
1201 | 1199 |
1202 return (make_vector (XINT (length), init)); | 1200 return make_vector (XINT (length), init); |
1203 } | 1201 } |
1204 | 1202 |
1205 DEFUN ("vector", Fvector, 0, MANY, 0, /* | 1203 DEFUN ("vector", Fvector, 0, MANY, 0, /* |
1206 Return a newly created vector with specified arguments as elements. | 1204 Return a newly created vector with specified arguments as elements. |
1207 Any number of arguments, even zero arguments, are allowed. | 1205 Any number of arguments, even zero arguments, are allowed. |
1216 XSETVECTOR (vector, p); | 1214 XSETVECTOR (vector, p); |
1217 | 1215 |
1218 for (elt = 0; elt < nargs; elt++) | 1216 for (elt = 0; elt < nargs; elt++) |
1219 vector_data(p)[elt] = args[elt]; | 1217 vector_data(p)[elt] = args[elt]; |
1220 | 1218 |
1221 return (vector); | 1219 return vector; |
1222 } | 1220 } |
1223 | 1221 |
1224 Lisp_Object | 1222 Lisp_Object |
1225 vector1 (Lisp_Object obj0) | 1223 vector1 (Lisp_Object obj0) |
1226 { | 1224 { |
1340 bit_vector_next (p) = all_bit_vectors; | 1338 bit_vector_next (p) = all_bit_vectors; |
1341 /* make sure the extra bits in the last long are 0; the calling | 1339 /* make sure the extra bits in the last long are 0; the calling |
1342 functions might not set them. */ | 1340 functions might not set them. */ |
1343 p->bits[BIT_VECTOR_LONG_STORAGE (sizei) - 1] = 0; | 1341 p->bits[BIT_VECTOR_LONG_STORAGE (sizei) - 1] = 0; |
1344 XSETBIT_VECTOR (all_bit_vectors, p); | 1342 XSETBIT_VECTOR (all_bit_vectors, p); |
1345 return (p); | 1343 return p; |
1346 } | 1344 } |
1347 | 1345 |
1348 Lisp_Object | 1346 Lisp_Object |
1349 make_bit_vector (EMACS_INT length, Lisp_Object init) | 1347 make_bit_vector (EMACS_INT length, Lisp_Object init) |
1350 { | 1348 { |
1371 last integer are 0, so that equal/hash is easy. */ | 1369 last integer are 0, so that equal/hash is easy. */ |
1372 if (bits_in_last) | 1370 if (bits_in_last) |
1373 p->bits[num_longs - 1] &= (1 << bits_in_last) - 1; | 1371 p->bits[num_longs - 1] &= (1 << bits_in_last) - 1; |
1374 } | 1372 } |
1375 | 1373 |
1376 return (bit_vector); | 1374 return bit_vector; |
1377 } | 1375 } |
1378 | 1376 |
1379 Lisp_Object | 1377 Lisp_Object |
1380 make_bit_vector_from_byte_vector (unsigned char *bytevec, EMACS_INT length) | 1378 make_bit_vector_from_byte_vector (unsigned char *bytevec, EMACS_INT length) |
1381 { | 1379 { |
1402 (length, init)) | 1400 (length, init)) |
1403 { | 1401 { |
1404 if (!INTP (length) || XINT (length) < 0) | 1402 if (!INTP (length) || XINT (length) < 0) |
1405 length = wrong_type_argument (Qnatnump, length); | 1403 length = wrong_type_argument (Qnatnump, length); |
1406 | 1404 |
1407 return (make_bit_vector (XINT (length), init)); | 1405 return make_bit_vector (XINT (length), init); |
1408 } | 1406 } |
1409 | 1407 |
1410 DEFUN ("bit-vector", Fbit_vector, 0, MANY, 0, /* | 1408 DEFUN ("bit-vector", Fbit_vector, 0, MANY, 0, /* |
1411 Return a newly created bit vector with specified arguments as elements. | 1409 Return a newly created bit vector with specified arguments as elements. |
1412 Any number of arguments, even zero arguments, are allowed. | 1410 Any number of arguments, even zero arguments, are allowed. |
1424 XSETBIT_VECTOR (bit_vector, p); | 1422 XSETBIT_VECTOR (bit_vector, p); |
1425 | 1423 |
1426 for (elt = 0; elt < nargs; elt++) | 1424 for (elt = 0; elt < nargs; elt++) |
1427 set_bit_vector_bit (p, elt, !ZEROP (args[elt])); | 1425 set_bit_vector_bit (p, elt, !ZEROP (args[elt])); |
1428 | 1426 |
1429 return (bit_vector); | 1427 return bit_vector; |
1430 } | 1428 } |
1431 | 1429 |
1432 | 1430 |
1433 /**********************************************************************/ | 1431 /**********************************************************************/ |
1434 /* Compiled-function allocation */ | 1432 /* Compiled-function allocation */ |
1467 b->doc_and_interactive = Qnil; | 1465 b->doc_and_interactive = Qnil; |
1468 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK | 1466 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK |
1469 b->annotated = Qnil; | 1467 b->annotated = Qnil; |
1470 #endif | 1468 #endif |
1471 XSETCOMPILED_FUNCTION (new, b); | 1469 XSETCOMPILED_FUNCTION (new, b); |
1472 return (new); | 1470 return new; |
1473 } | 1471 } |
1474 | 1472 |
1475 DEFUN ("make-byte-code", Fmake_byte_code, 4, MANY, 0, /* | 1473 DEFUN ("make-byte-code", Fmake_byte_code, 4, MANY, 0, /* |
1476 Create a compiled-function object. | 1474 Create a compiled-function object. |
1477 Usage: (arglist instructions constants stack-size | 1475 Usage: (arglist instructions constants stack-size |
1631 b->doc_and_interactive = Vfile_domain; | 1629 b->doc_and_interactive = Vfile_domain; |
1632 #endif | 1630 #endif |
1633 else | 1631 else |
1634 b->doc_and_interactive = doc_string; | 1632 b->doc_and_interactive = doc_string; |
1635 | 1633 |
1636 return (val); | 1634 return val; |
1637 } | 1635 } |
1638 } | 1636 } |
1639 | 1637 |
1640 | 1638 |
1641 /**********************************************************************/ | 1639 /**********************************************************************/ |
1694 | 1692 |
1695 extent_face (e) = Qnil; | 1693 extent_face (e) = Qnil; |
1696 e->flags.end_open = 1; /* default is for endpoints to behave like markers */ | 1694 e->flags.end_open = 1; /* default is for endpoints to behave like markers */ |
1697 e->flags.detachable = 1; | 1695 e->flags.detachable = 1; |
1698 | 1696 |
1699 return (e); | 1697 return e; |
1700 } | 1698 } |
1701 | 1699 |
1702 | 1700 |
1703 /**********************************************************************/ | 1701 /**********************************************************************/ |
1704 /* Event allocation */ | 1702 /* Event allocation */ |
1816 #define BIG_STRING_FULLSIZE_P(fullsize) ((fullsize) >= STRING_CHARS_BLOCK_SIZE) | 1814 #define BIG_STRING_FULLSIZE_P(fullsize) ((fullsize) >= STRING_CHARS_BLOCK_SIZE) |
1817 #define BIG_STRING_SIZE_P(size) (BIG_STRING_FULLSIZE_P (STRING_FULLSIZE(size))) | 1815 #define BIG_STRING_SIZE_P(size) (BIG_STRING_FULLSIZE_P (STRING_FULLSIZE(size))) |
1818 | 1816 |
1819 #define CHARS_TO_STRING_CHAR(x) \ | 1817 #define CHARS_TO_STRING_CHAR(x) \ |
1820 ((struct string_chars *) \ | 1818 ((struct string_chars *) \ |
1821 (((char *) (x)) - (slot_offset (struct string_chars, chars)))) | 1819 (((char *) (x)) - (slot_offset (struct string_chars, chars[0])))) |
1822 | 1820 |
1823 | 1821 |
1824 struct string_chars | 1822 struct string_chars |
1825 { | 1823 { |
1826 struct Lisp_String *string; | 1824 struct Lisp_String *string; |
1909 s->plist = Qnil; | 1907 s->plist = Qnil; |
1910 | 1908 |
1911 set_string_byte (s, length, 0); | 1909 set_string_byte (s, length, 0); |
1912 | 1910 |
1913 XSETSTRING (val, s); | 1911 XSETSTRING (val, s); |
1914 return (val); | 1912 return val; |
1915 } | 1913 } |
1916 | 1914 |
1917 #ifdef VERIFY_STRING_CHARS_INTEGRITY | 1915 #ifdef VERIFY_STRING_CHARS_INTEGRITY |
1918 static void verify_string_chars_integrity (void); | 1916 static void verify_string_chars_integrity (void); |
1919 #endif | 1917 #endif |
2104 for (i = 0; i < XINT (length); i++) | 2102 for (i = 0; i < XINT (length); i++) |
2105 for (j = 0; j < len; j++) | 2103 for (j = 0; j < len; j++) |
2106 ptr[k++] = str[j]; | 2104 ptr[k++] = str[j]; |
2107 } | 2105 } |
2108 } | 2106 } |
2109 return (val); | 2107 return val; |
2110 } | 2108 } |
2111 | 2109 |
2112 /* Take some raw memory, which MUST already be in internal format, | 2110 /* Take some raw memory, which MUST already be in internal format, |
2113 and package it up it into a Lisp string. */ | 2111 and package it up it into a Lisp string. */ |
2114 Lisp_Object | 2112 Lisp_Object |
2121 bytecount_to_charcount (contents, length); /* Just for the assertions */ | 2119 bytecount_to_charcount (contents, length); /* Just for the assertions */ |
2122 #endif | 2120 #endif |
2123 | 2121 |
2124 val = make_uninit_string (length); | 2122 val = make_uninit_string (length); |
2125 memcpy (XSTRING_DATA (val), contents, length); | 2123 memcpy (XSTRING_DATA (val), contents, length); |
2126 return (val); | 2124 return val; |
2127 } | 2125 } |
2128 | 2126 |
2129 /* Take some raw memory, encoded in some external data format, | 2127 /* Take some raw memory, encoded in some external data format, |
2130 and convert it into a Lisp string. */ | 2128 and convert it into a Lisp string. */ |
2131 Lisp_Object | 2129 Lisp_Object |
2358 if (SYMBOLP (tem)) | 2356 if (SYMBOLP (tem)) |
2359 { | 2357 { |
2360 s = XSYMBOL (tem)->name; | 2358 s = XSYMBOL (tem)->name; |
2361 if (!PURIFIED (s)) abort (); | 2359 if (!PURIFIED (s)) abort (); |
2362 XSETSTRING (new, s); | 2360 XSETSTRING (new, s); |
2363 return (new); | 2361 return new; |
2364 } | 2362 } |
2365 } | 2363 } |
2366 | 2364 |
2367 if (!check_purespace (size)) | 2365 if (!check_purespace (size)) |
2368 return (make_string (data, length)); | 2366 return make_string (data, length); |
2369 | 2367 |
2370 s = (struct Lisp_String *) (PUREBEG + pureptr); | 2368 s = (struct Lisp_String *) (PUREBEG + pureptr); |
2371 set_string_length (s, length); | 2369 set_string_length (s, length); |
2372 if (no_need_to_copy_data) | 2370 if (no_need_to_copy_data) |
2373 { | 2371 { |
2390 | 2388 |
2391 /* Do this after the official "completion" of the purecopying. */ | 2389 /* Do this after the official "completion" of the purecopying. */ |
2392 s->plist = Fpurecopy (plist); | 2390 s->plist = Fpurecopy (plist); |
2393 | 2391 |
2394 XSETSTRING (new, s); | 2392 XSETSTRING (new, s); |
2395 return (new); | 2393 return new; |
2396 } | 2394 } |
2397 | 2395 |
2398 | 2396 |
2399 Lisp_Object | 2397 Lisp_Object |
2400 make_pure_pname (CONST Bufbyte *data, Bytecount length, | 2398 make_pure_pname (CONST Bufbyte *data, Bytecount length, |
2405 bump_purestat (&purestat_string_pname, pure_sizeof (name)); | 2403 bump_purestat (&purestat_string_pname, pure_sizeof (name)); |
2406 | 2404 |
2407 /* We've made (at least) Qnil now, and Vobarray will soon be set up. */ | 2405 /* We've made (at least) Qnil now, and Vobarray will soon be set up. */ |
2408 symbols_initialized = 1; | 2406 symbols_initialized = 1; |
2409 | 2407 |
2410 return (name); | 2408 return name; |
2411 } | 2409 } |
2412 | 2410 |
2413 | 2411 |
2414 Lisp_Object | 2412 Lisp_Object |
2415 pure_cons (Lisp_Object car, Lisp_Object cdr) | 2413 pure_cons (Lisp_Object car, Lisp_Object cdr) |
2416 { | 2414 { |
2417 Lisp_Object new; | 2415 Lisp_Object new; |
2418 | 2416 |
2419 if (!check_purespace (sizeof (struct Lisp_Cons))) | 2417 if (!check_purespace (sizeof (struct Lisp_Cons))) |
2420 return (Fcons (Fpurecopy (car), Fpurecopy (cdr))); | 2418 return Fcons (Fpurecopy (car), Fpurecopy (cdr)); |
2421 | 2419 |
2422 XSETCONS (new, PUREBEG + pureptr); | 2420 XSETCONS (new, PUREBEG + pureptr); |
2423 pureptr += sizeof (struct Lisp_Cons); | 2421 pureptr += sizeof (struct Lisp_Cons); |
2424 bump_purestat (&purestat_cons, sizeof (struct Lisp_Cons)); | 2422 bump_purestat (&purestat_cons, sizeof (struct Lisp_Cons)); |
2425 | 2423 |
2426 XCAR (new) = Fpurecopy (car); | 2424 XCAR (new) = Fpurecopy (car); |
2427 XCDR (new) = Fpurecopy (cdr); | 2425 XCDR (new) = Fpurecopy (cdr); |
2428 return (new); | 2426 return new; |
2429 } | 2427 } |
2430 | 2428 |
2431 Lisp_Object | 2429 Lisp_Object |
2432 pure_list (int nargs, Lisp_Object *args) | 2430 pure_list (int nargs, Lisp_Object *args) |
2433 { | 2431 { |
2472 p = (char *) (((unsigned EMACS_INT) p + alignment - 1) & - alignment); | 2470 p = (char *) (((unsigned EMACS_INT) p + alignment - 1) & - alignment); |
2473 pureptr = p - (char *) PUREBEG; | 2471 pureptr = p - (char *) PUREBEG; |
2474 } | 2472 } |
2475 | 2473 |
2476 if (!check_purespace (sizeof (struct Lisp_Float))) | 2474 if (!check_purespace (sizeof (struct Lisp_Float))) |
2477 return (make_float (num)); | 2475 return make_float (num); |
2478 | 2476 |
2479 f = (struct Lisp_Float *) (PUREBEG + pureptr); | 2477 f = (struct Lisp_Float *) (PUREBEG + pureptr); |
2480 set_lheader_implementation (&(f->lheader), lrecord_float); | 2478 set_lheader_implementation (&(f->lheader), lrecord_float); |
2481 pureptr += sizeof (struct Lisp_Float); | 2479 pureptr += sizeof (struct Lisp_Float); |
2482 bump_purestat (&purestat_float, sizeof (struct Lisp_Float)); | 2480 bump_purestat (&purestat_float, sizeof (struct Lisp_Float)); |
2483 | 2481 |
2484 float_next (f) = ((struct Lisp_Float *) -1); | 2482 float_next (f) = ((struct Lisp_Float *) -1); |
2485 float_data (f) = num; | 2483 float_data (f) = num; |
2486 XSETFLOAT (val, f); | 2484 XSETFLOAT (val, f); |
2487 return (val); | 2485 return val; |
2488 } | 2486 } |
2489 | 2487 |
2490 #endif /* LISP_FLOAT_TYPE */ | 2488 #endif /* LISP_FLOAT_TYPE */ |
2491 | 2489 |
2492 Lisp_Object | 2490 Lisp_Object |
2497 + (len - 1) * sizeof (Lisp_Object)); | 2495 + (len - 1) * sizeof (Lisp_Object)); |
2498 | 2496 |
2499 init = Fpurecopy (init); | 2497 init = Fpurecopy (init); |
2500 | 2498 |
2501 if (!check_purespace (size)) | 2499 if (!check_purespace (size)) |
2502 return (make_vector (len, init)); | 2500 return make_vector (len, init); |
2503 | 2501 |
2504 XSETVECTOR (new, PUREBEG + pureptr); | 2502 XSETVECTOR (new, PUREBEG + pureptr); |
2505 pureptr += size; | 2503 pureptr += size; |
2506 bump_purestat (&purestat_vector_all, size); | 2504 bump_purestat (&purestat_vector_all, size); |
2507 | 2505 |
2508 XVECTOR (new)->size = len; | 2506 XVECTOR_LENGTH (new) = len; |
2509 | 2507 |
2510 for (size = 0; size < len; size++) | 2508 for (size = 0; size < len; size++) |
2511 vector_data (XVECTOR (new))[size] = init; | 2509 XVECTOR_DATA (new)[size] = init; |
2512 | 2510 |
2513 return (new); | 2511 return new; |
2514 } | 2512 } |
2515 | 2513 |
2516 #if 0 | 2514 #if 0 |
2517 /* Presently unused */ | 2515 /* Presently unused */ |
2518 void * | 2516 void * |
2523 if (pureptr + size > get_PURESIZE()) | 2521 if (pureptr + size > get_PURESIZE()) |
2524 pure_storage_exhausted (); | 2522 pure_storage_exhausted (); |
2525 | 2523 |
2526 set_lheader_implementation (header, implementation); | 2524 set_lheader_implementation (header, implementation); |
2527 header->next = 0; | 2525 header->next = 0; |
2528 return (header); | 2526 return header; |
2529 } | 2527 } |
2530 #endif | 2528 #endif |
2531 | 2529 |
2532 | 2530 |
2533 | 2531 |
2538 */ | 2536 */ |
2539 (obj)) | 2537 (obj)) |
2540 { | 2538 { |
2541 int i; | 2539 int i; |
2542 if (!purify_flag) | 2540 if (!purify_flag) |
2543 return (obj); | 2541 return obj; |
2544 | 2542 |
2545 if (!POINTER_TYPE_P (XTYPE (obj)) | 2543 if (!POINTER_TYPE_P (XTYPE (obj)) |
2546 || PURIFIED (XPNTR (obj))) | 2544 || PURIFIED (XPNTR (obj))) |
2547 return (obj); | 2545 return obj; |
2548 | 2546 |
2549 switch (XTYPE (obj)) | 2547 switch (XTYPE (obj)) |
2550 { | 2548 { |
2551 case Lisp_Cons: | 2549 case Lisp_Cons: |
2552 return pure_cons (XCAR (obj), XCDR (obj)); | 2550 return pure_cons (XCAR (obj), XCDR (obj)); |
2560 case Lisp_Vector: | 2558 case Lisp_Vector: |
2561 { | 2559 { |
2562 struct Lisp_Vector *o = XVECTOR (obj); | 2560 struct Lisp_Vector *o = XVECTOR (obj); |
2563 Lisp_Object new = make_pure_vector (vector_length (o), Qnil); | 2561 Lisp_Object new = make_pure_vector (vector_length (o), Qnil); |
2564 for (i = 0; i < vector_length (o); i++) | 2562 for (i = 0; i < vector_length (o); i++) |
2565 vector_data (XVECTOR (new))[i] = Fpurecopy (o->contents[i]); | 2563 XVECTOR_DATA (new)[i] = Fpurecopy (o->contents[i]); |
2566 return (new); | 2564 return new; |
2567 } | 2565 } |
2568 | 2566 |
2569 default: | 2567 default: |
2570 { | 2568 { |
2571 if (COMPILED_FUNCTIONP (obj)) | 2569 if (COMPILED_FUNCTIONP (obj)) |
2578 n->bytecodes = Fpurecopy (o->bytecodes); | 2576 n->bytecodes = Fpurecopy (o->bytecodes); |
2579 n->constants = Fpurecopy (o->constants); | 2577 n->constants = Fpurecopy (o->constants); |
2580 n->arglist = Fpurecopy (o->arglist); | 2578 n->arglist = Fpurecopy (o->arglist); |
2581 n->doc_and_interactive = Fpurecopy (o->doc_and_interactive); | 2579 n->doc_and_interactive = Fpurecopy (o->doc_and_interactive); |
2582 n->maxdepth = o->maxdepth; | 2580 n->maxdepth = o->maxdepth; |
2583 return (new); | 2581 return new; |
2584 } | 2582 } |
2585 #ifdef LISP_FLOAT_TYPE | 2583 #ifdef LISP_FLOAT_TYPE |
2586 else if (FLOATP (obj)) | 2584 else if (FLOATP (obj)) |
2587 return make_pure_float (float_data (XFLOAT (obj))); | 2585 return make_pure_float (float_data (XFLOAT (obj))); |
2588 #endif /* LISP_FLOAT_TYPE */ | 2586 #endif /* LISP_FLOAT_TYPE */ |
2589 else if (!SYMBOLP (obj)) | 2587 else if (!SYMBOLP (obj)) |
2590 signal_simple_error ("Can't purecopy %S", obj); | 2588 signal_simple_error ("Can't purecopy %S", obj); |
2591 } | 2589 } |
2592 } | 2590 } |
2593 return (obj); | 2591 return obj; |
2594 } | 2592 } |
2595 | 2593 |
2596 | 2594 |
2597 | 2595 |
2598 static void | 2596 static void |
2946 int total = 0; | 2944 int total = 0; |
2947 | 2945 |
2948 /*tail_recurse: */ | 2946 /*tail_recurse: */ |
2949 if (!POINTER_TYPE_P (XTYPE (obj)) | 2947 if (!POINTER_TYPE_P (XTYPE (obj)) |
2950 || !PURIFIED (XPNTR (obj))) | 2948 || !PURIFIED (XPNTR (obj))) |
2951 return (total); | 2949 return total; |
2952 | 2950 |
2953 /* symbol's sizes are accounted for separately */ | 2951 /* symbol's sizes are accounted for separately */ |
2954 if (SYMBOLP (obj)) | 2952 if (SYMBOLP (obj)) |
2955 return (total); | 2953 return total; |
2956 | 2954 |
2957 switch (XTYPE (obj)) | 2955 switch (XTYPE (obj)) |
2958 { | 2956 { |
2959 case Lisp_String: | 2957 case Lisp_String: |
2960 { | 2958 { |
3055 | 3053 |
3056 /* Others can't be purified */ | 3054 /* Others can't be purified */ |
3057 default: | 3055 default: |
3058 abort (); | 3056 abort (); |
3059 } | 3057 } |
3060 return (total); | 3058 return total; |
3061 } | 3059 } |
3062 #endif /* PURESTAT */ | 3060 #endif /* PURESTAT */ |
3063 | 3061 |
3064 | 3062 |
3065 | 3063 |
3097 abort (); | 3095 abort (); |
3098 type_index = ++last_lrecord_type_index_assigned; | 3096 type_index = ++last_lrecord_type_index_assigned; |
3099 lrecord_implementations_table[type_index] = implementation; | 3097 lrecord_implementations_table[type_index] = implementation; |
3100 *(implementation->lrecord_type_index) = type_index; | 3098 *(implementation->lrecord_type_index) = type_index; |
3101 } | 3099 } |
3102 return (type_index); | 3100 return type_index; |
3103 } | 3101 } |
3104 | 3102 |
3105 /* stats on lcrecords in use - kinda kludgy */ | 3103 /* stats on lcrecords in use - kinda kludgy */ |
3106 | 3104 |
3107 static struct | 3105 static struct |
3796 case Lisp_Record: | 3794 case Lisp_Record: |
3797 return MARKED_RECORD_HEADER_P (XRECORD_LHEADER (obj)); | 3795 return MARKED_RECORD_HEADER_P (XRECORD_LHEADER (obj)); |
3798 case Lisp_String: | 3796 case Lisp_String: |
3799 return XMARKBIT (XSTRING (obj)->plist); | 3797 return XMARKBIT (XSTRING (obj)->plist); |
3800 case Lisp_Vector: | 3798 case Lisp_Vector: |
3801 return (vector_length (XVECTOR (obj)) < 0); | 3799 return XVECTOR_LENGTH (obj) < 0; |
3802 #ifndef LRECORD_SYMBOL | 3800 #ifndef LRECORD_SYMBOL |
3803 case Lisp_Symbol: | 3801 case Lisp_Symbol: |
3804 return XMARKBIT (XSYMBOL (obj)->plist); | 3802 return XMARKBIT (XSYMBOL (obj)->plist); |
3805 #endif | 3803 #endif |
3806 default: | 3804 default: |
4200 gc_plist_hack (CONST char *name, int value, Lisp_Object tail) | 4198 gc_plist_hack (CONST char *name, int value, Lisp_Object tail) |
4201 { | 4199 { |
4202 /* C doesn't have local functions (or closures, or GC, or readable syntax, | 4200 /* C doesn't have local functions (or closures, or GC, or readable syntax, |
4203 or portable numeric datatypes, or bit-vectors, or characters, or | 4201 or portable numeric datatypes, or bit-vectors, or characters, or |
4204 arrays, or exceptions, or ...) */ | 4202 arrays, or exceptions, or ...) */ |
4205 return (cons3 (intern (name), make_int (value), tail)); | 4203 return cons3 (intern (name), make_int (value), tail); |
4206 } | 4204 } |
4207 | 4205 |
4208 #define HACK_O_MATIC(type, name, pl) \ | 4206 #define HACK_O_MATIC(type, name, pl) \ |
4209 { \ | 4207 { \ |
4210 int s = 0; \ | 4208 int s = 0; \ |
4330 ret[2] = Fcons (make_int (gc_count_num_marker_in_use), | 4328 ret[2] = Fcons (make_int (gc_count_num_marker_in_use), |
4331 make_int (gc_count_num_marker_freelist)); | 4329 make_int (gc_count_num_marker_freelist)); |
4332 ret[3] = make_int (gc_count_string_total_size); | 4330 ret[3] = make_int (gc_count_string_total_size); |
4333 ret[4] = make_int (gc_count_vector_total_size); | 4331 ret[4] = make_int (gc_count_vector_total_size); |
4334 ret[5] = pl; | 4332 ret[5] = pl; |
4335 return (Flist (6, ret)); | 4333 return Flist (6, ret); |
4336 } | 4334 } |
4337 #undef HACK_O_MATIC | 4335 #undef HACK_O_MATIC |
4338 | 4336 |
4339 DEFUN ("consing-since-gc", Fconsing_since_gc, 0, 0, "", /* | 4337 DEFUN ("consing-since-gc", Fconsing_since_gc, 0, 0, "", /* |
4340 Return the number of bytes consed since the last garbage collection. | 4338 Return the number of bytes consed since the last garbage collection. |
4343 | 4341 |
4344 If this value exceeds `gc-cons-threshold', a garbage collection happens. | 4342 If this value exceeds `gc-cons-threshold', a garbage collection happens. |
4345 */ | 4343 */ |
4346 ()) | 4344 ()) |
4347 { | 4345 { |
4348 return (make_int (consing_since_gc)); | 4346 return make_int (consing_since_gc); |
4349 } | 4347 } |
4350 | 4348 |
4351 DEFUN ("memory-limit", Fmemory_limit, 0, 0, "", /* | 4349 DEFUN ("memory-limit", Fmemory_limit, 0, 0, "", /* |
4352 Return the address of the last byte Emacs has allocated, divided by 1024. | 4350 Return the address of the last byte Emacs has allocated, divided by 1024. |
4353 This may be helpful in debugging Emacs's memory usage. | 4351 This may be helpful in debugging Emacs's memory usage. |
4354 The value is divided by 1024 to make sure it will fit in a lisp integer. | 4352 The value is divided by 1024 to make sure it will fit in a lisp integer. |
4355 */ | 4353 */ |
4356 ()) | 4354 ()) |
4357 { | 4355 { |
4358 return (make_int ((EMACS_INT) sbrk (0) / 1024)); | 4356 return make_int ((EMACS_INT) sbrk (0) / 1024); |
4359 } | 4357 } |
4360 | 4358 |
4361 | 4359 |
4362 | 4360 |
4363 int | 4361 int |
4364 object_dead_p (Lisp_Object obj) | 4362 object_dead_p (Lisp_Object obj) |
4365 { | 4363 { |
4366 return ((BUFFERP (obj) && !BUFFER_LIVE_P (XBUFFER (obj))) || | 4364 return ((BUFFERP (obj) && !BUFFER_LIVE_P (XBUFFER (obj))) || |
4367 (FRAMEP (obj) && !FRAME_LIVE_P (XFRAME (obj))) || | 4365 (FRAMEP (obj) && !FRAME_LIVE_P (XFRAME (obj))) || |
4368 (WINDOWP (obj) && !WINDOW_LIVE_P (XWINDOW (obj))) || | 4366 (WINDOWP (obj) && !WINDOW_LIVE_P (XWINDOW (obj))) || |
4369 (DEVICEP (obj) && !DEVICE_LIVE_P (XDEVICE (obj))) || | 4367 (DEVICEP (obj) && !DEVICE_LIVE_P (XDEVICE (obj))) || |
4370 (CONSOLEP (obj) && !CONSOLE_LIVE_P (XCONSOLE (obj))) || | 4368 (CONSOLEP (obj) && !CONSOLE_LIVE_P (XCONSOLE (obj))) || |
4371 (EVENTP (obj) && !EVENT_LIVE_P (XEVENT (obj))) || | 4369 (EVENTP (obj) && !EVENT_LIVE_P (XEVENT (obj))) || |
4372 (EXTENTP (obj) && !EXTENT_LIVE_P (XEXTENT (obj)))); | 4370 (EXTENTP (obj) && !EXTENT_LIVE_P (XEXTENT (obj)))); |
4373 | 4371 |
4374 } | 4372 } |
4375 | 4373 |
4376 #ifdef MEMORY_USAGE_STATS | 4374 #ifdef MEMORY_USAGE_STATS |
4377 | 4375 |