aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2012-08-05 19:47:28 +0400
committerDmitry Antipov2012-08-05 19:47:28 +0400
commit663e2b3f88f9be61399e06dfc0b76700f90c6ca6 (patch)
tree71e48dfc0079f80f2089b5bdebe991a200d594ed /src
parent777fe95e05ab77e77e4ecee45382ec64d381c776 (diff)
downloademacs-663e2b3f88f9be61399e06dfc0b76700f90c6ca6.tar.gz
emacs-663e2b3f88f9be61399e06dfc0b76700f90c6ca6.zip
Generalize common compile-time constants.
* lisp.h (header_size, bool_header_size, word_size): Now here. (struct Lisp_Vector): Add comment. (struct Lisp_Bool_Vector): Move up to define handy constants. (VECSIZE, PSEUDOVECSIZE): Simplify. (SAFE_ALLOCA_LISP): Use new constant. Adjust indentation. * buffer.c, buffer.h, bytecode.c, callint.c, eval.c, fns.c: * font.c, fontset.c, keyboard.c, keymap.c, macros.c, menu.c: * msdos.c, w32menu.c, w32term.h, window.c, xdisp.c, xfaces.c: * xfont.c, xmenu.c: Use word_size where appropriate.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog13
-rw-r--r--src/alloc.c14
-rw-r--r--src/buffer.c9
-rw-r--r--src/buffer.h2
-rw-r--r--src/bytecode.c2
-rw-r--r--src/callint.c2
-rw-r--r--src/eval.c4
-rw-r--r--src/fns.c2
-rw-r--r--src/font.c2
-rw-r--r--src/fontset.c6
-rw-r--r--src/keyboard.c10
-rw-r--r--src/keymap.c2
-rw-r--r--src/lisp.h80
-rw-r--r--src/macros.c4
-rw-r--r--src/menu.c2
-rw-r--r--src/msdos.c8
-rw-r--r--src/w32menu.c8
-rw-r--r--src/w32term.h2
-rw-r--r--src/window.c2
-rw-r--r--src/xdisp.c2
-rw-r--r--src/xfaces.c4
-rw-r--r--src/xfont.c4
-rw-r--r--src/xmenu.c2
23 files changed, 101 insertions, 85 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d760dd1df78..55433577cee 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
12012-08-05 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Generalize common compile-time constants.
4 * lisp.h (header_size, bool_header_size, word_size): Now here.
5 (struct Lisp_Vector): Add comment.
6 (struct Lisp_Bool_Vector): Move up to define handy constants.
7 (VECSIZE, PSEUDOVECSIZE): Simplify.
8 (SAFE_ALLOCA_LISP): Use new constant. Adjust indentation.
9 * buffer.c, buffer.h, bytecode.c, callint.c, eval.c, fns.c:
10 * font.c, fontset.c, keyboard.c, keymap.c, macros.c, menu.c:
11 * msdos.c, w32menu.c, w32term.h, window.c, xdisp.c, xfaces.c:
12 * xfont.c, xmenu.c: Use word_size where appropriate.
13
12012-08-05 Lawrence Mitchell <wence@gmx.li> 142012-08-05 Lawrence Mitchell <wence@gmx.li>
2 15
3 * search.c (Freplace_match): Treat \? in the replacement text 16 * search.c (Freplace_match): Treat \? in the replacement text
diff --git a/src/alloc.c b/src/alloc.c
index 3939e704978..7d1ff7625f2 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -155,7 +155,7 @@ static pthread_mutex_t alloc_mutex;
155 155
156/* Default value of gc_cons_threshold (see below). */ 156/* Default value of gc_cons_threshold (see below). */
157 157
158#define GC_DEFAULT_THRESHOLD (100000 * sizeof (Lisp_Object)) 158#define GC_DEFAULT_THRESHOLD (100000 * word_size)
159 159
160/* Global variables. */ 160/* Global variables. */
161struct emacs_globals globals; 161struct emacs_globals globals;
@@ -278,14 +278,6 @@ static void sweep_strings (void);
278static void free_misc (Lisp_Object); 278static void free_misc (Lisp_Object);
279extern Lisp_Object which_symbols (Lisp_Object, EMACS_INT) EXTERNALLY_VISIBLE; 279extern Lisp_Object which_symbols (Lisp_Object, EMACS_INT) EXTERNALLY_VISIBLE;
280 280
281/* Handy constants for vectorlike objects. */
282enum
283 {
284 header_size = offsetof (struct Lisp_Vector, contents),
285 bool_header_size = offsetof (struct Lisp_Bool_Vector, data),
286 word_size = sizeof (Lisp_Object)
287 };
288
289/* When scanning the C stack for live Lisp objects, Emacs keeps track 281/* When scanning the C stack for live Lisp objects, Emacs keeps track
290 of what memory allocated via lisp_malloc is intended for what 282 of what memory allocated via lisp_malloc is intended for what
291 purpose. This enumeration specifies the type of memory. */ 283 purpose. This enumeration specifies the type of memory. */
@@ -2810,9 +2802,9 @@ listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...)
2810 Lisp_Object val, *objp; 2802 Lisp_Object val, *objp;
2811 2803
2812 /* Change to SAFE_ALLOCA if you hit this eassert. */ 2804 /* Change to SAFE_ALLOCA if you hit this eassert. */
2813 eassert (count <= MAX_ALLOCA / sizeof (Lisp_Object)); 2805 eassert (count <= MAX_ALLOCA / word_size);
2814 2806
2815 objp = alloca (count * sizeof (Lisp_Object)); 2807 objp = alloca (count * word_size);
2816 objp[0] = arg; 2808 objp[0] = arg;
2817 va_start (ap, arg); 2809 va_start (ap, arg);
2818 for (i = 1; i < count; i++) 2810 for (i = 1; i < count; i++)
diff --git a/src/buffer.c b/src/buffer.c
index a8af8a84f7f..37e520f9f5f 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -99,7 +99,7 @@ static Lisp_Object Vbuffer_local_symbols;
99/* Maximum length of an overlay vector. */ 99/* Maximum length of an overlay vector. */
100#define OVERLAY_COUNT_MAX \ 100#define OVERLAY_COUNT_MAX \
101 ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, \ 101 ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, \
102 min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object))) 102 min (PTRDIFF_MAX, SIZE_MAX) / word_size))
103 103
104/* Flags indicating which built-in buffer-local variables 104/* Flags indicating which built-in buffer-local variables
105 are permanent locals. */ 105 are permanent locals. */
@@ -4267,7 +4267,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after,
4267 ptrdiff_t i; 4267 ptrdiff_t i;
4268 4268
4269 memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, 4269 memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents,
4270 size * sizeof (Lisp_Object)); 4270 size * word_size);
4271 gcpro1.var = copy; 4271 gcpro1.var = copy;
4272 gcpro1.nvars = size; 4272 gcpro1.nvars = size;
4273 4273
@@ -4886,8 +4886,7 @@ init_buffer_once (void)
4886 sure that this is still correct. Otherwise, mark_vectorlike may not 4886 sure that this is still correct. Otherwise, mark_vectorlike may not
4887 trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */ 4887 trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */
4888 const int pvecsize 4888 const int pvecsize
4889 = (offsetof (struct buffer, own_text) - sizeof (struct vectorlike_header)) 4889 = (offsetof (struct buffer, own_text) - header_size) / word_size;
4890 / sizeof (Lisp_Object);
4891 4890
4892 memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags); 4891 memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags);
4893 4892
@@ -4972,7 +4971,7 @@ init_buffer_once (void)
4972 The local flag bits are in the local_var_flags slot of the buffer. */ 4971 The local flag bits are in the local_var_flags slot of the buffer. */
4973 4972
4974 /* Nothing can work if this isn't true */ 4973 /* Nothing can work if this isn't true */
4975 { verify (sizeof (EMACS_INT) == sizeof (Lisp_Object)); } 4974 { verify (sizeof (EMACS_INT) == word_size); }
4976 4975
4977 /* 0 means not a lisp var, -1 means always local, else mask */ 4976 /* 0 means not a lisp var, -1 means always local, else mask */
4978 memset (&buffer_local_flags, 0, sizeof buffer_local_flags); 4977 memset (&buffer_local_flags, 0, sizeof buffer_local_flags);
diff --git a/src/buffer.h b/src/buffer.h
index b13aab8443e..9ca714b6707 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1029,7 +1029,7 @@ extern int last_per_buffer_idx;
1029#define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \ 1029#define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \
1030 for (offset = PER_BUFFER_VAR_OFFSET (name); \ 1030 for (offset = PER_BUFFER_VAR_OFFSET (name); \
1031 offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ 1031 offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \
1032 offset += sizeof (Lisp_Object)) 1032 offset += word_size)
1033 1033
1034/* Return the index of buffer-local variable VAR. Each per-buffer 1034/* Return the index of buffer-local variable VAR. Each per-buffer
1035 variable has an index > 0 associated with it, except when it always 1035 variable has an index > 0 associated with it, except when it always
diff --git a/src/bytecode.c b/src/bytecode.c
index 523d56bc97b..49369de33e9 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -536,7 +536,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
536 stack.byte_string = bytestr; 536 stack.byte_string = bytestr;
537 stack.pc = stack.byte_string_start = SDATA (bytestr); 537 stack.pc = stack.byte_string_start = SDATA (bytestr);
538 stack.constants = vector; 538 stack.constants = vector;
539 if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth)) 539 if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth))
540 memory_full (SIZE_MAX); 540 memory_full (SIZE_MAX);
541 top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); 541 top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top);
542#if BYTE_MAINTAIN_TOP 542#if BYTE_MAINTAIN_TOP
diff --git a/src/callint.c b/src/callint.c
index 4b53b5df34b..51d0a5fa2e8 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -465,7 +465,7 @@ invoke it. If KEYS is omitted or nil, the return value of
465 } 465 }
466 466
467 if (min (MOST_POSITIVE_FIXNUM, 467 if (min (MOST_POSITIVE_FIXNUM,
468 min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) 468 min (PTRDIFF_MAX, SIZE_MAX) / word_size)
469 < nargs) 469 < nargs)
470 memory_full (SIZE_MAX); 470 memory_full (SIZE_MAX);
471 471
diff --git a/src/eval.c b/src/eval.c
index 64f384f2ca9..5eb144eb0b2 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2301,7 +2301,7 @@ usage: (apply FUNCTION &rest ARGUMENTS) */)
2301 gcpro1.nvars = 1 + numargs; 2301 gcpro1.nvars = 1 + numargs;
2302 } 2302 }
2303 2303
2304 memcpy (funcall_args, args, nargs * sizeof (Lisp_Object)); 2304 memcpy (funcall_args, args, nargs * word_size);
2305 /* Spread the last arg we got. Its first element goes in 2305 /* Spread the last arg we got. Its first element goes in
2306 the slot that it used to occupy, hence this value of I. */ 2306 the slot that it used to occupy, hence this value of I. */
2307 i = nargs - 1; 2307 i = nargs - 1;
@@ -2794,7 +2794,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2794 { 2794 {
2795 internal_args = alloca (XSUBR (fun)->max_args 2795 internal_args = alloca (XSUBR (fun)->max_args
2796 * sizeof *internal_args); 2796 * sizeof *internal_args);
2797 memcpy (internal_args, args + 1, numargs * sizeof (Lisp_Object)); 2797 memcpy (internal_args, args + 1, numargs * word_size);
2798 for (i = numargs; i < XSUBR (fun)->max_args; i++) 2798 for (i = numargs; i < XSUBR (fun)->max_args; i++)
2799 internal_args[i] = Qnil; 2799 internal_args[i] = Qnil;
2800 } 2800 }
diff --git a/src/fns.c b/src/fns.c
index 3f988699a27..739ffcaea22 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3569,7 +3569,7 @@ hashfn_user_defined (struct Lisp_Hash_Table *h, Lisp_Object key)
3569/* An upper bound on the size of a hash table index. It must fit in 3569/* An upper bound on the size of a hash table index. It must fit in
3570 ptrdiff_t and be a valid Emacs fixnum. */ 3570 ptrdiff_t and be a valid Emacs fixnum. */
3571#define INDEX_SIZE_BOUND \ 3571#define INDEX_SIZE_BOUND \
3572 ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, PTRDIFF_MAX / sizeof (Lisp_Object))) 3572 ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, PTRDIFF_MAX / word_size))
3573 3573
3574/* Create and initialize a new hash table. 3574/* Create and initialize a new hash table.
3575 3575
diff --git a/src/font.c b/src/font.c
index c70c2abdc23..ca0ccc171eb 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2138,7 +2138,7 @@ static Lisp_Object
2138font_vconcat_entity_vectors (Lisp_Object list) 2138font_vconcat_entity_vectors (Lisp_Object list)
2139{ 2139{
2140 int nargs = XINT (Flength (list)); 2140 int nargs = XINT (Flength (list));
2141 Lisp_Object *args = alloca (sizeof (Lisp_Object) * nargs); 2141 Lisp_Object *args = alloca (word_size * nargs);
2142 int i; 2142 int i;
2143 2143
2144 for (i = 0; i < nargs; i++, list = XCDR (list)) 2144 for (i = 0; i < nargs; i++, list = XCDR (list))
diff --git a/src/fontset.c b/src/fontset.c
index 858a2e3cd3b..7ea1deeaecb 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -429,7 +429,7 @@ reorder_font_vector (Lisp_Object font_group, struct font *font)
429 } 429 }
430 430
431 if (score_changed) 431 if (score_changed)
432 qsort (XVECTOR (vec)->contents, size, sizeof (Lisp_Object), 432 qsort (XVECTOR (vec)->contents, size, word_size,
433 fontset_compare_rfontdef); 433 fontset_compare_rfontdef);
434 XSETCAR (font_group, make_number (charset_ordered_list_tick)); 434 XSETCAR (font_group, make_number (charset_ordered_list_tick));
435} 435}
@@ -1893,7 +1893,7 @@ format is the same as above. */)
1893 1893
1894 /* Recode fontsets realized on FRAME from the base fontset FONTSET 1894 /* Recode fontsets realized on FRAME from the base fontset FONTSET
1895 in the table `realized'. */ 1895 in the table `realized'. */
1896 realized[0] = alloca (sizeof (Lisp_Object) * ASIZE (Vfontset_table)); 1896 realized[0] = alloca (word_size * ASIZE (Vfontset_table));
1897 for (i = j = 0; i < ASIZE (Vfontset_table); i++) 1897 for (i = j = 0; i < ASIZE (Vfontset_table); i++)
1898 { 1898 {
1899 elt = FONTSET_FROM_ID (i); 1899 elt = FONTSET_FROM_ID (i);
@@ -1904,7 +1904,7 @@ format is the same as above. */)
1904 } 1904 }
1905 realized[0][j] = Qnil; 1905 realized[0][j] = Qnil;
1906 1906
1907 realized[1] = alloca (sizeof (Lisp_Object) * ASIZE (Vfontset_table)); 1907 realized[1] = alloca (word_size * ASIZE (Vfontset_table));
1908 for (i = j = 0; ! NILP (realized[0][i]); i++) 1908 for (i = j = 0; ! NILP (realized[0][i]); i++)
1909 { 1909 {
1910 elt = FONTSET_DEFAULT (realized[0][i]); 1910 elt = FONTSET_DEFAULT (realized[0][i]);
diff --git a/src/keyboard.c b/src/keyboard.c
index 39112479eb7..de77f7cf33a 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7527,7 +7527,7 @@ menu_bar_items (Lisp_Object old)
7527 if (end > i + 4) 7527 if (end > i + 4)
7528 memmove (aref_addr (menu_bar_items_vector, i), 7528 memmove (aref_addr (menu_bar_items_vector, i),
7529 aref_addr (menu_bar_items_vector, i + 4), 7529 aref_addr (menu_bar_items_vector, i + 4),
7530 (end - i - 4) * sizeof (Lisp_Object)); 7530 (end - i - 4) * word_size);
7531 ASET (menu_bar_items_vector, end - 4, tem0); 7531 ASET (menu_bar_items_vector, end - 4, tem0);
7532 ASET (menu_bar_items_vector, end - 3, tem1); 7532 ASET (menu_bar_items_vector, end - 3, tem1);
7533 ASET (menu_bar_items_vector, end - 2, tem2); 7533 ASET (menu_bar_items_vector, end - 2, tem2);
@@ -7577,7 +7577,7 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
7577 if (menu_bar_items_index > i + 4) 7577 if (menu_bar_items_index > i + 4)
7578 memmove (aref_addr (menu_bar_items_vector, i), 7578 memmove (aref_addr (menu_bar_items_vector, i),
7579 aref_addr (menu_bar_items_vector, i + 4), 7579 aref_addr (menu_bar_items_vector, i + 4),
7580 (menu_bar_items_index - i - 4) * sizeof (Lisp_Object)); 7580 (menu_bar_items_index - i - 4) * word_size);
7581 menu_bar_items_index -= 4; 7581 menu_bar_items_index -= 4;
7582 } 7582 }
7583 } 7583 }
@@ -8082,7 +8082,7 @@ process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void
8082 if (ntool_bar_items > i + TOOL_BAR_ITEM_NSLOTS) 8082 if (ntool_bar_items > i + TOOL_BAR_ITEM_NSLOTS)
8083 memmove (v, v + TOOL_BAR_ITEM_NSLOTS, 8083 memmove (v, v + TOOL_BAR_ITEM_NSLOTS,
8084 ((ntool_bar_items - i - TOOL_BAR_ITEM_NSLOTS) 8084 ((ntool_bar_items - i - TOOL_BAR_ITEM_NSLOTS)
8085 * sizeof (Lisp_Object))); 8085 * word_size));
8086 ntool_bar_items -= TOOL_BAR_ITEM_NSLOTS; 8086 ntool_bar_items -= TOOL_BAR_ITEM_NSLOTS;
8087 break; 8087 break;
8088 } 8088 }
@@ -10425,9 +10425,9 @@ DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0,
10425 { 10425 {
10426 val = Fvector (NUM_RECENT_KEYS, keys); 10426 val = Fvector (NUM_RECENT_KEYS, keys);
10427 memcpy (XVECTOR (val)->contents, keys + recent_keys_index, 10427 memcpy (XVECTOR (val)->contents, keys + recent_keys_index,
10428 (NUM_RECENT_KEYS - recent_keys_index) * sizeof (Lisp_Object)); 10428 (NUM_RECENT_KEYS - recent_keys_index) * word_size);
10429 memcpy (XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index, 10429 memcpy (XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index,
10430 keys, recent_keys_index * sizeof (Lisp_Object)); 10430 keys, recent_keys_index * word_size);
10431 return val; 10431 return val;
10432 } 10432 }
10433} 10433}
diff --git a/src/keymap.c b/src/keymap.c
index ed65a5f3d8a..bd2f3c99c26 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -2069,7 +2069,7 @@ The `kbd' macro is an approximate inverse of this. */)
2069 size += XINT (Flength (prefix)); 2069 size += XINT (Flength (prefix));
2070 2070
2071 /* This has one extra element at the end that we don't pass to Fconcat. */ 2071 /* This has one extra element at the end that we don't pass to Fconcat. */
2072 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object) / 4 < size) 2072 if (min (PTRDIFF_MAX, SIZE_MAX) / word_size / 4 < size)
2073 memory_full (SIZE_MAX); 2073 memory_full (SIZE_MAX);
2074 SAFE_ALLOCA_LISP (args, size * 4); 2074 SAFE_ALLOCA_LISP (args, size * 4);
2075 2075
diff --git a/src/lisp.h b/src/lisp.h
index dda6797df81..8a6a2a99791 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -824,25 +824,49 @@ struct vectorlike_header
824 } next; 824 } next;
825 }; 825 };
826 826
827/* Regular vector is just a header plus array of Lisp_Objects. */
828
827struct Lisp_Vector 829struct Lisp_Vector
828 { 830 {
829 struct vectorlike_header header; 831 struct vectorlike_header header;
830 Lisp_Object contents[1]; 832 Lisp_Object contents[1];
831 }; 833 };
832 834
835/* A boolvector is a kind of vectorlike, with contents are like a string. */
836
837struct Lisp_Bool_Vector
838 {
839 /* HEADER.SIZE is the vector's size field. It doesn't have the real size,
840 just the subtype information. */
841 struct vectorlike_header header;
842 /* This is the size in bits. */
843 EMACS_INT size;
844 /* This contains the actual bits, packed into bytes. */
845 unsigned char data[1];
846 };
847
848/* Some handy constants for calculating sizes
849 and offsets, mostly of vectorlike objects. */
850
851enum
852 {
853 header_size = offsetof (struct Lisp_Vector, contents),
854 bool_header_size = offsetof (struct Lisp_Bool_Vector, data),
855 word_size = sizeof (Lisp_Object)
856 };
857
833/* If a struct is made to look like a vector, this macro returns the length 858/* If a struct is made to look like a vector, this macro returns the length
834 of the shortest vector that would hold that struct. */ 859 of the shortest vector that would hold that struct. */
835#define VECSIZE(type) ((sizeof (type) \ 860
836 - offsetof (struct Lisp_Vector, contents[0]) \ 861#define VECSIZE(type) \
837 + sizeof (Lisp_Object) - 1) /* Round up. */ \ 862 ((sizeof (type) - header_size + word_size - 1) / word_size)
838 / sizeof (Lisp_Object))
839 863
840/* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields 864/* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields
841 at the end and we need to compute the number of Lisp_Object fields (the 865 at the end and we need to compute the number of Lisp_Object fields (the
842 ones that the GC needs to trace). */ 866 ones that the GC needs to trace). */
843#define PSEUDOVECSIZE(type, nonlispfield) \ 867
844 ((offsetof (type, nonlispfield) - offsetof (struct Lisp_Vector, contents[0])) \ 868#define PSEUDOVECSIZE(type, nonlispfield) \
845 / sizeof (Lisp_Object)) 869 ((offsetof (type, nonlispfield) - header_size) / word_size)
846 870
847/* A char-table is a kind of vectorlike, with contents are like a 871/* A char-table is a kind of vectorlike, with contents are like a
848 vector but with a few other slots. For some purposes, it makes 872 vector but with a few other slots. For some purposes, it makes
@@ -978,18 +1002,6 @@ struct Lisp_Sub_Char_Table
978 Lisp_Object contents[1]; 1002 Lisp_Object contents[1];
979 }; 1003 };
980 1004
981/* A boolvector is a kind of vectorlike, with contents are like a string. */
982struct Lisp_Bool_Vector
983 {
984 /* HEADER.SIZE is the vector's size field. It doesn't have the real size,
985 just the subtype information. */
986 struct vectorlike_header header;
987 /* This is the size in bits. */
988 EMACS_INT size;
989 /* This contains the actual bits, packed into bytes. */
990 unsigned char data[1];
991 };
992
993/* This structure describes a built-in function. 1005/* This structure describes a built-in function.
994 It is generated by the DEFUN macro only. 1006 It is generated by the DEFUN macro only.
995 defsubr makes it into a Lisp object. 1007 defsubr makes it into a Lisp object.
@@ -3483,21 +3495,21 @@ extern void *record_xmalloc (size_t);
3483 3495
3484/* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */ 3496/* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */
3485 3497
3486#define SAFE_ALLOCA_LISP(buf, nelt) \ 3498#define SAFE_ALLOCA_LISP(buf, nelt) \
3487 do { \ 3499 do { \
3488 if ((nelt) < MAX_ALLOCA / sizeof (Lisp_Object)) \ 3500 if ((nelt) < MAX_ALLOCA / word_size) \
3489 buf = alloca ((nelt) * sizeof (Lisp_Object)); \ 3501 buf = alloca ((nelt) * word_size); \
3490 else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \ 3502 else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / word_size) \
3491 { \ 3503 { \
3492 Lisp_Object arg_; \ 3504 Lisp_Object arg_; \
3493 buf = xmalloc ((nelt) * sizeof (Lisp_Object)); \ 3505 buf = xmalloc ((nelt) * word_size); \
3494 arg_ = make_save_value (buf, nelt); \ 3506 arg_ = make_save_value (buf, nelt); \
3495 XSAVE_VALUE (arg_)->dogc = 1; \ 3507 XSAVE_VALUE (arg_)->dogc = 1; \
3496 sa_must_free = 1; \ 3508 sa_must_free = 1; \
3497 record_unwind_protect (safe_alloca_unwind, arg_); \ 3509 record_unwind_protect (safe_alloca_unwind, arg_); \
3498 } \ 3510 } \
3499 else \ 3511 else \
3500 memory_full (SIZE_MAX); \ 3512 memory_full (SIZE_MAX); \
3501 } while (0) 3513 } while (0)
3502 3514
3503 3515
diff --git a/src/macros.c b/src/macros.c
index a07d8ddbd23..8a4361fc1f6 100644
--- a/src/macros.c
+++ b/src/macros.c
@@ -63,7 +63,7 @@ macro before appending to it. */)
63 63
64 if (!current_kboard->kbd_macro_buffer) 64 if (!current_kboard->kbd_macro_buffer)
65 { 65 {
66 current_kboard->kbd_macro_buffer = xmalloc (30 * sizeof (Lisp_Object)); 66 current_kboard->kbd_macro_buffer = xmalloc (30 * word_size);
67 current_kboard->kbd_macro_bufsize = 30; 67 current_kboard->kbd_macro_bufsize = 30;
68 } 68 }
69 update_mode_lines++; 69 update_mode_lines++;
@@ -73,7 +73,7 @@ macro before appending to it. */)
73 { 73 {
74 current_kboard->kbd_macro_buffer 74 current_kboard->kbd_macro_buffer
75 = xrealloc (current_kboard->kbd_macro_buffer, 75 = xrealloc (current_kboard->kbd_macro_buffer,
76 30 * sizeof (Lisp_Object)); 76 30 * word_size);
77 current_kboard->kbd_macro_bufsize = 30; 77 current_kboard->kbd_macro_bufsize = 30;
78 } 78 }
79 current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_buffer; 79 current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_buffer;
diff --git a/src/menu.c b/src/menu.c
index eaf05ff3cba..3e466b46aa3 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -976,7 +976,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data)
976 976
977 prefix = entry = Qnil; 977 prefix = entry = Qnil;
978 i = 0; 978 i = 0;
979 subprefix_stack = alloca (menu_items_used * sizeof (Lisp_Object)); 979 subprefix_stack = alloca (menu_items_used * word_size);
980 980
981 while (i < menu_items_used) 981 while (i < menu_items_used)
982 { 982 {
diff --git a/src/msdos.c b/src/msdos.c
index 481526d935e..93af0d6e26e 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1594,9 +1594,9 @@ IT_set_frame_parameters (struct frame *f, Lisp_Object alist)
1594 Lisp_Object tail; 1594 Lisp_Object tail;
1595 int i, j, length = XINT (Flength (alist)); 1595 int i, j, length = XINT (Flength (alist));
1596 Lisp_Object *parms 1596 Lisp_Object *parms
1597 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); 1597 = (Lisp_Object *) alloca (length * word_size);
1598 Lisp_Object *values 1598 Lisp_Object *values
1599 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); 1599 = (Lisp_Object *) alloca (length * word_size);
1600 /* Do we have to reverse the foreground and background colors? */ 1600 /* Do we have to reverse the foreground and background colors? */
1601 int reverse = EQ (Fcdr (Fassq (Qreverse, FVAR (f, param_alist))), Qt); 1601 int reverse = EQ (Fcdr (Fassq (Qreverse, FVAR (f, param_alist))), Qt);
1602 int redraw = 0, fg_set = 0, bg_set = 0; 1602 int redraw = 0, fg_set = 0, bg_set = 0;
@@ -2435,9 +2435,9 @@ and then the scan code. */)
2435 { 2435 {
2436 val = Fvector (NUM_RECENT_DOSKEYS, keys); 2436 val = Fvector (NUM_RECENT_DOSKEYS, keys);
2437 memcpy (XVECTOR (val)->contents, keys + recent_doskeys_index, 2437 memcpy (XVECTOR (val)->contents, keys + recent_doskeys_index,
2438 (NUM_RECENT_DOSKEYS - recent_doskeys_index) * sizeof (Lisp_Object)); 2438 (NUM_RECENT_DOSKEYS - recent_doskeys_index) * word_size);
2439 memcpy (XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index, 2439 memcpy (XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index,
2440 keys, recent_doskeys_index * sizeof (Lisp_Object)); 2440 keys, recent_doskeys_index * word_size);
2441 return val; 2441 return val;
2442 } 2442 }
2443} 2443}
diff --git a/src/w32menu.c b/src/w32menu.c
index 67bd575258e..f6b7e62049a 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -276,7 +276,7 @@ menubar_selection_callback (FRAME_PTR f, void * client_data)
276 if (!f) 276 if (!f)
277 return; 277 return;
278 entry = Qnil; 278 entry = Qnil;
279 subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object)); 279 subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * word_size);
280 vector = FVAR (f, menu_bar_vector); 280 vector = FVAR (f, menu_bar_vector);
281 prefix = Qnil; 281 prefix = Qnil;
282 i = 0; 282 i = 0;
@@ -387,7 +387,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
387 int previous_menu_items_used = f->menu_bar_items_used; 387 int previous_menu_items_used = f->menu_bar_items_used;
388 Lisp_Object *previous_items 388 Lisp_Object *previous_items
389 = (Lisp_Object *) alloca (previous_menu_items_used 389 = (Lisp_Object *) alloca (previous_menu_items_used
390 * sizeof (Lisp_Object)); 390 * word_size);
391 391
392 /* If we are making a new widget, its contents are empty, 392 /* If we are making a new widget, its contents are empty,
393 do always reinitialize them. */ 393 do always reinitialize them. */
@@ -420,7 +420,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
420 /* Save the frame's previous menu bar contents data. */ 420 /* Save the frame's previous menu bar contents data. */
421 if (previous_menu_items_used) 421 if (previous_menu_items_used)
422 memcpy (previous_items, XVECTOR (FVAR (f, menu_bar_vector))->contents, 422 memcpy (previous_items, XVECTOR (FVAR (f, menu_bar_vector))->contents,
423 previous_menu_items_used * sizeof (Lisp_Object)); 423 previous_menu_items_used * word_size);
424 424
425 /* Fill in menu_items with the current menu bar contents. 425 /* Fill in menu_items with the current menu bar contents.
426 This can evaluate Lisp code. */ 426 This can evaluate Lisp code. */
@@ -665,7 +665,7 @@ w32_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
665 widget_value **submenu_stack 665 widget_value **submenu_stack
666 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); 666 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
667 Lisp_Object *subprefix_stack 667 Lisp_Object *subprefix_stack
668 = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object)); 668 = (Lisp_Object *) alloca (menu_items_used * word_size);
669 int submenu_depth = 0; 669 int submenu_depth = 0;
670 int first_pane; 670 int first_pane;
671 671
diff --git a/src/w32term.h b/src/w32term.h
index c0a958ba5e5..ccbf3c42c0e 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -429,7 +429,7 @@ struct scroll_bar {
429#define SCROLL_BAR_VEC_SIZE \ 429#define SCROLL_BAR_VEC_SIZE \
430 ((sizeof (struct scroll_bar) \ 430 ((sizeof (struct scroll_bar) \
431 - sizeof (EMACS_INT) - sizeof (struct Lisp_Vector *)) \ 431 - sizeof (EMACS_INT) - sizeof (struct Lisp_Vector *)) \
432 / sizeof (Lisp_Object)) 432 / word_size)
433 433
434/* Turning a lisp vector value into a pointer to a struct scroll_bar. */ 434/* Turning a lisp vector value into a pointer to a struct scroll_bar. */
435#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec)) 435#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
diff --git a/src/window.c b/src/window.c
index beabc28cf6d..f4f6e3c2eee 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3263,7 +3263,7 @@ make_parent_window (Lisp_Object window, int horflag)
3263 p = allocate_window (); 3263 p = allocate_window ();
3264 memcpy ((char *) p + sizeof (struct vectorlike_header), 3264 memcpy ((char *) p + sizeof (struct vectorlike_header),
3265 (char *) o + sizeof (struct vectorlike_header), 3265 (char *) o + sizeof (struct vectorlike_header),
3266 sizeof (Lisp_Object) * VECSIZE (struct window)); 3266 word_size * VECSIZE (struct window));
3267 XSETWINDOW (parent, p); 3267 XSETWINDOW (parent, p);
3268 3268
3269 p->sequence_number = ++sequence_number; 3269 p->sequence_number = ++sequence_number;
diff --git a/src/xdisp.c b/src/xdisp.c
index 2af15acbe65..300e16bb4a8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2420,7 +2420,7 @@ safe_call (ptrdiff_t nargs, Lisp_Object func, ...)
2420 ptrdiff_t i; 2420 ptrdiff_t i;
2421 ptrdiff_t count = SPECPDL_INDEX (); 2421 ptrdiff_t count = SPECPDL_INDEX ();
2422 struct gcpro gcpro1; 2422 struct gcpro gcpro1;
2423 Lisp_Object *args = alloca (nargs * sizeof (Lisp_Object)); 2423 Lisp_Object *args = alloca (nargs * word_size);
2424 2424
2425 args[0] = func; 2425 args[0] = func;
2426 va_start (ap, func); 2426 va_start (ap, func);
diff --git a/src/xfaces.c b/src/xfaces.c
index df6cf6a3684..6aab7edd5f2 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1657,7 +1657,7 @@ the face font sort order. */)
1657 vec = Fvconcat (ndrivers, drivers); 1657 vec = Fvconcat (ndrivers, drivers);
1658 nfonts = ASIZE (vec); 1658 nfonts = ASIZE (vec);
1659 1659
1660 qsort (XVECTOR (vec)->contents, nfonts, sizeof (Lisp_Object), 1660 qsort (XVECTOR (vec)->contents, nfonts, word_size,
1661 compare_fonts_by_sort_order); 1661 compare_fonts_by_sort_order);
1662 1662
1663 result = Qnil; 1663 result = Qnil;
@@ -2768,7 +2768,7 @@ The value is TO. */)
2768 } 2768 }
2769 2769
2770 memcpy (XVECTOR (copy)->contents, XVECTOR (lface)->contents, 2770 memcpy (XVECTOR (copy)->contents, XVECTOR (lface)->contents,
2771 LFACE_VECTOR_SIZE * sizeof (Lisp_Object)); 2771 LFACE_VECTOR_SIZE * word_size);
2772 2772
2773 /* Changing a named face means that all realized faces depending on 2773 /* Changing a named face means that all realized faces depending on
2774 that face are invalid. Since we cannot tell which realized faces 2774 that face are invalid. Since we cannot tell which realized faces
diff --git a/src/xfont.c b/src/xfont.c
index 1ebac6100f2..e3e2eb18c29 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -464,11 +464,11 @@ xfont_list_pattern (Display *display, const char *pattern,
464 continue; 464 continue;
465 } 465 }
466 if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX), 466 if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
467 sizeof (Lisp_Object) * 7) 467 word_size * 7)
468 || ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7])) 468 || ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7]))
469 { 469 {
470 memcpy (props, aref_addr (entity, FONT_FOUNDRY_INDEX), 470 memcpy (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
471 sizeof (Lisp_Object) * 7); 471 word_size * 7);
472 props[7] = AREF (entity, FONT_SPACING_INDEX); 472 props[7] = AREF (entity, FONT_SPACING_INDEX);
473 scripts = xfont_supported_scripts (display, indices[i], 473 scripts = xfont_supported_scripts (display, indices[i],
474 xfont_scratch_props, encoding); 474 xfont_scratch_props, encoding);
diff --git a/src/xmenu.c b/src/xmenu.c
index e7ed9d69627..eff4bb1ccd0 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1015,7 +1015,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
1015 /* Save the frame's previous menu bar contents data. */ 1015 /* Save the frame's previous menu bar contents data. */
1016 if (previous_menu_items_used) 1016 if (previous_menu_items_used)
1017 memcpy (previous_items, XVECTOR (FVAR (f, menu_bar_vector))->contents, 1017 memcpy (previous_items, XVECTOR (FVAR (f, menu_bar_vector))->contents,
1018 previous_menu_items_used * sizeof (Lisp_Object)); 1018 previous_menu_items_used * word_size);
1019 1019
1020 /* Fill in menu_items with the current menu bar contents. 1020 /* Fill in menu_items with the current menu bar contents.
1021 This can evaluate Lisp code. */ 1021 This can evaluate Lisp code. */