c/syscall: zerrors
This commit is contained in:
@@ -8,8 +8,6 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("os.Environ:", os.Environ())
|
||||
|
||||
ls := "ls"
|
||||
args := []string{ls, "-l"}
|
||||
if runtime.GOOS == "windows" {
|
||||
|
||||
@@ -19,3 +19,9 @@ package syscall
|
||||
const (
|
||||
LLGoPackage = "decl"
|
||||
)
|
||||
|
||||
type Errno = uintptr
|
||||
|
||||
// A Signal is a number describing a process signal.
|
||||
// It implements the os.Signal interface.
|
||||
type Signal = int
|
||||
|
||||
1153
c/syscall/zerrors_aix_ppc64.go
Normal file
1153
c/syscall/zerrors_aix_ppc64.go
Normal file
File diff suppressed because it is too large
Load Diff
1279
c/syscall/zerrors_darwin_amd64.go
Normal file
1279
c/syscall/zerrors_darwin_amd64.go
Normal file
File diff suppressed because it is too large
Load Diff
1291
c/syscall/zerrors_darwin_arm64.go
Normal file
1291
c/syscall/zerrors_darwin_arm64.go
Normal file
File diff suppressed because it is too large
Load Diff
1392
c/syscall/zerrors_dragonfly_amd64.go
Normal file
1392
c/syscall/zerrors_dragonfly_amd64.go
Normal file
File diff suppressed because it is too large
Load Diff
1580
c/syscall/zerrors_freebsd_386.go
Normal file
1580
c/syscall/zerrors_freebsd_386.go
Normal file
File diff suppressed because it is too large
Load Diff
1581
c/syscall/zerrors_freebsd_amd64.go
Normal file
1581
c/syscall/zerrors_freebsd_amd64.go
Normal file
File diff suppressed because it is too large
Load Diff
1580
c/syscall/zerrors_freebsd_arm.go
Normal file
1580
c/syscall/zerrors_freebsd_arm.go
Normal file
File diff suppressed because it is too large
Load Diff
1581
c/syscall/zerrors_freebsd_arm64.go
Normal file
1581
c/syscall/zerrors_freebsd_arm64.go
Normal file
File diff suppressed because it is too large
Load Diff
1581
c/syscall/zerrors_freebsd_riscv64.go
Normal file
1581
c/syscall/zerrors_freebsd_riscv64.go
Normal file
File diff suppressed because it is too large
Load Diff
1355
c/syscall/zerrors_linux_386.go
Normal file
1355
c/syscall/zerrors_linux_386.go
Normal file
File diff suppressed because it is too large
Load Diff
1356
c/syscall/zerrors_linux_amd64.go
Normal file
1356
c/syscall/zerrors_linux_amd64.go
Normal file
File diff suppressed because it is too large
Load Diff
1368
c/syscall/zerrors_linux_arm.go
Normal file
1368
c/syscall/zerrors_linux_arm.go
Normal file
File diff suppressed because it is too large
Load Diff
1632
c/syscall/zerrors_linux_arm64.go
Normal file
1632
c/syscall/zerrors_linux_arm64.go
Normal file
File diff suppressed because it is too large
Load Diff
1931
c/syscall/zerrors_linux_loong64.go
Normal file
1931
c/syscall/zerrors_linux_loong64.go
Normal file
File diff suppressed because it is too large
Load Diff
1639
c/syscall/zerrors_linux_mips.go
Normal file
1639
c/syscall/zerrors_linux_mips.go
Normal file
File diff suppressed because it is too large
Load Diff
1622
c/syscall/zerrors_linux_mips64.go
Normal file
1622
c/syscall/zerrors_linux_mips64.go
Normal file
File diff suppressed because it is too large
Load Diff
1622
c/syscall/zerrors_linux_mips64le.go
Normal file
1622
c/syscall/zerrors_linux_mips64le.go
Normal file
File diff suppressed because it is too large
Load Diff
1639
c/syscall/zerrors_linux_mipsle.go
Normal file
1639
c/syscall/zerrors_linux_mipsle.go
Normal file
File diff suppressed because it is too large
Load Diff
1687
c/syscall/zerrors_linux_ppc64.go
Normal file
1687
c/syscall/zerrors_linux_ppc64.go
Normal file
File diff suppressed because it is too large
Load Diff
1711
c/syscall/zerrors_linux_ppc64le.go
Normal file
1711
c/syscall/zerrors_linux_ppc64le.go
Normal file
File diff suppressed because it is too large
Load Diff
1686
c/syscall/zerrors_linux_riscv64.go
Normal file
1686
c/syscall/zerrors_linux_riscv64.go
Normal file
File diff suppressed because it is too large
Load Diff
1747
c/syscall/zerrors_linux_s390x.go
Normal file
1747
c/syscall/zerrors_linux_s390x.go
Normal file
File diff suppressed because it is too large
Load Diff
1575
c/syscall/zerrors_netbsd_386.go
Normal file
1575
c/syscall/zerrors_netbsd_386.go
Normal file
File diff suppressed because it is too large
Load Diff
1565
c/syscall/zerrors_netbsd_amd64.go
Normal file
1565
c/syscall/zerrors_netbsd_amd64.go
Normal file
File diff suppressed because it is too large
Load Diff
1551
c/syscall/zerrors_netbsd_arm.go
Normal file
1551
c/syscall/zerrors_netbsd_arm.go
Normal file
File diff suppressed because it is too large
Load Diff
1565
c/syscall/zerrors_netbsd_arm64.go
Normal file
1565
c/syscall/zerrors_netbsd_arm64.go
Normal file
File diff suppressed because it is too large
Load Diff
1454
c/syscall/zerrors_openbsd_386.go
Normal file
1454
c/syscall/zerrors_openbsd_386.go
Normal file
File diff suppressed because it is too large
Load Diff
1453
c/syscall/zerrors_openbsd_amd64.go
Normal file
1453
c/syscall/zerrors_openbsd_amd64.go
Normal file
File diff suppressed because it is too large
Load Diff
1453
c/syscall/zerrors_openbsd_arm.go
Normal file
1453
c/syscall/zerrors_openbsd_arm.go
Normal file
File diff suppressed because it is too large
Load Diff
1540
c/syscall/zerrors_openbsd_arm64.go
Normal file
1540
c/syscall/zerrors_openbsd_arm64.go
Normal file
File diff suppressed because it is too large
Load Diff
1547
c/syscall/zerrors_openbsd_mips64.go
Normal file
1547
c/syscall/zerrors_openbsd_mips64.go
Normal file
File diff suppressed because it is too large
Load Diff
1247
c/syscall/zerrors_solaris_amd64.go
Normal file
1247
c/syscall/zerrors_solaris_amd64.go
Normal file
File diff suppressed because it is too large
Load Diff
148
c/syscall/zerrors_windows.go
Normal file
148
c/syscall/zerrors_windows.go
Normal file
@@ -0,0 +1,148 @@
|
||||
// mkerrors_windows.sh -m32
|
||||
// Code generated by the command above; DO NOT EDIT.
|
||||
|
||||
package syscall
|
||||
|
||||
// Go names for Windows errors.
|
||||
const (
|
||||
ENOENT Errno = ERROR_FILE_NOT_FOUND
|
||||
ENOTDIR Errno = ERROR_PATH_NOT_FOUND
|
||||
)
|
||||
|
||||
// Windows reserves errors >= 1<<29 for application use.
|
||||
const APPLICATION_ERROR = 1 << 29
|
||||
|
||||
// Invented values to support what package os and others expects.
|
||||
const (
|
||||
E2BIG Errno = APPLICATION_ERROR + iota
|
||||
EACCES
|
||||
EADDRINUSE
|
||||
EADDRNOTAVAIL
|
||||
EADV
|
||||
EAFNOSUPPORT
|
||||
EAGAIN
|
||||
EALREADY
|
||||
EBADE
|
||||
EBADF
|
||||
EBADFD
|
||||
EBADMSG
|
||||
EBADR
|
||||
EBADRQC
|
||||
EBADSLT
|
||||
EBFONT
|
||||
EBUSY
|
||||
ECANCELED
|
||||
ECHILD
|
||||
ECHRNG
|
||||
ECOMM
|
||||
ECONNABORTED
|
||||
ECONNREFUSED
|
||||
ECONNRESET
|
||||
EDEADLK
|
||||
EDEADLOCK
|
||||
EDESTADDRREQ
|
||||
EDOM
|
||||
EDOTDOT
|
||||
EDQUOT
|
||||
EEXIST
|
||||
EFAULT
|
||||
EFBIG
|
||||
EHOSTDOWN
|
||||
EHOSTUNREACH
|
||||
EIDRM
|
||||
EILSEQ
|
||||
EINPROGRESS
|
||||
EINTR
|
||||
EINVAL
|
||||
EIO
|
||||
EISCONN
|
||||
EISDIR
|
||||
EISNAM
|
||||
EKEYEXPIRED
|
||||
EKEYREJECTED
|
||||
EKEYREVOKED
|
||||
EL2HLT
|
||||
EL2NSYNC
|
||||
EL3HLT
|
||||
EL3RST
|
||||
ELIBACC
|
||||
ELIBBAD
|
||||
ELIBEXEC
|
||||
ELIBMAX
|
||||
ELIBSCN
|
||||
ELNRNG
|
||||
ELOOP
|
||||
EMEDIUMTYPE
|
||||
EMFILE
|
||||
EMLINK
|
||||
EMSGSIZE
|
||||
EMULTIHOP
|
||||
ENAMETOOLONG
|
||||
ENAVAIL
|
||||
ENETDOWN
|
||||
ENETRESET
|
||||
ENETUNREACH
|
||||
ENFILE
|
||||
ENOANO
|
||||
ENOBUFS
|
||||
ENOCSI
|
||||
ENODATA
|
||||
ENODEV
|
||||
ENOEXEC
|
||||
ENOKEY
|
||||
ENOLCK
|
||||
ENOLINK
|
||||
ENOMEDIUM
|
||||
ENOMEM
|
||||
ENOMSG
|
||||
ENONET
|
||||
ENOPKG
|
||||
ENOPROTOOPT
|
||||
ENOSPC
|
||||
ENOSR
|
||||
ENOSTR
|
||||
ENOSYS
|
||||
ENOTBLK
|
||||
ENOTCONN
|
||||
ENOTEMPTY
|
||||
ENOTNAM
|
||||
ENOTRECOVERABLE
|
||||
ENOTSOCK
|
||||
ENOTSUP
|
||||
ENOTTY
|
||||
ENOTUNIQ
|
||||
ENXIO
|
||||
EOPNOTSUPP
|
||||
EOVERFLOW
|
||||
EOWNERDEAD
|
||||
EPERM
|
||||
EPFNOSUPPORT
|
||||
EPIPE
|
||||
EPROTO
|
||||
EPROTONOSUPPORT
|
||||
EPROTOTYPE
|
||||
ERANGE
|
||||
EREMCHG
|
||||
EREMOTE
|
||||
EREMOTEIO
|
||||
ERESTART
|
||||
EROFS
|
||||
ESHUTDOWN
|
||||
ESOCKTNOSUPPORT
|
||||
ESPIPE
|
||||
ESRCH
|
||||
ESRMNT
|
||||
ESTALE
|
||||
ESTRPIPE
|
||||
ETIME
|
||||
ETIMEDOUT
|
||||
ETOOMANYREFS
|
||||
ETXTBSY
|
||||
EUCLEAN
|
||||
EUNATCH
|
||||
EUSERS
|
||||
EWOULDBLOCK
|
||||
EXDEV
|
||||
EXFULL
|
||||
EWINDOWS
|
||||
)
|
||||
@@ -9,8 +9,11 @@
|
||||
package syscall
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"runtime"
|
||||
"sync"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/c/os"
|
||||
@@ -106,13 +109,10 @@ type ProcAttr struct {
|
||||
Sys *SysProcAttr
|
||||
}
|
||||
|
||||
/* TODO(xsw):
|
||||
var zeroProcAttr ProcAttr
|
||||
var zeroSysProcAttr SysProcAttr
|
||||
*/
|
||||
|
||||
func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error) {
|
||||
/* TODO(xsw):
|
||||
var p [2]int
|
||||
var n int
|
||||
var err1 Errno
|
||||
@@ -127,45 +127,30 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
|
||||
}
|
||||
|
||||
// Convert args to C form.
|
||||
argv0p, err := BytePtrFromString(argv0)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
argvp, err := SlicePtrFromStrings(argv)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
envvp, err := SlicePtrFromStrings(attr.Env)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
argv0p := c.AllocaCStr(argv0)
|
||||
argvp := c.AllocaCStrs(argv, true)
|
||||
envvp := c.AllocaCStrs(attr.Env, true)
|
||||
|
||||
if (runtime.GOOS == "freebsd" || runtime.GOOS == "dragonfly") && len(argv) > 0 && len(argv[0]) > len(argv0) {
|
||||
argvp[0] = argv0p
|
||||
*argvp = argv0p
|
||||
}
|
||||
|
||||
var chroot *byte
|
||||
var chroot *c.Char
|
||||
if sys.Chroot != "" {
|
||||
chroot, err = BytePtrFromString(sys.Chroot)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
chroot = c.AllocaCStr(sys.Chroot)
|
||||
}
|
||||
}
|
||||
var dir *byte
|
||||
var dir *c.Char
|
||||
if attr.Dir != "" {
|
||||
dir, err = BytePtrFromString(attr.Dir)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
dir = c.AllocaCStr(attr.Dir)
|
||||
}
|
||||
|
||||
// Both Setctty and Foreground use the Ctty field,
|
||||
// but they give it slightly different meanings.
|
||||
if sys.Setctty && sys.Foreground {
|
||||
return 0, errorspkg.New("both Setctty and Foreground set in SysProcAttr")
|
||||
return 0, errors.New("both Setctty and Foreground set in SysProcAttr")
|
||||
}
|
||||
if sys.Setctty && sys.Ctty >= len(attr.Files) {
|
||||
return 0, errorspkg.New("Setctty set but Ctty not valid in child")
|
||||
return 0, errors.New("Setctty set but Ctty not valid in child")
|
||||
}
|
||||
|
||||
acquireForkLock()
|
||||
@@ -214,8 +199,6 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
|
||||
|
||||
// Read got EOF, so pipe closed on exec, so exec succeeded.
|
||||
return pid, nil
|
||||
*/
|
||||
panic("todo: syscall.forkExec")
|
||||
}
|
||||
|
||||
// Combination of fork and exec, careful to be thread safe.
|
||||
|
||||
@@ -82,7 +82,7 @@ func Kill(pid int, signum Signal) (err error) {
|
||||
if ret == 0 {
|
||||
return nil
|
||||
}
|
||||
return Errno(os.Errno)
|
||||
return Errno(ret)
|
||||
}
|
||||
|
||||
func Open(path string, mode int, perm uint32) (fd int, err error) {
|
||||
@@ -114,7 +114,7 @@ func Close(fd int) (err error) {
|
||||
if ret == 0 {
|
||||
return nil
|
||||
}
|
||||
return Errno(os.Errno)
|
||||
return Errno(ret)
|
||||
}
|
||||
|
||||
type Stat_t = syscall.Stat_t
|
||||
@@ -124,7 +124,7 @@ func Lstat(path string, stat *Stat_t) (err error) {
|
||||
if ret == 0 {
|
||||
return nil
|
||||
}
|
||||
return Errno(os.Errno)
|
||||
return Errno(ret)
|
||||
}
|
||||
|
||||
func Stat(path string, stat *Stat_t) (err error) {
|
||||
@@ -132,5 +132,19 @@ func Stat(path string, stat *Stat_t) (err error) {
|
||||
if ret == 0 {
|
||||
return nil
|
||||
}
|
||||
return Errno(os.Errno)
|
||||
return Errno(ret)
|
||||
}
|
||||
|
||||
func Pipe(p []int) (err error) {
|
||||
if len(p) != 2 {
|
||||
return EINVAL
|
||||
}
|
||||
var q [2]c.Int
|
||||
ret := os.Pipe(&q)
|
||||
if ret == 0 {
|
||||
p[0] = int(q[0])
|
||||
p[1] = int(q[1])
|
||||
return nil
|
||||
}
|
||||
return Errno(ret)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user