aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Bitfields.ml
diff options
context:
space:
mode:
Diffstat (limited to 'cparser/Bitfields.ml')
-rw-r--r--cparser/Bitfields.ml4
1 files changed, 2 insertions, 2 deletions
diff --git a/cparser/Bitfields.ml b/cparser/Bitfields.ml
index 7a00f719..6d4050f1 100644
--- a/cparser/Bitfields.ml
+++ b/cparser/Bitfields.ml
@@ -267,7 +267,7 @@ let bitfield_extract env bf carrier =
unsigned int bitfield_insert(unsigned int x, int ofs, int sz, unsigned int y)
{
unsigned int mask = ((1U << sz) - 1) << ofs;
- return (x & ~mask) | ((y << ofs) & mask);
+ return ((y << ofs) & mask) | (x & ~mask);
}
If the bitfield is of type _Bool, the new value (y above) must be converted
@@ -284,7 +284,7 @@ let bitfield_assign env bf carrier newval =
eshift env Oshl newval_casted (intconst (Int64.of_int bf.bf_pos) IUInt) in
let newval_masked = ebinint env Oand newval_shifted msk
and oldval_masked = ebinint env Oand carrier notmsk in
- ebinint env Oor oldval_masked newval_masked
+ ebinint env Oor newval_masked oldval_masked
(* Initialize a bitfield *)