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.go31
1 files changed, 30 insertions, 1 deletions
diff --git a/vendor/modernc.org/libc/pthread.go b/vendor/modernc.org/libc/pthread.go
index 06792905c..528b83f9c 100644
--- a/vendor/modernc.org/libc/pthread.go
+++ b/vendor/modernc.org/libc/pthread.go
@@ -34,7 +34,9 @@ var (
// Thread local storage.
type TLS struct {
- errnop uintptr
+ errnop uintptr
+ allocaStack [][]uintptr
+ allocas []uintptr
pthreadData
stack stackHeader
@@ -61,6 +63,33 @@ func newTLS(detached bool) *TLS {
return t
}
+func (t *TLS) alloca(n size_t) (r uintptr) {
+ r = Xmalloc(t, n)
+ t.allocas = append(t.allocas, r)
+ return r
+}
+
+func (t *TLS) FreeAlloca() func() {
+ t.allocaStack = append(t.allocaStack, t.allocas)
+ t.allocas = nil
+ return func() {
+ for _, v := range t.allocas {
+ Xfree(t, v)
+ }
+ n := len(t.allocaStack)
+ t.allocas = t.allocaStack[n-1]
+ t.allocaStack = t.allocaStack[:n-1]
+ }
+}
+
+func Xalloca(tls *TLS, size size_t) uintptr {
+ return tls.alloca(size)
+}
+
+func X__builtin_alloca(tls *TLS, size size_t) uintptr {
+ return Xalloca(tls, size)
+}
+
// Pthread specific part of a TLS.
type pthreadData struct {
done chan struct{}