summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-07-13 22:46:57 -0700
committerOri Bernstein <ori@eigenstate.org>2019-07-13 22:46:57 -0700
commit820585fb7338092fa5b5001b81ad45b06376939d (patch)
tree47214d3efdf0459fdcd73994d83d2d54ed00b686 /lib
parent77246bfe1b9f147b1b255e811fb8b2032c49dc9e (diff)
downloadmc-820585fb7338092fa5b5001b81ad45b06376939d.tar.gz
Oops, mangled something with git9.
Diffstat (limited to 'lib')
-rw-r--r--lib/json/test/inputs/n_structure_no_data.json0
-rw-r--r--lib/json/test/inputs/n_structure_whitespace_U+2060_word_joiner.json1
-rw-r--r--lib/json/test/inputs/y_number_negative_zero.json1
-rw-r--r--lib/std/dir+openbsd.myr65
-rw-r--r--lib/std/syswrap-ss+openbsd.myr31
-rw-r--r--lib/std/test/bigint.myr8
-rw-r--r--lib/sys/ifreq+netbsd.myr2
-rw-r--r--lib/sys/ifreq+openbsd.myr2
-rw-r--r--lib/sys/ifreq+plan9.myr2
-rw-r--r--lib/sys/syserrno+openbsd.myr123
-rw-r--r--lib/thread/ncpu+openbsd.myr23
11 files changed, 250 insertions, 8 deletions
diff --git a/lib/json/test/inputs/n_structure_no_data.json b/lib/json/test/inputs/n_structure_no_data.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/json/test/inputs/n_structure_no_data.json
diff --git a/lib/json/test/inputs/n_structure_whitespace_U+2060_word_joiner.json b/lib/json/test/inputs/n_structure_whitespace_U+2060_word_joiner.json
new file mode 100644
index 0000000..81156a6
--- /dev/null
+++ b/lib/json/test/inputs/n_structure_whitespace_U+2060_word_joiner.json
@@ -0,0 +1 @@
+[⁠] \ No newline at end of file
diff --git a/lib/json/test/inputs/y_number_negative_zero.json b/lib/json/test/inputs/y_number_negative_zero.json
new file mode 100644
index 0000000..37af131
--- /dev/null
+++ b/lib/json/test/inputs/y_number_negative_zero.json
@@ -0,0 +1 @@
+[-0] \ No newline at end of file
diff --git a/lib/std/dir+openbsd.myr b/lib/std/dir+openbsd.myr
new file mode 100644
index 0000000..274175d
--- /dev/null
+++ b/lib/std/dir+openbsd.myr
@@ -0,0 +1,65 @@
+use sys
+
+use "alloc"
+use "die"
+use "memops"
+use "option"
+use "result"
+use "slcp"
+use "sldup"
+use "types"
+
+pkg std =
+ type dir = struct
+ fd : sys.fd
+ buf : byte[16384]
+ len : int64
+ off : int64
+ ;;
+
+ const diropen : (p : byte[:] -> std.result(dir#, byte[:]))
+ const dirread : (d : dir# -> std.option(byte[:]))
+ const dirclose : (d : dir# -> void)
+;;
+
+const diropen = {p
+ var fd
+ var dir
+
+ fd = sys.open(p, sys.Ordonly | sys.Odir)
+ if fd < 0
+ -> `Err "couldn't open directory"
+ ;;
+ dir = zalloc()
+ dir.fd = fd
+ -> `Ok dir
+}
+
+const dirread = {d
+ var len
+ var dent
+ var namelen
+
+ if d.off >= d.len
+ len = sys.getdents(d.fd, d.buf[:])
+ if len <= 0
+ -> `None
+ ;;
+ d.len = len
+ d.off = 0
+ ;;
+
+ dent = (&d.buf[d.off] : sys.dirent#)
+ namelen = 0
+ d.off += (dent.reclen : int64)
+ while dent.name[namelen] != 0
+ namelen++
+ ;;
+ -> `Some sldup(dent.name[:namelen])
+}
+
+const dirclose = {d
+ sys.close(d.fd)
+ free(d)
+}
+
diff --git a/lib/std/syswrap-ss+openbsd.myr b/lib/std/syswrap-ss+openbsd.myr
new file mode 100644
index 0000000..0f4ed65
--- /dev/null
+++ b/lib/std/syswrap-ss+openbsd.myr
@@ -0,0 +1,31 @@
+use sys
+use "types"
+use "errno"
+use "cstrconv"
+use "slcp"
+use "die"
+
+pkg std =
+ const nanosleep : (nsecs : uint64 -> errno)
+ $noret const exit : (status:int -> void)
+
+ pkglocal const bgetcwd : (buf : byte[:] -> errno)
+;;
+
+const exit = {status; sys.exit(status)}
+
+const bgetcwd = {buf
+ -> (sys.__getcwd(buf) - 1 : errno)
+}
+
+const nanosleep = {nsecs
+ var req, rem
+ var s, ns
+
+ s = (nsecs / 1_000_000_000 : int64)
+ ns = (nsecs % 1_000_000_000 : int64)
+ req = [.sec = s, .nsec = ns]
+
+ -> (sys.nanosleep(&req, &rem) : errno)
+}
+
diff --git a/lib/std/test/bigint.myr b/lib/std/test/bigint.myr
index 77b822f..c87f1f3 100644
--- a/lib/std/test/bigint.myr
+++ b/lib/std/test/bigint.myr
@@ -21,7 +21,6 @@ const main = {
[.name = "format-zero", .fn = fmtzero],
[.name = "division", .fn = smokediv],
[.name = "modulo", .fn = smokemod],
- [.name = "shift", .fn = shiftoff],
[.name = "add-negatives", .fn = addneg],
[.name = "sub-negatives", .fn = subneg],
][:])
@@ -265,13 +264,6 @@ const subneg = {c
"0")
}
-const shiftoff = {c
- run(c, std.mk(`Shr ( \
- std.mk(`Val "1"), \
- std.mk(`Val "65"))), \
- "0")
-}
-
const run = {c : testr.ctx#, e : cmd#, res : byte[:]
var buf : byte[4096]
var v, n
diff --git a/lib/sys/ifreq+netbsd.myr b/lib/sys/ifreq+netbsd.myr
new file mode 100644
index 0000000..e7d6400
--- /dev/null
+++ b/lib/sys/ifreq+netbsd.myr
@@ -0,0 +1,2 @@
+pkg sys =
+;;
diff --git a/lib/sys/ifreq+openbsd.myr b/lib/sys/ifreq+openbsd.myr
new file mode 100644
index 0000000..e7d6400
--- /dev/null
+++ b/lib/sys/ifreq+openbsd.myr
@@ -0,0 +1,2 @@
+pkg sys =
+;;
diff --git a/lib/sys/ifreq+plan9.myr b/lib/sys/ifreq+plan9.myr
new file mode 100644
index 0000000..e7d6400
--- /dev/null
+++ b/lib/sys/ifreq+plan9.myr
@@ -0,0 +1,2 @@
+pkg sys =
+;;
diff --git a/lib/sys/syserrno+openbsd.myr b/lib/sys/syserrno+openbsd.myr
new file mode 100644
index 0000000..e48f893
--- /dev/null
+++ b/lib/sys/syserrno+openbsd.myr
@@ -0,0 +1,123 @@
+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 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 filesystem */
+ 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 */
+ const Esocktnosupport : errno = -44 /* Socket type not supported */
+ const Eopnotsupp : errno = -45 /* Operation not supported */
+ const Epfnosupport : errno = -46 /* Protocol family not supported */
+ const Eafnosupport : errno = -47 /* Address family not supported by protocol family */
+ const Eaddrinuse : errno = -48 /* Address already in use */
+ const Eaddrnotavail : errno = -49 /* Can't assign requested address */
+
+ /* ipc/network software -- operational errors */
+ const Enetdown : errno = -50 /* Network is down */
+ const Enetunreach : errno = -51 /* Network is unreachable */
+ const Enetreset : errno = -52 /* Network dropped connection on reset */
+ const Econnaborted : errno = -53 /* Software caused connection abort */
+ const Econnreset : errno = -54 /* Connection reset by peer */
+ const Enobufs : errno = -55 /* No buffer space available */
+ const Eisconn : errno = -56 /* Socket is already connected */
+ const Enotconn : errno = -57 /* Socket is not connected */
+ const Eshutdown : errno = -58 /* Can't send after socket shutdown */
+ const Etoomanyrefs : errno = -59 /* Too many references: can't splice */
+ const Etimedout : errno = -60 /* Operation timed out */
+ const Econnrefused : errno = -61 /* Connection refused */
+
+ const Eloop : errno = -62 /* Too many levels of symbolic links */
+ const Enametoolong : errno = -63 /* File name too long */
+
+ /* should be rearranged */
+ const Ehostdown : errno = -64 /* Host is down */
+ const Ehostunreach : errno = -65 /* No route to host */
+ const Enotempty : errno = -66 /* Directory not empty */
+
+ /* quotas & mush */
+ const Eproclim : errno = -67 /* Too many processes */
+ const Eusers : errno = -68 /* Too many users */
+ const Edquot : errno = -69 /* Disc quota exceeded */
+
+ /* Network File System */
+ const Estale : errno = -70 /* Stale NFS file handle */
+ const Eremote : errno = -71 /* Too many levels of remote in path */
+ const Ebadrpc : errno = -72 /* RPC struct is bad */
+ const Erpcmismatch : errno = -73 /* RPC version wrong */
+ const Eprogunavail : errno = -74 /* RPC prog. not avail */
+ const Eprogmismatch : errno = -75 /* Program version wrong */
+ const Eprocunavail : errno = -76 /* Bad procedure for program */
+
+ const Enolck : errno = -77 /* No locks available */
+ const Enosys : errno = -78 /* Function not implemented */
+
+ const Eftype : errno = -79 /* Inappropriate file type or format */
+ const Eauth : errno = -80 /* Authentication error */
+ const Eneedauth : errno = -81 /* Need authenticator */
+ const Eidrm : errno = -82 /* Identifier removed */
+ const Enomsg : errno = -83 /* No message of desired type */
+ const Eoverflow : errno = -84 /* Value too large to be stored in data type */
+ const Ecanceled : errno = -85 /* Operation canceled */
+ const Eilseq : errno = -86 /* Illegal byte sequence */
+ const Enoattr : errno = -87 /* Attribute not found */
+
+ const Edoofus : errno = -88 /* Programming error */
+
+ const Ebadmsg : errno = -89 /* Bad message */
+ const Emultihop : errno = -90 /* Multihop attempted */
+ const Enolink : errno = -91 /* Link has been severed */
+ const Eproto : errno = -92 /* Protocol error */
+
+ const Enotcapable : errno = -93 /* Capabilities insufficient */
+ const Ecapmode : errno = -94 /* Not permitted in capability mode */
+ const Enotrecoverable : errno = -95 /* State not recoverable */
+ const Eownerdead : errno = -96 /* Previous owner died */
+
+ const Elast : errno = -96 /* Must be equal largest errno */
+;;
diff --git a/lib/thread/ncpu+openbsd.myr b/lib/thread/ncpu+openbsd.myr
new file mode 100644
index 0000000..1aa3dc1
--- /dev/null
+++ b/lib/thread/ncpu+openbsd.myr
@@ -0,0 +1,23 @@
+use std
+use sys
+
+pkg thread =
+ const ncpu : (-> int)
+;;
+
+const ncpu = {
+ var mib : int[2]
+ var ncpu : int
+ var ncpusz
+ var res
+
+ mib[0] = 6 /* CTL_HW */
+ mib[1] = 3 /* HW_NCPU */
+ ncpusz = sizeof(int)
+
+ res = sys.sysctl(mib[:], (&ncpu : void#), &ncpusz, (0 : void#), (0 : sys.size#))
+ if res < 0 || ncpu <= 0
+ -> 1
+ ;;
+ -> ncpu
+}