fix 64-bit bitfield type value evaluation mask/shift

This commit is contained in:
Ryan Fleury
2024-11-15 11:44:51 -08:00
parent fe657987d6
commit c42e7837ac
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -170,7 +170,7 @@ e_value_eval_from_eval(E_Eval eval)
U64 valid_bits_mask = 0; U64 valid_bits_mask = 0;
for(U64 idx = 0; idx < type->count; idx += 1) for(U64 idx = 0; idx < type->count; idx += 1)
{ {
valid_bits_mask |= (1<<idx); valid_bits_mask |= (1ull<<idx);
} }
eval.value.u64 = eval.value.u64 >> type->off; eval.value.u64 = eval.value.u64 >> type->off;
eval.value.u64 = eval.value.u64 & valid_bits_mask; eval.value.u64 = eval.value.u64 & valid_bits_mask;
+11
View File
@@ -91,6 +91,13 @@ struct TypeWithBitfield
int z : 10; int z : 10;
}; };
typedef struct BitfieldType64 BitfieldType64;
struct BitfieldType64
{
uint64_t size : 63;
uint64_t is_free : 1;
};
void void
c_type_with_bitfield_usage(void) c_type_with_bitfield_usage(void)
{ {
@@ -103,4 +110,8 @@ c_type_with_bitfield_usage(void)
int x = (b.v + b.x); int x = (b.v + b.x);
int y = (b.y - b.z); int y = (b.y - b.z);
int z = (b.w) + 5; int z = (b.w) + 5;
BitfieldType64 b64 = {0};
b64.size = 524288;
b64.is_free = 1;
int abc = 0;
} }