Source file
src/syscall/syscall_linux_loong64.go
1
2
3
4
5 package syscall
6
7 import "unsafe"
8
9 const (
10 _SYS_setgroups = SYS_SETGROUPS
11 _SYS_clone3 = 435
12 _SYS_faccessat2 = 439
13 _SYS_fchmodat2 = 452
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 func makedev(major uint32, minor uint32) uint64 {
39 majorH := uint64(major >> 12)
40 majorL := uint64(major & 0xfff)
41 minorH := uint64(minor >> 8)
42 minorL := uint64(minor & 0xff)
43 return (majorH << 44) | (minorH << 20) | (majorL << 8) | minorL
44 }
45
46 func timespecFromStatxTimestamp(x statxTimestamp) Timespec {
47 return Timespec{
48 Sec: x.Sec,
49 Nsec: int64(x.Nsec),
50 }
51 }
52
53 func fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) {
54 var r statx_t
55
56 if err = statx(dirfd, path, _AT_NO_AUTOMOUNT|flags, _STATX_BASIC_STATS, &r); err != nil {
57 return err
58 }
59
60 stat.Dev = makedev(r.Dev_major, r.Dev_minor)
61 stat.Ino = r.Ino
62 stat.Mode = uint32(r.Mode)
63 stat.Nlink = r.Nlink
64 stat.Uid = r.Uid
65 stat.Gid = r.Gid
66 stat.Rdev = makedev(r.Rdev_major, r.Rdev_minor)
67
68
69 stat.Size = int64(r.Size)
70 stat.Blksize = int32(r.Blksize)
71 stat.Blocks = int64(r.Blocks)
72 stat.Atim = timespecFromStatxTimestamp(r.Atime)
73 stat.Mtim = timespecFromStatxTimestamp(r.Mtime)
74 stat.Ctim = timespecFromStatxTimestamp(r.Ctime)
75
76 return nil
77 }
78
79 func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
80 return fstatat(fd, path, stat, flags)
81 }
82
83 func Fstat(fd int, stat *Stat_t) (err error) {
84 return fstatat(fd, "", stat, _AT_EMPTY_PATH)
85 }
86
87 func Stat(path string, stat *Stat_t) (err error) {
88 return fstatat(_AT_FDCWD, path, stat, 0)
89 }
90
91 func Lchown(path string, uid int, gid int) (err error) {
92 return Fchownat(_AT_FDCWD, path, uid, gid, _AT_SYMLINK_NOFOLLOW)
93 }
94
95 func Lstat(path string, stat *Stat_t) (err error) {
96 return fstatat(_AT_FDCWD, path, stat, _AT_SYMLINK_NOFOLLOW)
97 }
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118 type sigset_t struct {
119 X__val [16]uint64
120 }
121
122
123
124 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
125 var ts *Timespec
126 if timeout != nil {
127 ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
128 }
129 return pselect(nfd, r, w, e, ts, nil)
130 }
131
132
133
134 func setTimespec(sec, nsec int64) Timespec {
135 return Timespec{Sec: sec, Nsec: nsec}
136 }
137
138 func setTimeval(sec, usec int64) Timeval {
139 return Timeval{Sec: sec, Usec: usec}
140 }
141
142 func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) {
143 if tv == nil {
144 return utimensat(dirfd, path, nil, 0)
145 }
146
147 ts := []Timespec{
148 NsecToTimespec(TimevalToNsec(tv[0])),
149 NsecToTimespec(TimevalToNsec(tv[1])),
150 }
151 return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
152 }
153
154 func Time(t *Time_t) (Time_t, error) {
155 var tv Timeval
156 err := Gettimeofday(&tv)
157 if err != nil {
158 return 0, err
159 }
160 if t != nil {
161 *t = Time_t(tv.Sec)
162 }
163 return Time_t(tv.Sec), nil
164 }
165
166 func Utime(path string, buf *Utimbuf) error {
167 tv := []Timeval{
168 {Sec: buf.Actime},
169 {Sec: buf.Modtime},
170 }
171 return Utimes(path, tv)
172 }
173
174 func utimes(path string, tv *[2]Timeval) (err error) {
175 if tv == nil {
176 return utimensat(_AT_FDCWD, path, nil, 0)
177 }
178
179 ts := []Timespec{
180 NsecToTimespec(TimevalToNsec(tv[0])),
181 NsecToTimespec(TimevalToNsec(tv[1])),
182 }
183 return utimensat(_AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
184 }
185
186 func (r *PtraceRegs) GetEra() uint64 { return r.Era }
187
188 func (r *PtraceRegs) SetEra(era uint64) { r.Era = era }
189
190 func (iov *Iovec) SetLen(length int) {
191 iov.Len = uint64(length)
192 }
193
194 func (msghdr *Msghdr) SetControllen(length int) {
195 msghdr.Controllen = uint64(length)
196 }
197
198 func (cmsg *Cmsghdr) SetLen(length int) {
199 cmsg.Len = uint64(length)
200 }
201
202 func InotifyInit() (fd int, err error) {
203 return InotifyInit1(0)
204 }
205
206
207
208 func Pause() error {
209 _, err := ppoll(nil, 0, nil, nil)
210 return err
211 }
212
View as plain text