diff mbox series

libgo patch committed: Hurd fix

Message ID CAOyqgcVbjSRTMf3wvJPs+8j2N=67_1jda6Ro3aiJeO+MR2CqSQ@mail.gmail.com
State New
Headers show
Series libgo patch committed: Hurd fix | expand

Commit Message

Ian Lance Taylor Dec. 9, 2019, 3:43 a.m. UTC
I've committed this Hurd fix by Samuel Thibault for GCC PR 92861.

Ian

Comments

Ian Lance Taylor Dec. 9, 2019, 6:03 p.m. UTC | #1
On Sun, Dec 8, 2019 at 7:43 PM Ian Lance Taylor <iant@golang.org> wrote:
>
> I've committed this Hurd fix by Samuel Thibault for GCC PR 92861.

And a followup patch, also by Samuel Thibault.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 279106)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-1da5ceb8daaab7a243fffd6a647554cf674716f8
+6f2bf15e15bf7516c393966577d72b79cba7f980
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/runtime/os_hurd.go
===================================================================
--- libgo/go/runtime/os_hurd.go	(revision 279106)
+++ libgo/go/runtime/os_hurd.go	(working copy)
@@ -125,7 +125,3 @@ func osinit() {
 		physPageSize = uintptr(getPageSize())
 	}
 }
-
-const (
-	_CLOCK_REALTIME = 0
-)
diff mbox series

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 279063)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -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.
Index: libgo/go/runtime/os_hurd.go
===================================================================
--- libgo/go/runtime/os_hurd.go	(revision 279062)
+++ libgo/go/runtime/os_hurd.go	(working copy)
@@ -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
+)