x/sys/unix: missing constants used with struct Timex on Linux #58012
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Try to use constants to initialize fields of
struct Timex
, e.g.The Timex value would then be used with unix.Adjtimex or with unix.ClockAdjtime #57618.
What did you expect to see?
Successful compilation.
What did you see instead?
Compiler errors
Background
<sys/timex.h>
defines constants with 4 different prefixes:TIME_
- used for return value of adjtimex and clock_adjtime (e.g. TIME_OK)ADJ_
- used for the modes field of struct timex (e.g. ADJ_SETOFFSET)STA_
- use for the status field of struct timex (e.g. STA_INS)MOD_
- alternative names forADJ_
constants defined by ntp_adjtime kernel APIThese are documented in adjtimex(2): https://manpages.ubuntu.com/manpages/focal/man2/adjtimex.2.html
The unix package already defines the
TIME_
constants for linux, but it doesn't define any of the others. I would like to add theADJ_
andSTA_
ones; most uses of adjtimex require theADJ_
constants. I will do a CL if that sounds reasonable.I don't propose adding the
MOD_
ones at this stage, since the unix package does not provide ntp_adjtime. It would be possible for the unix package to provide the ntp_adjtime syscall on the various BSD flavors, at which point it would make sense for linux to provide ntp_adjtime (including theMOD_
constants) implemented in terms of adjtimex (and theADJ_
constants), which would allow for Go code to use NtpAdjtime and be portable between Linux and BSD. But that seems like a separable issue to me. If the package owners would prefer to include theMOD_
constants now, I can do that also.The text was updated successfully, but these errors were encountered: