Commit 663e2b3f authored by Dmitry Antipov's avatar Dmitry Antipov

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.
parent 777fe95e
2012-08-05 Dmitry Antipov <dmantipov@yandex.ru>
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.
2012-08-05 Lawrence Mitchell <wence@gmx.li> 2012-08-05 Lawrence Mitchell <wence@gmx.li>
* search.c (Freplace_match): Treat \? in the replacement text * search.c (Freplace_match): Treat \? in the replacement text
......
...@@ -155,7 +155,7 @@ static pthread_mutex_t alloc_mutex; ...@@ -155,7 +155,7 @@ static pthread_mutex_t alloc_mutex;
/* Default value of gc_cons_threshold (see below). */ /* Default value of gc_cons_threshold (see below). */
#define GC_DEFAULT_THRESHOLD (100000 * sizeof (Lisp_Object)) #define GC_DEFAULT_THRESHOLD (100000 * word_size)
/* Global variables. */ /* Global variables. */
struct emacs_globals globals; struct emacs_globals globals;
...@@ -278,14 +278,6 @@ static void sweep_strings (void); ...@@ -278,14 +278,6 @@ static void sweep_strings (void);
static void free_misc (Lisp_Object); static void free_misc (Lisp_Object);
extern Lisp_Object which_symbols (Lisp_Object, EMACS_INT) EXTERNALLY_VISIBLE; extern Lisp_Object which_symbols (Lisp_Object, EMACS_INT) EXTERNALLY_VISIBLE;
/* Handy constants for vectorlike objects. */
enum
{
header_size = offsetof (struct Lisp_Vector, contents),
bool_header_size = offsetof (struct Lisp_Bool_Vector, data),
word_size = sizeof (Lisp_Object)
};
/* When scanning the C stack for live Lisp objects, Emacs keeps track /* When scanning the C stack for live Lisp objects, Emacs keeps track
of what memory allocated via lisp_malloc is intended for what of what memory allocated via lisp_malloc is intended for what
purpose. This enumeration specifies the type of memory. */ purpose. This enumeration specifies the type of memory. */
...@@ -2810,9 +2802,9 @@ listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...) ...@@ -2810,9 +2802,9 @@ listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...)
Lisp_Object val, *objp; Lisp_Object val, *objp;
/* Change to SAFE_ALLOCA if you hit this eassert. */ /* Change to SAFE_ALLOCA if you hit this eassert. */
eassert (count <= MAX_ALLOCA / sizeof (Lisp_Object)); eassert (count <= MAX_ALLOCA / word_size);
objp = alloca (count * sizeof (Lisp_Object)); objp = alloca (count * word_size);
objp[0] = arg; objp[0] = arg;
va_start (ap, arg); va_start (ap, arg);
for (i = 1; i < count; i++) for (i = 1; i < count; i++)
......
...@@ -99,7 +99,7 @@ static Lisp_Object Vbuffer_local_symbols; ...@@ -99,7 +99,7 @@ static Lisp_Object Vbuffer_local_symbols;
/* Maximum length of an overlay vector. */ /* Maximum length of an overlay vector. */
#define OVERLAY_COUNT_MAX \ #define OVERLAY_COUNT_MAX \
((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, \ ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, \
min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object))) min (PTRDIFF_MAX, SIZE_MAX) / word_size))
/* Flags indicating which built-in buffer-local variables /* Flags indicating which built-in buffer-local variables
are permanent locals. */ are permanent locals. */
...@@ -4267,7 +4267,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, ...@@ -4267,7 +4267,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after,
ptrdiff_t i; ptrdiff_t i;
memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents,
size * sizeof (Lisp_Object)); size * word_size);
gcpro1.var = copy; gcpro1.var = copy;
gcpro1.nvars = size; gcpro1.nvars = size;
...@@ -4886,8 +4886,7 @@ init_buffer_once (void) ...@@ -4886,8 +4886,7 @@ init_buffer_once (void)
sure that this is still correct. Otherwise, mark_vectorlike may not sure that this is still correct. Otherwise, mark_vectorlike may not
trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */ trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */
const int pvecsize const int pvecsize
= (offsetof (struct buffer, own_text) - sizeof (struct vectorlike_header)) = (offsetof (struct buffer, own_text) - header_size) / word_size;
/ sizeof (Lisp_Object);
memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags); memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags);
...@@ -4972,7 +4971,7 @@ init_buffer_once (void) ...@@ -4972,7 +4971,7 @@ init_buffer_once (void)
The local flag bits are in the local_var_flags slot of the buffer. */ The local flag bits are in the local_var_flags slot of the buffer. */
/* Nothing can work if this isn't true */ /* Nothing can work if this isn't true */
{ verify (sizeof (EMACS_INT) == sizeof (Lisp_Object)); } { verify (sizeof (EMACS_INT) == word_size); }
/* 0 means not a lisp var, -1 means always local, else mask */ /* 0 means not a lisp var, -1 means always local, else mask */
memset (&buffer_local_flags, 0, sizeof buffer_local_flags); memset (&buffer_local_flags, 0, sizeof buffer_local_flags);
......
...@@ -1029,7 +1029,7 @@ extern int last_per_buffer_idx; ...@@ -1029,7 +1029,7 @@ extern int last_per_buffer_idx;
#define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \ #define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \
for (offset = PER_BUFFER_VAR_OFFSET (name); \ for (offset = PER_BUFFER_VAR_OFFSET (name); \
offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \
offset += sizeof (Lisp_Object)) offset += word_size)
/* Return the index of buffer-local variable VAR. Each per-buffer /* Return the index of buffer-local variable VAR. Each per-buffer
variable has an index > 0 associated with it, except when it always variable has an index > 0 associated with it, except when it always
......
...@@ -536,7 +536,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, ...@@ -536,7 +536,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
stack.byte_string = bytestr; stack.byte_string = bytestr;
stack.pc = stack.byte_string_start = SDATA (bytestr); stack.pc = stack.byte_string_start = SDATA (bytestr);
stack.constants = vector; stack.constants = vector;
if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth)) if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth))
memory_full (SIZE_MAX); memory_full (SIZE_MAX);
top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top);
#if BYTE_MAINTAIN_TOP #if BYTE_MAINTAIN_TOP
......
...@@ -465,7 +465,7 @@ invoke it. If KEYS is omitted or nil, the return value of ...@@ -465,7 +465,7 @@ invoke it. If KEYS is omitted or nil, the return value of
} }
if (min (MOST_POSITIVE_FIXNUM, if (min (MOST_POSITIVE_FIXNUM,
min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) min (PTRDIFF_MAX, SIZE_MAX) / word_size)
< nargs) < nargs)
memory_full (SIZE_MAX); memory_full (SIZE_MAX);
......
...@@ -2301,7 +2301,7 @@ usage: (apply FUNCTION &rest ARGUMENTS) */) ...@@ -2301,7 +2301,7 @@ usage: (apply FUNCTION &rest ARGUMENTS) */)
gcpro1.nvars = 1 + numargs; gcpro1.nvars = 1 + numargs;
} }
memcpy (funcall_args, args, nargs * sizeof (Lisp_Object)); memcpy (funcall_args, args, nargs * word_size);
/* Spread the last arg we got. Its first element goes in /* Spread the last arg we got. Its first element goes in
the slot that it used to occupy, hence this value of I. */ the slot that it used to occupy, hence this value of I. */
i = nargs - 1; i = nargs - 1;
...@@ -2794,7 +2794,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) ...@@ -2794,7 +2794,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
{ {
internal_args = alloca (XSUBR (fun)->max_args internal_args = alloca (XSUBR (fun)->max_args
* sizeof *internal_args); * sizeof *internal_args);
memcpy (internal_args, args + 1, numargs * sizeof (Lisp_Object)); memcpy (internal_args, args + 1, numargs * word_size);
for (i = numargs; i < XSUBR (fun)->max_args; i++) for (i = numargs; i < XSUBR (fun)->max_args; i++)
internal_args[i] = Qnil; internal_args[i] = Qnil;
} }
......
...@@ -3569,7 +3569,7 @@ hashfn_user_defined (struct Lisp_Hash_Table *h, Lisp_Object key) ...@@ -3569,7 +3569,7 @@ hashfn_user_defined (struct Lisp_Hash_Table *h, Lisp_Object key)
/* An upper bound on the size of a hash table index. It must fit in /* An upper bound on the size of a hash table index. It must fit in
ptrdiff_t and be a valid Emacs fixnum. */ ptrdiff_t and be a valid Emacs fixnum. */
#define INDEX_SIZE_BOUND \ #define INDEX_SIZE_BOUND \
((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, PTRDIFF_MAX / sizeof (Lisp_Object))) ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, PTRDIFF_MAX / word_size))
/* Create and initialize a new hash table. /* Create and initialize a new hash table.
......
...@@ -2138,7 +2138,7 @@ static Lisp_Object ...@@ -2138,7 +2138,7 @@ static Lisp_Object
font_vconcat_entity_vectors (Lisp_Object list) font_vconcat_entity_vectors (Lisp_Object list)
{ {
int nargs = XINT (Flength (list)); int nargs = XINT (Flength (list));
Lisp_Object *args = alloca (sizeof (Lisp_Object) * nargs); Lisp_Object *args = alloca (word_size * nargs);
int i; int i;
for (i = 0; i < nargs; i++, list = XCDR (list)) for (i = 0; i < nargs; i++, list = XCDR (list))
......
...@@ -429,7 +429,7 @@ reorder_font_vector (Lisp_Object font_group, struct font *font) ...@@ -429,7 +429,7 @@ reorder_font_vector (Lisp_Object font_group, struct font *font)
} }
if (score_changed) if (score_changed)
qsort (XVECTOR (vec)->contents, size, sizeof (Lisp_Object), qsort (XVECTOR (vec)->contents, size, word_size,
fontset_compare_rfontdef); fontset_compare_rfontdef);
XSETCAR (font_group, make_number (charset_ordered_list_tick)); XSETCAR (font_group, make_number (charset_ordered_list_tick));
} }
...@@ -1893,7 +1893,7 @@ format is the same as above. */) ...@@ -1893,7 +1893,7 @@ format is the same as above. */)
/* Recode fontsets realized on FRAME from the base fontset FONTSET /* Recode fontsets realized on FRAME from the base fontset FONTSET
in the table `realized'. */ in the table `realized'. */
realized[0] = alloca (sizeof (Lisp_Object) * ASIZE (Vfontset_table)); realized[0] = alloca (word_size * ASIZE (Vfontset_table));
for (i = j = 0; i < ASIZE (Vfontset_table); i++) for (i = j = 0; i < ASIZE (Vfontset_table); i++)
{ {
elt = FONTSET_FROM_ID (i); elt = FONTSET_FROM_ID (i);
...@@ -1904,7 +1904,7 @@ format is the same as above. */) ...@@ -1904,7 +1904,7 @@ format is the same as above. */)
} }
realized[0][j] = Qnil; realized[0][j] = Qnil;
realized[1] = alloca (sizeof (Lisp_Object) * ASIZE (Vfontset_table)); realized[1] = alloca (word_size * ASIZE (Vfontset_table));
for (i = j = 0; ! NILP (realized[0][i]); i++) for (i = j = 0; ! NILP (realized[0][i]); i++)
{ {
elt = FONTSET_DEFAULT (realized[0][i]); elt = FONTSET_DEFAULT (realized[0][i]);
......
...@@ -7527,7 +7527,7 @@ menu_bar_items (Lisp_Object old) ...@@ -7527,7 +7527,7 @@ menu_bar_items (Lisp_Object old)
if (end > i + 4) if (end > i + 4)
memmove (aref_addr (menu_bar_items_vector, i), memmove (aref_addr (menu_bar_items_vector, i),
aref_addr (menu_bar_items_vector, i + 4), aref_addr (menu_bar_items_vector, i + 4),
(end - i - 4) * sizeof (Lisp_Object)); (end - i - 4) * word_size);
ASET (menu_bar_items_vector, end - 4, tem0); ASET (menu_bar_items_vector, end - 4, tem0);
ASET (menu_bar_items_vector, end - 3, tem1); ASET (menu_bar_items_vector, end - 3, tem1);
ASET (menu_bar_items_vector, end - 2, tem2); 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,7 +7577,7 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
if (menu_bar_items_index > i + 4) if (menu_bar_items_index > i + 4)
memmove (aref_addr (menu_bar_items_vector, i), memmove (aref_addr (menu_bar_items_vector, i),
aref_addr (menu_bar_items_vector, i + 4), aref_addr (menu_bar_items_vector, i + 4),
(menu_bar_items_index - i - 4) * sizeof (Lisp_Object)); (menu_bar_items_index - i - 4) * word_size);
menu_bar_items_index -= 4; menu_bar_items_index -= 4;
} }
} }
...@@ -8082,7 +8082,7 @@ process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void ...@@ -8082,7 +8082,7 @@ process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void
if (ntool_bar_items > i + TOOL_BAR_ITEM_NSLOTS) if (ntool_bar_items > i + TOOL_BAR_ITEM_NSLOTS)
memmove (v, v + TOOL_BAR_ITEM_NSLOTS, memmove (v, v + TOOL_BAR_ITEM_NSLOTS,
((ntool_bar_items - i - TOOL_BAR_ITEM_NSLOTS) ((ntool_bar_items - i - TOOL_BAR_ITEM_NSLOTS)
* sizeof (Lisp_Object))); * word_size));
ntool_bar_items -= TOOL_BAR_ITEM_NSLOTS; ntool_bar_items -= TOOL_BAR_ITEM_NSLOTS;
break; break;
} }
...@@ -10425,9 +10425,9 @@ DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0, ...@@ -10425,9 +10425,9 @@ DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0,
{ {
val = Fvector (NUM_RECENT_KEYS, keys); val = Fvector (NUM_RECENT_KEYS, keys);
memcpy (XVECTOR (val)->contents, keys + recent_keys_index, memcpy (XVECTOR (val)->contents, keys + recent_keys_index,
(NUM_RECENT_KEYS - recent_keys_index) * sizeof (Lisp_Object)); (NUM_RECENT_KEYS - recent_keys_index) * word_size);
memcpy (XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index, memcpy (XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index,
keys, recent_keys_index * sizeof (Lisp_Object)); keys, recent_keys_index * word_size);
return val; return val;
} }
} }
......
...@@ -2069,7 +2069,7 @@ The `kbd' macro is an approximate inverse of this. */) ...@@ -2069,7 +2069,7 @@ The `kbd' macro is an approximate inverse of this. */)
size += XINT (Flength (prefix)); size += XINT (Flength (prefix));
/* This has one extra element at the end that we don't pass to Fconcat. */ /* This has one extra element at the end that we don't pass to Fconcat. */
if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object) / 4 < size) if (min (PTRDIFF_MAX, SIZE_MAX) / word_size / 4 < size)
memory_full (SIZE_MAX); memory_full (SIZE_MAX);
SAFE_ALLOCA_LISP (args, size * 4); SAFE_ALLOCA_LISP (args, size * 4);
......
...@@ -824,25 +824,49 @@ struct vectorlike_header ...@@ -824,25 +824,49 @@ struct vectorlike_header
} next; } next;
}; };
/* Regular vector is just a header plus array of Lisp_Objects. */
struct Lisp_Vector struct Lisp_Vector
{ {
struct vectorlike_header header; struct vectorlike_header header;
Lisp_Object contents[1]; Lisp_Object contents[1];
}; };
/* A boolvector is a kind of vectorlike, with contents are like a string. */
struct Lisp_Bool_Vector
{
/* HEADER.SIZE is the vector's size field. It doesn't have the real size,
just the subtype information. */
struct vectorlike_header header;
/* This is the size in bits. */
EMACS_INT size;
/* This contains the actual bits, packed into bytes. */
unsigned char data[1];
};
/* Some handy constants for calculating sizes
and offsets, mostly of vectorlike objects. */
enum
{
header_size = offsetof (struct Lisp_Vector, contents),
bool_header_size = offsetof (struct Lisp_Bool_Vector, data),
word_size = sizeof (Lisp_Object)
};
/* If a struct is made to look like a vector, this macro returns the length /* If a struct is made to look like a vector, this macro returns the length
of the shortest vector that would hold that struct. */ of the shortest vector that would hold that struct. */
#define VECSIZE(type) ((sizeof (type) \
- offsetof (struct Lisp_Vector, contents[0]) \ #define VECSIZE(type) \
+ sizeof (Lisp_Object) - 1) /* Round up. */ \ ((sizeof (type) - header_size + word_size - 1) / word_size)
/ sizeof (Lisp_Object))
/* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields /* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields
at the end and we need to compute the number of Lisp_Object fields (the at the end and we need to compute the number of Lisp_Object fields (the
ones that the GC needs to trace). */ ones that the GC needs to trace). */
#define PSEUDOVECSIZE(type, nonlispfield) \
((offsetof (type, nonlispfield) - offsetof (struct Lisp_Vector, contents[0])) \ #define PSEUDOVECSIZE(type, nonlispfield) \
/ sizeof (Lisp_Object)) ((offsetof (type, nonlispfield) - header_size) / word_size)
/* A char-table is a kind of vectorlike, with contents are like a /* A char-table is a kind of vectorlike, with contents are like a
vector but with a few other slots. For some purposes, it makes vector but with a few other slots. For some purposes, it makes
...@@ -978,18 +1002,6 @@ struct Lisp_Sub_Char_Table ...@@ -978,18 +1002,6 @@ struct Lisp_Sub_Char_Table
Lisp_Object contents[1]; Lisp_Object contents[1];
}; };
/* A boolvector is a kind of vectorlike, with contents are like a string. */
struct Lisp_Bool_Vector
{
/* HEADER.SIZE is the vector's size field. It doesn't have the real size,
just the subtype information. */
struct vectorlike_header header;
/* This is the size in bits. */
EMACS_INT size;
/* This contains the actual bits, packed into bytes. */
unsigned char data[1];
};
/* This structure describes a built-in function. /* This structure describes a built-in function.
It is generated by the DEFUN macro only. It is generated by the DEFUN macro only.
defsubr makes it into a Lisp object. defsubr makes it into a Lisp object.
...@@ -3483,21 +3495,21 @@ extern void *record_xmalloc (size_t); ...@@ -3483,21 +3495,21 @@ extern void *record_xmalloc (size_t);
/* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */ /* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */
#define SAFE_ALLOCA_LISP(buf, nelt) \ #define SAFE_ALLOCA_LISP(buf, nelt) \
do { \ do { \
if ((nelt) < MAX_ALLOCA / sizeof (Lisp_Object)) \ if ((nelt) < MAX_ALLOCA / word_size) \
buf = alloca ((nelt) * sizeof (Lisp_Object)); \ buf = alloca ((nelt) * word_size); \
else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \ else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / word_size) \
{ \ { \
Lisp_Object arg_; \ Lisp_Object arg_; \
buf = xmalloc ((nelt) * sizeof (Lisp_Object)); \ buf = xmalloc ((nelt) * word_size); \
arg_ = make_save_value (buf, nelt); \ arg_ = make_save_value (buf, nelt); \
XSAVE_VALUE (arg_)->dogc = 1; \ XSAVE_VALUE (arg_)->dogc = 1; \
sa_must_free = 1; \ sa_must_free = 1; \
record_unwind_protect (safe_alloca_unwind, arg_); \ record_unwind_protect (safe_alloca_unwind, arg_); \
} \ } \
else \ else \
memory_full (SIZE_MAX); \ memory_full (SIZE_MAX); \
} while (0) } while (0)
......
...@@ -63,7 +63,7 @@ macro before appending to it. */) ...@@ -63,7 +63,7 @@ macro before appending to it. */)
if (!current_kboard->kbd_macro_buffer) if (!current_kboard->kbd_macro_buffer)
{ {
current_kboard->kbd_macro_buffer = xmalloc (30 * sizeof (Lisp_Object)); current_kboard->kbd_macro_buffer = xmalloc (30 * word_size);
current_kboard->kbd_macro_bufsize = 30; current_kboard->kbd_macro_bufsize = 30;
} }
update_mode_lines++; update_mode_lines++;
...@@ -73,7 +73,7 @@ macro before appending to it. */) ...@@ -73,7 +73,7 @@ macro before appending to it. */)
{ {
current_kboard->kbd_macro_buffer current_kboard->kbd_macro_buffer
= xrealloc (current_kboard->kbd_macro_buffer, = xrealloc (current_kboard->kbd_macro_buffer,
30 * sizeof (Lisp_Object)); 30 * word_size);
current_kboard->kbd_macro_bufsize = 30; current_kboard->kbd_macro_bufsize = 30;
} }
current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_buffer; current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_buffer;
......
...@@ -976,7 +976,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data) ...@@ -976,7 +976,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data)
prefix = entry = Qnil; prefix = entry = Qnil;
i = 0; i = 0;
subprefix_stack = alloca (menu_items_used * sizeof (Lisp_Object)); subprefix_stack = alloca (menu_items_used * word_size);
while (i < menu_items_used) while (i < menu_items_used)
{ {
......
...@@ -1594,9 +1594,9 @@ IT_set_frame_parameters (struct frame *f, Lisp_Object alist) ...@@ -1594,9 +1594,9 @@ IT_set_frame_parameters (struct frame *f, Lisp_Object alist)
Lisp_Object tail; Lisp_Object tail;
int i, j, length = XINT (Flength (alist)); int i, j, length = XINT (Flength (alist));
Lisp_Object *parms Lisp_Object *parms
= (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); = (Lisp_Object *) alloca (length * word_size);
Lisp_Object *values Lisp_Object *values
= (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); = (Lisp_Object *) alloca (length * word_size);
/* Do we have to reverse the foreground and background colors? */ /* Do we have to reverse the foreground and background colors? */
int reverse = EQ (Fcdr (Fassq (Qreverse, FVAR (f, param_alist))), Qt); int reverse = EQ (Fcdr (Fassq (Qreverse, FVAR (f, param_alist))), Qt);
int redraw = 0, fg_set = 0, bg_set = 0; int redraw = 0, fg_set = 0, bg_set = 0;
...@@ -2435,9 +2435,9 @@ and then the scan code. */) ...@@ -2435,9 +2435,9 @@ and then the scan code. */)
{ {
val = Fvector (NUM_RECENT_DOSKEYS, keys); val = Fvector (NUM_RECENT_DOSKEYS, keys);
memcpy (XVECTOR (val)->contents, keys + recent_doskeys_index, memcpy (XVECTOR (val)->contents, keys + recent_doskeys_index,
(NUM_RECENT_DOSKEYS - recent_doskeys_index) * sizeof (Lisp_Object)); (NUM_RECENT_DOSKEYS - recent_doskeys_index) * word_size);
memcpy (XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index, memcpy (XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index,
keys, recent_doskeys_index * sizeof (Lisp_Object)); keys, recent_doskeys_index * word_size);
return val; return val;
} }
} }
......
...@@ -276,7 +276,7 @@ menubar_selection_callback (FRAME_PTR f, void * client_data) ...@@ -276,7 +276,7 @@ menubar_selection_callback (FRAME_PTR f, void * client_data)
if (!f) if (!f)
return; return;
entry = Qnil; entry = Qnil;
subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object)); subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * word_size);
vector = FVAR (f, menu_bar_vector); vector = FVAR (f, menu_bar_vector);
prefix = Qnil; prefix = Qnil;
i = 0; i = 0;
...@@ -387,7 +387,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) ...@@ -387,7 +387,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
int previous_menu_items_used = f->menu_bar_items_used; int previous_menu_items_used = f->menu_bar_items_used;
Lisp_Object *previous_items Lisp_Object *previous_items
= (Lisp_Object *) alloca (previous_menu_items_used = (Lisp_Object *) alloca (previous_menu_items_used
* sizeof (Lisp_Object)); * word_size);
/* If we are making a new widget, its contents are empty, /* If we are making a new widget, its contents are empty,
do always reinitialize them. */ do always reinitialize them. */
...@@ -420,7 +420,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) ...@@ -420,7 +420,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
/* Save the frame's previous menu bar contents data. */ /* Save the frame's previous menu bar contents data. */
if (previous_menu_items_used) if (previous_menu_items_used)
memcpy (previous_items, XVECTOR (FVAR (f, menu_bar_vector))->contents, memcpy (previous_items, XVECTOR (FVAR (f, menu_bar_vector))->contents,
previous_menu_items_used * sizeof (Lisp_Object)); previous_menu_items_used * word_size);
/* Fill in menu_items with the current menu bar contents. /* Fill in menu_items with the current menu bar contents.
This can evaluate Lisp code. */ 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,7 +665,7 @@ w32_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
widget_value **submenu_stack widget_value **submenu_stack
= (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
Lisp_Object *subprefix_stack Lisp_Object *subprefix_stack
= (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object)); = (Lisp_Object *) alloca (menu_items_used * word_size);
int submenu_depth = 0; int submenu_depth = 0;
int first_pane; int first_pane;
......
...@@ -429,7 +429,7 @@ struct scroll_bar { ...@@ -429,7 +429,7 @@ struct scroll_bar {
#define SCROLL_BAR_VEC_SIZE \ #define SCROLL_BAR_VEC_SIZE \
((sizeof (struct scroll_bar) \ ((sizeof (struct scroll_bar) \
- sizeof (EMACS_INT) - sizeof (struct Lisp_Vector *)) \ - sizeof (EMACS_INT) - sizeof (struct Lisp_Vector *)) \
/ sizeof (Lisp_Object)) / word_size)
/* Turning a lisp vector value into a pointer to a struct scroll_bar. */ /* Turning a lisp vector value into a pointer to a struct scroll_bar. */
#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec)) #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
......
...@@ -3263,7 +3263,7 @@ make_parent_window (Lisp_Object window, int horflag) ...@@ -3263,7 +3263,7 @@ make_parent_window (Lisp_Object window, int horflag)
p = allocate_window (); p = allocate_window ();
memcpy ((char *) p + sizeof (struct vectorlike_header), memcpy ((char *) p + sizeof (struct vectorlike_header),
(char *) o + sizeof (struct vectorlike_header), (char *) o + sizeof (struct vectorlike_header),
sizeof (Lisp_Object) * VECSIZE (struct window)); word_size * VECSIZE (struct window));
XSETWINDOW (parent, p); XSETWINDOW (parent, p);
p->sequence_number = ++sequence_number; p->sequence_number = ++sequence_number;
......
...@@ -2420,7 +2420,7 @@ safe_call (ptrdiff_t nargs, Lisp_Object func, ...) ...@@ -2420,7 +2420,7 @@ safe_call (ptrdiff_t nargs, Lisp_Object func, ...)
ptrdiff_t i; ptrdiff_t i;
ptrdiff_t count = SPECPDL_INDEX (); ptrdiff_t count = SPECPDL_INDEX ();
struct gcpro gcpro1; struct gcpro gcpro1;
Lisp_Object *args = alloca (nargs * sizeof (Lisp_Object)); Lisp_Object *args = alloca (nargs * word_size);
args[0] = func; args[0] = func;
va_start (ap, func); va_start (ap, func);
......
...@@ -1657,7 +1657,7 @@ the face font sort order. */) ...@@ -1657,7 +1657,7 @@ the face font sort order. */)