Skip to content

Commit

Permalink
Adjust 64bit path
Browse files Browse the repository at this point in the history
  • Loading branch information
filmor committed Feb 10, 2024
1 parent 6f99e74 commit 0a4bc26
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rustler/src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,14 @@ impl<'a> Term<'a> {
const TAG_PRIMARY_BOXED: usize = 0x2;
const TAG_PRIMARY_SIZE: usize = 2;
const TAG_PRIMARY_HEADER: usize = 0x0;
const TAG_PTR_MASK: usize = 0x7;
const FLOAT_SUBTAG: usize = 0x6 << TAG_PRIMARY_SIZE;
const TAG_HEADER_FLOAT: usize = TAG_PRIMARY_HEADER | FLOAT_SUBTAG;
const HEADER_ARITY_OFFSET: usize = 6;

const SIZE: usize = if cfg!(target_pointer_width = "64") {
// Also TAG_PTR_MASK 0x7
// TAG_LITERAL_PTR 0x4
1
} else {
2
Expand All @@ -125,7 +128,12 @@ impl<'a> Term<'a> {

let term_val = self.as_c_arg();
if term_val & TAG_PRIMARY_MASK == TAG_PRIMARY_BOXED {
let term_ptr = term_val - TAG_PRIMARY_BOXED;
dbg!(term_val);
let term_ptr = if cfg!(target_pointer_width = "64") {
term_val & !TAG_PTR_MASK
} else {
term_val - TAG_PRIMARY_BOXED
};
let header = unsafe { *(term_ptr as *const usize) };
dbg!(header, HEADER_FLONUM, SIZE);
header == HEADER_FLONUM
Expand Down

0 comments on commit 0a4bc26

Please sign in to comment.