forked from diodechain/diode_client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_runtime.sh
More file actions
executable file
·40 lines (35 loc) · 903 Bytes
/
patch_runtime.sh
File metadata and controls
executable file
·40 lines (35 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
SUDO=`which sudo`
read -r -d '' PATCH <<'EOF'
diff --git src/runtime/runtime.go src/runtime/runtime.go
index 33ecc260dd..dea79f6095 100644
--- src/runtime/runtime.go
+++ src/runtime/runtime.go
***************
*** 14,19 ****
--- 14,25 ----
//go:generate go run mkfastlog2table.go
//go:generate go run mklockrank.go -o lockrank.go
+ // GetGoID returns the goid
+ func GetGoID() uint64 {
+ _g_ := getg()
+ return uint64(_g_.goid)
+ }
+
var ticks ticksType
type ticksType struct {
EOF
FILE="$(go env GOROOT)/src/runtime/runtime.go"
CMD="-tN -r- $FILE"
OS=`uname -s`
if [[ ! -z $(grep "GetGoID" "$FILE") ]]; then
echo "$FILE is already patched!"
exit 0
fi
if ! patch --dry-run -R $CMD <<< "$PATCH" >> /dev/null; then
if [[ $OS == "Darwin" ]]; then
patch $CMD <<< "$PATCH" && echo "Runtime Patched!"
else
$SUDO patch $CMD <<< "$PATCH" && echo "Runtime Patched!"
fi
fi