aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov2012-11-09 15:38:31 +0400
committerDmitry Antipov2012-11-09 15:38:31 +0400
commit7d377c482f6e60464c9891ee64cf6bcdf770a707 (patch)
treecbc3bd3c5569c9e5a5857f0ef151e98b94e9a36a /src/alloc.c
parent7ad27466f1bd9a61389b8b8b83db21ff2acfc575 (diff)
downloademacs-7d377c482f6e60464c9891ee64cf6bcdf770a707.tar.gz
emacs-7d377c482f6e60464c9891ee64cf6bcdf770a707.zip
Tweak last vectorlike_header change.
* alloc.c (struct Lisp_Vectorlike_Free): Special type to represent vectorlike object on the free list. This is introduced to avoid some (but not all) pointer casting and aliasing problems, see http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00105.html. * .gdbinit (pvectype, pvecsize): New commands to examine vectorlike objects. (xvectype, xvecsize): Use them to examine Lisp_Object values.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 808557dd70f..0a3d469d09b 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2611,16 +2611,18 @@ 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/* When V is on the free list, first word after header is used as a pointer 2614/* This special type is used to represent any block-allocated vectorlike
2615 to next vector on the free list. It might be done in a better way with: 2615 object on the free list. */
2616 2616
2617 (*(struct Lisp_Vector **)&(v->contents[0])) 2617struct Lisp_Vectorlike_Free
2618{
2619 struct vectorlike_header header;
2620 struct Lisp_Vector *next;
2621};
2618 2622
2619 but this breaks GCC's strict-aliasing rules (which looks more relaxed 2623/* When V is on the free list, it's always treated as Lisp_Vectorlike_Free. */
2620 for char and void pointers). */
2621 2624
2622#define NEXT_IN_FREE_LIST(v) \ 2625#define NEXT_IN_FREE_LIST(v) ((struct Lisp_Vectorlike_Free *) v)->next
2623 (*(struct Lisp_Vector **)((char *) v + header_size))
2624 2626
2625/* Common shortcut to setup vector on a free list. */ 2627/* Common shortcut to setup vector on a free list. */
2626 2628