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