Skip to content

Commit 1545659

Browse files
aykevldeadprogram
authored andcommitted
internal/syscall/unix: use our own version of this package
The upstream one assumes it's running on a Unix system (which makes sense), but this package is also used on baremetal. So replace it on systems that need a replaced syscall package.
1 parent 38e3d55 commit 1545659

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

loader/goroot.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
269269

270270
if needsSyscallPackage {
271271
paths["syscall/"] = true // include syscall/js
272+
paths["internal/syscall/"] = true
273+
paths["internal/syscall/unix/"] = false
272274
}
273275
return paths
274276
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package unix
2+
3+
const (
4+
R_OK = 0x4
5+
W_OK = 0x2
6+
X_OK = 0x1
7+
)

src/internal/syscall/unix/eaccess.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package unix
2+
3+
import "syscall"
4+
5+
func Eaccess(path string, mode uint32) error {
6+
// We don't support this syscall on baremetal or wasm.
7+
// Callers are generally able to deal with this since unix.Eaccess also
8+
// isn't available on Android.
9+
return syscall.ENOSYS
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package unix
2+
3+
type GetRandomFlag uintptr
4+
5+
const (
6+
GRND_NONBLOCK GetRandomFlag = 0x0001
7+
GRND_RANDOM GetRandomFlag = 0x0002
8+
)
9+
10+
func GetRandom(p []byte, flags GetRandomFlag) (n int, err error) {
11+
panic("todo: unix.GetRandom")
12+
}

0 commit comments

Comments
 (0)