summaryrefslogtreecommitdiff
path: root/vendor/modernc.org/libc/pthread.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/modernc.org/libc/pthread.go')
-rw-r--r--vendor/modernc.org/libc/pthread.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/modernc.org/libc/pthread.go b/vendor/modernc.org/libc/pthread.go
index f47156a80..9e49cc0e4 100644
--- a/vendor/modernc.org/libc/pthread.go
+++ b/vendor/modernc.org/libc/pthread.go
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !(linux && (amd64 || loong64))
+
package libc // import "modernc.org/libc"
import (
@@ -37,6 +39,7 @@ type TLS struct {
errnop uintptr
allocaStack [][]uintptr
allocas []uintptr
+ jumpBuffers []uintptr
pthreadData
stack stackHeader
@@ -82,6 +85,29 @@ func (t *TLS) FreeAlloca() func() {
}
}
+func (tls *TLS) PushJumpBuffer(jb uintptr) {
+ tls.jumpBuffers = append(tls.jumpBuffers, jb)
+}
+
+type LongjmpRetval int32
+
+func (tls *TLS) PopJumpBuffer(jb uintptr) {
+ n := len(tls.jumpBuffers)
+ if n == 0 || tls.jumpBuffers[n-1] != jb {
+ panic(todo("unsupported setjmp/longjmp usage"))
+ }
+
+ tls.jumpBuffers = tls.jumpBuffers[:n-1]
+}
+
+func (tls *TLS) Longjmp(jb uintptr, val int32) {
+ tls.PopJumpBuffer(jb)
+ if val == 0 {
+ val = 1
+ }
+ panic(LongjmpRetval(val))
+}
+
func Xalloca(tls *TLS, size size_t) uintptr {
if __ccgo_strace {
trc("tls=%v size=%v, (%v:)", tls, size, origin(2))
@@ -420,6 +446,7 @@ func (m *mutex) lock(id int32) int32 {
m.Unlock()
m.wait.Lock()
+ // intentional empty section - wake up other waiters
m.wait.Unlock()
}
default: