aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2012-11-11 17:09:34 -0800
committerPaul Eggert2012-11-11 17:09:34 -0800
commit76ae24d77f44a5021171960044b8403710251027 (patch)
treefcd9bde8ed3845bb00fb173c0b711641797819cb /src/alloc.c
parent1479c557b7a9abb6eea3b2881adae471fedeec4d (diff)
downloademacs-76ae24d77f44a5021171960044b8403710251027.tar.gz
emacs-76ae24d77f44a5021171960044b8403710251027.zip
Another tweak to vectorlike_header change.
* alloc.c (struct Lisp_Vectorlike_Free, NEXT_IN_FREE_LIST): Remove, and replace all uses with ... (next_in_free_list, set_next_in_free_list): New functions, which respect C's aliasing rules better.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 0a3d469d09b..a66a752f5dc 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2611,18 +2611,21 @@ verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS));
2611 2611
2612#define VINDEX(nbytes) (((nbytes) - VBLOCK_BYTES_MIN) / roundup_size) 2612#define VINDEX(nbytes) (((nbytes) - VBLOCK_BYTES_MIN) / roundup_size)
2613 2613
2614/* This special type is used to represent any block-allocated vectorlike 2614/* Get and set the next field in block-allocated vectorlike objects on
2615 object on the free list. */ 2615 the free list. Doing it this way respects C's aliasing rules.
2616 2616 We could instead make 'contents' a union, but that would mean
2617struct Lisp_Vectorlike_Free 2617 changes everywhere that the code uses 'contents'. */
2618static struct Lisp_Vector *
2619next_in_free_list (struct Lisp_Vector *v)
2618{ 2620{
2619 struct vectorlike_header header; 2621 intptr_t i = XLI (v->contents[0]);
2620 struct Lisp_Vector *next; 2622 return (struct Lisp_Vector *) i;
2621}; 2623}
2622 2624static void
2623/* When V is on the free list, it's always treated as Lisp_Vectorlike_Free. */ 2625set_next_in_free_list (struct Lisp_Vector *v, struct Lisp_Vector *next)
2624 2626{
2625#define NEXT_IN_FREE_LIST(v) ((struct Lisp_Vectorlike_Free *) v)->next 2627 v->contents[0] = XIL ((intptr_t) next);
2628}
2626 2629
2627/* Common shortcut to setup vector on a free list. */ 2630/* Common shortcut to setup vector on a free list. */
2628 2631
@@ -2633,7 +2636,7 @@ struct Lisp_Vectorlike_Free
2633 eassert ((nbytes) % roundup_size == 0); \ 2636 eassert ((nbytes) % roundup_size == 0); \
2634 (tmp) = VINDEX (nbytes); \ 2637 (tmp) = VINDEX (nbytes); \
2635 eassert ((tmp) < VECTOR_MAX_FREE_LIST_INDEX); \ 2638 eassert ((tmp) < VECTOR_MAX_FREE_LIST_INDEX); \
2636 NEXT_IN_FREE_LIST (v) = vector_free_lists[tmp]; \ 2639 set_next_in_free_list (v, vector_free_lists[tmp]); \
2637 vector_free_lists[tmp] = (v); \ 2640 vector_free_lists[tmp] = (v); \
2638 total_free_vector_slots += (nbytes) / word_size; \ 2641 total_free_vector_slots += (nbytes) / word_size; \
2639 } while (0) 2642 } while (0)
@@ -2730,7 +2733,7 @@ allocate_vector_from_block (size_t nbytes)
2730 if (vector_free_lists[index]) 2733 if (vector_free_lists[index])
2731 { 2734 {
2732 vector = vector_free_lists[index]; 2735 vector = vector_free_lists[index];
2733 vector_free_lists[index] = NEXT_IN_FREE_LIST (vector); 2736 vector_free_lists[index] = next_in_free_list (vector);
2734 total_free_vector_slots -= nbytes / word_size; 2737 total_free_vector_slots -= nbytes / word_size;
2735 return vector; 2738 return vector;
2736 } 2739 }
@@ -2744,7 +2747,7 @@ allocate_vector_from_block (size_t nbytes)
2744 { 2747 {
2745 /* This vector is larger than requested. */ 2748 /* This vector is larger than requested. */
2746 vector = vector_free_lists[index]; 2749 vector = vector_free_lists[index];
2747 vector_free_lists[index] = NEXT_IN_FREE_LIST (vector); 2750 vector_free_lists[index] = next_in_free_list (vector);
2748 total_free_vector_slots -= nbytes / word_size; 2751 total_free_vector_slots -= nbytes / word_size;
2749 2752
2750 /* Excess bytes are used for the smaller vector, 2753 /* Excess bytes are used for the smaller vector,