mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Added more comments
This commit is contained in:
@@ -35,6 +35,9 @@ type AlignedAtomicInt64 struct {
|
||||
}
|
||||
|
||||
func (aa *AlignedAtomicInt64) ptr() *int64 {
|
||||
// In the 15-byte aa.value, there are guaranteed to be 8 contiguous
|
||||
// bytes with 64-bit alignment. We find an address in this range by
|
||||
// adding 7, then clear the 3 least significant bits to get its start.
|
||||
return (*int64)(unsafe.Pointer((uintptr(unsafe.Pointer(&aa.value)) + 7) &^ 7))
|
||||
}
|
||||
|
||||
@@ -67,6 +70,9 @@ type AlignedAtomicUint64 struct {
|
||||
}
|
||||
|
||||
func (aa *AlignedAtomicUint64) ptr() *uint64 {
|
||||
// In the 15-byte aa.value, there are guaranteed to be 8 contiguous
|
||||
// bytes with 64-bit alignment. We find an address in this range by
|
||||
// adding 7, then clear the 3 least significant bits to get its start.
|
||||
return (*uint64)(unsafe.Pointer((uintptr(unsafe.Pointer(&aa.value)) + 7) &^ 7))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user