]> Cypherpunks repositories - gostls13.git/commit
runtime: fix plan9 monotonic time, crypto randomness
authorRuss Cox <rsc@golang.org>
Tue, 11 Mar 2025 15:23:24 +0000 (11:23 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 1 Apr 2025 00:06:53 +0000 (17:06 -0700)
commit4c32b1cc753e9005ed7c741bf69d3cb69ee3a56c
treef17291ce003aa2c72c130120abb76b394c399a11
parent6d418096b2dfe2a2e47b7aa83b46748fb301e6cb
runtime: fix plan9 monotonic time, crypto randomness

Open /dev/bintime at process start on Plan 9,
marked close-on-exec, hold it open for the duration of the
process, and use it for obtaining time.

The change to using /dev/bintime also sets up for an upcoming
Plan 9 change to add monotonic time to that file. If the monotonic
field is available, then nanotime1 and time.now use that field.
Otherwise they fall back to using Unix nanoseconds as "monotonic",
as they always have.

Before this CL, monotonic time went backward any time
aux/timesync decided to adjust the system's time-of-day backward.

Also use /dev/random for randomness (once at startup).
Before this CL, there was no real randomness in the runtime
on Plan 9 (the crypto/rand package still had some). Now there will be.

Change-Id: I0c20ae79d3d96eff1a5f839a56cec5c4bc517e61
Reviewed-on: https://go-review.googlesource.com/c/go/+/656755
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
src/runtime/env_plan9.go
src/runtime/os_plan9.go
src/runtime/sys_plan9_386.s
src/runtime/sys_plan9_amd64.s
src/runtime/sys_plan9_arm.s
src/runtime/timestub.go
src/runtime/timestub2.go