From 946e2dd405b66eecd51a9d9f3f82555c7e13a7d7 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 11 Nov 2019 12:39:41 +0100 Subject: [PATCH] runtime/unix: simplify time functions There is no need for separate datatypes for 32-bit and 64-bit *nix systems, because the int type already provides this. --- src/runtime/runtime_unix.go | 8 +++++--- src/runtime/runtime_unix32.go | 6 ------ src/runtime/runtime_unix64.go | 6 ------ 3 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 src/runtime/runtime_unix32.go delete mode 100644 src/runtime/runtime_unix64.go diff --git a/src/runtime/runtime_unix.go b/src/runtime/runtime_unix.go index 0e1c26eb..ce07fe65 100644 --- a/src/runtime/runtime_unix.go +++ b/src/runtime/runtime_unix.go @@ -35,10 +35,12 @@ type timeUnit int64 const tickMicros = 1 -// TODO: Linux/amd64-specific +// Note: tv_sec and tv_nsec vary in size by platform. They are 32-bit on 32-bit +// systems and 64-bit on 64-bit systems (at least on macOS/Linux), so we can +// simply use the 'int' type which does the same. type timespec struct { - tv_sec timeT - tv_nsec timeT + tv_sec int // time_t: follows the platform bitness + tv_nsec int // long: on Linux and macOS, follows the platform bitness } const CLOCK_MONOTONIC_RAW = 4 diff --git a/src/runtime/runtime_unix32.go b/src/runtime/runtime_unix32.go deleted file mode 100644 index 507efce1..00000000 --- a/src/runtime/runtime_unix32.go +++ /dev/null @@ -1,6 +0,0 @@ -// +build !baremetal -// +build arm - -package runtime - -type timeT int32 diff --git a/src/runtime/runtime_unix64.go b/src/runtime/runtime_unix64.go deleted file mode 100644 index a8902daf..00000000 --- a/src/runtime/runtime_unix64.go +++ /dev/null @@ -1,6 +0,0 @@ -// +build !baremetal -// +build arm64 amd64 i386 - -package runtime - -type timeT int64