You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assuming that foo has an alignment requirement of e.g. 8.
This lets zig code nicely implement the common pattern of using lower pointer bits as tag bits without lots of error-prone @ptrToInt and masking. An immediate user would be the red-black tree code.
The text was updated successfully, but these errors were encountered:
An attribute on the pointer type might not be necessary: similar to how e.g. a u7 might be stored in a 8 bit register, may be passed as a 32 bit parameter and takes up 8 bits in a non-packed struct: *align(4096) foo may be passed in a 64bit register and takes up usize bits in a non-packed struct, but only takes up usize-12 bits in a packed struct.
The current packed structs are C ABI compatible. Everywhere else in Zig extern signifies external ABI compatibility, thus I propose we change the existing packed to extern packed. We can then add this feature as packed on structs (not pointers).
and a allocator algorithm would run and assign the small ones to be packed into the pointers. It could eventually even be smart and pick less-used pointers. You can also do this manually using a sub-struct:
What if aligned pointers could be packed?
*packed align(4096) foo
only needsusize-12
bits.Such pointers would mostly be used in a packed struct such as:
assuming that
foo
has an alignment requirement of e.g.8
.This lets zig code nicely implement the common pattern of using lower pointer bits as tag bits without lots of error-prone
@ptrToInt
and masking. An immediate user would be the red-black tree code.The text was updated successfully, but these errors were encountered: