diff options
| author | Dmitry Antipov | 2012-11-09 15:38:31 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-11-09 15:38:31 +0400 |
| commit | 7d377c482f6e60464c9891ee64cf6bcdf770a707 (patch) | |
| tree | cbc3bd3c5569c9e5a5857f0ef151e98b94e9a36a /src | |
| parent | 7ad27466f1bd9a61389b8b8b83db21ff2acfc575 (diff) | |
| download | emacs-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')
| -rw-r--r-- | src/.gdbinit | 36 | ||||
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/alloc.c | 16 |
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, | |||
| 650 | a second line gives the more precise type. | 650 | a second line gives the more precise type. |
| 651 | end | 651 | end |
| 652 | 652 | ||
| 653 | define xvectype | 653 | define 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 |
| 662 | end | 661 | end |
| 663 | document xvectype | 662 | document pvectype |
| 664 | Print the type or vector subtype of $. | 663 | Print the subtype of vectorlike object. |
| 665 | This command assumes that $ is a vector or pseudovector. | 664 | Takes one argument, a pointer to an object. |
| 666 | end | 665 | end |
| 667 | 666 | ||
| 668 | define xvecsize | 667 | define xvectype |
| 669 | xgetptr $ | 668 | xgetptr $ |
| 670 | set $size = ((struct Lisp_Vector *) $ptr)->header.size | 669 | pvectype $ptr |
| 670 | end | ||
| 671 | document xvectype | ||
| 672 | Print the subtype of vectorlike object. | ||
| 673 | This command assumes that $ is a Lisp_Object. | ||
| 674 | end | ||
| 675 | |||
| 676 | define 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 |
| 679 | end | 686 | end |
| 687 | document pvecsize | ||
| 688 | Print the size of vectorlike object. | ||
| 689 | Takes one argument, a pointer to an object. | ||
| 690 | end | ||
| 691 | |||
| 692 | define xvecsize | ||
| 693 | xgetptr $ | ||
| 694 | pvecsize $ptr | ||
| 695 | end | ||
| 680 | document xvecsize | 696 | document xvecsize |
| 681 | Print the size or vector subtype of $. | 697 | Print the size of $ |
| 682 | This command assumes that $ is a vector or pseudovector. | 698 | This command assumes that $ is a Lisp_Object. |
| 683 | end | 699 | end |
| 684 | 700 | ||
| 685 | define xmisctype | 701 | define xmisctype |
diff --git a/src/ChangeLog b/src/ChangeLog index 6cf10f0fa30..752dd4313f8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2012-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 | |||
| 1 | 2012-11-09 Jan Djärv <jan.h.d@swipnet.se> | 12 | 2012-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])) | 2617 | struct 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 | ||