jc/base.jai
2025-05-14 16:52:04 -06:00

29 lines
589 B
Text

uint :: #type u64;
sint :: #type s64;
rune :: #type u32;
rawptr :: #type *void;
Default_Align :: #run 2 * align_of(rawptr);
align_of :: ($T: Type) -> uint #expand {
return #run -> uint {
info := type_info(struct{ p: u8; t: T; });
return info.members[1].offset_in_bytes.(uint);
};
}
default_of :: ($T: Type) -> T #expand {
default: T;
return default;
}
zero_of :: ($T: Type) -> T #expand {
zero: T = ---;
memset(*zero, 0, size_of(T));
return zero;
}
bitcast :: ($T: Type, expr: Code) -> T #expand {
value := expr;
return (*value).(*T).*;
}