[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r110868: Another tweak to vectorlike_
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r110868: Another tweak to vectorlike_header change. |
Date: |
Sun, 11 Nov 2012 17:09:34 -0800 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 110868
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Sun 2012-11-11 17:09:34 -0800
message:
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.
modified:
src/ChangeLog
src/alloc.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-11-11 18:39:29 +0000
+++ b/src/ChangeLog 2012-11-12 01:09:34 +0000
@@ -1,3 +1,11 @@
+2012-11-12 Paul Eggert <address@hidden>
+
+ 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.
+
2012-11-11 Paul Eggert <address@hidden>
* window.c (list4i): Rename from 'quad'. All uses changed.
=== modified file 'src/alloc.c'
--- a/src/alloc.c 2012-11-09 11:38:31 +0000
+++ b/src/alloc.c 2012-11-12 01:09:34 +0000
@@ -2611,18 +2611,21 @@
#define VINDEX(nbytes) (((nbytes) - VBLOCK_BYTES_MIN) / roundup_size)
-/* This special type is used to represent any block-allocated vectorlike
- object on the free list. */
-
-struct Lisp_Vectorlike_Free
-{
- struct vectorlike_header header;
- struct Lisp_Vector *next;
-};
-
-/* When V is on the free list, it's always treated as Lisp_Vectorlike_Free. */
-
-#define NEXT_IN_FREE_LIST(v) ((struct Lisp_Vectorlike_Free *) v)->next
+/* Get and set the next field in block-allocated vectorlike objects on
+ the free list. Doing it this way respects C's aliasing rules.
+ We could instead make 'contents' a union, but that would mean
+ changes everywhere that the code uses 'contents'. */
+static struct Lisp_Vector *
+next_in_free_list (struct Lisp_Vector *v)
+{
+ intptr_t i = XLI (v->contents[0]);
+ return (struct Lisp_Vector *) i;
+}
+static void
+set_next_in_free_list (struct Lisp_Vector *v, struct Lisp_Vector *next)
+{
+ v->contents[0] = XIL ((intptr_t) next);
+}
/* Common shortcut to setup vector on a free list. */
@@ -2633,7 +2636,7 @@
eassert ((nbytes) % roundup_size == 0); \
(tmp) = VINDEX (nbytes); \
eassert ((tmp) < VECTOR_MAX_FREE_LIST_INDEX); \
- NEXT_IN_FREE_LIST (v) = vector_free_lists[tmp]; \
+ set_next_in_free_list (v, vector_free_lists[tmp]); \
vector_free_lists[tmp] = (v); \
total_free_vector_slots += (nbytes) / word_size; \
} while (0)
@@ -2730,7 +2733,7 @@
if (vector_free_lists[index])
{
vector = vector_free_lists[index];
- vector_free_lists[index] = NEXT_IN_FREE_LIST (vector);
+ vector_free_lists[index] = next_in_free_list (vector);
total_free_vector_slots -= nbytes / word_size;
return vector;
}
@@ -2744,7 +2747,7 @@
{
/* This vector is larger than requested. */
vector = vector_free_lists[index];
- vector_free_lists[index] = NEXT_IN_FREE_LIST (vector);
+ vector_free_lists[index] = next_in_free_list (vector);
total_free_vector_slots -= nbytes / word_size;
/* Excess bytes are used for the smaller vector,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r110868: Another tweak to vectorlike_header change.,
Paul Eggert <=