darwin: use custom syscall pkg that uses libsystem

Go 1.12 switched to using libSystem.dylib for system calls, because
Apple recommends against doing direct system calls that Go 1.11 and
earlier did. For more information, see:
  https://github.com/golang/go/issues/17490
  https://developer.apple.com/library/archive/qa/qa1118/_index.html

While the old syscall package was relatively easy to support in TinyGo
(just implement syscall.Syscall*), this got a whole lot harder with Go
1.12 as all syscalls now go through CGo magic to call the underlying
libSystem functions. Therefore, this commit overrides the stdlib syscall
package with a custom package that performs calls with libc (libSystem).
This may be useful not just for darwin but for other platforms as well
that do not place the stable ABI at the syscall boundary like Linux but
at the libc boundary.

Only a very minimal part of the syscall package has been implemented, to
get the tests to pass. More calls can easily be added in the future.
This commit is contained in:
Ayke van Laethem
2019-03-24 12:59:09 +01:00
committed by Ron Evans
parent 2523772b5d
commit 86f8778748
8 changed files with 143 additions and 149 deletions
-119
View File
@@ -6,8 +6,6 @@
package syscall
import "runtime"
// TODO: generate with runtime/mknacl.sh, allow override with IRT.
const (
sys_null = 1
@@ -223,123 +221,6 @@ const (
EWOULDBLOCK Errno = EAGAIN /* Operation would block */
)
// TODO: Auto-generate some day. (Hard-coded in binaries so not likely to change.)
var errorstr = [...]string{
EPERM: "Operation not permitted",
ENOENT: "No such file or directory",
ESRCH: "No such process",
EINTR: "Interrupted system call",
EIO: "I/O error",
ENXIO: "No such device or address",
E2BIG: "Argument list too long",
ENOEXEC: "Exec format error",
EBADF: "Bad file number",
ECHILD: "No child processes",
EAGAIN: "Try again",
ENOMEM: "Out of memory",
EACCES: "Permission denied",
EFAULT: "Bad address",
EBUSY: "Device or resource busy",
EEXIST: "File exists",
EXDEV: "Cross-device link",
ENODEV: "No such device",
ENOTDIR: "Not a directory",
EISDIR: "Is a directory",
EINVAL: "Invalid argument",
ENFILE: "File table overflow",
EMFILE: "Too many open files",
ENOTTY: "Not a typewriter",
EFBIG: "File too large",
ENOSPC: "No space left on device",
ESPIPE: "Illegal seek",
EROFS: "Read-only file system",
EMLINK: "Too many links",
EPIPE: "Broken pipe",
ENAMETOOLONG: "File name too long",
ENOSYS: "not implemented on " + runtime.GOOS,
EDQUOT: "Quota exceeded",
EDOM: "Math arg out of domain of func",
ERANGE: "Math result not representable",
EDEADLK: "Deadlock condition",
ENOLCK: "No record locks available",
ENOTEMPTY: "Directory not empty",
ELOOP: "Too many symbolic links",
ENOMSG: "No message of desired type",
EIDRM: "Identifier removed",
ECHRNG: "Channel number out of range",
EL2NSYNC: "Level 2 not synchronized",
EL3HLT: "Level 3 halted",
EL3RST: "Level 3 reset",
ELNRNG: "Link number out of range",
EUNATCH: "Protocol driver not attached",
ENOCSI: "No CSI structure available",
EL2HLT: "Level 2 halted",
EBADE: "Invalid exchange",
EBADR: "Invalid request descriptor",
EXFULL: "Exchange full",
ENOANO: "No anode",
EBADRQC: "Invalid request code",
EBADSLT: "Invalid slot",
EBFONT: "Bad font file fmt",
ENOSTR: "Device not a stream",
ENODATA: "No data (for no delay io)",
ETIME: "Timer expired",
ENOSR: "Out of streams resources",
ENONET: "Machine is not on the network",
ENOPKG: "Package not installed",
EREMOTE: "The object is remote",
ENOLINK: "The link has been severed",
EADV: "Advertise error",
ESRMNT: "Srmount error",
ECOMM: "Communication error on send",
EPROTO: "Protocol error",
EMULTIHOP: "Multihop attempted",
EDOTDOT: "Cross mount point (not really error)",
EBADMSG: "Trying to read unreadable message",
EOVERFLOW: "Value too large for defined data type",
ENOTUNIQ: "Given log. name not unique",
EBADFD: "f.d. invalid for this operation",
EREMCHG: "Remote address changed",
ELIBACC: "Can't access a needed shared lib",
ELIBBAD: "Accessing a corrupted shared lib",
ELIBSCN: ".lib section in a.out corrupted",
ELIBMAX: "Attempting to link in too many libs",
ELIBEXEC: "Attempting to exec a shared library",
ENOTSOCK: "Socket operation on non-socket",
EDESTADDRREQ: "Destination address required",
EMSGSIZE: "Message too long",
EPROTOTYPE: "Protocol wrong type for socket",
ENOPROTOOPT: "Protocol not available",
EPROTONOSUPPORT: "Unknown protocol",
ESOCKTNOSUPPORT: "Socket type not supported",
EOPNOTSUPP: "Operation not supported on transport endpoint",
EPFNOSUPPORT: "Protocol family not supported",
EAFNOSUPPORT: "Address family not supported by protocol family",
EADDRINUSE: "Address already in use",
EADDRNOTAVAIL: "Address not available",
ENETDOWN: "Network interface is not configured",
ENETUNREACH: "Network is unreachable",
ECONNABORTED: "Connection aborted",
ECONNRESET: "Connection reset by peer",
ENOBUFS: "No buffer space available",
EISCONN: "Socket is already connected",
ENOTCONN: "Socket is not connected",
ESHUTDOWN: "Can't send after socket shutdown",
ETIMEDOUT: "Connection timed out",
ECONNREFUSED: "Connection refused",
EHOSTDOWN: "Host is down",
EHOSTUNREACH: "Host is unreachable",
EALREADY: "Socket already connected",
EINPROGRESS: "Connection already in progress",
ENOMEDIUM: "No medium (in tape drive)",
ECANCELED: "Operation canceled.",
ELBIN: "Inode is remote (not really error)",
EFTYPE: "Inappropriate file type or format",
ENMFILE: "No more files",
ENOSHARE: "No such host or network path",
ECASECLASH: "Filename exists with different case",
}
// Do the interface allocations only once for common
// Errno values.
var (