diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-12-09 03:43:33 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-12-09 03:43:33 +0000 |
commit | 9135a6ffc5c878c3ee51242be919cab919e83646 (patch) | |
tree | 86c4a0e50934092b44b31a139ea2f88fce046eed | |
parent | 77cc6ae6d642ee8a9438b6606d7ba6cc0911fd2b (diff) | |
download | gcc-9135a6ffc5c878c3ee51242be919cab919e83646.zip gcc-9135a6ffc5c878c3ee51242be919cab919e83646.tar.gz gcc-9135a6ffc5c878c3ee51242be919cab919e83646.tar.bz2 |
re PR go/92861 (Passes relative time to sem_timedwait on GNU/Hurd)
PR go/92861
runtime: use absolute time for sem_timedwait
Patch by Samuel Thibault.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210457
From-SVN: r279106
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | libgo/go/runtime/os_hurd.go | 28 |
2 files changed, 27 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index d1005ba..009a866 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -15c7bc9f0a432bc09716758412ea41d6caa6491b +1da5ceb8daaab7a243fffd6a647554cf674716f8 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/go/runtime/os_hurd.go b/libgo/go/runtime/os_hurd.go index 2a09e12..fab1774 100644 --- a/libgo/go/runtime/os_hurd.go +++ b/libgo/go/runtime/os_hurd.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// This file is derived from os_solaris.go. +// This file is derived from os_aix.go. package runtime @@ -37,6 +37,10 @@ func sem_post(sem *_sem_t) int32 //extern sem_timedwait func sem_timedwait(sem *_sem_t, timeout *timespec) int32 +//go:noescape +//extern clock_gettime +func clock_gettime(clock_id int32, timeout *timespec) int32 + //go:nosplit func semacreate(mp *m) { if mp.waitsema != 0 { @@ -60,7 +64,23 @@ func semasleep(ns int64) int32 { _m_ := getg().m if ns >= 0 { var ts timespec - ts.setNsec(ns) + + if clock_gettime(_CLOCK_REALTIME, &ts) != 0 { + throw("clock_gettime") + } + + sec := int64(ts.tv_sec) + ns/1e9 + nsec := int64(ts.tv_nsec) + ns%1e9 + if nsec >= 1e9 { + sec++ + nsec -= 1e9 + } + if sec != int64(timespec_sec_t(sec)) { + // Handle overflows (timespec_sec_t is 32-bit in 32-bit applications) + sec = 1<<31 - 1 + } + ts.tv_sec = timespec_sec_t(sec) + ts.tv_nsec = timespec_nsec_t(nsec) if sem_timedwait((*_sem_t)(unsafe.Pointer(_m_.waitsema)), &ts) != 0 { err := errno() @@ -105,3 +125,7 @@ func osinit() { physPageSize = uintptr(getPageSize()) } } + +const ( + _CLOCK_REALTIME = 0 +) |