summaryrefslogtreecommitdiff
path: root/vendor/modernc.org/libc/pthread.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-11-06 14:40:53 +0000
committerLibravatar GitHub <noreply@github.com>2023-11-06 14:40:53 +0000
commit28f85db30afe5709c9814186ae14eb12199cbc35 (patch)
tree3e7292cc6e9c97dc35feadec95a9fe00ad63890e /vendor/modernc.org/libc/pthread.go
parent[feature] support canceling scheduled tasks, some federation API performance ... (diff)
downloadgotosocial-28f85db30afe5709c9814186ae14eb12199cbc35.tar.xz
[chore]: Bump modernc.org/sqlite from 1.26.0 to 1.27.0 (#2339)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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{}