mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-10-07 01:22:54 +08:00
all: use Go 1.19 and its atomic types
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:

committed by
Jason A. Donenfeld

parent
d1d08426b2
commit
b51010ba13
@@ -10,7 +10,6 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"golang.zx2c4.com/wireguard/replay"
|
||||
)
|
||||
@@ -23,7 +22,7 @@ import (
|
||||
*/
|
||||
|
||||
type Keypair struct {
|
||||
sendNonce uint64 // accessed atomically
|
||||
sendNonce atomic.Uint64
|
||||
send cipher.AEAD
|
||||
receive cipher.AEAD
|
||||
replayFilter replay.Filter
|
||||
@@ -37,15 +36,7 @@ type Keypairs struct {
|
||||
sync.RWMutex
|
||||
current *Keypair
|
||||
previous *Keypair
|
||||
next *Keypair
|
||||
}
|
||||
|
||||
func (kp *Keypairs) storeNext(next *Keypair) {
|
||||
atomic.StorePointer((*unsafe.Pointer)((unsafe.Pointer)(&kp.next)), (unsafe.Pointer)(next))
|
||||
}
|
||||
|
||||
func (kp *Keypairs) loadNext() *Keypair {
|
||||
return (*Keypair)(atomic.LoadPointer((*unsafe.Pointer)((unsafe.Pointer)(&kp.next))))
|
||||
next atomic.Pointer[Keypair]
|
||||
}
|
||||
|
||||
func (kp *Keypairs) Current() *Keypair {
|
||||
|
Reference in New Issue
Block a user