Change vectorlike from struct to union
* src/lisp.h (vectorlike_headed): Change from struct to union. All uses changed. Since it has only one member, this does not change semantics. This is designed to simplify future changes needed to fix bugs like Bug#29040. All uses changed.
This commit is contained in:
parent
6aa0a26b46
commit
5d68dc9a2f
13 changed files with 35 additions and 35 deletions
|
@ -248,7 +248,7 @@ of 8k bytes, and small vectors are packed into blocks of 4k bytes).
|
||||||
@cindex storage of vector-like Lisp objects
|
@cindex storage of vector-like Lisp objects
|
||||||
Beyond the basic vector, a lot of objects like window, buffer, and
|
Beyond the basic vector, a lot of objects like window, buffer, and
|
||||||
frame are managed as if they were vectors. The corresponding C data
|
frame are managed as if they were vectors. The corresponding C data
|
||||||
structures include the @code{struct vectorlike_header} field whose
|
structures include the @code{union vectorlike_header} field whose
|
||||||
@code{size} member contains the subtype enumerated by @code{enum pvec_type}
|
@code{size} member contains the subtype enumerated by @code{enum pvec_type}
|
||||||
and an information about how many @code{Lisp_Object} fields this structure
|
and an information about how many @code{Lisp_Object} fields this structure
|
||||||
contains and what the size of the rest data is. This information is
|
contains and what the size of the rest data is. This information is
|
||||||
|
@ -1085,7 +1085,7 @@ Some of the fields of @code{struct buffer} are:
|
||||||
|
|
||||||
@table @code
|
@table @code
|
||||||
@item header
|
@item header
|
||||||
A header of type @code{struct vectorlike_header} is common to all
|
A header of type @code{union vectorlike_header} is common to all
|
||||||
vectorlike objects.
|
vectorlike objects.
|
||||||
|
|
||||||
@item own_text
|
@item own_text
|
||||||
|
|
|
@ -504,7 +504,7 @@ struct buffer_text
|
||||||
|
|
||||||
struct buffer
|
struct buffer
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* The name of this buffer. */
|
/* The name of this buffer. */
|
||||||
Lisp_Object name_;
|
Lisp_Object name_;
|
||||||
|
|
|
@ -244,7 +244,7 @@ enum font_property_index
|
||||||
|
|
||||||
struct font_spec
|
struct font_spec
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
Lisp_Object props[FONT_SPEC_MAX];
|
Lisp_Object props[FONT_SPEC_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ struct font_spec
|
||||||
|
|
||||||
struct font_entity
|
struct font_entity
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
Lisp_Object props[FONT_ENTITY_MAX];
|
Lisp_Object props[FONT_ENTITY_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ struct font_entity
|
||||||
|
|
||||||
struct font
|
struct font
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* All Lisp_Object components must come first.
|
/* All Lisp_Object components must come first.
|
||||||
That ensures they are all aligned normally. */
|
That ensures they are all aligned normally. */
|
||||||
|
|
|
@ -79,7 +79,7 @@ enum ns_appearance_type
|
||||||
|
|
||||||
struct frame
|
struct frame
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* All Lisp_Object components must come first.
|
/* All Lisp_Object components must come first.
|
||||||
That ensures they are all aligned normally. */
|
That ensures they are all aligned normally. */
|
||||||
|
|
28
src/lisp.h
28
src/lisp.h
|
@ -796,11 +796,11 @@ struct Lisp_Symbol
|
||||||
/* Header of vector-like objects. This documents the layout constraints on
|
/* Header of vector-like objects. This documents the layout constraints on
|
||||||
vectors and pseudovectors (objects of PVEC_xxx subtype). It also prevents
|
vectors and pseudovectors (objects of PVEC_xxx subtype). It also prevents
|
||||||
compilers from being fooled by Emacs's type punning: XSETPSEUDOVECTOR
|
compilers from being fooled by Emacs's type punning: XSETPSEUDOVECTOR
|
||||||
and PSEUDOVECTORP cast their pointers to struct vectorlike_header *,
|
and PSEUDOVECTORP cast their pointers to union vectorlike_header *,
|
||||||
because when two such pointers potentially alias, a compiler won't
|
because when two such pointers potentially alias, a compiler won't
|
||||||
incorrectly reorder loads and stores to their size fields. See
|
incorrectly reorder loads and stores to their size fields. See
|
||||||
Bug#8546. */
|
Bug#8546. */
|
||||||
struct vectorlike_header
|
union vectorlike_header
|
||||||
{
|
{
|
||||||
/* The only field contains various pieces of information:
|
/* The only field contains various pieces of information:
|
||||||
- The MSB (ARRAY_MARK_FLAG) holds the gcmarkbit.
|
- The MSB (ARRAY_MARK_FLAG) holds the gcmarkbit.
|
||||||
|
@ -1094,10 +1094,10 @@ INLINE bool
|
||||||
| ((restsize) << PSEUDOVECTOR_SIZE_BITS) \
|
| ((restsize) << PSEUDOVECTOR_SIZE_BITS) \
|
||||||
| (lispsize)))
|
| (lispsize)))
|
||||||
|
|
||||||
/* The cast to struct vectorlike_header * avoids aliasing issues. */
|
/* The cast to union vectorlike_header * avoids aliasing issues. */
|
||||||
#define XSETPSEUDOVECTOR(a, b, code) \
|
#define XSETPSEUDOVECTOR(a, b, code) \
|
||||||
XSETTYPED_PSEUDOVECTOR (a, b, \
|
XSETTYPED_PSEUDOVECTOR (a, b, \
|
||||||
(((struct vectorlike_header *) \
|
(((union vectorlike_header *) \
|
||||||
XUNTAG (a, Lisp_Vectorlike)) \
|
XUNTAG (a, Lisp_Vectorlike)) \
|
||||||
->size), \
|
->size), \
|
||||||
code)
|
code)
|
||||||
|
@ -1399,7 +1399,7 @@ STRING_SET_CHARS (Lisp_Object string, ptrdiff_t newsize)
|
||||||
|
|
||||||
struct Lisp_Vector
|
struct Lisp_Vector
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
Lisp_Object contents[FLEXIBLE_ARRAY_MEMBER];
|
Lisp_Object contents[FLEXIBLE_ARRAY_MEMBER];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1456,7 +1456,7 @@ PSEUDOVECTOR_TYPE (struct Lisp_Vector *v)
|
||||||
|
|
||||||
/* Can't be used with PVEC_NORMAL_VECTOR. */
|
/* Can't be used with PVEC_NORMAL_VECTOR. */
|
||||||
INLINE bool
|
INLINE bool
|
||||||
PSEUDOVECTOR_TYPEP (struct vectorlike_header *a, enum pvec_type code)
|
PSEUDOVECTOR_TYPEP (union vectorlike_header *a, enum pvec_type code)
|
||||||
{
|
{
|
||||||
/* We don't use PSEUDOVECTOR_TYPE here so as to avoid a shift
|
/* We don't use PSEUDOVECTOR_TYPE here so as to avoid a shift
|
||||||
* operation when `code' is known. */
|
* operation when `code' is known. */
|
||||||
|
@ -1472,8 +1472,8 @@ PSEUDOVECTORP (Lisp_Object a, int code)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Converting to struct vectorlike_header * avoids aliasing issues. */
|
/* Converting to union vectorlike_header * avoids aliasing issues. */
|
||||||
struct vectorlike_header *h = XUNTAG (a, Lisp_Vectorlike);
|
union vectorlike_header *h = XUNTAG (a, Lisp_Vectorlike);
|
||||||
return PSEUDOVECTOR_TYPEP (h, code);
|
return PSEUDOVECTOR_TYPEP (h, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1484,7 +1484,7 @@ struct Lisp_Bool_Vector
|
||||||
{
|
{
|
||||||
/* HEADER.SIZE is the vector's size field. It doesn't have the real size,
|
/* HEADER.SIZE is the vector's size field. It doesn't have the real size,
|
||||||
just the subtype information. */
|
just the subtype information. */
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
/* This is the size in bits. */
|
/* This is the size in bits. */
|
||||||
EMACS_INT size;
|
EMACS_INT size;
|
||||||
/* The actual bits, packed into bytes.
|
/* The actual bits, packed into bytes.
|
||||||
|
@ -1697,7 +1697,7 @@ struct Lisp_Char_Table
|
||||||
pseudovector type information. It holds the size, too.
|
pseudovector type information. It holds the size, too.
|
||||||
The size counts the defalt, parent, purpose, ascii,
|
The size counts the defalt, parent, purpose, ascii,
|
||||||
contents, and extras slots. */
|
contents, and extras slots. */
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* This holds a default value,
|
/* This holds a default value,
|
||||||
which is used whenever the value for a specific character is nil. */
|
which is used whenever the value for a specific character is nil. */
|
||||||
|
@ -1739,7 +1739,7 @@ struct Lisp_Sub_Char_Table
|
||||||
{
|
{
|
||||||
/* HEADER.SIZE is the vector's size field, which also holds the
|
/* HEADER.SIZE is the vector's size field, which also holds the
|
||||||
pseudovector type information. It holds the size, too. */
|
pseudovector type information. It holds the size, too. */
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* Depth of this sub char-table. It should be 1, 2, or 3. A sub
|
/* Depth of this sub char-table. It should be 1, 2, or 3. A sub
|
||||||
char-table of depth 1 contains 16 elements, and each element
|
char-table of depth 1 contains 16 elements, and each element
|
||||||
|
@ -1814,7 +1814,7 @@ CHAR_TABLE_SET (Lisp_Object ct, int idx, Lisp_Object val)
|
||||||
|
|
||||||
struct Lisp_Subr
|
struct Lisp_Subr
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
union {
|
union {
|
||||||
Lisp_Object (*a0) (void);
|
Lisp_Object (*a0) (void);
|
||||||
Lisp_Object (*a1) (Lisp_Object);
|
Lisp_Object (*a1) (Lisp_Object);
|
||||||
|
@ -2026,7 +2026,7 @@ struct hash_table_test
|
||||||
struct Lisp_Hash_Table
|
struct Lisp_Hash_Table
|
||||||
{
|
{
|
||||||
/* This is for Lisp; the hash table code does not refer to it. */
|
/* This is for Lisp; the hash table code does not refer to it. */
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* Nil if table is non-weak. Otherwise a symbol describing the
|
/* Nil if table is non-weak. Otherwise a symbol describing the
|
||||||
weakness of the table. */
|
weakness of the table. */
|
||||||
|
@ -3929,7 +3929,7 @@ typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t,
|
||||||
|
|
||||||
struct Lisp_Module_Function
|
struct Lisp_Module_Function
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* Fields traced by GC; these must come first. */
|
/* Fields traced by GC; these must come first. */
|
||||||
Lisp_Object documentation;
|
Lisp_Object documentation;
|
||||||
|
|
|
@ -41,7 +41,7 @@ enum { PROCESS_OPEN_FDS = 6 };
|
||||||
|
|
||||||
struct Lisp_Process
|
struct Lisp_Process
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* Name of subprocess terminal. */
|
/* Name of subprocess terminal. */
|
||||||
Lisp_Object tty_name;
|
Lisp_Object tty_name;
|
||||||
|
|
|
@ -373,7 +373,7 @@ extern struct tty_display_info *gpm_tty;
|
||||||
struct terminal
|
struct terminal
|
||||||
{
|
{
|
||||||
/* This is for Lisp; the terminal code does not refer to it. */
|
/* This is for Lisp; the terminal code does not refer to it. */
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* Parameter alist of this terminal. */
|
/* Parameter alist of this terminal. */
|
||||||
Lisp_Object param_alist;
|
Lisp_Object param_alist;
|
||||||
|
|
|
@ -35,7 +35,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
struct thread_state
|
struct thread_state
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* The buffer in which the last search was performed, or
|
/* The buffer in which the last search was performed, or
|
||||||
Qt if the last search was done in a string;
|
Qt if the last search was done in a string;
|
||||||
|
@ -230,7 +230,7 @@ typedef struct
|
||||||
/* A mutex as a lisp object. */
|
/* A mutex as a lisp object. */
|
||||||
struct Lisp_Mutex
|
struct Lisp_Mutex
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* The name of the mutex, or nil. */
|
/* The name of the mutex, or nil. */
|
||||||
Lisp_Object name;
|
Lisp_Object name;
|
||||||
|
@ -261,7 +261,7 @@ XMUTEX (Lisp_Object a)
|
||||||
/* A condition variable as a lisp object. */
|
/* A condition variable as a lisp object. */
|
||||||
struct Lisp_CondVar
|
struct Lisp_CondVar
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* The associated mutex. */
|
/* The associated mutex. */
|
||||||
Lisp_Object mutex;
|
Lisp_Object mutex;
|
||||||
|
|
|
@ -431,7 +431,7 @@ extern struct w32_output w32term_display;
|
||||||
struct scroll_bar {
|
struct scroll_bar {
|
||||||
|
|
||||||
/* This field is shared by all vectors. */
|
/* This field is shared by all vectors. */
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* The window we're a scroll bar for. */
|
/* The window we're a scroll bar for. */
|
||||||
Lisp_Object window;
|
Lisp_Object window;
|
||||||
|
|
|
@ -3733,8 +3733,8 @@ make_parent_window (Lisp_Object window, bool horflag)
|
||||||
|
|
||||||
o = XWINDOW (window);
|
o = XWINDOW (window);
|
||||||
p = allocate_window ();
|
p = allocate_window ();
|
||||||
memcpy ((char *) p + sizeof (struct vectorlike_header),
|
memcpy ((char *) p + sizeof (union vectorlike_header),
|
||||||
(char *) o + sizeof (struct vectorlike_header),
|
(char *) o + sizeof (union vectorlike_header),
|
||||||
word_size * VECSIZE (struct window));
|
word_size * VECSIZE (struct window));
|
||||||
/* P's buffer slot may change from nil to a buffer... */
|
/* P's buffer slot may change from nil to a buffer... */
|
||||||
adjust_window_count (p, 1);
|
adjust_window_count (p, 1);
|
||||||
|
@ -6232,7 +6232,7 @@ from the top of the window. */)
|
||||||
|
|
||||||
struct save_window_data
|
struct save_window_data
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
Lisp_Object selected_frame;
|
Lisp_Object selected_frame;
|
||||||
Lisp_Object current_window;
|
Lisp_Object current_window;
|
||||||
Lisp_Object f_current_buffer;
|
Lisp_Object f_current_buffer;
|
||||||
|
@ -6260,7 +6260,7 @@ struct save_window_data
|
||||||
/* This is saved as a Lisp_Vector. */
|
/* This is saved as a Lisp_Vector. */
|
||||||
struct saved_window
|
struct saved_window
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
Lisp_Object window, buffer, start, pointm, old_pointm;
|
Lisp_Object window, buffer, start, pointm, old_pointm;
|
||||||
Lisp_Object pixel_left, pixel_top, pixel_height, pixel_width;
|
Lisp_Object pixel_left, pixel_top, pixel_height, pixel_width;
|
||||||
|
|
|
@ -88,7 +88,7 @@ struct cursor_pos
|
||||||
struct window
|
struct window
|
||||||
{
|
{
|
||||||
/* This is for Lisp; the terminal code does not refer to it. */
|
/* This is for Lisp; the terminal code does not refer to it. */
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* The frame this window is on. */
|
/* The frame this window is on. */
|
||||||
Lisp_Object frame;
|
Lisp_Object frame;
|
||||||
|
|
|
@ -887,7 +887,7 @@ extern void x_mark_frame_dirty (struct frame *f);
|
||||||
struct scroll_bar
|
struct scroll_bar
|
||||||
{
|
{
|
||||||
/* These fields are shared by all vectors. */
|
/* These fields are shared by all vectors. */
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* The window we're a scroll bar for. */
|
/* The window we're a scroll bar for. */
|
||||||
Lisp_Object window;
|
Lisp_Object window;
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct window;
|
||||||
|
|
||||||
struct xwidget
|
struct xwidget
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
|
|
||||||
/* Auxiliary data. */
|
/* Auxiliary data. */
|
||||||
Lisp_Object plist;
|
Lisp_Object plist;
|
||||||
|
@ -62,7 +62,7 @@ struct xwidget
|
||||||
|
|
||||||
struct xwidget_view
|
struct xwidget_view
|
||||||
{
|
{
|
||||||
struct vectorlike_header header;
|
union vectorlike_header header;
|
||||||
Lisp_Object model;
|
Lisp_Object model;
|
||||||
Lisp_Object w;
|
Lisp_Object w;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue