Source file
src/syscall/mkpost.go
Documentation: syscall
1
2
3
4
5
6
7
8
9
10
11
12
13 package main
14
15 import (
16 "fmt"
17 "go/format"
18 "io"
19 "log"
20 "os"
21 "regexp"
22 "strings"
23 )
24
25 func main() {
26 b, err := io.ReadAll(os.Stdin)
27 if err != nil {
28 log.Fatal(err)
29 }
30 s := string(b)
31
32 goarch := os.Getenv("GOARCH")
33 goos := os.Getenv("GOOS")
34 switch {
35 case goarch == "s390x" && goos == "linux":
36
37 re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)")
38 s = re.ReplaceAllString(s, "Ptrace$1")
39
40
41 re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*")
42 s = re.ReplaceAllString(s, "_")
43
44
45 s = strings.Replace(s, "X__val", "MKPOSTFSIDVAL", 1)
46
47
48 re = regexp.MustCompile("X_[A-Za-z0-9_]*")
49 s = re.ReplaceAllString(s, "_")
50
51
52 s = strings.Replace(s, "MKPOSTFSIDVAL", "X__val", 1)
53
54
55
56 re = regexp.MustCompile("(Data\\s+\\[14\\])uint8")
57 s = re.ReplaceAllString(s, "${1}int8")
58
59 case goos == "freebsd":
60
61 re := regexp.MustCompile("(A|M|C|Birth)tim\\s+Timespec")
62 s = re.ReplaceAllString(s, "${1}timespec Timespec")
63 }
64
65
66 b, err = format.Source([]byte(s))
67 if err != nil {
68 log.Fatal(err)
69 }
70
71
72
73 re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)")
74 s = re.ReplaceAllString(string(b), "$1 | go run mkpost.go")
75
76 fmt.Print(s)
77 }
78
View as plain text