diff options
| author | Kenichi Handa | 2012-07-17 07:09:08 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2012-07-17 07:09:08 +0900 |
| commit | 8c536f15bf95916d56bb50495d22b7da7e09fff9 (patch) | |
| tree | ac6f8bf5103bdbd1d6a75f05def9bc7aa9e96547 /src/alloc.c | |
| parent | 21a8caaa4af24f258e6c7f80c1fc913b00aee044 (diff) | |
| parent | c05cf3902ae658cc8bf413124245c9e1cdcca2d7 (diff) | |
| download | emacs-8c536f15bf95916d56bb50495d22b7da7e09fff9.tar.gz emacs-8c536f15bf95916d56bb50495d22b7da7e09fff9.zip | |
merge trunk
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 166 |
1 files changed, 85 insertions, 81 deletions
diff --git a/src/alloc.c b/src/alloc.c index a120ce9b61f..7c461c5a6af 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -66,7 +66,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 66 | 66 | ||
| 67 | #include <unistd.h> | 67 | #include <unistd.h> |
| 68 | #ifndef HAVE_UNISTD_H | 68 | #ifndef HAVE_UNISTD_H |
| 69 | extern POINTER_TYPE *sbrk (); | 69 | extern void *sbrk (); |
| 70 | #endif | 70 | #endif |
| 71 | 71 | ||
| 72 | #include <fcntl.h> | 72 | #include <fcntl.h> |
| @@ -234,11 +234,11 @@ static ptrdiff_t pure_bytes_used_before_overflow; | |||
| 234 | 234 | ||
| 235 | /* Index in pure at which next pure Lisp object will be allocated.. */ | 235 | /* Index in pure at which next pure Lisp object will be allocated.. */ |
| 236 | 236 | ||
| 237 | static EMACS_INT pure_bytes_used_lisp; | 237 | static ptrdiff_t pure_bytes_used_lisp; |
| 238 | 238 | ||
| 239 | /* Number of bytes allocated for non-Lisp objects in pure storage. */ | 239 | /* Number of bytes allocated for non-Lisp objects in pure storage. */ |
| 240 | 240 | ||
| 241 | static EMACS_INT pure_bytes_used_non_lisp; | 241 | static ptrdiff_t pure_bytes_used_non_lisp; |
| 242 | 242 | ||
| 243 | /* If nonzero, this is a warning delivered by malloc and not yet | 243 | /* If nonzero, this is a warning delivered by malloc and not yet |
| 244 | displayed. */ | 244 | displayed. */ |
| @@ -273,6 +273,7 @@ static Lisp_Object Qpost_gc_hook; | |||
| 273 | static void mark_buffer (Lisp_Object); | 273 | static void mark_buffer (Lisp_Object); |
| 274 | static void mark_terminals (void); | 274 | static void mark_terminals (void); |
| 275 | static void gc_sweep (void); | 275 | static void gc_sweep (void); |
| 276 | static Lisp_Object make_pure_vector (ptrdiff_t); | ||
| 276 | static void mark_glyph_matrix (struct glyph_matrix *); | 277 | static void mark_glyph_matrix (struct glyph_matrix *); |
| 277 | static void mark_face_cache (struct face_cache *); | 278 | static void mark_face_cache (struct face_cache *); |
| 278 | 279 | ||
| @@ -306,7 +307,7 @@ enum mem_type | |||
| 306 | MEM_TYPE_VECTORLIKE | 307 | MEM_TYPE_VECTORLIKE |
| 307 | }; | 308 | }; |
| 308 | 309 | ||
| 309 | static POINTER_TYPE *lisp_malloc (size_t, enum mem_type); | 310 | static void *lisp_malloc (size_t, enum mem_type); |
| 310 | 311 | ||
| 311 | 312 | ||
| 312 | #if GC_MARK_STACK || defined GC_MALLOC_CHECK | 313 | #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
| @@ -387,8 +388,8 @@ static void *min_heap_address, *max_heap_address; | |||
| 387 | static struct mem_node mem_z; | 388 | static struct mem_node mem_z; |
| 388 | #define MEM_NIL &mem_z | 389 | #define MEM_NIL &mem_z |
| 389 | 390 | ||
| 390 | static struct Lisp_Vector *allocate_vectorlike (EMACS_INT); | 391 | static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t); |
| 391 | static void lisp_free (POINTER_TYPE *); | 392 | static void lisp_free (void *); |
| 392 | static void mark_stack (void); | 393 | static void mark_stack (void); |
| 393 | static int live_vector_p (struct mem_node *, void *); | 394 | static int live_vector_p (struct mem_node *, void *); |
| 394 | static int live_buffer_p (struct mem_node *, void *); | 395 | static int live_buffer_p (struct mem_node *, void *); |
| @@ -435,15 +436,15 @@ static Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag}; | |||
| 435 | 436 | ||
| 436 | static int staticidx = 0; | 437 | static int staticidx = 0; |
| 437 | 438 | ||
| 438 | static POINTER_TYPE *pure_alloc (size_t, int); | 439 | static void *pure_alloc (size_t, int); |
| 439 | 440 | ||
| 440 | 441 | ||
| 441 | /* Value is SZ rounded up to the next multiple of ALIGNMENT. | 442 | /* Value is SZ rounded up to the next multiple of ALIGNMENT. |
| 442 | ALIGNMENT must be a power of 2. */ | 443 | ALIGNMENT must be a power of 2. */ |
| 443 | 444 | ||
| 444 | #define ALIGN(ptr, ALIGNMENT) \ | 445 | #define ALIGN(ptr, ALIGNMENT) \ |
| 445 | ((POINTER_TYPE *) ((((uintptr_t) (ptr)) + (ALIGNMENT) - 1) \ | 446 | ((void *) (((uintptr_t) (ptr) + (ALIGNMENT) - 1) \ |
| 446 | & ~((ALIGNMENT) - 1))) | 447 | & ~ ((ALIGNMENT) - 1))) |
| 447 | 448 | ||
| 448 | 449 | ||
| 449 | 450 | ||
| @@ -475,7 +476,7 @@ display_malloc_warning (void) | |||
| 475 | /* Called if we can't allocate relocatable space for a buffer. */ | 476 | /* Called if we can't allocate relocatable space for a buffer. */ |
| 476 | 477 | ||
| 477 | void | 478 | void |
| 478 | buffer_memory_full (EMACS_INT nbytes) | 479 | buffer_memory_full (ptrdiff_t nbytes) |
| 479 | { | 480 | { |
| 480 | /* If buffers use the relocating allocator, no need to free | 481 | /* If buffers use the relocating allocator, no need to free |
| 481 | spare_memory, because we may have plenty of malloc space left | 482 | spare_memory, because we may have plenty of malloc space left |
| @@ -604,7 +605,7 @@ static ptrdiff_t check_depth; | |||
| 604 | 605 | ||
| 605 | /* Like malloc, but wraps allocated block with header and trailer. */ | 606 | /* Like malloc, but wraps allocated block with header and trailer. */ |
| 606 | 607 | ||
| 607 | static POINTER_TYPE * | 608 | static void * |
| 608 | overrun_check_malloc (size_t size) | 609 | overrun_check_malloc (size_t size) |
| 609 | { | 610 | { |
| 610 | register unsigned char *val; | 611 | register unsigned char *val; |
| @@ -622,15 +623,15 @@ overrun_check_malloc (size_t size) | |||
| 622 | XMALLOC_OVERRUN_CHECK_SIZE); | 623 | XMALLOC_OVERRUN_CHECK_SIZE); |
| 623 | } | 624 | } |
| 624 | --check_depth; | 625 | --check_depth; |
| 625 | return (POINTER_TYPE *)val; | 626 | return val; |
| 626 | } | 627 | } |
| 627 | 628 | ||
| 628 | 629 | ||
| 629 | /* Like realloc, but checks old block for overrun, and wraps new block | 630 | /* Like realloc, but checks old block for overrun, and wraps new block |
| 630 | with header and trailer. */ | 631 | with header and trailer. */ |
| 631 | 632 | ||
| 632 | static POINTER_TYPE * | 633 | static void * |
| 633 | overrun_check_realloc (POINTER_TYPE *block, size_t size) | 634 | overrun_check_realloc (void *block, size_t size) |
| 634 | { | 635 | { |
| 635 | register unsigned char *val = (unsigned char *) block; | 636 | register unsigned char *val = (unsigned char *) block; |
| 636 | int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; | 637 | int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; |
| @@ -652,7 +653,7 @@ overrun_check_realloc (POINTER_TYPE *block, size_t size) | |||
| 652 | memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE); | 653 | memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE); |
| 653 | } | 654 | } |
| 654 | 655 | ||
| 655 | val = (unsigned char *) realloc ((POINTER_TYPE *)val, size + overhead); | 656 | val = realloc (val, size + overhead); |
| 656 | 657 | ||
| 657 | if (val && check_depth == 1) | 658 | if (val && check_depth == 1) |
| 658 | { | 659 | { |
| @@ -663,13 +664,13 @@ overrun_check_realloc (POINTER_TYPE *block, size_t size) | |||
| 663 | XMALLOC_OVERRUN_CHECK_SIZE); | 664 | XMALLOC_OVERRUN_CHECK_SIZE); |
| 664 | } | 665 | } |
| 665 | --check_depth; | 666 | --check_depth; |
| 666 | return (POINTER_TYPE *)val; | 667 | return val; |
| 667 | } | 668 | } |
| 668 | 669 | ||
| 669 | /* Like free, but checks block for overrun. */ | 670 | /* Like free, but checks block for overrun. */ |
| 670 | 671 | ||
| 671 | static void | 672 | static void |
| 672 | overrun_check_free (POINTER_TYPE *block) | 673 | overrun_check_free (void *block) |
| 673 | { | 674 | { |
| 674 | unsigned char *val = (unsigned char *) block; | 675 | unsigned char *val = (unsigned char *) block; |
| 675 | 676 | ||
| @@ -718,13 +719,13 @@ overrun_check_free (POINTER_TYPE *block) | |||
| 718 | 719 | ||
| 719 | /* Like malloc but check for no memory and block interrupt input.. */ | 720 | /* Like malloc but check for no memory and block interrupt input.. */ |
| 720 | 721 | ||
| 721 | POINTER_TYPE * | 722 | void * |
| 722 | xmalloc (size_t size) | 723 | xmalloc (size_t size) |
| 723 | { | 724 | { |
| 724 | register POINTER_TYPE *val; | 725 | void *val; |
| 725 | 726 | ||
| 726 | MALLOC_BLOCK_INPUT; | 727 | MALLOC_BLOCK_INPUT; |
| 727 | val = (POINTER_TYPE *) malloc (size); | 728 | val = malloc (size); |
| 728 | MALLOC_UNBLOCK_INPUT; | 729 | MALLOC_UNBLOCK_INPUT; |
| 729 | 730 | ||
| 730 | if (!val && size) | 731 | if (!val && size) |
| @@ -735,18 +736,18 @@ xmalloc (size_t size) | |||
| 735 | 736 | ||
| 736 | /* Like realloc but check for no memory and block interrupt input.. */ | 737 | /* Like realloc but check for no memory and block interrupt input.. */ |
| 737 | 738 | ||
| 738 | POINTER_TYPE * | 739 | void * |
| 739 | xrealloc (POINTER_TYPE *block, size_t size) | 740 | xrealloc (void *block, size_t size) |
| 740 | { | 741 | { |
| 741 | register POINTER_TYPE *val; | 742 | void *val; |
| 742 | 743 | ||
| 743 | MALLOC_BLOCK_INPUT; | 744 | MALLOC_BLOCK_INPUT; |
| 744 | /* We must call malloc explicitly when BLOCK is 0, since some | 745 | /* We must call malloc explicitly when BLOCK is 0, since some |
| 745 | reallocs don't do this. */ | 746 | reallocs don't do this. */ |
| 746 | if (! block) | 747 | if (! block) |
| 747 | val = (POINTER_TYPE *) malloc (size); | 748 | val = malloc (size); |
| 748 | else | 749 | else |
| 749 | val = (POINTER_TYPE *) realloc (block, size); | 750 | val = realloc (block, size); |
| 750 | MALLOC_UNBLOCK_INPUT; | 751 | MALLOC_UNBLOCK_INPUT; |
| 751 | 752 | ||
| 752 | if (!val && size) | 753 | if (!val && size) |
| @@ -758,7 +759,7 @@ xrealloc (POINTER_TYPE *block, size_t size) | |||
| 758 | /* Like free but block interrupt input. */ | 759 | /* Like free but block interrupt input. */ |
| 759 | 760 | ||
| 760 | void | 761 | void |
| 761 | xfree (POINTER_TYPE *block) | 762 | xfree (void *block) |
| 762 | { | 763 | { |
| 763 | if (!block) | 764 | if (!block) |
| 764 | return; | 765 | return; |
| @@ -893,7 +894,7 @@ safe_alloca_unwind (Lisp_Object arg) | |||
| 893 | static void *lisp_malloc_loser; | 894 | static void *lisp_malloc_loser; |
| 894 | #endif | 895 | #endif |
| 895 | 896 | ||
| 896 | static POINTER_TYPE * | 897 | static void * |
| 897 | lisp_malloc (size_t nbytes, enum mem_type type) | 898 | lisp_malloc (size_t nbytes, enum mem_type type) |
| 898 | { | 899 | { |
| 899 | register void *val; | 900 | register void *val; |
| @@ -938,7 +939,7 @@ lisp_malloc (size_t nbytes, enum mem_type type) | |||
| 938 | call to lisp_malloc. */ | 939 | call to lisp_malloc. */ |
| 939 | 940 | ||
| 940 | static void | 941 | static void |
| 941 | lisp_free (POINTER_TYPE *block) | 942 | lisp_free (void *block) |
| 942 | { | 943 | { |
| 943 | MALLOC_BLOCK_INPUT; | 944 | MALLOC_BLOCK_INPUT; |
| 944 | free (block); | 945 | free (block); |
| @@ -1034,7 +1035,7 @@ static struct ablock *free_ablock; | |||
| 1034 | /* Allocate an aligned block of nbytes. | 1035 | /* Allocate an aligned block of nbytes. |
| 1035 | Alignment is on a multiple of BLOCK_ALIGN and `nbytes' has to be | 1036 | Alignment is on a multiple of BLOCK_ALIGN and `nbytes' has to be |
| 1036 | smaller or equal to BLOCK_BYTES. */ | 1037 | smaller or equal to BLOCK_BYTES. */ |
| 1037 | static POINTER_TYPE * | 1038 | static void * |
| 1038 | lisp_align_malloc (size_t nbytes, enum mem_type type) | 1039 | lisp_align_malloc (size_t nbytes, enum mem_type type) |
| 1039 | { | 1040 | { |
| 1040 | void *base, *val; | 1041 | void *base, *val; |
| @@ -1141,7 +1142,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) | |||
| 1141 | } | 1142 | } |
| 1142 | 1143 | ||
| 1143 | static void | 1144 | static void |
| 1144 | lisp_align_free (POINTER_TYPE *block) | 1145 | lisp_align_free (void *block) |
| 1145 | { | 1146 | { |
| 1146 | struct ablock *ablock = block; | 1147 | struct ablock *ablock = block; |
| 1147 | struct ablocks *abase = ABLOCK_ABASE (ablock); | 1148 | struct ablocks *abase = ABLOCK_ABASE (ablock); |
| @@ -1662,7 +1663,7 @@ struct sdata | |||
| 1662 | 1663 | ||
| 1663 | #ifdef GC_CHECK_STRING_BYTES | 1664 | #ifdef GC_CHECK_STRING_BYTES |
| 1664 | 1665 | ||
| 1665 | EMACS_INT nbytes; | 1666 | ptrdiff_t nbytes; |
| 1666 | unsigned char data[1]; | 1667 | unsigned char data[1]; |
| 1667 | 1668 | ||
| 1668 | #define SDATA_NBYTES(S) (S)->nbytes | 1669 | #define SDATA_NBYTES(S) (S)->nbytes |
| @@ -1677,7 +1678,7 @@ struct sdata | |||
| 1677 | unsigned char data[1]; | 1678 | unsigned char data[1]; |
| 1678 | 1679 | ||
| 1679 | /* When STRING is null. */ | 1680 | /* When STRING is null. */ |
| 1680 | EMACS_INT nbytes; | 1681 | ptrdiff_t nbytes; |
| 1681 | } u; | 1682 | } u; |
| 1682 | 1683 | ||
| 1683 | #define SDATA_NBYTES(S) (S)->u.nbytes | 1684 | #define SDATA_NBYTES(S) (S)->u.nbytes |
| @@ -1787,24 +1788,24 @@ static char const string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] = | |||
| 1787 | #define SDATA_SIZE(NBYTES) \ | 1788 | #define SDATA_SIZE(NBYTES) \ |
| 1788 | ((SDATA_DATA_OFFSET \ | 1789 | ((SDATA_DATA_OFFSET \ |
| 1789 | + (NBYTES) + 1 \ | 1790 | + (NBYTES) + 1 \ |
| 1790 | + sizeof (EMACS_INT) - 1) \ | 1791 | + sizeof (ptrdiff_t) - 1) \ |
| 1791 | & ~(sizeof (EMACS_INT) - 1)) | 1792 | & ~(sizeof (ptrdiff_t) - 1)) |
| 1792 | 1793 | ||
| 1793 | #else /* not GC_CHECK_STRING_BYTES */ | 1794 | #else /* not GC_CHECK_STRING_BYTES */ |
| 1794 | 1795 | ||
| 1795 | /* The 'max' reserves space for the nbytes union member even when NBYTES + 1 is | 1796 | /* The 'max' reserves space for the nbytes union member even when NBYTES + 1 is |
| 1796 | less than the size of that member. The 'max' is not needed when | 1797 | less than the size of that member. The 'max' is not needed when |
| 1797 | SDATA_DATA_OFFSET is a multiple of sizeof (EMACS_INT), because then the | 1798 | SDATA_DATA_OFFSET is a multiple of sizeof (ptrdiff_t), because then the |
| 1798 | alignment code reserves enough space. */ | 1799 | alignment code reserves enough space. */ |
| 1799 | 1800 | ||
| 1800 | #define SDATA_SIZE(NBYTES) \ | 1801 | #define SDATA_SIZE(NBYTES) \ |
| 1801 | ((SDATA_DATA_OFFSET \ | 1802 | ((SDATA_DATA_OFFSET \ |
| 1802 | + (SDATA_DATA_OFFSET % sizeof (EMACS_INT) == 0 \ | 1803 | + (SDATA_DATA_OFFSET % sizeof (ptrdiff_t) == 0 \ |
| 1803 | ? NBYTES \ | 1804 | ? NBYTES \ |
| 1804 | : max (NBYTES, sizeof (EMACS_INT) - 1)) \ | 1805 | : max (NBYTES, sizeof (ptrdiff_t) - 1)) \ |
| 1805 | + 1 \ | 1806 | + 1 \ |
| 1806 | + sizeof (EMACS_INT) - 1) \ | 1807 | + sizeof (ptrdiff_t) - 1) \ |
| 1807 | & ~(sizeof (EMACS_INT) - 1)) | 1808 | & ~(sizeof (ptrdiff_t) - 1)) |
| 1808 | 1809 | ||
| 1809 | #endif /* not GC_CHECK_STRING_BYTES */ | 1810 | #endif /* not GC_CHECK_STRING_BYTES */ |
| 1810 | 1811 | ||
| @@ -1848,10 +1849,10 @@ static int check_string_bytes_count; | |||
| 1848 | 1849 | ||
| 1849 | /* Like GC_STRING_BYTES, but with debugging check. */ | 1850 | /* Like GC_STRING_BYTES, but with debugging check. */ |
| 1850 | 1851 | ||
| 1851 | EMACS_INT | 1852 | ptrdiff_t |
| 1852 | string_bytes (struct Lisp_String *s) | 1853 | string_bytes (struct Lisp_String *s) |
| 1853 | { | 1854 | { |
| 1854 | EMACS_INT nbytes = | 1855 | ptrdiff_t nbytes = |
| 1855 | (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte); | 1856 | (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte); |
| 1856 | 1857 | ||
| 1857 | if (!PURE_POINTER_P (s) | 1858 | if (!PURE_POINTER_P (s) |
| @@ -1874,7 +1875,7 @@ check_sblock (struct sblock *b) | |||
| 1874 | { | 1875 | { |
| 1875 | /* Compute the next FROM here because copying below may | 1876 | /* Compute the next FROM here because copying below may |
| 1876 | overwrite data we need to compute it. */ | 1877 | overwrite data we need to compute it. */ |
| 1877 | EMACS_INT nbytes; | 1878 | ptrdiff_t nbytes; |
| 1878 | 1879 | ||
| 1879 | /* Check that the string size recorded in the string is the | 1880 | /* Check that the string size recorded in the string is the |
| 1880 | same as the one recorded in the sdata structure. */ | 1881 | same as the one recorded in the sdata structure. */ |
| @@ -2020,7 +2021,7 @@ allocate_string_data (struct Lisp_String *s, | |||
| 2020 | { | 2021 | { |
| 2021 | struct sdata *data, *old_data; | 2022 | struct sdata *data, *old_data; |
| 2022 | struct sblock *b; | 2023 | struct sblock *b; |
| 2023 | EMACS_INT needed, old_nbytes; | 2024 | ptrdiff_t needed, old_nbytes; |
| 2024 | 2025 | ||
| 2025 | if (STRING_BYTES_MAX < nbytes) | 2026 | if (STRING_BYTES_MAX < nbytes) |
| 2026 | string_overflow (); | 2027 | string_overflow (); |
| @@ -2265,7 +2266,7 @@ compact_small_strings (void) | |||
| 2265 | { | 2266 | { |
| 2266 | /* Compute the next FROM here because copying below may | 2267 | /* Compute the next FROM here because copying below may |
| 2267 | overwrite data we need to compute it. */ | 2268 | overwrite data we need to compute it. */ |
| 2268 | EMACS_INT nbytes; | 2269 | ptrdiff_t nbytes; |
| 2269 | 2270 | ||
| 2270 | #ifdef GC_CHECK_STRING_BYTES | 2271 | #ifdef GC_CHECK_STRING_BYTES |
| 2271 | /* Check that the string size recorded in the string is the | 2272 | /* Check that the string size recorded in the string is the |
| @@ -2395,7 +2396,8 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) | |||
| 2395 | { | 2396 | { |
| 2396 | register Lisp_Object val; | 2397 | register Lisp_Object val; |
| 2397 | struct Lisp_Bool_Vector *p; | 2398 | struct Lisp_Bool_Vector *p; |
| 2398 | EMACS_INT length_in_chars, length_in_elts; | 2399 | ptrdiff_t length_in_chars; |
| 2400 | EMACS_INT length_in_elts; | ||
| 2399 | int bits_per_value; | 2401 | int bits_per_value; |
| 2400 | 2402 | ||
| 2401 | CHECK_NATNUM (length); | 2403 | CHECK_NATNUM (length); |
| @@ -2403,8 +2405,6 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) | |||
| 2403 | bits_per_value = sizeof (EMACS_INT) * BOOL_VECTOR_BITS_PER_CHAR; | 2405 | bits_per_value = sizeof (EMACS_INT) * BOOL_VECTOR_BITS_PER_CHAR; |
| 2404 | 2406 | ||
| 2405 | length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value; | 2407 | length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value; |
| 2406 | length_in_chars = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1) | ||
| 2407 | / BOOL_VECTOR_BITS_PER_CHAR); | ||
| 2408 | 2408 | ||
| 2409 | /* We must allocate one more elements than LENGTH_IN_ELTS for the | 2409 | /* We must allocate one more elements than LENGTH_IN_ELTS for the |
| 2410 | slot `size' of the struct Lisp_Bool_Vector. */ | 2410 | slot `size' of the struct Lisp_Bool_Vector. */ |
| @@ -2416,6 +2416,8 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) | |||
| 2416 | p = XBOOL_VECTOR (val); | 2416 | p = XBOOL_VECTOR (val); |
| 2417 | p->size = XFASTINT (length); | 2417 | p->size = XFASTINT (length); |
| 2418 | 2418 | ||
| 2419 | length_in_chars = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1) | ||
| 2420 | / BOOL_VECTOR_BITS_PER_CHAR); | ||
| 2419 | if (length_in_chars) | 2421 | if (length_in_chars) |
| 2420 | { | 2422 | { |
| 2421 | memset (p->data, ! NILP (init) ? -1 : 0, length_in_chars); | 2423 | memset (p->data, ! NILP (init) ? -1 : 0, length_in_chars); |
| @@ -2434,10 +2436,10 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) | |||
| 2434 | multibyte, depending on the contents. */ | 2436 | multibyte, depending on the contents. */ |
| 2435 | 2437 | ||
| 2436 | Lisp_Object | 2438 | Lisp_Object |
| 2437 | make_string (const char *contents, EMACS_INT nbytes) | 2439 | make_string (const char *contents, ptrdiff_t nbytes) |
| 2438 | { | 2440 | { |
| 2439 | register Lisp_Object val; | 2441 | register Lisp_Object val; |
| 2440 | EMACS_INT nchars, multibyte_nbytes; | 2442 | ptrdiff_t nchars, multibyte_nbytes; |
| 2441 | 2443 | ||
| 2442 | parse_str_as_multibyte ((const unsigned char *) contents, nbytes, | 2444 | parse_str_as_multibyte ((const unsigned char *) contents, nbytes, |
| 2443 | &nchars, &multibyte_nbytes); | 2445 | &nchars, &multibyte_nbytes); |
| @@ -2454,7 +2456,7 @@ make_string (const char *contents, EMACS_INT nbytes) | |||
| 2454 | /* Make an unibyte string from LENGTH bytes at CONTENTS. */ | 2456 | /* Make an unibyte string from LENGTH bytes at CONTENTS. */ |
| 2455 | 2457 | ||
| 2456 | Lisp_Object | 2458 | Lisp_Object |
| 2457 | make_unibyte_string (const char *contents, EMACS_INT length) | 2459 | make_unibyte_string (const char *contents, ptrdiff_t length) |
| 2458 | { | 2460 | { |
| 2459 | register Lisp_Object val; | 2461 | register Lisp_Object val; |
| 2460 | val = make_uninit_string (length); | 2462 | val = make_uninit_string (length); |
| @@ -2468,7 +2470,7 @@ make_unibyte_string (const char *contents, EMACS_INT length) | |||
| 2468 | 2470 | ||
| 2469 | Lisp_Object | 2471 | Lisp_Object |
| 2470 | make_multibyte_string (const char *contents, | 2472 | make_multibyte_string (const char *contents, |
| 2471 | EMACS_INT nchars, EMACS_INT nbytes) | 2473 | ptrdiff_t nchars, ptrdiff_t nbytes) |
| 2472 | { | 2474 | { |
| 2473 | register Lisp_Object val; | 2475 | register Lisp_Object val; |
| 2474 | val = make_uninit_multibyte_string (nchars, nbytes); | 2476 | val = make_uninit_multibyte_string (nchars, nbytes); |
| @@ -2482,7 +2484,7 @@ make_multibyte_string (const char *contents, | |||
| 2482 | 2484 | ||
| 2483 | Lisp_Object | 2485 | Lisp_Object |
| 2484 | make_string_from_bytes (const char *contents, | 2486 | make_string_from_bytes (const char *contents, |
| 2485 | EMACS_INT nchars, EMACS_INT nbytes) | 2487 | ptrdiff_t nchars, ptrdiff_t nbytes) |
| 2486 | { | 2488 | { |
| 2487 | register Lisp_Object val; | 2489 | register Lisp_Object val; |
| 2488 | val = make_uninit_multibyte_string (nchars, nbytes); | 2490 | val = make_uninit_multibyte_string (nchars, nbytes); |
| @@ -2500,7 +2502,7 @@ make_string_from_bytes (const char *contents, | |||
| 2500 | 2502 | ||
| 2501 | Lisp_Object | 2503 | Lisp_Object |
| 2502 | make_specified_string (const char *contents, | 2504 | make_specified_string (const char *contents, |
| 2503 | EMACS_INT nchars, EMACS_INT nbytes, int multibyte) | 2505 | ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte) |
| 2504 | { | 2506 | { |
| 2505 | register Lisp_Object val; | 2507 | register Lisp_Object val; |
| 2506 | 2508 | ||
| @@ -2699,8 +2701,10 @@ make_float (double float_value) | |||
| 2699 | GC are put on a free list to be reallocated before allocating | 2701 | GC are put on a free list to be reallocated before allocating |
| 2700 | any new cons cells from the latest cons_block. */ | 2702 | any new cons cells from the latest cons_block. */ |
| 2701 | 2703 | ||
| 2702 | #define CONS_BLOCK_SIZE \ | 2704 | #define CONS_BLOCK_SIZE \ |
| 2703 | (((BLOCK_BYTES - sizeof (struct cons_block *)) * CHAR_BIT) \ | 2705 | (((BLOCK_BYTES - sizeof (struct cons_block *) \ |
| 2706 | /* The compiler might add padding at the end. */ \ | ||
| 2707 | - (sizeof (struct Lisp_Cons) - sizeof (int))) * CHAR_BIT) \ | ||
| 2704 | / (sizeof (struct Lisp_Cons) * CHAR_BIT + 1)) | 2708 | / (sizeof (struct Lisp_Cons) * CHAR_BIT + 1)) |
| 2705 | 2709 | ||
| 2706 | #define CONS_BLOCK(fptr) \ | 2710 | #define CONS_BLOCK(fptr) \ |
| @@ -2939,7 +2943,7 @@ enum | |||
| 2939 | with room for LEN Lisp_Objects. */ | 2943 | with room for LEN Lisp_Objects. */ |
| 2940 | 2944 | ||
| 2941 | static struct Lisp_Vector * | 2945 | static struct Lisp_Vector * |
| 2942 | allocate_vectorlike (EMACS_INT len) | 2946 | allocate_vectorlike (ptrdiff_t len) |
| 2943 | { | 2947 | { |
| 2944 | struct Lisp_Vector *p; | 2948 | struct Lisp_Vector *p; |
| 2945 | size_t nbytes; | 2949 | size_t nbytes; |
| @@ -2995,7 +2999,7 @@ allocate_vector (EMACS_INT len) | |||
| 2995 | /* Allocate other vector-like structures. */ | 2999 | /* Allocate other vector-like structures. */ |
| 2996 | 3000 | ||
| 2997 | struct Lisp_Vector * | 3001 | struct Lisp_Vector * |
| 2998 | allocate_pseudovector (int memlen, int lisplen, EMACS_INT tag) | 3002 | allocate_pseudovector (int memlen, int lisplen, int tag) |
| 2999 | { | 3003 | { |
| 3000 | struct Lisp_Vector *v = allocate_vectorlike (memlen); | 3004 | struct Lisp_Vector *v = allocate_vectorlike (memlen); |
| 3001 | int i; | 3005 | int i; |
| @@ -3059,14 +3063,14 @@ See also the function `vector'. */) | |||
| 3059 | (register Lisp_Object length, Lisp_Object init) | 3063 | (register Lisp_Object length, Lisp_Object init) |
| 3060 | { | 3064 | { |
| 3061 | Lisp_Object vector; | 3065 | Lisp_Object vector; |
| 3062 | register EMACS_INT sizei; | 3066 | register ptrdiff_t sizei; |
| 3063 | register EMACS_INT i; | 3067 | register ptrdiff_t i; |
| 3064 | register struct Lisp_Vector *p; | 3068 | register struct Lisp_Vector *p; |
| 3065 | 3069 | ||
| 3066 | CHECK_NATNUM (length); | 3070 | CHECK_NATNUM (length); |
| 3067 | sizei = XFASTINT (length); | ||
| 3068 | 3071 | ||
| 3069 | p = allocate_vector (sizei); | 3072 | p = allocate_vector (XFASTINT (length)); |
| 3073 | sizei = XFASTINT (length); | ||
| 3070 | for (i = 0; i < sizei; i++) | 3074 | for (i = 0; i < sizei; i++) |
| 3071 | p->contents[i] = init; | 3075 | p->contents[i] = init; |
| 3072 | 3076 | ||
| @@ -4297,8 +4301,8 @@ mark_maybe_pointer (void *p) | |||
| 4297 | wider than a pointer might allocate a Lisp_Object in non-adjacent halves. | 4301 | wider than a pointer might allocate a Lisp_Object in non-adjacent halves. |
| 4298 | If USE_LSB_TAG, the bottom half is not a valid pointer, but it should | 4302 | If USE_LSB_TAG, the bottom half is not a valid pointer, but it should |
| 4299 | suffice to widen it to to a Lisp_Object and check it that way. */ | 4303 | suffice to widen it to to a Lisp_Object and check it that way. */ |
| 4300 | #if defined USE_LSB_TAG || UINTPTR_MAX >> VALBITS != 0 | 4304 | #if defined USE_LSB_TAG || VAL_MAX < UINTPTR_MAX |
| 4301 | # if !defined USE_LSB_TAG && UINTPTR_MAX >> VALBITS >> GCTYPEBITS != 0 | 4305 | # if !defined USE_LSB_TAG && VAL_MAX < UINTPTR_MAX >> GCTYPEBITS |
| 4302 | /* If tag bits straddle pointer-word boundaries, neither mark_maybe_pointer | 4306 | /* If tag bits straddle pointer-word boundaries, neither mark_maybe_pointer |
| 4303 | nor mark_maybe_object can follow the pointers. This should not occur on | 4307 | nor mark_maybe_object can follow the pointers. This should not occur on |
| 4304 | any practical porting target. */ | 4308 | any practical porting target. */ |
| @@ -4722,10 +4726,10 @@ valid_lisp_object_p (Lisp_Object obj) | |||
| 4722 | pointer to it. TYPE is the Lisp type for which the memory is | 4726 | pointer to it. TYPE is the Lisp type for which the memory is |
| 4723 | allocated. TYPE < 0 means it's not used for a Lisp object. */ | 4727 | allocated. TYPE < 0 means it's not used for a Lisp object. */ |
| 4724 | 4728 | ||
| 4725 | static POINTER_TYPE * | 4729 | static void * |
| 4726 | pure_alloc (size_t size, int type) | 4730 | pure_alloc (size_t size, int type) |
| 4727 | { | 4731 | { |
| 4728 | POINTER_TYPE *result; | 4732 | void *result; |
| 4729 | #ifdef USE_LSB_TAG | 4733 | #ifdef USE_LSB_TAG |
| 4730 | size_t alignment = (1 << GCTYPEBITS); | 4734 | size_t alignment = (1 << GCTYPEBITS); |
| 4731 | #else | 4735 | #else |
| @@ -4791,14 +4795,14 @@ check_pure_size (void) | |||
| 4791 | address. Return NULL if not found. */ | 4795 | address. Return NULL if not found. */ |
| 4792 | 4796 | ||
| 4793 | static char * | 4797 | static char * |
| 4794 | find_string_data_in_pure (const char *data, EMACS_INT nbytes) | 4798 | find_string_data_in_pure (const char *data, ptrdiff_t nbytes) |
| 4795 | { | 4799 | { |
| 4796 | int i; | 4800 | int i; |
| 4797 | EMACS_INT skip, bm_skip[256], last_char_skip, infinity, start, start_max; | 4801 | ptrdiff_t skip, bm_skip[256], last_char_skip, infinity, start, start_max; |
| 4798 | const unsigned char *p; | 4802 | const unsigned char *p; |
| 4799 | char *non_lisp_beg; | 4803 | char *non_lisp_beg; |
| 4800 | 4804 | ||
| 4801 | if (pure_bytes_used_non_lisp < nbytes + 1) | 4805 | if (pure_bytes_used_non_lisp <= nbytes) |
| 4802 | return NULL; | 4806 | return NULL; |
| 4803 | 4807 | ||
| 4804 | /* Set up the Boyer-Moore table. */ | 4808 | /* Set up the Boyer-Moore table. */ |
| @@ -4862,7 +4866,7 @@ find_string_data_in_pure (const char *data, EMACS_INT nbytes) | |||
| 4862 | 4866 | ||
| 4863 | Lisp_Object | 4867 | Lisp_Object |
| 4864 | make_pure_string (const char *data, | 4868 | make_pure_string (const char *data, |
| 4865 | EMACS_INT nchars, EMACS_INT nbytes, int multibyte) | 4869 | ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte) |
| 4866 | { | 4870 | { |
| 4867 | Lisp_Object string; | 4871 | Lisp_Object string; |
| 4868 | struct Lisp_String *s; | 4872 | struct Lisp_String *s; |
| @@ -4890,7 +4894,7 @@ make_pure_c_string (const char *data) | |||
| 4890 | { | 4894 | { |
| 4891 | Lisp_Object string; | 4895 | Lisp_Object string; |
| 4892 | struct Lisp_String *s; | 4896 | struct Lisp_String *s; |
| 4893 | EMACS_INT nchars = strlen (data); | 4897 | ptrdiff_t nchars = strlen (data); |
| 4894 | 4898 | ||
| 4895 | s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); | 4899 | s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String); |
| 4896 | s->size = nchars; | 4900 | s->size = nchars; |
| @@ -4936,8 +4940,8 @@ make_pure_float (double num) | |||
| 4936 | /* Return a vector with room for LEN Lisp_Objects allocated from | 4940 | /* Return a vector with room for LEN Lisp_Objects allocated from |
| 4937 | pure space. */ | 4941 | pure space. */ |
| 4938 | 4942 | ||
| 4939 | Lisp_Object | 4943 | static Lisp_Object |
| 4940 | make_pure_vector (EMACS_INT len) | 4944 | make_pure_vector (ptrdiff_t len) |
| 4941 | { | 4945 | { |
| 4942 | Lisp_Object new; | 4946 | Lisp_Object new; |
| 4943 | struct Lisp_Vector *p; | 4947 | struct Lisp_Vector *p; |
| @@ -4981,8 +4985,8 @@ Does not copy symbols. Copies strings without text properties. */) | |||
| 4981 | else if (COMPILEDP (obj) || VECTORP (obj)) | 4985 | else if (COMPILEDP (obj) || VECTORP (obj)) |
| 4982 | { | 4986 | { |
| 4983 | register struct Lisp_Vector *vec; | 4987 | register struct Lisp_Vector *vec; |
| 4984 | register EMACS_INT i; | 4988 | register ptrdiff_t i; |
| 4985 | EMACS_INT size; | 4989 | ptrdiff_t size; |
| 4986 | 4990 | ||
| 4987 | size = ASIZE (obj); | 4991 | size = ASIZE (obj); |
| 4988 | if (size & PSEUDOVECTOR_FLAG) | 4992 | if (size & PSEUDOVECTOR_FLAG) |
| @@ -5034,10 +5038,10 @@ staticpro (Lisp_Object *varaddress) | |||
| 5034 | 5038 | ||
| 5035 | /* Temporarily prevent garbage collection. */ | 5039 | /* Temporarily prevent garbage collection. */ |
| 5036 | 5040 | ||
| 5037 | int | 5041 | ptrdiff_t |
| 5038 | inhibit_garbage_collection (void) | 5042 | inhibit_garbage_collection (void) |
| 5039 | { | 5043 | { |
| 5040 | int count = SPECPDL_INDEX (); | 5044 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5041 | 5045 | ||
| 5042 | specbind (Qgc_cons_threshold, make_number (MOST_POSITIVE_FIXNUM)); | 5046 | specbind (Qgc_cons_threshold, make_number (MOST_POSITIVE_FIXNUM)); |
| 5043 | return count; | 5047 | return count; |
| @@ -5063,7 +5067,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5063 | ptrdiff_t i; | 5067 | ptrdiff_t i; |
| 5064 | int message_p; | 5068 | int message_p; |
| 5065 | Lisp_Object total[8]; | 5069 | Lisp_Object total[8]; |
| 5066 | int count = SPECPDL_INDEX (); | 5070 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5067 | EMACS_TIME t1, t2, t3; | 5071 | EMACS_TIME t1, t2, t3; |
| 5068 | 5072 | ||
| 5069 | if (abort_on_gc) | 5073 | if (abort_on_gc) |
| @@ -5358,7 +5362,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5358 | 5362 | ||
| 5359 | if (!NILP (Vpost_gc_hook)) | 5363 | if (!NILP (Vpost_gc_hook)) |
| 5360 | { | 5364 | { |
| 5361 | int gc_count = inhibit_garbage_collection (); | 5365 | ptrdiff_t gc_count = inhibit_garbage_collection (); |
| 5362 | safe_run_hooks (Qpost_gc_hook); | 5366 | safe_run_hooks (Qpost_gc_hook); |
| 5363 | unbind_to (gc_count, Qnil); | 5367 | unbind_to (gc_count, Qnil); |
| 5364 | } | 5368 | } |
| @@ -5443,8 +5447,8 @@ ptrdiff_t mark_object_loop_halt EXTERNALLY_VISIBLE; | |||
| 5443 | static void | 5447 | static void |
| 5444 | mark_vectorlike (struct Lisp_Vector *ptr) | 5448 | mark_vectorlike (struct Lisp_Vector *ptr) |
| 5445 | { | 5449 | { |
| 5446 | EMACS_INT size = ptr->header.size; | 5450 | ptrdiff_t size = ptr->header.size; |
| 5447 | EMACS_INT i; | 5451 | ptrdiff_t i; |
| 5448 | 5452 | ||
| 5449 | eassert (!VECTOR_MARKED_P (ptr)); | 5453 | eassert (!VECTOR_MARKED_P (ptr)); |
| 5450 | VECTOR_MARK (ptr); /* Else mark it */ | 5454 | VECTOR_MARK (ptr); /* Else mark it */ |
| @@ -6325,7 +6329,7 @@ Lisp_Object | |||
| 6325 | which_symbols (Lisp_Object obj, EMACS_INT find_max) | 6329 | which_symbols (Lisp_Object obj, EMACS_INT find_max) |
| 6326 | { | 6330 | { |
| 6327 | struct symbol_block *sblk; | 6331 | struct symbol_block *sblk; |
| 6328 | int gc_count = inhibit_garbage_collection (); | 6332 | ptrdiff_t gc_count = inhibit_garbage_collection (); |
| 6329 | Lisp_Object found = Qnil; | 6333 | Lisp_Object found = Qnil; |
| 6330 | 6334 | ||
| 6331 | if (! DEADP (obj)) | 6335 | if (! DEADP (obj)) |