File tree 8 files changed +59
-28
lines changed
8 files changed +59
-28
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2016 Peter Mattis.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
+ // implied. See the License for the specific language governing
13
+ // permissions and limitations under the License. See the AUTHORS file
14
+ // for names of contributors.
15
+
16
+ // +build amd64 amd64p32
17
+ // +build go1.5
18
+
19
+ package goid
20
+
21
+ func Get () int64
Original file line number Diff line number Diff line change 18
18
// +build amd64 amd64p32
19
19
// +build go1.5
20
20
21
+ #include "go_asm.h"
21
22
#include "textflag.h"
22
23
23
- // func getg() *g
24
- TEXT ·getg(SB),NOSPLIT,$0 -8
25
- MOVQ (TLS), BX
26
- MOVQ BX, ret +0 (FP)
24
+ // func Get() int64
25
+ TEXT ·Get(SB),NOSPLIT,$0 -8
26
+ MOVQ (TLS), R14
27
+ MOVQ g_goid(R14), R13
28
+ MOVQ R13, ret +0 (FP)
27
29
RET
Original file line number Diff line number Diff line change
1
+ // Copyright 2016 Peter Mattis.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
+ // implied. See the License for the specific language governing
13
+ // permissions and limitations under the License. See the AUTHORS file
14
+ // for names of contributors.
15
+
16
+ // +build arm
17
+ // +build go1.5
18
+
19
+ package goid
20
+
21
+ // Backdoor access to runtime·getg().
22
+ func getg () * g // in goid_go1.5plus.s
23
+
24
+ func Get () int64 {
25
+ return getg ().goid
26
+ }
File renamed without changes.
Original file line number Diff line number Diff line change @@ -42,3 +42,9 @@ func TestGet(t *testing.T) {
42
42
}
43
43
}
44
44
}
45
+
46
+ func BenchmarkGet (b * testing.B ) {
47
+ for i := 0 ; i < b .N ; i ++ {
48
+ Get ()
49
+ }
50
+ }
Original file line number Diff line number Diff line change 13
13
// permissions and limitations under the License. See the AUTHORS file
14
14
// for names of contributors.
15
15
16
- // +build amd64 amd64p32 arm
17
16
// +build go1.5,!go1.6
18
17
19
18
package goid
@@ -55,10 +54,3 @@ type g struct {
55
54
stackLock uint32
56
55
goid int64 // Here it is!
57
56
}
58
-
59
- // Backdoor access to runtime·getg().
60
- func getg () * g // in goid_go1.5plus.s
61
-
62
- func Get () int64 {
63
- return getg ().goid
64
- }
Original file line number Diff line number Diff line change 1
- // +build amd64 amd64p32 arm
2
1
// +build go1.6,!go1.9
3
2
4
3
package goid
@@ -41,10 +40,3 @@ type g struct {
41
40
stackLock uint32
42
41
goid int64 // Here it is!
43
42
}
44
-
45
- // Backdoor access to runtime·getg().
46
- func getg () * g // in goid_go1.5plus{,_arm}.s
47
-
48
- func Get () int64 {
49
- return getg ().goid
50
- }
Original file line number Diff line number Diff line change 1
- // +build amd64 amd64p32 arm
2
1
// +build go1.9
3
2
4
3
package goid
@@ -35,10 +34,3 @@ type g struct {
35
34
stackLock uint32
36
35
goid int64 // Here it is!
37
36
}
38
-
39
- // Backdoor access to runtime·getg().
40
- func getg () * g // in goid_go1.5plus{,_arm}.s
41
-
42
- func Get () int64 {
43
- return getg ().goid
44
- }
You can’t perform that action at this time.
0 commit comments