LEFT | RIGHT |
1 #!/bin/sh | 1 #!/bin/sh |
2 # Copyright 2009 The Go Authors. All rights reserved. | 2 # Copyright 2009 The Go Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style | 3 # Use of this source code is governed by a BSD-style |
4 # license that can be found in the LICENSE file. | 4 # license that can be found in the LICENSE file. |
5 | 5 |
6 set -e | 6 set -e |
7 | 7 |
8 cat <<'EOF' | 8 cat <<'EOF' |
9 // Assembly constants. | 9 // Assembly constants. |
10 // AUTOMATICALLY GENERATED BY mkasmh.sh DURING BUILD | 10 // AUTOMATICALLY GENERATED BY mkasmh.sh DURING BUILD |
11 | 11 |
12 EOF | 12 EOF |
13 | 13 |
14 case "$GOARCH" in | 14 case "$GOARCH" in |
15 386) | 15 386) |
16 # The offsets 0 and 4 are also known to: | 16 # The offsets 0 and 4 are also known to: |
17 # nacl/thread.c:/^newosproc | |
18 # ../../cmd/8l/pass.c:/D_GS | 17 # ../../cmd/8l/pass.c:/D_GS |
19 # ../../libcgo/linux_386.c:/^threadentry | 18 # ../../libcgo/linux_386.c:/^threadentry |
20 # ../../libcgo/darwin_386.c:/^threadentry | 19 # ../../libcgo/darwin_386.c:/^threadentry |
21 case "$GOOS" in | 20 case "$GOOS" in |
22 windows) | 21 windows) |
23 echo '#define get_tls(r) MOVL 0x2c(FS), r' | 22 echo '#define get_tls(r) MOVL 0x2c(FS), r' |
24 echo '#define g(r) 0(r)' | 23 echo '#define g(r) 0(r)' |
25 echo '#define m(r) 4(r)' | 24 echo '#define m(r) 4(r)' |
26 ;; | 25 ;; |
27 plan9) | 26 plan9) |
28 » » echo '#define» get_tls(r)' | 27 » » echo '#define» get_tls(r)» MOVL _tos(SB), r ' |
29 » » echo '#define» g(r)» 0xdfffefc0' | 28 » » echo '#define» g(r)» -8(r)' |
30 » » echo '#define» m(r)» 0xdfffefc4' | 29 » » echo '#define» m(r)» -4(r)' |
31 ;; | 30 ;; |
32 linux) | 31 linux) |
33 # On Linux systems, what we call 0(GS) and 4(GS) for g and m | 32 # On Linux systems, what we call 0(GS) and 4(GS) for g and m |
34 # turn into %gs:-8 and %gs:-4 (using gcc syntax to denote | 33 # turn into %gs:-8 and %gs:-4 (using gcc syntax to denote |
35 # what the machine sees as opposed to 8l input). | 34 # what the machine sees as opposed to 8l input). |
36 # 8l rewrites 0(GS) and 4(GS) into these. | 35 # 8l rewrites 0(GS) and 4(GS) into these. |
37 # | 36 # |
38 # On Linux Xen, it is not allowed to use %gs:-8 and %gs:-4 | 37 # On Linux Xen, it is not allowed to use %gs:-8 and %gs:-4 |
39 # directly. Instead, we have to store %gs:0 into a temporary | 38 # directly. Instead, we have to store %gs:0 into a temporary |
40 # register and then use -8(%reg) and -4(%reg). This kind | 39 # register and then use -8(%reg) and -4(%reg). This kind |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 echo '#define LR R14' | 85 echo '#define LR R14' |
87 ;; | 86 ;; |
88 *) | 87 *) |
89 echo 'unknown $GOARCH: '$GOARCH 1>&2 | 88 echo 'unknown $GOARCH: '$GOARCH 1>&2 |
90 exit 1 | 89 exit 1 |
91 ;; | 90 ;; |
92 esac | 91 esac |
93 echo | 92 echo |
94 | 93 |
95 awk ' | 94 awk ' |
| 95 { gsub(/\r/, ""); } |
96 /^aggr G$/ { aggr="g" } | 96 /^aggr G$/ { aggr="g" } |
97 /^aggr M$/ { aggr = "m" } | 97 /^aggr M$/ { aggr = "m" } |
98 /^aggr Gobuf$/ { aggr = "gobuf" } | 98 /^aggr Gobuf$/ { aggr = "gobuf" } |
99 /^}/ { aggr = "" } | 99 /^}/ { aggr = "" } |
100 | 100 |
101 # Gobuf 24 sched; | 101 # Gobuf 24 sched; |
102 # 'Y' 48 stack0; | 102 # 'Y' 48 stack0; |
103 # 'Y' 56 entry; | 103 # 'Y' 56 entry; |
104 # 'A' G 64 alllink; | 104 # 'A' G 64 alllink; |
105 aggr != "" && /^ / { | 105 aggr != "" && /^ / { |
106 name=$NF; | 106 name=$NF; |
107 sub(/;/, "", name); | 107 sub(/;/, "", name); |
108 offset=$(NF-1); | 108 offset=$(NF-1); |
109 printf("#define %s_%s %s\n", aggr, name, offset); | 109 printf("#define %s_%s %s\n", aggr, name, offset); |
110 } | 110 } |
111 ' runtime.acid.$GOARCH | 111 ' runtime.acid.$GOARCH |
112 | 112 |
LEFT | RIGHT |