Source file
src/runtime/sys_darwin_arm64.go
1
2
3
4
5 package runtime
6
7 import (
8 "internal/abi"
9 "internal/goarch"
10 "unsafe"
11 )
12
13
14
15
16
17 func g0_pthread_key_create(k *pthreadkey, destructor uintptr) int32 {
18 ret := asmcgocall(unsafe.Pointer(abi.FuncPCABI0(pthread_key_create_trampoline)), unsafe.Pointer(&k))
19 KeepAlive(k)
20 return ret
21 }
22 func pthread_key_create_trampoline()
23
24
25
26 func g0_pthread_setspecific(k pthreadkey, value uintptr) int32 {
27 return asmcgocall(unsafe.Pointer(abi.FuncPCABI0(pthread_setspecific_trampoline)), unsafe.Pointer(&k))
28 }
29 func pthread_setspecific_trampoline()
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 func tlsinit(tlsg *uintptr, tlsbase *[_PTHREAD_KEYS_MAX]uintptr) {
45 var k pthreadkey
46 err := g0_pthread_key_create(&k, 0)
47 if err != 0 {
48 abort()
49 }
50
51 const magic = 0xc476c475c47957
52 err = g0_pthread_setspecific(k, magic)
53 if err != 0 {
54 abort()
55 }
56
57 for i, x := range tlsbase {
58 if x == magic {
59 *tlsg = uintptr(i * goarch.PtrSize)
60 g0_pthread_setspecific(k, 0)
61 return
62 }
63 }
64 abort()
65 }
66
View as plain text