summaryrefslogtreecommitdiff
path: root/src/pdumper.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-04-01 11:54:23 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-04-01 12:02:37 -0700
commit9287813da1ae9076f29be111674d1795bee66447 (patch)
treed48781deb3ccc24f40de2944efdccc6a84280fd5 /src/pdumper.c
parent197fbfc71f49b307baa3831a30732c3a0c4c7420 (diff)
downloademacs-9287813da1ae9076f29be111674d1795bee66447.tar.gz
Fix union Lisp_Fwd * alignment bug
It's not portable to cast (e.g.) struct Lisp_Objfwd * to union Lisp_Fwd * and then back again, because the compiler can then assume that the pointer is aligned for union Lisp_Fwd * when accessing the struct Lisp_Objfwd * components, and this assumption might be incorrect becase we don't force that alignment. * src/lisp.h (lispfwd): New type, replacing ... (union Lisp_Fwd): ... this type, which was removed. All uses changed. (SET_SYMBOL_FWD): 2nd arg is now void *, not lispfwd. All uses changed (casts no longer needed; they were not portable anyway).
Diffstat (limited to 'src/pdumper.c')
-rw-r--r--src/pdumper.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/pdumper.c b/src/pdumper.c
index a9b3732a2d4..53a10b62b3f 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2334,32 +2334,30 @@ dump_fwd_kboard_obj (struct dump_context *ctx,
}
static dump_off
-dump_fwd (struct dump_context *ctx, union Lisp_Fwd *fwd)
+dump_fwd (struct dump_context *ctx, lispfwd fwd)
{
-#if CHECK_STRUCTS && !defined (HASH_Lisp_Fwd_5227B18E87)
-# error "Lisp_Fwd changed. See CHECK_STRUCTS comment."
-#endif
#if CHECK_STRUCTS && !defined (HASH_Lisp_Fwd_Type_9CBA6EE55E)
# error "Lisp_Fwd_Type changed. See CHECK_STRUCTS comment."
#endif
+ void const *p = fwd.fwdptr;
dump_off offset;
switch (XFWDTYPE (fwd))
{
case Lisp_Fwd_Int:
- offset = dump_fwd_int (ctx, &fwd->u_intfwd);
+ offset = dump_fwd_int (ctx, p);
break;
case Lisp_Fwd_Bool:
- offset = dump_fwd_bool (ctx, &fwd->u_boolfwd);
+ offset = dump_fwd_bool (ctx, p);
break;
case Lisp_Fwd_Obj:
- offset = dump_fwd_obj (ctx, &fwd->u_objfwd);
+ offset = dump_fwd_obj (ctx, p);
break;
case Lisp_Fwd_Buffer_Obj:
- offset = dump_fwd_buffer_obj (ctx, &fwd->u_buffer_objfwd);
+ offset = dump_fwd_buffer_obj (ctx, p);
break;
case Lisp_Fwd_Kboard_Obj:
- offset = dump_fwd_kboard_obj (ctx, &fwd->u_kboard_objfwd);
+ offset = dump_fwd_kboard_obj (ctx, p);
break;
default:
emacs_abort ();
@@ -2372,20 +2370,20 @@ static dump_off
dump_blv (struct dump_context *ctx,
const struct Lisp_Buffer_Local_Value *blv)
{
-#if CHECK_STRUCTS && !defined (HASH_Lisp_Buffer_Local_Value_066F33A92E)
+#if CHECK_STRUCTS && !defined HASH_Lisp_Buffer_Local_Value_3C363FAC3C
# error "Lisp_Buffer_Local_Value changed. See CHECK_STRUCTS comment."
#endif
struct Lisp_Buffer_Local_Value out;
dump_object_start (ctx, &out, sizeof (out));
DUMP_FIELD_COPY (&out, blv, local_if_set);
DUMP_FIELD_COPY (&out, blv, found);
- if (blv->fwd)
- dump_field_fixup_later (ctx, &out, blv, &blv->fwd);
+ if (blv->fwd.fwdptr)
+ dump_field_fixup_later (ctx, &out, blv, &blv->fwd.fwdptr);
dump_field_lv (ctx, &out, blv, &blv->where, WEIGHT_NORMAL);
dump_field_lv (ctx, &out, blv, &blv->defcell, WEIGHT_STRONG);
dump_field_lv (ctx, &out, blv, &blv->valcell, WEIGHT_STRONG);
dump_off offset = dump_object_finish (ctx, &out, sizeof (out));
- if (blv->fwd)
+ if (blv->fwd.fwdptr)
dump_remember_fixup_ptr_raw
(ctx,
offset + dump_offsetof (struct Lisp_Buffer_Local_Value, fwd),
@@ -2437,7 +2435,7 @@ dump_symbol (struct dump_context *ctx,
Lisp_Object object,
dump_off offset)
{
-#if CHECK_STRUCTS && !defined (HASH_Lisp_Symbol_60EA1E748E)
+#if CHECK_STRUCTS && !defined HASH_Lisp_Symbol_999DC26DEC
# error "Lisp_Symbol changed. See CHECK_STRUCTS comment."
#endif
#if CHECK_STRUCTS && !defined (HASH_symbol_redirect_ADB4F5B113)