common/mclock: remove dependency on github.com/aristanetworks/goarista (#22211)

This commit is contained in:
Daniel Liu 2024-12-17 11:02:22 +08:00
parent d852f8cf88
commit 6f19ace5e2
4 changed files with 9 additions and 7 deletions

View file

@ -20,15 +20,19 @@ package mclock
import (
"time"
"github.com/aristanetworks/goarista/monotime"
_ "unsafe" // for go:linkname
)
//go:noescape
//go:linkname nanotime runtime.nanotime
func nanotime() int64
// AbsTime represents absolute monotonic time.
type AbsTime time.Duration
type AbsTime int64
// Now returns the current absolute monotonic time.
func Now() AbsTime {
return AbsTime(monotime.Now())
return AbsTime(nanotime())
}
// Add returns t + d as absolute time.
@ -74,7 +78,7 @@ type System struct{}
// Now returns the current monotonic time.
func (c System) Now() AbsTime {
return AbsTime(monotime.Now())
return Now()
}
// Sleep blocks for the given duration.

1
common/mclock/mclock.s Normal file
View file

@ -0,0 +1 @@
// This file exists in order to be able to use go:linkname.

1
go.mod
View file

@ -4,7 +4,6 @@ go 1.22
require (
github.com/VictoriaMetrics/fastcache v1.12.2
github.com/aristanetworks/goarista v0.0.0-20231019142648-8c6f0862ab98
github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6
github.com/cespare/cp v1.1.1
github.com/davecgh/go-spew v1.1.1

2
go.sum
View file

@ -4,8 +4,6 @@ github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjC
github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/aristanetworks/goarista v0.0.0-20231019142648-8c6f0862ab98 h1:7buXGE+m4OPjyo8rUJgA8RmARNMq+m99JJLR+Z+ZWN0=
github.com/aristanetworks/goarista v0.0.0-20231019142648-8c6f0862ab98/go.mod h1:DLTg9Gp4FAXF5EpqYBQnUeBbRsNLY7b2HR94TE5XQtE=
github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8=
github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6 h1:Eey/GGQ/E5Xp1P2Lyx1qj007hLZfbi0+CoVeJruGCtI=