mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Rename AlignedRef -> UnalignedRef
This commit is contained in:
@@ -933,14 +933,14 @@ fn void* trealloc(void* ptr, usz size, usz alignment = mem::DEFAULT_MEM_ALIGNMEN
|
||||
|
||||
<*
|
||||
Takes the address of a possibly unaligned variable or member,
|
||||
and offers safe access to that member, by constructing an AlignedRef.
|
||||
and offers safe access to that member, by constructing an UnalignedRef.
|
||||
|
||||
@require $defined(&#arg) : "It must be possible to take the address of the argument."
|
||||
@return "An 'AlignedRef' with the proper type and alignment, with a pointer to argument"
|
||||
@return "An 'UnalignedRef' with the proper type and alignment, with a pointer to argument"
|
||||
*>
|
||||
macro @aligned_addr(#arg) @builtin
|
||||
macro @unaligned_addr(#arg) @builtin
|
||||
{
|
||||
return (AlignedRef{$typeof(#arg), $alignof(#arg)})&#arg;
|
||||
return (UnalignedRef{$typeof(#arg), $alignof(#arg)})&#arg;
|
||||
}
|
||||
|
||||
module std::core::mem @if(env::NO_LIBC);
|
||||
@@ -1003,16 +1003,16 @@ module std::core::mem::alignment { Type, ALIGNMENT };
|
||||
import std::core::mem @public;
|
||||
|
||||
<*
|
||||
An AlignedRef offers correctly aligned access to addresses that may be unaligned or overaligned.
|
||||
An UnalignedRef offers correctly aligned access to addresses that may be unaligned or overaligned.
|
||||
*>
|
||||
typedef AlignedRef = Type*;
|
||||
typedef UnalignedRef = Type*;
|
||||
|
||||
macro Type AlignedRef.get(self)
|
||||
macro Type UnalignedRef.get(self)
|
||||
{
|
||||
return @unaligned_load(*(Type*)self, ALIGNMENT);
|
||||
}
|
||||
|
||||
macro Type AlignedRef.set(&self, Type val)
|
||||
macro Type UnalignedRef.set(&self, Type val)
|
||||
{
|
||||
return @unaligned_store(*(Type*)self, val, ALIGNMENT);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
- Added readline_to_stream that takes a stream.
|
||||
- Added `Ref` and `RefCounted` experimental functionality.
|
||||
- Added `Volatile` generic type.
|
||||
- Added `AlignedRef` generic type.
|
||||
- Added `UnalignedRef` generic type.
|
||||
|
||||
## 0.7.3 Change list
|
||||
|
||||
|
||||
Reference in New Issue
Block a user