Skip to content

Commit

Permalink
fix: stop importing nanotime from runtime via linkname
Browse files Browse the repository at this point in the history
  • Loading branch information
maypok86 authored and jackc committed Sep 9, 2024
1 parent ee87cc3 commit 56ab1e8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
16 changes: 16 additions & 0 deletions nanotime.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package puddle

import "time"

// nanotime returns the time in nanoseconds since process start.
//
// This approach, described at
// https://github.com/golang/go/issues/61765#issuecomment-1672090302,
// is fast, monotonic, and portable, and avoids the previous
// dependence on runtime.nanotime using the (unsafe) linkname hack.
// In particular, time.Since does less work than time.Now.
func nanotime() int64 {
return time.Since(globalStart).Nanoseconds()
}

var globalStart = time.Now()
13 changes: 0 additions & 13 deletions nanotime_time.go

This file was deleted.

12 changes: 0 additions & 12 deletions nanotime_unsafe.go

This file was deleted.

0 comments on commit 56ab1e8

Please sign in to comment.