aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Antipov2012-11-09 15:38:31 +0400
committerDmitry Antipov2012-11-09 15:38:31 +0400
commit7d377c482f6e60464c9891ee64cf6bcdf770a707 (patch)
treecbc3bd3c5569c9e5a5857f0ef151e98b94e9a36a
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.
-rw-r--r--src/.gdbinit36
-rw-r--r--src/ChangeLog11
-rw-r--r--src/alloc.c16
3 files changed, 46 insertions, 17 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index f187bafcba7..fa580cc99bf 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -650,9 +650,8 @@ If the first type printed is Lisp_Vector or Lisp_Misc,
650a second line gives the more precise type. 650a second line gives the more precise type.
651end 651end
652 652
653define xvectype 653define pvectype
654 xgetptr $ 654 set $size = ((struct Lisp_Vector *) $arg0)->header.size
655 set $size = ((struct Lisp_Vector *) $ptr)->header.size
656 if ($size & PSEUDOVECTOR_FLAG) 655 if ($size & PSEUDOVECTOR_FLAG)
657 output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS) 656 output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS)
658 else 657 else
@@ -660,14 +659,22 @@ define xvectype
660 end 659 end
661 echo \n 660 echo \n
662end 661end
663document xvectype 662document pvectype
664Print the type or vector subtype of $. 663Print the subtype of vectorlike object.
665This command assumes that $ is a vector or pseudovector. 664Takes one argument, a pointer to an object.
666end 665end
667 666
668define xvecsize 667define xvectype
669 xgetptr $ 668 xgetptr $
670 set $size = ((struct Lisp_Vector *) $ptr)->header.size 669 pvectype $ptr
670end
671document xvectype
672Print the subtype of vectorlike object.
673This command assumes that $ is a Lisp_Object.
674end
675
676define pvecsize
677 set $size = ((struct Lisp_Vector *) $arg0)->header.size
671 if ($size & PSEUDOVECTOR_FLAG) 678 if ($size & PSEUDOVECTOR_FLAG)
672 output ($size & PSEUDOVECTOR_SIZE_MASK) 679 output ($size & PSEUDOVECTOR_SIZE_MASK)
673 echo \n 680 echo \n
@@ -677,9 +684,18 @@ define xvecsize
677 end 684 end
678 echo \n 685 echo \n
679end 686end
687document pvecsize
688Print the size of vectorlike object.
689Takes one argument, a pointer to an object.
690end
691
692define xvecsize
693 xgetptr $
694 pvecsize $ptr
695end
680document xvecsize 696document xvecsize
681Print the size or vector subtype of $. 697Print the size of $
682This command assumes that $ is a vector or pseudovector. 698This command assumes that $ is a Lisp_Object.
683end 699end
684 700
685define xmisctype 701define xmisctype
diff --git a/src/ChangeLog b/src/ChangeLog
index 6cf10f0fa30..752dd4313f8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12012-11-09 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Tweak last vectorlike_header change.
4 * alloc.c (struct Lisp_Vectorlike_Free): Special type to represent
5 vectorlike object on the free list. This is introduced to avoid
6 some (but not all) pointer casting and aliasing problems, see
7 http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00105.html.
8 * .gdbinit (pvectype, pvecsize): New commands to examine vectorlike
9 objects.
10 (xvectype, xvecsize): Use them to examine Lisp_Object values.
11
12012-11-09 Jan Djärv <jan.h.d@swipnet.se> 122012-11-09 Jan Djärv <jan.h.d@swipnet.se>
2 13
3 * nsfont.m (ns_descriptor_to_entity): Qcondesed and Qexpanded has 14 * nsfont.m (ns_descriptor_to_entity): Qcondesed and Qexpanded has
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