aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2018-11-20 15:15:41 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2018-11-20 15:15:41 +0100
commitb7fe793fd2427e233ac3da64d0d50334f75a81e6 (patch)
treee038abb9024ee2b2c329b7620e601a1f3ed4369c
parent2ac731d8c35d8dc367f72b95aad97061b2229f59 (diff)
downloadcompcert-b7fe793fd2427e233ac3da64d0d50334f75a81e6.tar.gz
compcert-b7fe793fd2427e233ac3da64d0d50334f75a81e6.zip
Fix fixme in PackedStructs.
Instead of relying testing that the size of pointers is 64bit the size of registers should be tested. Also it should be a fatal error to reverse a long long on an architecture that does not support reverse 64bit read/writes. Bug 24982
-rw-r--r--cparser/PackedStructs.ml8
1 files changed, 4 insertions, 4 deletions
diff --git a/cparser/PackedStructs.ml b/cparser/PackedStructs.ml
index a2c91c0a..3c27f3a9 100644
--- a/cparser/PackedStructs.ml
+++ b/cparser/PackedStructs.ml
@@ -36,7 +36,7 @@ let byteswapped_fields : (ident * string, unit) Hashtbl.t
let rec can_byte_swap env ty =
match unroll env ty with
- | TInt(ik, _) -> (sizeof_ikind ik <= !config.sizeof_ptr (*FIXME*), sizeof_ikind ik > 1)
+ | TInt(ik, _) -> (sizeof_ikind ik <= !config.sizeof_intreg, sizeof_ikind ik > 1)
| TEnum(_, _) -> (true, sizeof_ikind enum_ikind > 1)
| TPtr(_, _) -> (true, true) (* tolerance? *)
| TArray(ty_elt, _, _) -> can_byte_swap env ty_elt
@@ -66,7 +66,7 @@ let transf_field_decl mfa swapped loc env struct_id f =
if swapped then begin
let (can_swap, must_swap) = can_byte_swap env f.fld_typ in
if not can_swap then
- error loc "cannot byte-swap field of type '%a'"
+ fatal_error loc "cannot byte-swap field of type '%a'"
Cprint.typ f.fld_typ;
if must_swap then
Hashtbl.add byteswapped_fields (struct_id, f.fld_name) ()
@@ -141,7 +141,7 @@ let use_reversed = ref false
let bswap_read loc env lval =
let ty = lval.etyp in
let (bsize, aty) = accessor_type loc env ty in
- assert (bsize = 16 || bsize = 32 || (bsize = 64 && !config.sizeof_ptr = 8));
+ assert (bsize = 16 || bsize = 32 || (bsize = 64 && !config.sizeof_intreg = 8));
try
if !use_reversed then begin
let (id, fty) =
@@ -168,7 +168,7 @@ let bswap_write loc env lhs rhs =
let ty = lhs.etyp in
let (bsize, aty) =
accessor_type loc env ty in
- assert (bsize = 16 || bsize = 32 || (bsize = 64 && !config.sizeof_ptr = 8));
+ assert (bsize = 16 || bsize = 32 || (bsize = 64 && !config.sizeof_intreg = 8));
try
if !use_reversed then begin
let (id, fty) =