ref: 2550b676852c8bbea1c4f22984991000fe6fc855
parent: db794e2073cc57f0a6f7606c0086b73fe9f02fda
author: Ori Bernstein <[email protected]>
date: Mon Dec 29 07:12:48 EST 2014
Get OSX up to par with some of the new code.
--- a/libstd/sys+osx-x64.myr
+++ b/libstd/sys+osx-x64.myr
@@ -12,6 +12,7 @@
type sockfam = uint8 /* socket family */
type filemode = uint16 /* file permission bits */
type kflags = uint16 /* kqueue flags */
+ type whence = int64
type timespec = struct
sec : uint64
@@ -118,6 +119,10 @@
ext : uint64[2] /* filter-specific extensions */
;;
+ const Seekset : whence = 0
+ const Seekcur : whence = 1
+ const Seekend : whence = 2
+
/* kqueue events */
const Kevadd : kflags = 0x0001 /* add event to kq (implies enable) */
const Kevdelete : kflags = 0x0002 /* delete event from kq */
@@ -569,7 +574,7 @@
const unlink : (path:byte[:] -> int)
const read : (fd:fd, buf:byte[:] -> size)
const write : (fd:fd, buf:byte[:] -> size)
- const lseek : (fd:fd, off:uint64, whence:int64 -> int64)
+ const lseek : (fd:fd, off:off, whence:whence -> off)
const stat : (path:byte[:], sb:statbuf# -> int64)
const lstat : (path:byte[:], sb:statbuf# -> int64)
const fstat : (fd:fd, sb:statbuf# -> int64)
@@ -631,7 +636,7 @@
extern const __osx_fork : (-> pid)
extern const __osx_pipe : (fd : fd[2]# -> int64)
extern const __osx_getpid : (-> pid)
-extern const __osx_lseek : (fd:fd, off:uint64, whence:int64 -> int64)
+extern const __osx_lseek : (fd:fd, off:off, whence:whence -> off)
extern const __osx_gettimeofday : (tv : timeval#, tz : timezone# -> int)
/*
extern const __osx_ptrace
@@ -703,7 +708,7 @@
const unlink = {path; -> syscall(Sysunlink, cstring(path)) castto(int)}
const read = {fd, buf; -> syscall(Sysread, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
const write = {fd, buf; -> syscall(Syswrite, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
-const lseek = {fd, off, whence; -> syscall(Syslseek, a(fd), a(off), a(whence))}
+const lseek = {fd, off, whence; -> __osx_lseek(fd, off, whence)}
const stat = {path, sb; -> syscall(Sysstat64, cstring(path), a(sb))}
const lstat = {path, sb; -> syscall(Syslstat64, cstring(path), a(sb))}
const fstat = {fd, sb; -> syscall(Sysfstat64, a(fd), a(sb))}
--- /dev/null
+++ b/libstd/syserrno+osx.myr
@@ -1,0 +1,54 @@
+pkg sys =
+ type errno = int
+
+ const Eperm : errno = -1 /* Operation not permitted */
+ const Enoent : errno = -2 /* No such file or directory */
+ const Esrch : errno = -3 /* No such process */
+ const Eintr : errno = -4 /* Interrupted system call */
+ const Eio : errno = -5 /* Input/output error */
+ const Enxio : errno = -6 /* Device not configured */
+ const E2big : errno = -7 /* Argument list too long */
+ const Enoexec : errno = -8 /* Exec format error */
+ const Ebadf : errno = -9 /* Bad file descriptor */
+ const Echild : errno = -10 /* No child processes */
+ const Edeadlk : errno = -11 /* Resource deadlock avoided */
+ /* 11 was EAGAIN */
+ const Enomem : errno = -12 /* Cannot allocate memory */
+ const Eacces : errno = -13 /* Permission denied */
+ const Efault : errno = -14 /* Bad address */
+ const Enotblk : errno = -15 /* Block device required */
+ const Ebusy : errno = -16 /* Device / Resource busy */
+ const Eexist : errno = -17 /* File exists */
+ const Exdev : errno = -18 /* Cross-device link */
+ const Enodev : errno = -19 /* Operation not supported by device */
+ const Enotdir : errno = -20 /* Not a directory */
+ const Eisdir : errno = -21 /* Is a directory */
+ const Einval : errno = -22 /* Invalid argument */
+ const Enfile : errno = -23 /* Too many open files in system */
+ const Emfile : errno = -24 /* Too many open files */
+ const Enotty : errno = -25 /* Inappropriate ioctl for device */
+ const Etxtbsy : errno = -26 /* Text file busy */
+ const Efbig : errno = -27 /* File too large */
+ const Enospc : errno = -28 /* No space left on device */
+ const Espipe : errno = -29 /* Illegal seek */
+ const Erofs : errno = -30 /* Read-only file system */
+ const Emlink : errno = -31 /* Too many links */
+ const Epipe : errno = -32 /* Broken pipe */
+
+ /* math software */
+ const Edom : errno = -33 /* Numerical argument out of domain */
+ const Erange : errno = -34 /* Result too large */
+
+ /* non-blocking and interrupt i/o */
+ const Eagain : errno = -35 /* Resource temporarily unavailable */
+ const Einprogress : errno = -36 /* Operation now in progress */
+ const Ealready : errno = -37 /* Operation already in progress */
+
+ /* ipc/network software -- argument errors */
+ const Enotsock : errno = -38 /* Socket operation on non-socket */
+ const Edestaddrreq : errno = -39 /* Destination address required */
+ const Emsgsize : errno = -40 /* Message too long */
+ const Eprototype : errno = -41 /* Protocol wrong type for socket */
+ const Enoprotoopt : errno = -42 /* Protocol not available */
+ const Eprotonosupport : errno = -43 /* Protocol not supported */
+;;
--- a/libstd/syserrno.myr
+++ b/libstd/syserrno.myr
@@ -1,38 +1,54 @@
pkg sys =
type errno = int
- const Eperm : errno = -1 /* Operation not permitted */
- const Enoent : errno = -2 /* No such file or directory */
- const Esrch : errno = -3 /* No such process */
- const Eintr : errno = -4 /* Interrupted system call */
- const Eio : errno = -5 /* I/O error */
- const Enxio : errno = -6 /* No such device or address */
- const E2big : errno = -7 /* Argument list too long */
- const Enoexec : errno = -8 /* Exec format error */
- const Ebadf : errno = -9 /* Bad file number */
- const Echild : errno = -10 /* No child processes */
- const Eagain : errno = -11 /* Try again */
- const Enomem : errno = -12 /* Out of memory */
- const Eacces : errno = -13 /* Permission denied */
- const Efault : errno = -14 /* Bad address */
- const Enotblk : errno = -15 /* Block device required */
- const Ebusy : errno = -16 /* Device or resource busy */
- const Eexist : errno = -17 /* File exists */
- const Exdev : errno = -18 /* Cross-device link */
- const Enodev : errno = -19 /* No such device */
- const Enotdir : errno = -20 /* Not a directory */
- const Eisdir : errno = -21 /* Is a directory */
- const Einval : errno = -22 /* Invalid argument */
- const Enfile : errno = -23 /* File table overflow */
- const Emfile : errno = -24 /* Too many open files */
- const Enotty : errno = -25 /* Not a typewriter */
- const Etxtbsy : errno = -26 /* Text file busy */
- const Efbig : errno = -27 /* File too large */
- const Enospc : errno = -28 /* No space left on device */
- const Espipe : errno = -29 /* Illegal seek */
- const Erofs : errno = -30 /* Read-only file system */
- const Emlink : errno = -31 /* Too many links */
- const Epipe : errno = -32 /* Broken pipe */
- const Edom : errno = -33 /* Math argument out of domain of func */
- const Erange : errno = -34 /* Math result not representable */
+ const Eperm : errno = -1 /* Operation not permitted */
+ const Enoent : errno = -2 /* No such file or directory */
+ const Esrch : errno = -3 /* No such process */
+ const Eintr : errno = -4 /* Interrupted system call */
+ const Eio : errno = -5 /* Input/output error */
+ const Enxio : errno = -6 /* Device not configured */
+ const E2big : errno = -7 /* Argument list too long */
+ const Enoexec : errno = -8 /* Exec format error */
+ const Ebadf : errno = -9 /* Bad file descriptor */
+ const Echild : errno = -10 /* No child processes */
+ const Edeadlk : errno = -11 /* Resource deadlock avoided */
+ /* 11 was EAGAIN */
+ const Enomem : errno = -12 /* Cannot allocate memory */
+ const Eacces : errno = -13 /* Permission denied */
+ const Efault : errno = -14 /* Bad address */
+ const Enotblk : errno = -15 /* Block device required */
+ const Ebusy : errno = -16 /* Device / Resource busy */
+ const Eexist : errno = -17 /* File exists */
+ const Exdev : errno = -18 /* Cross-device link */
+ const Enodev : errno = -19 /* Operation not supported by device */
+ const Enotdir : errno = -20 /* Not a directory */
+ const Eisdir : errno = -21 /* Is a directory */
+ const Einval : errno = -22 /* Invalid argument */
+ const Enfile : errno = -23 /* Too many open files in system */
+ const Emfile : errno = -24 /* Too many open files */
+ const Enotty : errno = -25 /* Inappropriate ioctl for device */
+ const Etxtbsy : errno = -26 /* Text file busy */
+ const Efbig : errno = -27 /* File too large */
+ const Enospc : errno = -28 /* No space left on device */
+ const Espipe : errno = -29 /* Illegal seek */
+ const Erofs : errno = -30 /* Read-only file system */
+ const Emlink : errno = -31 /* Too many links */
+ const Epipe : errno = -32 /* Broken pipe */
+
+ /* math software */
+ const Edom : errno = -33 /* Numerical argument out of domain */
+ const Erange : errno = -34 /* Result too large */
+
+ /* non-blocking and interrupt i/o */
+ const Eagain : errno = -35 /* Resource temporarily unavailable */
+ const Einprogress : errno = -36 /* Operation now in progress */
+ const Ealready : errno = -37 /* Operation already in progress */
+
+ /* ipc/network software -- argument errors */
+ const Enotsock : errno = -38 /* Socket operation on non-socket */
+ const Edestaddrreq : errno = -39 /* Destination address required */
+ const Emsgsize : errno = -40 /* Message too long */
+ const Eprototype : errno = -41 /* Protocol wrong type for socket */
+ const Enoprotoopt : errno = -42 /* Protocol not available */
+ const Eprotonosupport : errno = -43 /* Protocol not supported */
;;
--- a/libstd/systypes.myr
+++ b/libstd/systypes.myr
@@ -1,7 +1,7 @@
pkg sys =
- type size = int64 /* spans entire address space */
- type usize = int64 /* signed size */
- type off = uint64 /* file offsets */
- type intptr = uint64 /* can hold any pointer losslessly */
- type time = int64 /* milliseconds since epoch */
+ type size = int64 /* spans entire address space */
+ type usize = int64 /* signed size */
+ type off = int64 /* file offsets */
+ type intptr = uint64/* can hold any pointer losslessly */
+ type time = int64 /* milliseconds since epoch */
;;
--- a/libstd/syswrap+posixy.myr
+++ b/libstd/syswrap+posixy.myr
@@ -98,9 +98,12 @@
const fmtime = {path
var sb
+ var sec, nsec
if sys.stat(path, &sb) == 0
- -> `Some ((sb.mtime.sec*1_000 + sb.mtime.nsec/1_000_000) castto(time))
+ sec = sb.mtime.sec castto(time)
+ nsec = sb.mtime.nsec castto(time)
+ -> `Some sec*1000 + nsec/1_000_000
else
-> `None
;;