aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2017-11-13 08:51:41 -0800
committerPaul Eggert2017-11-13 10:16:51 -0800
commit5d68dc9a2fd1b9b883db6bc1c226541b50de8bb1 (patch)
tree196afa86890522fcde540c618ac85e307194127b /src
parent6aa0a26b46240d79eddd7e0d275454e235a60b84 (diff)
downloademacs-5d68dc9a2fd1b9b883db6bc1c226541b50de8bb1.tar.gz
emacs-5d68dc9a2fd1b9b883db6bc1c226541b50de8bb1.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.h2
-rw-r--r--src/font.h6
-rw-r--r--src/frame.h2
-rw-r--r--src/lisp.h28
-rw-r--r--src/process.h2
-rw-r--r--src/termhooks.h2
-rw-r--r--src/thread.h6
-rw-r--r--src/w32term.h2
-rw-r--r--src/window.c8
-rw-r--r--src/window.h2
-rw-r--r--src/xterm.h2
-rw-r--r--src/xwidget.h4
12 files changed, 33 insertions, 33 deletions
diff --git a/src/buffer.h b/src/buffer.h
index ac7c5a54679..46c7c6e5ad6 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -504,7 +504,7 @@ struct buffer_text
504 504
505struct buffer 505struct buffer
506{ 506{
507 struct vectorlike_header header; 507 union vectorlike_header header;
508 508
509 /* The name of this buffer. */ 509 /* The name of this buffer. */
510 Lisp_Object name_; 510 Lisp_Object name_;
diff --git a/src/font.h b/src/font.h
index 8f2e27f0edd..43d6f67e3e9 100644
--- a/src/font.h
+++ b/src/font.h
@@ -244,7 +244,7 @@ enum font_property_index
244 244
245struct font_spec 245struct font_spec
246{ 246{
247 struct vectorlike_header header; 247 union vectorlike_header header;
248 Lisp_Object props[FONT_SPEC_MAX]; 248 Lisp_Object props[FONT_SPEC_MAX];
249}; 249};
250 250
@@ -252,7 +252,7 @@ struct font_spec
252 252
253struct font_entity 253struct font_entity
254{ 254{
255 struct vectorlike_header header; 255 union vectorlike_header header;
256 Lisp_Object props[FONT_ENTITY_MAX]; 256 Lisp_Object props[FONT_ENTITY_MAX];
257}; 257};
258 258
@@ -265,7 +265,7 @@ struct font_entity
265 265
266struct font 266struct font
267{ 267{
268 struct vectorlike_header header; 268 union vectorlike_header header;
269 269
270 /* All Lisp_Object components must come first. 270 /* All Lisp_Object components must come first.
271 That ensures they are all aligned normally. */ 271 That ensures they are all aligned normally. */
diff --git a/src/frame.h b/src/frame.h
index e610fc768d3..a3b77636435 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -79,7 +79,7 @@ enum ns_appearance_type
79 79
80struct frame 80struct frame
81{ 81{
82 struct vectorlike_header header; 82 union vectorlike_header header;
83 83
84 /* All Lisp_Object components must come first. 84 /* All Lisp_Object components must come first.
85 That ensures they are all aligned normally. */ 85 That ensures they are all aligned normally. */
diff --git a/src/lisp.h b/src/lisp.h
index 015346858b5..1d6fd5a4fe2 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -796,11 +796,11 @@ struct Lisp_Symbol
796/* Header of vector-like objects. This documents the layout constraints on 796/* Header of vector-like objects. This documents the layout constraints on
797 vectors and pseudovectors (objects of PVEC_xxx subtype). It also prevents 797 vectors and pseudovectors (objects of PVEC_xxx subtype). It also prevents
798 compilers from being fooled by Emacs's type punning: XSETPSEUDOVECTOR 798 compilers from being fooled by Emacs's type punning: XSETPSEUDOVECTOR
799 and PSEUDOVECTORP cast their pointers to struct vectorlike_header *, 799 and PSEUDOVECTORP cast their pointers to union vectorlike_header *,
800 because when two such pointers potentially alias, a compiler won't 800 because when two such pointers potentially alias, a compiler won't
801 incorrectly reorder loads and stores to their size fields. See 801 incorrectly reorder loads and stores to their size fields. See
802 Bug#8546. */ 802 Bug#8546. */
803struct vectorlike_header 803union vectorlike_header
804 { 804 {
805 /* The only field contains various pieces of information: 805 /* The only field contains various pieces of information:
806 - The MSB (ARRAY_MARK_FLAG) holds the gcmarkbit. 806 - The MSB (ARRAY_MARK_FLAG) holds the gcmarkbit.
@@ -1094,10 +1094,10 @@ INLINE bool
1094 | ((restsize) << PSEUDOVECTOR_SIZE_BITS) \ 1094 | ((restsize) << PSEUDOVECTOR_SIZE_BITS) \
1095 | (lispsize))) 1095 | (lispsize)))
1096 1096
1097/* The cast to struct vectorlike_header * avoids aliasing issues. */ 1097/* The cast to union vectorlike_header * avoids aliasing issues. */
1098#define XSETPSEUDOVECTOR(a, b, code) \ 1098#define XSETPSEUDOVECTOR(a, b, code) \
1099 XSETTYPED_PSEUDOVECTOR (a, b, \ 1099 XSETTYPED_PSEUDOVECTOR (a, b, \
1100 (((struct vectorlike_header *) \ 1100 (((union vectorlike_header *) \
1101 XUNTAG (a, Lisp_Vectorlike)) \ 1101 XUNTAG (a, Lisp_Vectorlike)) \
1102 ->size), \ 1102 ->size), \
1103 code) 1103 code)
@@ -1399,7 +1399,7 @@ STRING_SET_CHARS (Lisp_Object string, ptrdiff_t newsize)
1399 1399
1400struct Lisp_Vector 1400struct Lisp_Vector
1401 { 1401 {
1402 struct vectorlike_header header; 1402 union vectorlike_header header;
1403 Lisp_Object contents[FLEXIBLE_ARRAY_MEMBER]; 1403 Lisp_Object contents[FLEXIBLE_ARRAY_MEMBER];
1404 }; 1404 };
1405 1405
@@ -1456,7 +1456,7 @@ PSEUDOVECTOR_TYPE (struct Lisp_Vector *v)
1456 1456
1457/* Can't be used with PVEC_NORMAL_VECTOR. */ 1457/* Can't be used with PVEC_NORMAL_VECTOR. */
1458INLINE bool 1458INLINE bool
1459PSEUDOVECTOR_TYPEP (struct vectorlike_header *a, enum pvec_type code) 1459PSEUDOVECTOR_TYPEP (union vectorlike_header *a, enum pvec_type code)
1460{ 1460{
1461 /* We don't use PSEUDOVECTOR_TYPE here so as to avoid a shift 1461 /* We don't use PSEUDOVECTOR_TYPE here so as to avoid a shift
1462 * operation when `code' is known. */ 1462 * operation when `code' is known. */
@@ -1472,8 +1472,8 @@ PSEUDOVECTORP (Lisp_Object a, int code)
1472 return false; 1472 return false;
1473 else 1473 else
1474 { 1474 {
1475 /* Converting to struct vectorlike_header * avoids aliasing issues. */ 1475 /* Converting to union vectorlike_header * avoids aliasing issues. */
1476 struct vectorlike_header *h = XUNTAG (a, Lisp_Vectorlike); 1476 union vectorlike_header *h = XUNTAG (a, Lisp_Vectorlike);
1477 return PSEUDOVECTOR_TYPEP (h, code); 1477 return PSEUDOVECTOR_TYPEP (h, code);
1478 } 1478 }
1479} 1479}
@@ -1484,7 +1484,7 @@ struct Lisp_Bool_Vector
1484 { 1484 {
1485 /* HEADER.SIZE is the vector's size field. It doesn't have the real size, 1485 /* HEADER.SIZE is the vector's size field. It doesn't have the real size,
1486 just the subtype information. */ 1486 just the subtype information. */
1487 struct vectorlike_header header; 1487 union vectorlike_header header;
1488 /* This is the size in bits. */ 1488 /* This is the size in bits. */
1489 EMACS_INT size; 1489 EMACS_INT size;
1490 /* The actual bits, packed into bytes. 1490 /* The actual bits, packed into bytes.
@@ -1697,7 +1697,7 @@ struct Lisp_Char_Table
1697 pseudovector type information. It holds the size, too. 1697 pseudovector type information. It holds the size, too.
1698 The size counts the defalt, parent, purpose, ascii, 1698 The size counts the defalt, parent, purpose, ascii,
1699 contents, and extras slots. */ 1699 contents, and extras slots. */
1700 struct vectorlike_header header; 1700 union vectorlike_header header;
1701 1701
1702 /* This holds a default value, 1702 /* This holds a default value,
1703 which is used whenever the value for a specific character is nil. */ 1703 which is used whenever the value for a specific character is nil. */
@@ -1739,7 +1739,7 @@ struct Lisp_Sub_Char_Table
1739 { 1739 {
1740 /* HEADER.SIZE is the vector's size field, which also holds the 1740 /* HEADER.SIZE is the vector's size field, which also holds the
1741 pseudovector type information. It holds the size, too. */ 1741 pseudovector type information. It holds the size, too. */
1742 struct vectorlike_header header; 1742 union vectorlike_header header;
1743 1743
1744 /* Depth of this sub char-table. It should be 1, 2, or 3. A sub 1744 /* Depth of this sub char-table. It should be 1, 2, or 3. A sub
1745 char-table of depth 1 contains 16 elements, and each element 1745 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)
1814 1814
1815struct Lisp_Subr 1815struct Lisp_Subr
1816 { 1816 {
1817 struct vectorlike_header header; 1817 union vectorlike_header header;
1818 union { 1818 union {
1819 Lisp_Object (*a0) (void); 1819 Lisp_Object (*a0) (void);
1820 Lisp_Object (*a1) (Lisp_Object); 1820 Lisp_Object (*a1) (Lisp_Object);
@@ -2026,7 +2026,7 @@ struct hash_table_test
2026struct Lisp_Hash_Table 2026struct Lisp_Hash_Table
2027{ 2027{
2028 /* This is for Lisp; the hash table code does not refer to it. */ 2028 /* This is for Lisp; the hash table code does not refer to it. */
2029 struct vectorlike_header header; 2029 union vectorlike_header header;
2030 2030
2031 /* Nil if table is non-weak. Otherwise a symbol describing the 2031 /* Nil if table is non-weak. Otherwise a symbol describing the
2032 weakness of the table. */ 2032 weakness of the table. */
@@ -3929,7 +3929,7 @@ typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t,
3929 3929
3930struct Lisp_Module_Function 3930struct Lisp_Module_Function
3931{ 3931{
3932 struct vectorlike_header header; 3932 union vectorlike_header header;
3933 3933
3934 /* Fields traced by GC; these must come first. */ 3934 /* Fields traced by GC; these must come first. */
3935 Lisp_Object documentation; 3935 Lisp_Object documentation;
diff --git a/src/process.h b/src/process.h
index 5a044f669f2..5670f447365 100644
--- a/src/process.h
+++ b/src/process.h
@@ -41,7 +41,7 @@ enum { PROCESS_OPEN_FDS = 6 };
41 41
42struct Lisp_Process 42struct Lisp_Process
43 { 43 {
44 struct vectorlike_header header; 44 union vectorlike_header header;
45 45
46 /* Name of subprocess terminal. */ 46 /* Name of subprocess terminal. */
47 Lisp_Object tty_name; 47 Lisp_Object tty_name;
diff --git a/src/termhooks.h b/src/termhooks.h
index dd6044aabd5..fe4e993c968 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -373,7 +373,7 @@ extern struct tty_display_info *gpm_tty;
373struct terminal 373struct terminal
374{ 374{
375 /* This is for Lisp; the terminal code does not refer to it. */ 375 /* This is for Lisp; the terminal code does not refer to it. */
376 struct vectorlike_header header; 376 union vectorlike_header header;
377 377
378 /* Parameter alist of this terminal. */ 378 /* Parameter alist of this terminal. */
379 Lisp_Object param_alist; 379 Lisp_Object param_alist;
diff --git a/src/thread.h b/src/thread.h
index 19baafbf8a1..1845974bc28 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -35,7 +35,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
35 35
36struct thread_state 36struct thread_state
37{ 37{
38 struct vectorlike_header header; 38 union vectorlike_header header;
39 39
40 /* The buffer in which the last search was performed, or 40 /* The buffer in which the last search was performed, or
41 Qt if the last search was done in a string; 41 Qt if the last search was done in a string;
@@ -230,7 +230,7 @@ typedef struct
230/* A mutex as a lisp object. */ 230/* A mutex as a lisp object. */
231struct Lisp_Mutex 231struct Lisp_Mutex
232{ 232{
233 struct vectorlike_header header; 233 union vectorlike_header header;
234 234
235 /* The name of the mutex, or nil. */ 235 /* The name of the mutex, or nil. */
236 Lisp_Object name; 236 Lisp_Object name;
@@ -261,7 +261,7 @@ XMUTEX (Lisp_Object a)
261/* A condition variable as a lisp object. */ 261/* A condition variable as a lisp object. */
262struct Lisp_CondVar 262struct Lisp_CondVar
263{ 263{
264 struct vectorlike_header header; 264 union vectorlike_header header;
265 265
266 /* The associated mutex. */ 266 /* The associated mutex. */
267 Lisp_Object mutex; 267 Lisp_Object mutex;
diff --git a/src/w32term.h b/src/w32term.h
index 8d08ca0a2bf..de234cb57db 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -431,7 +431,7 @@ extern struct w32_output w32term_display;
431struct scroll_bar { 431struct scroll_bar {
432 432
433 /* This field is shared by all vectors. */ 433 /* This field is shared by all vectors. */
434 struct vectorlike_header header; 434 union vectorlike_header header;
435 435
436 /* The window we're a scroll bar for. */ 436 /* The window we're a scroll bar for. */
437 Lisp_Object window; 437 Lisp_Object window;
diff --git a/src/window.c b/src/window.c
index cc1d2a7b36e..7f472523b49 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3733,8 +3733,8 @@ make_parent_window (Lisp_Object window, bool horflag)
3733 3733
3734 o = XWINDOW (window); 3734 o = XWINDOW (window);
3735 p = allocate_window (); 3735 p = allocate_window ();
3736 memcpy ((char *) p + sizeof (struct vectorlike_header), 3736 memcpy ((char *) p + sizeof (union vectorlike_header),
3737 (char *) o + sizeof (struct vectorlike_header), 3737 (char *) o + sizeof (union vectorlike_header),
3738 word_size * VECSIZE (struct window)); 3738 word_size * VECSIZE (struct window));
3739 /* P's buffer slot may change from nil to a buffer... */ 3739 /* P's buffer slot may change from nil to a buffer... */
3740 adjust_window_count (p, 1); 3740 adjust_window_count (p, 1);
@@ -6232,7 +6232,7 @@ from the top of the window. */)
6232 6232
6233struct save_window_data 6233struct save_window_data
6234 { 6234 {
6235 struct vectorlike_header header; 6235 union vectorlike_header header;
6236 Lisp_Object selected_frame; 6236 Lisp_Object selected_frame;
6237 Lisp_Object current_window; 6237 Lisp_Object current_window;
6238 Lisp_Object f_current_buffer; 6238 Lisp_Object f_current_buffer;
@@ -6260,7 +6260,7 @@ struct save_window_data
6260/* This is saved as a Lisp_Vector. */ 6260/* This is saved as a Lisp_Vector. */
6261struct saved_window 6261struct saved_window
6262{ 6262{
6263 struct vectorlike_header header; 6263 union vectorlike_header header;
6264 6264
6265 Lisp_Object window, buffer, start, pointm, old_pointm; 6265 Lisp_Object window, buffer, start, pointm, old_pointm;
6266 Lisp_Object pixel_left, pixel_top, pixel_height, pixel_width; 6266 Lisp_Object pixel_left, pixel_top, pixel_height, pixel_width;
diff --git a/src/window.h b/src/window.h
index df7c23f824b..25c9686a9f0 100644
--- a/src/window.h
+++ b/src/window.h
@@ -88,7 +88,7 @@ struct cursor_pos
88struct window 88struct window
89 { 89 {
90 /* This is for Lisp; the terminal code does not refer to it. */ 90 /* This is for Lisp; the terminal code does not refer to it. */
91 struct vectorlike_header header; 91 union vectorlike_header header;
92 92
93 /* The frame this window is on. */ 93 /* The frame this window is on. */
94 Lisp_Object frame; 94 Lisp_Object frame;
diff --git a/src/xterm.h b/src/xterm.h
index 6274630706f..7ab20ba06c6 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -887,7 +887,7 @@ extern void x_mark_frame_dirty (struct frame *f);
887struct scroll_bar 887struct scroll_bar
888{ 888{
889 /* These fields are shared by all vectors. */ 889 /* These fields are shared by all vectors. */
890 struct vectorlike_header header; 890 union vectorlike_header header;
891 891
892 /* The window we're a scroll bar for. */ 892 /* The window we're a scroll bar for. */
893 Lisp_Object window; 893 Lisp_Object window;
diff --git a/src/xwidget.h b/src/xwidget.h
index 22a8eb3a557..02a0453dabb 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -33,7 +33,7 @@ struct window;
33 33
34struct xwidget 34struct xwidget
35{ 35{
36 struct vectorlike_header header; 36 union vectorlike_header header;
37 37
38 /* Auxiliary data. */ 38 /* Auxiliary data. */
39 Lisp_Object plist; 39 Lisp_Object plist;
@@ -62,7 +62,7 @@ struct xwidget
62 62
63struct xwidget_view 63struct xwidget_view
64{ 64{
65 struct vectorlike_header header; 65 union vectorlike_header header;
66 Lisp_Object model; 66 Lisp_Object model;
67 Lisp_Object w; 67 Lisp_Object w;
68 68