shithub: mc

Download patch

ref: 8d0b5de4e96b6c765fa8470184c8ba589c3b44b8
parent: b670491dc82509c0b000688f179bb6266a24f314
author: Ori Bernstein <[email protected]>
date: Sun Sep 9 09:13:27 EDT 2012

Move files into subdirectory in preparation for merge.

--- a/Makefile
+++ /dev/null
@@ -1,11 +1,0 @@
-# don't build anything for 'all'
-all: 
-	./bld.sh
-.PHONY: clean
-clean:
-	@for i in `awk '{print $$1}' tests`; do \
-	    echo rm -f $$i; \
-	    rm -f $$i; \
-	done
-
-install:
--- a/alloc.myr
+++ /dev/null
@@ -1,220 +1,0 @@
-use "die.use"
-use "sys.use"
-use "types.use"
-
-pkg std =
-	generic alloc	: (		-> @a*)
-	generic free	: (v:@a*	-> void)
-
-	generic mkslice	: (len : size	-> @a[:])
-	generic freeslice: (sl : @a[:]	-> void)
-
-	const bytealloc	: (sz:size	-> byte*)
-	const bytefree	: (m:byte*, sz:size	-> void)
-;;
-
-/* null pointers */
-const Zbyte	= 0 castto(byte*)
-const Zslab	= 0 castto(slab*)
-const Zchunk	= 0 castto(chunk*)
-
-const Slabsz 	= 1048576	/* 1 meg slabs */
-const Cachemax	= 16	/* maximum number of slabs in the cache */
-const Bucketmax	= 32768	/* Slabsz / 8; a balance. */
-const Align	= 16	/* minimum allocation alignment */
-
-var buckets	: bucket[32] /* excessive */
-var initdone	: int
-
-type bucket = struct
-	sz	: size	/* aligned size */
-	nper	: size	/* max number of elements per slab */
-	slabs	: slab*	/* partially filled or free slabs */
-	cache	: slab* /* cache of empty slabs, to prevent thrashing */
-	ncache	: size  /* size of cache */
-;;
-
-type slab = struct
-	head		: byte*	/* head of virtual addresses, so we don't leak address space */
-	next		: slab*	/* the next slab on the chain */
-	freehd	: chunk*	/* the nodes we're allocating */
-	nfree	: size	/* the number of free nodes */
-;;
-
-type chunk = struct	/* NB: must be smaller than sizeof(slab) */
-	next	: chunk*	/* the next chunk in the free list */
-;;
-
-generic alloc = {-> @a*
-	-> bytealloc(sizeof(@a)) castto(@a*)
-}
-
-generic free = {v:@a* -> void
-	bytefree(v castto(byte*), sizeof(@a))
-}
-
-generic mkslice = {len
-	var p
-
-	p = bytealloc(len*sizeof(@a)) castto(@a*)
-	-> p[0:len]
-}
-
-generic freeslice = {sl
-	-> bytefree(sl castto(byte*), sl.len * sizeof(@a))
-}
-
-const bytealloc = {sz
-	var i
-	var bkt
-
-	if !initdone
-		for i = 0; i < buckets.len && (Align << i) <= Bucketmax; i++
-			bktinit(&buckets[i], Align << i)
-		;;
-		initdone = 1
-	;;
-
-	if (sz <= Bucketmax)
-		bkt = &buckets[bktnum(sz)]
-		-> bktalloc(bkt)
-	else
-		-> mmap(Zbyte, sz, Mprotrw, Mpriv | Manon, -1, 0)
-	;;
-}
-
-const bytefree = {m, sz
-	var bkt
-
-	if (sz < Bucketmax)
-		bkt = &buckets[bktnum(sz)]
-		bktfree(bkt, m)
-	else
-		munmap(m, sz)
-	;;
-}
-
-const bktinit = {b : bucket*, sz
-	b.sz = align(sz, Align)
-	b.nper = (Slabsz - sizeof(slab))/b.sz
-	b.slabs = Zslab
-	b.cache = Zslab
-	b.ncache = 0
-}
-
-const mkslab = {bkt : bucket*
-	var i
-	var p
-	var s
-	var b
-	var bnext
-	var off /* offset of chunk head */
-
-	if bkt.ncache > 0
-		s = bkt.cache
-		bkt.cache = s.next
-		bkt.ncache--
-	;;
-	/* tricky: we need power of two alignment, so we allocate double the
-	   needed size, chop off the unaligned ends, and waste the address
-	   space. Since the OS is "smart enough", this shouldn't actually
-	   cost us memory, and 64 bits of address space means that we're not
-	   going to have issues with running out of address space for a
-	   while. On a 32 bit system this would be a bad idea. */
-	p = mmap(Zbyte, Slabsz*2, Mprotrw, Mpriv | Manon, -1, 0)
-	if p == Mapbad
-		die("Unable to mmap")
-	;;
-
-	s = align(p castto(intptr), Slabsz) castto(slab*)
-	s.head = p
-	s.nfree = bkt.nper
-	/* skip past the slab header */
-	off = align(sizeof(slab), Align)
-	bnext = nextchunk(s castto(chunk*), off)
-	s.freehd = bnext
-	for i = 0; i < bkt.nper; i++
-		b = bnext
-		bnext = nextchunk(b, bkt.sz)
-		b.next = bnext
-	;;
-	b.next = Zchunk
-	-> s
-}
-
-const bktalloc = {bkt
-	var s
-	var b
-
-	/* find a slab */
-	s = bkt.slabs
-	if s == Zslab
-		s = mkslab(bkt)
-		if s == Zslab
-			die("No memory left")
-		;;
-		bkt.slabs = s
-	;;
-
-	/* grab the first chunk on the slab */
-	b = s.freehd
-	s.freehd = b.next
-	s.nfree--
-	if !s.nfree
-		bkt.slabs = s.next
-		s.next = Zslab
-	;;
-
-	-> b castto(byte*)
-}
-
-const bktfree = {bkt, m
-	var s
-	var b
-
-	s = mtrunc(m, Slabsz) castto(slab*)
-	b = m castto(chunk*)
-	if s.nfree == 0
-		s.next = bkt.slabs
-		bkt.slabs = s
-	elif s.nfree == bkt.nper
-		if bkt.ncache < Cachemax
-			s.next = bkt.cache
-			bkt.cache = s
-		else
-			/* we mapped 2*Slabsz so we could align it,
-			 so we need to unmap the same */
-			munmap(s.head, Slabsz*2)
-		;;
-	;;
-	s.nfree++
-	b.next = s.freehd
-	s.freehd = b
-}
-
-const bktnum = {sz
-	var i
-	var bktsz
-
-	bktsz = Align
-	for i = 0; bktsz <= Bucketmax; i++
-		if bktsz >= sz
-			-> i
-		;;
-		bktsz *= 2
-	;;
-	die("Size does not match any buckets")
-}
-
-/* chunks are variable sizes, so we can't just take a slice */
-const nextchunk = {b, sz
-	-> ((b castto(intptr)) + sz) castto(chunk*)
-}
-
-const align = {v, align
-	-> (v + align - 1) & ~(align - 1)
-}
-
-const mtrunc = {m, align
-	-> ((m castto(intptr)) & ~(align - 1)) castto(byte*)
-}
--- a/bld.sh
+++ /dev/null
@@ -1,71 +1,0 @@
-#!/bin/bash
-
-# We have no dependency handling yet, so this is done via
-# a shell script. Also, we want to rebuild everything for
-# testing purposes on every run as things stand.
-
-export PATH=.:$PATH
-export MC=6m
-export MU=muse
-export CC=cc
-export ASOPT="-g"
-case `uname` in
-    Darwin) export SYS=osx;;
-    Linux) export SYS=linux;;
-esac
-
-function use {
-    for i in $@; do
-        N=`basename $i .myr`
-        N=${N%%-$SYS}
-
-        echo $MU -o $N.use $i && \
-        $MU -o $N.use $i
-    done
-}
-
-function build {
-    for i in $@; do
-        N=`basename $i .myr`
-
-        echo $MC $i && \
-            $MC -I. $i
-    done
-}
-
-function assem {
-    for i in $@; do
-        $CC $ASOPT -c $i
-    done
-}
-
-# Library source.
-ASM=syscall-$SYS.s
-MYR="types.myr \
-    sys-$SYS.myr \
-    die.myr \
-    varargs.myr \
-    alloc.myr\
-    utf.myr \
-    fmt.myr \
-    rand.myr \
-    chartype.myr"
-
-OBJ="$(echo $ASM | sed 's/\.s/.o /g') $(echo $MYR | sed 's/\.myr/.o /g')"
-USE="$(echo $MYR | sed 's/\.myr/.use /g' | sed "s/-$SYS//g")"
-rm $OBJ test libstd.a
-assem $ASM
-use $MYR
-build $MYR
-
-echo $MU -mo std $USE
-$MU -mo std $USE
-echo ar -rcs libstd.a $OBJ
-ar -rcs libstd.a $OBJ
-
-# build test program
-build test.myr
-COMP="$CC -o test test.o -L. -lstd"
-echo $COMP
-$COMP
-
--- a/chartype.myr
+++ /dev/null
@@ -1,1203 +1,0 @@
-use "die.use"
-use "sys.use"
-
-/* 
-   Tables adapted from plan 9's runetype.c,
-   which lives in sys/src/libc/port/runetype.c
-*/
-
-pkg std =
-	const isalpha	: (c : char -> bool)
-	const isnum	: (c : char -> bool)
-	const isalnum	: (c : char -> bool)
-	const isspace	: (c : char -> bool)
-
-	const islower	: (c : char -> bool)
-	const isupper	: (c : char -> bool)
-	const istitle	: (c : char -> bool)
-
-	const tolower	: (c : char -> char)
-	const toupper	: (c : char -> char)
-	const totitle	: (c : char -> char)
-;;
-
-/*
- * alpha ranges -
- *	only covers ranges not in lower||upper
- */
-const ralpha2 = [
-	0x00d8,	0x00f6,	/* Ø - ö */
-	0x00f8,	0x01f5,	/* ø - ǵ */
-	0x0250,	0x02a8,	/* ɐ - ʨ */
-	0x038e,	0x03a1,	/* Ύ - Ρ */
-	0x03a3,	0x03ce,	/* Σ - ώ */
-	0x03d0,	0x03d6,	/* ϐ - ϖ */
-	0x03e2,	0x03f3,	/* Ϣ - ϳ */
-	0x0490,	0x04c4,	/* Ґ - ӄ */
-	0x0561,	0x0587,	/* ա - և */
-	0x05d0,	0x05ea,	/* א - ת */
-	0x05f0,	0x05f2,	/* װ - ײ */
-	0x0621,	0x063a,	/* ء - غ */
-	0x0640,	0x064a,	/* ـ - ي */
-	0x0671,	0x06b7,	/* ٱ - ڷ */
-	0x06ba,	0x06be,	/* ں - ھ */
-	0x06c0,	0x06ce,	/* ۀ - ێ */
-	0x06d0,	0x06d3,	/* ې - ۓ */
-	0x0905,	0x0939,	/* अ - ह */
-	0x0958,	0x0961,	/* क़ - ॡ */
-	0x0985,	0x098c,	/* অ - ঌ */
-	0x098f,	0x0990,	/* এ - ঐ */
-	0x0993,	0x09a8,	/* ও - ন */
-	0x09aa,	0x09b0,	/* প - র */
-	0x09b6,	0x09b9,	/* শ - হ */
-	0x09dc,	0x09dd,	/* ড় - ঢ় */
-	0x09df,	0x09e1,	/* য় - ৡ */
-	0x09f0,	0x09f1,	/* ৰ - ৱ */
-	0x0a05,	0x0a0a,	/* ਅ - ਊ */
-	0x0a0f,	0x0a10,	/* ਏ - ਐ */
-	0x0a13,	0x0a28,	/* ਓ - ਨ */
-	0x0a2a,	0x0a30,	/* ਪ - ਰ */
-	0x0a32,	0x0a33,	/* ਲ - ਲ਼ */
-	0x0a35,	0x0a36,	/* ਵ - ਸ਼ */
-	0x0a38,	0x0a39,	/* ਸ - ਹ */
-	0x0a59,	0x0a5c,	/* ਖ਼ - ੜ */
-	0x0a85,	0x0a8b,	/* અ - ઋ */
-	0x0a8f,	0x0a91,	/* એ - ઑ */
-	0x0a93,	0x0aa8,	/* ઓ - ન */
-	0x0aaa,	0x0ab0,	/* પ - ર */
-	0x0ab2,	0x0ab3,	/* લ - ળ */
-	0x0ab5,	0x0ab9,	/* વ - હ */
-	0x0b05,	0x0b0c,	/* ଅ - ଌ */
-	0x0b0f,	0x0b10,	/* ଏ - ଐ */
-	0x0b13,	0x0b28,	/* ଓ - ନ */
-	0x0b2a,	0x0b30,	/* ପ - ର */
-	0x0b32,	0x0b33,	/* ଲ - ଳ */
-	0x0b36,	0x0b39,	/* ଶ - ହ */
-	0x0b5c,	0x0b5d,	/* ଡ଼ - ଢ଼ */
-	0x0b5f,	0x0b61,	/* ୟ - ୡ */
-	0x0b85,	0x0b8a,	/* அ - ஊ */
-	0x0b8e,	0x0b90,	/* எ - ஐ */
-	0x0b92,	0x0b95,	/* ஒ - க */
-	0x0b99,	0x0b9a,	/* ங - ச */
-	0x0b9e,	0x0b9f,	/* ஞ - ட */
-	0x0ba3,	0x0ba4,	/* ண - த */
-	0x0ba8,	0x0baa,	/* ந - ப */
-	0x0bae,	0x0bb5,	/* ம - வ */
-	0x0bb7,	0x0bb9,	/* ஷ - ஹ */
-	0x0c05,	0x0c0c,	/* అ - ఌ */
-	0x0c0e,	0x0c10,	/* ఎ - ఐ */
-	0x0c12,	0x0c28,	/* ఒ - న */
-	0x0c2a,	0x0c33,	/* ప - ళ */
-	0x0c35,	0x0c39,	/* వ - హ */
-	0x0c60,	0x0c61,	/* ౠ - ౡ */
-	0x0c85,	0x0c8c,	/* ಅ - ಌ */
-	0x0c8e,	0x0c90,	/* ಎ - ಐ */
-	0x0c92,	0x0ca8,	/* ಒ - ನ */
-	0x0caa,	0x0cb3,	/* ಪ - ಳ */
-	0x0cb5,	0x0cb9,	/* ವ - ಹ */
-	0x0ce0,	0x0ce1,	/* ೠ - ೡ */
-	0x0d05,	0x0d0c,	/* അ - ഌ */
-	0x0d0e,	0x0d10,	/* എ - ഐ */
-	0x0d12,	0x0d28,	/* ഒ - ന */
-	0x0d2a,	0x0d39,	/* പ - ഹ */
-	0x0d60,	0x0d61,	/* ൠ - ൡ */
-	0x0e01,	0x0e30,	/* ก - ะ */
-	0x0e32,	0x0e33,	/* า - ำ */
-	0x0e40,	0x0e46,	/* เ - ๆ */
-	0x0e5a,	0x0e5b,	/* ๚ - ๛ */
-	0x0e81,	0x0e82,	/* ກ - ຂ */
-	0x0e87,	0x0e88,	/* ງ - ຈ */
-	0x0e94,	0x0e97,	/* ດ - ທ */
-	0x0e99,	0x0e9f,	/* ນ - ຟ */
-	0x0ea1,	0x0ea3,	/* ມ - ຣ */
-	0x0eaa,	0x0eab,	/* ສ - ຫ */
-	0x0ead,	0x0eae,	/* ອ - ຮ */
-	0x0eb2,	0x0eb3,	/* າ - ຳ */
-	0x0ec0,	0x0ec4,	/* ເ - ໄ */
-	0x0edc,	0x0edd,	/* ໜ - ໝ */
-	0x0f18,	0x0f19,	/* ༘ - ༙ */
-	0x0f40,	0x0f47,	/* ཀ - ཇ */
-	0x0f49,	0x0f69,	/* ཉ - ཀྵ */
-	0x10d0,	0x10f6,	/* ა - ჶ */
-	0x1100,	0x1159,	/* ᄀ - ᅙ */
-	0x115f,	0x11a2,	/* ᅟ - ᆢ */
-	0x11a8,	0x11f9,	/* ᆨ - ᇹ */
-	0x1e00,	0x1e9b,	/* Ḁ - ẛ */
-	0x1f50,	0x1f57,	/* ὐ - ὗ */
-	0x1f80,	0x1fb4,	/* ᾀ - ᾴ */
-	0x1fb6,	0x1fbc,	/* ᾶ - ᾼ */
-	0x1fc2,	0x1fc4,	/* ῂ - ῄ */
-	0x1fc6,	0x1fcc,	/* ῆ - ῌ */
-	0x1fd0,	0x1fd3,	/* ῐ - ΐ */
-	0x1fd6,	0x1fdb,	/* ῖ - Ί */
-	0x1fe0,	0x1fec,	/* ῠ - Ῥ */
-	0x1ff2,	0x1ff4,	/* ῲ - ῴ */
-	0x1ff6,	0x1ffc,	/* ῶ - ῼ */
-	0x210a,	0x2113,	/* ℊ - ℓ */
-	0x2115,	0x211d,	/* ℕ - ℝ */
-	0x2120,	0x2122,	/* ℠ - ™ */
-	0x212a,	0x2131,	/* K - ℱ */
-	0x2133,	0x2138,	/* ℳ - ℸ */
-	0x3041,	0x3094,	/* ぁ - ゔ */
-	0x30a1,	0x30fa,	/* ァ - ヺ */
-	0x3105,	0x312c,	/* ㄅ - ㄬ */
-	0x3131,	0x318e,	/* ㄱ - ㆎ */
-	0x3192,	0x319f,	/* ㆒ - ㆟ */
-	0x3260,	0x327b,	/* ㉠ - ㉻ */
-	0x328a,	0x32b0,	/* ㊊ - ㊰ */
-	0x32d0,	0x32fe,	/* ㋐ - ㋾ */
-	0x3300,	0x3357,	/* ㌀ - ㍗ */
-	0x3371,	0x3376,	/* ㍱ - ㍶ */
-	0x337b,	0x3394,	/* ㍻ - ㎔ */
-	0x3399,	0x339e,	/* ㎙ - ㎞ */
-	0x33a9,	0x33ad,	/* ㎩ - ㎭ */
-	0x33b0,	0x33c1,	/* ㎰ - ㏁ */
-	0x33c3,	0x33c5,	/* ㏃ - ㏅ */
-	0x33c7,	0x33d7,	/* ㏇ - ㏗ */
-	0x33d9,	0x33dd,	/* ㏙ - ㏝ */
-	0x4e00,	0x9fff,	/* 一 - 鿿 */
-	0xac00,	0xd7a3,	/* 가 - 힣 */
-	0xf900,	0xfb06,	/* 豈 - st */
-	0xfb13,	0xfb17,	/* ﬓ - ﬗ */
-	0xfb1f,	0xfb28,	/* ײַ - ﬨ */
-	0xfb2a,	0xfb36,	/* שׁ - זּ */
-	0xfb38,	0xfb3c,	/* טּ - לּ */
-	0xfb40,	0xfb41,	/* נּ - סּ */
-	0xfb43,	0xfb44,	/* ףּ - פּ */
-	0xfb46,	0xfbb1,	/* צּ - ﮱ */
-	0xfbd3,	0xfd3d,	/* ﯓ - ﴽ */
-	0xfd50,	0xfd8f,	/* ﵐ - ﶏ */
-	0xfd92,	0xfdc7,	/* ﶒ - ﷇ */
-	0xfdf0,	0xfdf9,	/* ﷰ - ﷹ */
-	0xfe70,	0xfe72,	/* ﹰ - ﹲ */
-	0xfe76,	0xfefc,	/* ﹶ - ﻼ */
-	0xff66,	0xff6f,	/* ヲ - ッ */
-	0xff71,	0xff9d,	/* ア - ン */
-	0xffa0,	0xffbe,	/* ᅠ - ᄒ */
-	0xffc2,	0xffc7,	/* ᅡ - ᅦ */
-	0xffca,	0xffcf,	/* ᅧ - ᅬ */
-	0xffd2,	0xffd7,	/* ᅭ - ᅲ */
-	0xffda,	0xffdc	/* ᅳ - ᅵ */
-]
-
-/*
- * alpha singlets -
- *	only covers ranges not in lower||upper
- */
-const ralpha1 = [
-	0x00aa,	/* ª */
-	0x00b5,	/* µ */
-	0x00ba,	/* º */
-	0x03da,	/* Ϛ */
-	0x03dc,	/* Ϝ */
-	0x03de,	/* Ϟ */
-	0x03e0,	/* Ϡ */
-	0x06d5,	/* ە */
-	0x09b2,	/* ল */
-	0x0a5e,	/* ਫ਼ */
-	0x0a8d,	/* ઍ */
-	0x0ae0,	/* ૠ */
-	0x0b9c,	/* ஜ */
-	0x0cde,	/* ೞ */
-	0x0e4f,	/* ๏ */
-	0x0e84,	/* ຄ */
-	0x0e8a,	/* ຊ */
-	0x0e8d,	/* ຍ */
-	0x0ea5,	/* ລ */
-	0x0ea7,	/* ວ */
-	0x0eb0,	/* ະ */
-	0x0ebd,	/* ຽ */
-	0x1fbe,	/* ι */
-	0x207f,	/* ⁿ */
-	0x20a8,	/* ₨ */
-	0x2102,	/* ℂ */
-	0x2107,	/* ℇ */
-	0x2124,	/* ℤ */
-	0x2126,	/* Ω */
-	0x2128,	/* ℨ */
-	0xfb3e,	/* מּ */
-	0xfe74	/* ﹴ */
-]
-
-/*
- * space ranges
- */
-const rspace2 = [
-	0x0009,	0x000a,	/* rand newline */
-	0x0020,	0x0020,	/* space */
-	0x0085, 0x0085,
-	0x00a0,	0x00a0,	/*   */
-	0x1680, 0x1680,
-	0x180e, 0x180e,
-	0x2000,	0x200b,	/*   - ​ */
-	0x2028,	0x2029,	/* 
 - 
 */
-	0x202f, 0x202f,
-	0x205f, 0x205f,
-	0x3000,	0x3000,	/*   */
-	0xfeff,	0xfeff	/*  */
-]
-
-/*
- * lower case ranges
- *	3rd col is conversion excess 500
- */
-const rtoupper2 = [
-	0x0061,	0x007a, 468,	/* a-z A-Z */
-	0x00e0,	0x00f6, 468,	/* à-ö À-Ö */
-	0x00f8,	0x00fe, 468,	/* ø-þ Ø-Þ */
-	0x0256,	0x0257, 295,	/* ɖ-ɗ Ɖ-Ɗ */
-	0x0258,	0x0259, 298,	/* ɘ-ə Ǝ-Ə */
-	0x028a,	0x028b, 283,	/* ʊ-ʋ Ʊ-Ʋ */
-	0x03ad,	0x03af, 463,	/* έ-ί Έ-Ί */
-	0x03b1,	0x03c1, 468,	/* α-ρ Α-Ρ */
-	0x03c3,	0x03cb, 468,	/* σ-ϋ Σ-Ϋ */
-	0x03cd,	0x03ce, 437,	/* ύ-ώ Ύ-Ώ */
-	0x0430,	0x044f, 468,	/* а-я А-Я */
-	0x0451,	0x045c, 420,	/* ё-ќ Ё-Ќ */
-	0x045e,	0x045f, 420,	/* ў-џ Ў-Џ */
-	0x0561,	0x0586, 452,	/* ա-ֆ Ա-Ֆ */
-	0x1f00,	0x1f07, 508,	/* ἀ-ἇ Ἀ-Ἇ */
-	0x1f10,	0x1f15, 508,	/* ἐ-ἕ Ἐ-Ἕ */
-	0x1f20,	0x1f27, 508,	/* ἠ-ἧ Ἠ-Ἧ */
-	0x1f30,	0x1f37, 508,	/* ἰ-ἷ Ἰ-Ἷ */
-	0x1f40,	0x1f45, 508,	/* ὀ-ὅ Ὀ-Ὅ */
-	0x1f60,	0x1f67, 508,	/* ὠ-ὧ Ὠ-Ὧ */
-	0x1f70,	0x1f71, 574,	/* ὰ-ά Ὰ-Ά */
-	0x1f72,	0x1f75, 586,	/* ὲ-ή Ὲ-Ή */
-	0x1f76,	0x1f77, 600,	/* ὶ-ί Ὶ-Ί */
-	0x1f78,	0x1f79, 628,	/* ὸ-ό Ὸ-Ό */
-	0x1f7a,	0x1f7b, 612,	/* ὺ-ύ Ὺ-Ύ */
-	0x1f7c,	0x1f7d, 626,	/* ὼ-ώ Ὼ-Ώ */
-	0x1f80,	0x1f87, 508,	/* ᾀ-ᾇ ᾈ-ᾏ */
-	0x1f90,	0x1f97, 508,	/* ᾐ-ᾗ ᾘ-ᾟ */
-	0x1fa0,	0x1fa7, 508,	/* ᾠ-ᾧ ᾨ-ᾯ */
-	0x1fb0,	0x1fb1, 508,	/* ᾰ-ᾱ Ᾰ-Ᾱ */
-	0x1fd0,	0x1fd1, 508,	/* ῐ-ῑ Ῐ-Ῑ */
-	0x1fe0,	0x1fe1, 508,	/* ῠ-ῡ Ῠ-Ῡ */
-	0x2170,	0x217f, 484,	/* ⅰ-ⅿ Ⅰ-Ⅿ */
-	0x24d0,	0x24e9, 474,	/* ⓐ-ⓩ Ⓐ-Ⓩ */
-	0xff41,	0xff5a, 468	/* a-z A-Z */
-]
-
-/*
- * lower case singlets
- *	2nd col is conversion excess 500
- */
-const rtoupper1 = [
-	0x00ff, 621,	/* ÿ Ÿ */
-	0x0101, 499,	/* ā Ā */
-	0x0103, 499,	/* ă Ă */
-	0x0105, 499,	/* ą Ą */
-	0x0107, 499,	/* ć Ć */
-	0x0109, 499,	/* ĉ Ĉ */
-	0x010b, 499,	/* ċ Ċ */
-	0x010d, 499,	/* č Č */
-	0x010f, 499,	/* ď Ď */
-	0x0111, 499,	/* đ Đ */
-	0x0113, 499,	/* ē Ē */
-	0x0115, 499,	/* ĕ Ĕ */
-	0x0117, 499,	/* ė Ė */
-	0x0119, 499,	/* ę Ę */
-	0x011b, 499,	/* ě Ě */
-	0x011d, 499,	/* ĝ Ĝ */
-	0x011f, 499,	/* ğ Ğ */
-	0x0121, 499,	/* ġ Ġ */
-	0x0123, 499,	/* ģ Ģ */
-	0x0125, 499,	/* ĥ Ĥ */
-	0x0127, 499,	/* ħ Ħ */
-	0x0129, 499,	/* ĩ Ĩ */
-	0x012b, 499,	/* ī Ī */
-	0x012d, 499,	/* ĭ Ĭ */
-	0x012f, 499,	/* į Į */
-	0x0131, 268,	/* ı I */
-	0x0133, 499,	/* ij IJ */
-	0x0135, 499,	/* ĵ Ĵ */
-	0x0137, 499,	/* ķ Ķ */
-	0x013a, 499,	/* ĺ Ĺ */
-	0x013c, 499,	/* ļ Ļ */
-	0x013e, 499,	/* ľ Ľ */
-	0x0140, 499,	/* ŀ Ŀ */
-	0x0142, 499,	/* ł Ł */
-	0x0144, 499,	/* ń Ń */
-	0x0146, 499,	/* ņ Ņ */
-	0x0148, 499,	/* ň Ň */
-	0x014b, 499,	/* ŋ Ŋ */
-	0x014d, 499,	/* ō Ō */
-	0x014f, 499,	/* ŏ Ŏ */
-	0x0151, 499,	/* ő Ő */
-	0x0153, 499,	/* œ Œ */
-	0x0155, 499,	/* ŕ Ŕ */
-	0x0157, 499,	/* ŗ Ŗ */
-	0x0159, 499,	/* ř Ř */
-	0x015b, 499,	/* ś Ś */
-	0x015d, 499,	/* ŝ Ŝ */
-	0x015f, 499,	/* ş Ş */
-	0x0161, 499,	/* š Š */
-	0x0163, 499,	/* ţ Ţ */
-	0x0165, 499,	/* ť Ť */
-	0x0167, 499,	/* ŧ Ŧ */
-	0x0169, 499,	/* ũ Ũ */
-	0x016b, 499,	/* ū Ū */
-	0x016d, 499,	/* ŭ Ŭ */
-	0x016f, 499,	/* ů Ů */
-	0x0171, 499,	/* ű Ű */
-	0x0173, 499,	/* ų Ų */
-	0x0175, 499,	/* ŵ Ŵ */
-	0x0177, 499,	/* ŷ Ŷ */
-	0x017a, 499,	/* ź Ź */
-	0x017c, 499,	/* ż Ż */
-	0x017e, 499,	/* ž Ž */
-	0x017f, 200,	/* ſ S */
-	0x0183, 499,	/* ƃ Ƃ */
-	0x0185, 499,	/* ƅ Ƅ */
-	0x0188, 499,	/* ƈ Ƈ */
-	0x018c, 499,	/* ƌ Ƌ */
-	0x0192, 499,	/* ƒ Ƒ */
-	0x0199, 499,	/* ƙ Ƙ */
-	0x01a1, 499,	/* ơ Ơ */
-	0x01a3, 499,	/* ƣ Ƣ */
-	0x01a5, 499,	/* ƥ Ƥ */
-	0x01a8, 499,	/* ƨ Ƨ */
-	0x01ad, 499,	/* ƭ Ƭ */
-	0x01b0, 499,	/* ư Ư */
-	0x01b4, 499,	/* ƴ Ƴ */
-	0x01b6, 499,	/* ƶ Ƶ */
-	0x01b9, 499,	/* ƹ Ƹ */
-	0x01bd, 499,	/* ƽ Ƽ */
-	0x01c5, 499,	/* Dž DŽ */
-	0x01c6, 498,	/* dž DŽ */
-	0x01c8, 499,	/* Lj LJ */
-	0x01c9, 498,	/* lj LJ */
-	0x01cb, 499,	/* Nj NJ */
-	0x01cc, 498,	/* nj NJ */
-	0x01ce, 499,	/* ǎ Ǎ */
-	0x01d0, 499,	/* ǐ Ǐ */
-	0x01d2, 499,	/* ǒ Ǒ */
-	0x01d4, 499,	/* ǔ Ǔ */
-	0x01d6, 499,	/* ǖ Ǖ */
-	0x01d8, 499,	/* ǘ Ǘ */
-	0x01da, 499,	/* ǚ Ǚ */
-	0x01dc, 499,	/* ǜ Ǜ */
-	0x01df, 499,	/* ǟ Ǟ */
-	0x01e1, 499,	/* ǡ Ǡ */
-	0x01e3, 499,	/* ǣ Ǣ */
-	0x01e5, 499,	/* ǥ Ǥ */
-	0x01e7, 499,	/* ǧ Ǧ */
-	0x01e9, 499,	/* ǩ Ǩ */
-	0x01eb, 499,	/* ǫ Ǫ */
-	0x01ed, 499,	/* ǭ Ǭ */
-	0x01ef, 499,	/* ǯ Ǯ */
-	0x01f2, 499,	/* Dz DZ */
-	0x01f3, 498,	/* dz DZ */
-	0x01f5, 499,	/* ǵ Ǵ */
-	0x01fb, 499,	/* ǻ Ǻ */
-	0x01fd, 499,	/* ǽ Ǽ */
-	0x01ff, 499,	/* ǿ Ǿ */
-	0x0201, 499,	/* ȁ Ȁ */
-	0x0203, 499,	/* ȃ Ȃ */
-	0x0205, 499,	/* ȅ Ȅ */
-	0x0207, 499,	/* ȇ Ȇ */
-	0x0209, 499,	/* ȉ Ȉ */
-	0x020b, 499,	/* ȋ Ȋ */
-	0x020d, 499,	/* ȍ Ȍ */
-	0x020f, 499,	/* ȏ Ȏ */
-	0x0211, 499,	/* ȑ Ȑ */
-	0x0213, 499,	/* ȓ Ȓ */
-	0x0215, 499,	/* ȕ Ȕ */
-	0x0217, 499,	/* ȗ Ȗ */
-	0x0253, 290,	/* ɓ Ɓ */
-	0x0254, 294,	/* ɔ Ɔ */
-	0x025b, 297,	/* ɛ Ɛ */
-	0x0260, 295,	/* ɠ Ɠ */
-	0x0263, 293,	/* ɣ Ɣ */
-	0x0268, 291,	/* ɨ Ɨ */
-	0x0269, 289,	/* ɩ Ɩ */
-	0x026f, 289,	/* ɯ Ɯ */
-	0x0272, 287,	/* ɲ Ɲ */
-	0x0283, 282,	/* ʃ Ʃ */
-	0x0288, 282,	/* ʈ Ʈ */
-	0x0292, 281,	/* ʒ Ʒ */
-	0x03ac, 462,	/* ά Ά */
-	0x03cc, 436,	/* ό Ό */
-	0x03d0, 438,	/* ϐ Β */
-	0x03d1, 443,	/* ϑ Θ */
-	0x03d5, 453,	/* ϕ Φ */
-	0x03d6, 446,	/* ϖ Π */
-	0x03e3, 499,	/* ϣ Ϣ */
-	0x03e5, 499,	/* ϥ Ϥ */
-	0x03e7, 499,	/* ϧ Ϧ */
-	0x03e9, 499,	/* ϩ Ϩ */
-	0x03eb, 499,	/* ϫ Ϫ */
-	0x03ed, 499,	/* ϭ Ϭ */
-	0x03ef, 499,	/* ϯ Ϯ */
-	0x03f0, 414,	/* ϰ Κ */
-	0x03f1, 420,	/* ϱ Ρ */
-	0x0461, 499,	/* ѡ Ѡ */
-	0x0463, 499,	/* ѣ Ѣ */
-	0x0465, 499,	/* ѥ Ѥ */
-	0x0467, 499,	/* ѧ Ѧ */
-	0x0469, 499,	/* ѩ Ѩ */
-	0x046b, 499,	/* ѫ Ѫ */
-	0x046d, 499,	/* ѭ Ѭ */
-	0x046f, 499,	/* ѯ Ѯ */
-	0x0471, 499,	/* ѱ Ѱ */
-	0x0473, 499,	/* ѳ Ѳ */
-	0x0475, 499,	/* ѵ Ѵ */
-	0x0477, 499,	/* ѷ Ѷ */
-	0x0479, 499,	/* ѹ Ѹ */
-	0x047b, 499,	/* ѻ Ѻ */
-	0x047d, 499,	/* ѽ Ѽ */
-	0x047f, 499,	/* ѿ Ѿ */
-	0x0481, 499,	/* ҁ Ҁ */
-	0x0491, 499,	/* ґ Ґ */
-	0x0493, 499,	/* ғ Ғ */
-	0x0495, 499,	/* ҕ Ҕ */
-	0x0497, 499,	/* җ Җ */
-	0x0499, 499,	/* ҙ Ҙ */
-	0x049b, 499,	/* қ Қ */
-	0x049d, 499,	/* ҝ Ҝ */
-	0x049f, 499,	/* ҟ Ҟ */
-	0x04a1, 499,	/* ҡ Ҡ */
-	0x04a3, 499,	/* ң Ң */
-	0x04a5, 499,	/* ҥ Ҥ */
-	0x04a7, 499,	/* ҧ Ҧ */
-	0x04a9, 499,	/* ҩ Ҩ */
-	0x04ab, 499,	/* ҫ Ҫ */
-	0x04ad, 499,	/* ҭ Ҭ */
-	0x04af, 499,	/* ү Ү */
-	0x04b1, 499,	/* ұ Ұ */
-	0x04b3, 499,	/* ҳ Ҳ */
-	0x04b5, 499,	/* ҵ Ҵ */
-	0x04b7, 499,	/* ҷ Ҷ */
-	0x04b9, 499,	/* ҹ Ҹ */
-	0x04bb, 499,	/* һ Һ */
-	0x04bd, 499,	/* ҽ Ҽ */
-	0x04bf, 499,	/* ҿ Ҿ */
-	0x04c2, 499,	/* ӂ Ӂ */
-	0x04c4, 499,	/* ӄ Ӄ */
-	0x04c8, 499,	/* ӈ Ӈ */
-	0x04cc, 499,	/* ӌ Ӌ */
-	0x04d1, 499,	/* ӑ Ӑ */
-	0x04d3, 499,	/* ӓ Ӓ */
-	0x04d5, 499,	/* ӕ Ӕ */
-	0x04d7, 499,	/* ӗ Ӗ */
-	0x04d9, 499,	/* ә Ә */
-	0x04db, 499,	/* ӛ Ӛ */
-	0x04dd, 499,	/* ӝ Ӝ */
-	0x04df, 499,	/* ӟ Ӟ */
-	0x04e1, 499,	/* ӡ Ӡ */
-	0x04e3, 499,	/* ӣ Ӣ */
-	0x04e5, 499,	/* ӥ Ӥ */
-	0x04e7, 499,	/* ӧ Ӧ */
-	0x04e9, 499,	/* ө Ө */
-	0x04eb, 499,	/* ӫ Ӫ */
-	0x04ef, 499,	/* ӯ Ӯ */
-	0x04f1, 499,	/* ӱ Ӱ */
-	0x04f3, 499,	/* ӳ Ӳ */
-	0x04f5, 499,	/* ӵ Ӵ */
-	0x04f9, 499,	/* ӹ Ӹ */
-	0x1e01, 499,	/* ḁ Ḁ */
-	0x1e03, 499,	/* ḃ Ḃ */
-	0x1e05, 499,	/* ḅ Ḅ */
-	0x1e07, 499,	/* ḇ Ḇ */
-	0x1e09, 499,	/* ḉ Ḉ */
-	0x1e0b, 499,	/* ḋ Ḋ */
-	0x1e0d, 499,	/* ḍ Ḍ */
-	0x1e0f, 499,	/* ḏ Ḏ */
-	0x1e11, 499,	/* ḑ Ḑ */
-	0x1e13, 499,	/* ḓ Ḓ */
-	0x1e15, 499,	/* ḕ Ḕ */
-	0x1e17, 499,	/* ḗ Ḗ */
-	0x1e19, 499,	/* ḙ Ḙ */
-	0x1e1b, 499,	/* ḛ Ḛ */
-	0x1e1d, 499,	/* ḝ Ḝ */
-	0x1e1f, 499,	/* ḟ Ḟ */
-	0x1e21, 499,	/* ḡ Ḡ */
-	0x1e23, 499,	/* ḣ Ḣ */
-	0x1e25, 499,	/* ḥ Ḥ */
-	0x1e27, 499,	/* ḧ Ḧ */
-	0x1e29, 499,	/* ḩ Ḩ */
-	0x1e2b, 499,	/* ḫ Ḫ */
-	0x1e2d, 499,	/* ḭ Ḭ */
-	0x1e2f, 499,	/* ḯ Ḯ */
-	0x1e31, 499,	/* ḱ Ḱ */
-	0x1e33, 499,	/* ḳ Ḳ */
-	0x1e35, 499,	/* ḵ Ḵ */
-	0x1e37, 499,	/* ḷ Ḷ */
-	0x1e39, 499,	/* ḹ Ḹ */
-	0x1e3b, 499,	/* ḻ Ḻ */
-	0x1e3d, 499,	/* ḽ Ḽ */
-	0x1e3f, 499,	/* ḿ Ḿ */
-	0x1e41, 499,	/* ṁ Ṁ */
-	0x1e43, 499,	/* ṃ Ṃ */
-	0x1e45, 499,	/* ṅ Ṅ */
-	0x1e47, 499,	/* ṇ Ṇ */
-	0x1e49, 499,	/* ṉ Ṉ */
-	0x1e4b, 499,	/* ṋ Ṋ */
-	0x1e4d, 499,	/* ṍ Ṍ */
-	0x1e4f, 499,	/* ṏ Ṏ */
-	0x1e51, 499,	/* ṑ Ṑ */
-	0x1e53, 499,	/* ṓ Ṓ */
-	0x1e55, 499,	/* ṕ Ṕ */
-	0x1e57, 499,	/* ṗ Ṗ */
-	0x1e59, 499,	/* ṙ Ṙ */
-	0x1e5b, 499,	/* ṛ Ṛ */
-	0x1e5d, 499,	/* ṝ Ṝ */
-	0x1e5f, 499,	/* ṟ Ṟ */
-	0x1e61, 499,	/* ṡ Ṡ */
-	0x1e63, 499,	/* ṣ Ṣ */
-	0x1e65, 499,	/* ṥ Ṥ */
-	0x1e67, 499,	/* ṧ Ṧ */
-	0x1e69, 499,	/* ṩ Ṩ */
-	0x1e6b, 499,	/* ṫ Ṫ */
-	0x1e6d, 499,	/* ṭ Ṭ */
-	0x1e6f, 499,	/* ṯ Ṯ */
-	0x1e71, 499,	/* ṱ Ṱ */
-	0x1e73, 499,	/* ṳ Ṳ */
-	0x1e75, 499,	/* ṵ Ṵ */
-	0x1e77, 499,	/* ṷ Ṷ */
-	0x1e79, 499,	/* ṹ Ṹ */
-	0x1e7b, 499,	/* ṻ Ṻ */
-	0x1e7d, 499,	/* ṽ Ṽ */
-	0x1e7f, 499,	/* ṿ Ṿ */
-	0x1e81, 499,	/* ẁ Ẁ */
-	0x1e83, 499,	/* ẃ Ẃ */
-	0x1e85, 499,	/* ẅ Ẅ */
-	0x1e87, 499,	/* ẇ Ẇ */
-	0x1e89, 499,	/* ẉ Ẉ */
-	0x1e8b, 499,	/* ẋ Ẋ */
-	0x1e8d, 499,	/* ẍ Ẍ */
-	0x1e8f, 499,	/* ẏ Ẏ */
-	0x1e91, 499,	/* ẑ Ẑ */
-	0x1e93, 499,	/* ẓ Ẓ */
-	0x1e95, 499,	/* ẕ Ẕ */
-	0x1ea1, 499,	/* ạ Ạ */
-	0x1ea3, 499,	/* ả Ả */
-	0x1ea5, 499,	/* ấ Ấ */
-	0x1ea7, 499,	/* ầ Ầ */
-	0x1ea9, 499,	/* ẩ Ẩ */
-	0x1eab, 499,	/* ẫ Ẫ */
-	0x1ead, 499,	/* ậ Ậ */
-	0x1eaf, 499,	/* ắ Ắ */
-	0x1eb1, 499,	/* ằ Ằ */
-	0x1eb3, 499,	/* ẳ Ẳ */
-	0x1eb5, 499,	/* ẵ Ẵ */
-	0x1eb7, 499,	/* ặ Ặ */
-	0x1eb9, 499,	/* ẹ Ẹ */
-	0x1ebb, 499,	/* ẻ Ẻ */
-	0x1ebd, 499,	/* ẽ Ẽ */
-	0x1ebf, 499,	/* ế Ế */
-	0x1ec1, 499,	/* ề Ề */
-	0x1ec3, 499,	/* ể Ể */
-	0x1ec5, 499,	/* ễ Ễ */
-	0x1ec7, 499,	/* ệ Ệ */
-	0x1ec9, 499,	/* ỉ Ỉ */
-	0x1ecb, 499,	/* ị Ị */
-	0x1ecd, 499,	/* ọ Ọ */
-	0x1ecf, 499,	/* ỏ Ỏ */
-	0x1ed1, 499,	/* ố Ố */
-	0x1ed3, 499,	/* ồ Ồ */
-	0x1ed5, 499,	/* ổ Ổ */
-	0x1ed7, 499,	/* ỗ Ỗ */
-	0x1ed9, 499,	/* ộ Ộ */
-	0x1edb, 499,	/* ớ Ớ */
-	0x1edd, 499,	/* ờ Ờ */
-	0x1edf, 499,	/* ở Ở */
-	0x1ee1, 499,	/* ỡ Ỡ */
-	0x1ee3, 499,	/* ợ Ợ */
-	0x1ee5, 499,	/* ụ Ụ */
-	0x1ee7, 499,	/* ủ Ủ */
-	0x1ee9, 499,	/* ứ Ứ */
-	0x1eeb, 499,	/* ừ Ừ */
-	0x1eed, 499,	/* ử Ử */
-	0x1eef, 499,	/* ữ Ữ */
-	0x1ef1, 499,	/* ự Ự */
-	0x1ef3, 499,	/* ỳ Ỳ */
-	0x1ef5, 499,	/* ỵ Ỵ */
-	0x1ef7, 499,	/* ỷ Ỷ */
-	0x1ef9, 499,	/* ỹ Ỹ */
-	0x1f51, 508,	/* ὑ Ὑ */
-	0x1f53, 508,	/* ὓ Ὓ */
-	0x1f55, 508,	/* ὕ Ὕ */
-	0x1f57, 508,	/* ὗ Ὗ */
-	0x1fb3, 509,	/* ᾳ ᾼ */
-	0x1fc3, 509,	/* ῃ ῌ */
-	0x1fe5, 507,	/* ῥ Ῥ */
-	0x1ff3, 509	/* ῳ ῼ */
-]
-
-const rnums = [
-	0x0030, 0x0039,
-	0x0660, 0x0669,
-	0x06f0, 0x06f9,
-	0x07c0, 0x07c9,
-	0x0966, 0x096f,
-	0x09e6, 0x09ef,
-	0x0a66, 0x0a6f,
-	0x0ae6, 0x0aef,
-	0x0b66, 0x0b6f,
-	0x0be6, 0x0bef,
-	0x0c66, 0x0c6f,
-	0x0ce6, 0x0cef,
-	0x0d66, 0x0d6f,
-	0x0e50, 0x0e59,
-	0x0ed0, 0x0ed9,
-	0x0f20, 0x0f29,
-	0x1040, 0x1049,
-	0x17e0, 0x17e9,
-	0x1810, 0x1819,
-	0x1946, 0x194f,
-	0x19d0, 0x19d9,
-	0x1b50, 0x1b59,
-	0xff10, 0xff19,
-	0x104a0, 0x104a9,
-	0x1d7ce, 0x1d7ff
-]
-
-/*
- * upper case ranges
- *	3rd col is conversion excess 500
- */
-const rtolower2 = [
-	0x0041,	0x005a, 532,	/* A-Z a-z */
-	0x00c0,	0x00d6, 532,	/* À-Ö à-ö */
-	0x00d8,	0x00de, 532,	/* Ø-Þ ø-þ */
-	0x0189,	0x018a, 705,	/* Ɖ-Ɗ ɖ-ɗ */
-	0x018e,	0x018f, 702,	/* Ǝ-Ə ɘ-ə */
-	0x01b1,	0x01b2, 717,	/* Ʊ-Ʋ ʊ-ʋ */
-	0x0388,	0x038a, 537,	/* Έ-Ί έ-ί */
-	0x038e,	0x038f, 563,	/* Ύ-Ώ ύ-ώ */
-	0x0391,	0x03a1, 532,	/* Α-Ρ α-ρ */
-	0x03a3,	0x03ab, 532,	/* Σ-Ϋ σ-ϋ */
-	0x0401,	0x040c, 580,	/* Ё-Ќ ё-ќ */
-	0x040e,	0x040f, 580,	/* Ў-Џ ў-џ */
-	0x0410,	0x042f, 532,	/* А-Я а-я */
-	0x0531,	0x0556, 548,	/* Ա-Ֆ ա-ֆ */
-	0x10a0,	0x10c5, 548,	/* Ⴀ-Ⴥ ა-ჵ */
-	0x1f08,	0x1f0f, 492,	/* Ἀ-Ἇ ἀ-ἇ */
-	0x1f18,	0x1f1d, 492,	/* Ἐ-Ἕ ἐ-ἕ */
-	0x1f28,	0x1f2f, 492,	/* Ἠ-Ἧ ἠ-ἧ */
-	0x1f38,	0x1f3f, 492,	/* Ἰ-Ἷ ἰ-ἷ */
-	0x1f48,	0x1f4d, 492,	/* Ὀ-Ὅ ὀ-ὅ */
-	0x1f68,	0x1f6f, 492,	/* Ὠ-Ὧ ὠ-ὧ */
-	0x1f88,	0x1f8f, 492,	/* ᾈ-ᾏ ᾀ-ᾇ */
-	0x1f98,	0x1f9f, 492,	/* ᾘ-ᾟ ᾐ-ᾗ */
-	0x1fa8,	0x1faf, 492,	/* ᾨ-ᾯ ᾠ-ᾧ */
-	0x1fb8,	0x1fb9, 492,	/* Ᾰ-Ᾱ ᾰ-ᾱ */
-	0x1fba,	0x1fbb, 426,	/* Ὰ-Ά ὰ-ά */
-	0x1fc8,	0x1fcb, 414,	/* Ὲ-Ή ὲ-ή */
-	0x1fd8,	0x1fd9, 492,	/* Ῐ-Ῑ ῐ-ῑ */
-	0x1fda,	0x1fdb, 400,	/* Ὶ-Ί ὶ-ί */
-	0x1fe8,	0x1fe9, 492,	/* Ῠ-Ῡ ῠ-ῡ */
-	0x1fea,	0x1feb, 388,	/* Ὺ-Ύ ὺ-ύ */
-	0x1ff8,	0x1ff9, 372,	/* Ὸ-Ό ὸ-ό */
-	0x1ffa,	0x1ffb, 374,	/* Ὼ-Ώ ὼ-ώ */
-	0x2160,	0x216f, 516,	/* Ⅰ-Ⅿ ⅰ-ⅿ */
-	0x24b6,	0x24cf, 526,	/* Ⓐ-Ⓩ ⓐ-ⓩ */
-	0xff21,	0xff3a, 532	/* A-Z a-z */
-]
-
-/*
- * upper case singlets
- *	2nd col is conversion excess 500
- */
-const rtolower1 = [
-	0x0100, 501,	/* Ā ā */
-	0x0102, 501,	/* Ă ă */
-	0x0104, 501,	/* Ą ą */
-	0x0106, 501,	/* Ć ć */
-	0x0108, 501,	/* Ĉ ĉ */
-	0x010a, 501,	/* Ċ ċ */
-	0x010c, 501,	/* Č č */
-	0x010e, 501,	/* Ď ď */
-	0x0110, 501,	/* Đ đ */
-	0x0112, 501,	/* Ē ē */
-	0x0114, 501,	/* Ĕ ĕ */
-	0x0116, 501,	/* Ė ė */
-	0x0118, 501,	/* Ę ę */
-	0x011a, 501,	/* Ě ě */
-	0x011c, 501,	/* Ĝ ĝ */
-	0x011e, 501,	/* Ğ ğ */
-	0x0120, 501,	/* Ġ ġ */
-	0x0122, 501,	/* Ģ ģ */
-	0x0124, 501,	/* Ĥ ĥ */
-	0x0126, 501,	/* Ħ ħ */
-	0x0128, 501,	/* Ĩ ĩ */
-	0x012a, 501,	/* Ī ī */
-	0x012c, 501,	/* Ĭ ĭ */
-	0x012e, 501,	/* Į į */
-	0x0130, 301,	/* İ i */
-	0x0132, 501,	/* IJ ij */
-	0x0134, 501,	/* Ĵ ĵ */
-	0x0136, 501,	/* Ķ ķ */
-	0x0139, 501,	/* Ĺ ĺ */
-	0x013b, 501,	/* Ļ ļ */
-	0x013d, 501,	/* Ľ ľ */
-	0x013f, 501,	/* Ŀ ŀ */
-	0x0141, 501,	/* Ł ł */
-	0x0143, 501,	/* Ń ń */
-	0x0145, 501,	/* Ņ ņ */
-	0x0147, 501,	/* Ň ň */
-	0x014a, 501,	/* Ŋ ŋ */
-	0x014c, 501,	/* Ō ō */
-	0x014e, 501,	/* Ŏ ŏ */
-	0x0150, 501,	/* Ő ő */
-	0x0152, 501,	/* Œ œ */
-	0x0154, 501,	/* Ŕ ŕ */
-	0x0156, 501,	/* Ŗ ŗ */
-	0x0158, 501,	/* Ř ř */
-	0x015a, 501,	/* Ś ś */
-	0x015c, 501,	/* Ŝ ŝ */
-	0x015e, 501,	/* Ş ş */
-	0x0160, 501,	/* Š š */
-	0x0162, 501,	/* Ţ ţ */
-	0x0164, 501,	/* Ť ť */
-	0x0166, 501,	/* Ŧ ŧ */
-	0x0168, 501,	/* Ũ ũ */
-	0x016a, 501,	/* Ū ū */
-	0x016c, 501,	/* Ŭ ŭ */
-	0x016e, 501,	/* Ů ů */
-	0x0170, 501,	/* Ű ű */
-	0x0172, 501,	/* Ų ų */
-	0x0174, 501,	/* Ŵ ŵ */
-	0x0176, 501,	/* Ŷ ŷ */
-	0x0178, 379,	/* Ÿ ÿ */
-	0x0179, 501,	/* Ź ź */
-	0x017b, 501,	/* Ż ż */
-	0x017d, 501,	/* Ž ž */
-	0x0181, 710,	/* Ɓ ɓ */
-	0x0182, 501,	/* Ƃ ƃ */
-	0x0184, 501,	/* Ƅ ƅ */
-	0x0186, 706,	/* Ɔ ɔ */
-	0x0187, 501,	/* Ƈ ƈ */
-	0x018b, 501,	/* Ƌ ƌ */
-	0x0190, 703,	/* Ɛ ɛ */
-	0x0191, 501,	/* Ƒ ƒ */
-	0x0193, 705,	/* Ɠ ɠ */
-	0x0194, 707,	/* Ɣ ɣ */
-	0x0196, 711,	/* Ɩ ɩ */
-	0x0197, 709,	/* Ɨ ɨ */
-	0x0198, 501,	/* Ƙ ƙ */
-	0x019c, 711,	/* Ɯ ɯ */
-	0x019d, 713,	/* Ɲ ɲ */
-	0x01a0, 501,	/* Ơ ơ */
-	0x01a2, 501,	/* Ƣ ƣ */
-	0x01a4, 501,	/* Ƥ ƥ */
-	0x01a7, 501,	/* Ƨ ƨ */
-	0x01a9, 718,	/* Ʃ ʃ */
-	0x01ac, 501,	/* Ƭ ƭ */
-	0x01ae, 718,	/* Ʈ ʈ */
-	0x01af, 501,	/* Ư ư */
-	0x01b3, 501,	/* Ƴ ƴ */
-	0x01b5, 501,	/* Ƶ ƶ */
-	0x01b7, 719,	/* Ʒ ʒ */
-	0x01b8, 501,	/* Ƹ ƹ */
-	0x01bc, 501,	/* Ƽ ƽ */
-	0x01c4, 502,	/* DŽ dž */
-	0x01c5, 501,	/* Dž dž */
-	0x01c7, 502,	/* LJ lj */
-	0x01c8, 501,	/* Lj lj */
-	0x01ca, 502,	/* NJ nj */
-	0x01cb, 501,	/* Nj nj */
-	0x01cd, 501,	/* Ǎ ǎ */
-	0x01cf, 501,	/* Ǐ ǐ */
-	0x01d1, 501,	/* Ǒ ǒ */
-	0x01d3, 501,	/* Ǔ ǔ */
-	0x01d5, 501,	/* Ǖ ǖ */
-	0x01d7, 501,	/* Ǘ ǘ */
-	0x01d9, 501,	/* Ǚ ǚ */
-	0x01db, 501,	/* Ǜ ǜ */
-	0x01de, 501,	/* Ǟ ǟ */
-	0x01e0, 501,	/* Ǡ ǡ */
-	0x01e2, 501,	/* Ǣ ǣ */
-	0x01e4, 501,	/* Ǥ ǥ */
-	0x01e6, 501,	/* Ǧ ǧ */
-	0x01e8, 501,	/* Ǩ ǩ */
-	0x01ea, 501,	/* Ǫ ǫ */
-	0x01ec, 501,	/* Ǭ ǭ */
-	0x01ee, 501,	/* Ǯ ǯ */
-	0x01f1, 502,	/* DZ dz */
-	0x01f2, 501,	/* Dz dz */
-	0x01f4, 501,	/* Ǵ ǵ */
-	0x01fa, 501,	/* Ǻ ǻ */
-	0x01fc, 501,	/* Ǽ ǽ */
-	0x01fe, 501,	/* Ǿ ǿ */
-	0x0200, 501,	/* Ȁ ȁ */
-	0x0202, 501,	/* Ȃ ȃ */
-	0x0204, 501,	/* Ȅ ȅ */
-	0x0206, 501,	/* Ȇ ȇ */
-	0x0208, 501,	/* Ȉ ȉ */
-	0x020a, 501,	/* Ȋ ȋ */
-	0x020c, 501,	/* Ȍ ȍ */
-	0x020e, 501,	/* Ȏ ȏ */
-	0x0210, 501,	/* Ȑ ȑ */
-	0x0212, 501,	/* Ȓ ȓ */
-	0x0214, 501,	/* Ȕ ȕ */
-	0x0216, 501,	/* Ȗ ȗ */
-	0x0386, 538,	/* Ά ά */
-	0x038c, 564,	/* Ό ό */
-	0x03e2, 501,	/* Ϣ ϣ */
-	0x03e4, 501,	/* Ϥ ϥ */
-	0x03e6, 501,	/* Ϧ ϧ */
-	0x03e8, 501,	/* Ϩ ϩ */
-	0x03ea, 501,	/* Ϫ ϫ */
-	0x03ec, 501,	/* Ϭ ϭ */
-	0x03ee, 501,	/* Ϯ ϯ */
-	0x0460, 501,	/* Ѡ ѡ */
-	0x0462, 501,	/* Ѣ ѣ */
-	0x0464, 501,	/* Ѥ ѥ */
-	0x0466, 501,	/* Ѧ ѧ */
-	0x0468, 501,	/* Ѩ ѩ */
-	0x046a, 501,	/* Ѫ ѫ */
-	0x046c, 501,	/* Ѭ ѭ */
-	0x046e, 501,	/* Ѯ ѯ */
-	0x0470, 501,	/* Ѱ ѱ */
-	0x0472, 501,	/* Ѳ ѳ */
-	0x0474, 501,	/* Ѵ ѵ */
-	0x0476, 501,	/* Ѷ ѷ */
-	0x0478, 501,	/* Ѹ ѹ */
-	0x047a, 501,	/* Ѻ ѻ */
-	0x047c, 501,	/* Ѽ ѽ */
-	0x047e, 501,	/* Ѿ ѿ */
-	0x0480, 501,	/* Ҁ ҁ */
-	0x0490, 501,	/* Ґ ґ */
-	0x0492, 501,	/* Ғ ғ */
-	0x0494, 501,	/* Ҕ ҕ */
-	0x0496, 501,	/* Җ җ */
-	0x0498, 501,	/* Ҙ ҙ */
-	0x049a, 501,	/* Қ қ */
-	0x049c, 501,	/* Ҝ ҝ */
-	0x049e, 501,	/* Ҟ ҟ */
-	0x04a0, 501,	/* Ҡ ҡ */
-	0x04a2, 501,	/* Ң ң */
-	0x04a4, 501,	/* Ҥ ҥ */
-	0x04a6, 501,	/* Ҧ ҧ */
-	0x04a8, 501,	/* Ҩ ҩ */
-	0x04aa, 501,	/* Ҫ ҫ */
-	0x04ac, 501,	/* Ҭ ҭ */
-	0x04ae, 501,	/* Ү ү */
-	0x04b0, 501,	/* Ұ ұ */
-	0x04b2, 501,	/* Ҳ ҳ */
-	0x04b4, 501,	/* Ҵ ҵ */
-	0x04b6, 501,	/* Ҷ ҷ */
-	0x04b8, 501,	/* Ҹ ҹ */
-	0x04ba, 501,	/* Һ һ */
-	0x04bc, 501,	/* Ҽ ҽ */
-	0x04be, 501,	/* Ҿ ҿ */
-	0x04c1, 501,	/* Ӂ ӂ */
-	0x04c3, 501,	/* Ӄ ӄ */
-	0x04c7, 501,	/* Ӈ ӈ */
-	0x04cb, 501,	/* Ӌ ӌ */
-	0x04d0, 501,	/* Ӑ ӑ */
-	0x04d2, 501,	/* Ӓ ӓ */
-	0x04d4, 501,	/* Ӕ ӕ */
-	0x04d6, 501,	/* Ӗ ӗ */
-	0x04d8, 501,	/* Ә ә */
-	0x04da, 501,	/* Ӛ ӛ */
-	0x04dc, 501,	/* Ӝ ӝ */
-	0x04de, 501,	/* Ӟ ӟ */
-	0x04e0, 501,	/* Ӡ ӡ */
-	0x04e2, 501,	/* Ӣ ӣ */
-	0x04e4, 501,	/* Ӥ ӥ */
-	0x04e6, 501,	/* Ӧ ӧ */
-	0x04e8, 501,	/* Ө ө */
-	0x04ea, 501,	/* Ӫ ӫ */
-	0x04ee, 501,	/* Ӯ ӯ */
-	0x04f0, 501,	/* Ӱ ӱ */
-	0x04f2, 501,	/* Ӳ ӳ */
-	0x04f4, 501,	/* Ӵ ӵ */
-	0x04f8, 501,	/* Ӹ ӹ */
-	0x1e00, 501,	/* Ḁ ḁ */
-	0x1e02, 501,	/* Ḃ ḃ */
-	0x1e04, 501,	/* Ḅ ḅ */
-	0x1e06, 501,	/* Ḇ ḇ */
-	0x1e08, 501,	/* Ḉ ḉ */
-	0x1e0a, 501,	/* Ḋ ḋ */
-	0x1e0c, 501,	/* Ḍ ḍ */
-	0x1e0e, 501,	/* Ḏ ḏ */
-	0x1e10, 501,	/* Ḑ ḑ */
-	0x1e12, 501,	/* Ḓ ḓ */
-	0x1e14, 501,	/* Ḕ ḕ */
-	0x1e16, 501,	/* Ḗ ḗ */
-	0x1e18, 501,	/* Ḙ ḙ */
-	0x1e1a, 501,	/* Ḛ ḛ */
-	0x1e1c, 501,	/* Ḝ ḝ */
-	0x1e1e, 501,	/* Ḟ ḟ */
-	0x1e20, 501,	/* Ḡ ḡ */
-	0x1e22, 501,	/* Ḣ ḣ */
-	0x1e24, 501,	/* Ḥ ḥ */
-	0x1e26, 501,	/* Ḧ ḧ */
-	0x1e28, 501,	/* Ḩ ḩ */
-	0x1e2a, 501,	/* Ḫ ḫ */
-	0x1e2c, 501,	/* Ḭ ḭ */
-	0x1e2e, 501,	/* Ḯ ḯ */
-	0x1e30, 501,	/* Ḱ ḱ */
-	0x1e32, 501,	/* Ḳ ḳ */
-	0x1e34, 501,	/* Ḵ ḵ */
-	0x1e36, 501,	/* Ḷ ḷ */
-	0x1e38, 501,	/* Ḹ ḹ */
-	0x1e3a, 501,	/* Ḻ ḻ */
-	0x1e3c, 501,	/* Ḽ ḽ */
-	0x1e3e, 501,	/* Ḿ ḿ */
-	0x1e40, 501,	/* Ṁ ṁ */
-	0x1e42, 501,	/* Ṃ ṃ */
-	0x1e44, 501,	/* Ṅ ṅ */
-	0x1e46, 501,	/* Ṇ ṇ */
-	0x1e48, 501,	/* Ṉ ṉ */
-	0x1e4a, 501,	/* Ṋ ṋ */
-	0x1e4c, 501,	/* Ṍ ṍ */
-	0x1e4e, 501,	/* Ṏ ṏ */
-	0x1e50, 501,	/* Ṑ ṑ */
-	0x1e52, 501,	/* Ṓ ṓ */
-	0x1e54, 501,	/* Ṕ ṕ */
-	0x1e56, 501,	/* Ṗ ṗ */
-	0x1e58, 501,	/* Ṙ ṙ */
-	0x1e5a, 501,	/* Ṛ ṛ */
-	0x1e5c, 501,	/* Ṝ ṝ */
-	0x1e5e, 501,	/* Ṟ ṟ */
-	0x1e60, 501,	/* Ṡ ṡ */
-	0x1e62, 501,	/* Ṣ ṣ */
-	0x1e64, 501,	/* Ṥ ṥ */
-	0x1e66, 501,	/* Ṧ ṧ */
-	0x1e68, 501,	/* Ṩ ṩ */
-	0x1e6a, 501,	/* Ṫ ṫ */
-	0x1e6c, 501,	/* Ṭ ṭ */
-	0x1e6e, 501,	/* Ṯ ṯ */
-	0x1e70, 501,	/* Ṱ ṱ */
-	0x1e72, 501,	/* Ṳ ṳ */
-	0x1e74, 501,	/* Ṵ ṵ */
-	0x1e76, 501,	/* Ṷ ṷ */
-	0x1e78, 501,	/* Ṹ ṹ */
-	0x1e7a, 501,	/* Ṻ ṻ */
-	0x1e7c, 501,	/* Ṽ ṽ */
-	0x1e7e, 501,	/* Ṿ ṿ */
-	0x1e80, 501,	/* Ẁ ẁ */
-	0x1e82, 501,	/* Ẃ ẃ */
-	0x1e84, 501,	/* Ẅ ẅ */
-	0x1e86, 501,	/* Ẇ ẇ */
-	0x1e88, 501,	/* Ẉ ẉ */
-	0x1e8a, 501,	/* Ẋ ẋ */
-	0x1e8c, 501,	/* Ẍ ẍ */
-	0x1e8e, 501,	/* Ẏ ẏ */
-	0x1e90, 501,	/* Ẑ ẑ */
-	0x1e92, 501,	/* Ẓ ẓ */
-	0x1e94, 501,	/* Ẕ ẕ */
-	0x1ea0, 501,	/* Ạ ạ */
-	0x1ea2, 501,	/* Ả ả */
-	0x1ea4, 501,	/* Ấ ấ */
-	0x1ea6, 501,	/* Ầ ầ */
-	0x1ea8, 501,	/* Ẩ ẩ */
-	0x1eaa, 501,	/* Ẫ ẫ */
-	0x1eac, 501,	/* Ậ ậ */
-	0x1eae, 501,	/* Ắ ắ */
-	0x1eb0, 501,	/* Ằ ằ */
-	0x1eb2, 501,	/* Ẳ ẳ */
-	0x1eb4, 501,	/* Ẵ ẵ */
-	0x1eb6, 501,	/* Ặ ặ */
-	0x1eb8, 501,	/* Ẹ ẹ */
-	0x1eba, 501,	/* Ẻ ẻ */
-	0x1ebc, 501,	/* Ẽ ẽ */
-	0x1ebe, 501,	/* Ế ế */
-	0x1ec0, 501,	/* Ề ề */
-	0x1ec2, 501,	/* Ể ể */
-	0x1ec4, 501,	/* Ễ ễ */
-	0x1ec6, 501,	/* Ệ ệ */
-	0x1ec8, 501,	/* Ỉ ỉ */
-	0x1eca, 501,	/* Ị ị */
-	0x1ecc, 501,	/* Ọ ọ */
-	0x1ece, 501,	/* Ỏ ỏ */
-	0x1ed0, 501,	/* Ố ố */
-	0x1ed2, 501,	/* Ồ ồ */
-	0x1ed4, 501,	/* Ổ ổ */
-	0x1ed6, 501,	/* Ỗ ỗ */
-	0x1ed8, 501,	/* Ộ ộ */
-	0x1eda, 501,	/* Ớ ớ */
-	0x1edc, 501,	/* Ờ ờ */
-	0x1ede, 501,	/* Ở ở */
-	0x1ee0, 501,	/* Ỡ ỡ */
-	0x1ee2, 501,	/* Ợ ợ */
-	0x1ee4, 501,	/* Ụ ụ */
-	0x1ee6, 501,	/* Ủ ủ */
-	0x1ee8, 501,	/* Ứ ứ */
-	0x1eea, 501,	/* Ừ ừ */
-	0x1eec, 501,	/* Ử ử */
-	0x1eee, 501,	/* Ữ ữ */
-	0x1ef0, 501,	/* Ự ự */
-	0x1ef2, 501,	/* Ỳ ỳ */
-	0x1ef4, 501,	/* Ỵ ỵ */
-	0x1ef6, 501,	/* Ỷ ỷ */
-	0x1ef8, 501,	/* Ỹ ỹ */
-	0x1f59, 492,	/* Ὑ ὑ */
-	0x1f5b, 492,	/* Ὓ ὓ */
-	0x1f5d, 492,	/* Ὕ ὕ */
-	0x1f5f, 492,	/* Ὗ ὗ */
-	0x1fbc, 491,	/* ᾼ ᾳ */
-	0x1fcc, 491,	/* ῌ ῃ */
-	0x1fec, 493,	/* Ῥ ῥ */
-	0x1ffc, 491	/* ῼ ῳ */
-]
-
-/*
- * title characters are those between
- * upper and lower case. ie DZ Dz dz
- */
-const rtotitle1 = [
-	0x01c4, 501,	/* DŽ Dž */
-	0x01c6, 499,	/* dž Dž */
-	0x01c7, 501,	/* LJ Lj */
-	0x01c9, 499,	/* lj Lj */
-	0x01ca, 501,	/* NJ Nj */
-	0x01cc, 499,	/* nj Nj */
-	0x01f1, 501,	/* DZ Dz */
-	0x01f3, 499	/* dz Dz */
-]
-
-const findc = {c, t, sz, nelt, ret
-	var l
-	var m
-
-	/* we're processing in chunks of size 
-	   nelt, so 1 chunk is of length 'nelt' */
-	while t.len > nelt
-		sz /= 2
-		m = sz*nelt
-		l = t[m:]
-		if c >= l[0]
-			t = l[0:m]
-		else
-			t = t[0:m]
-		;;
-	;;
-
-	if t.len != 0 && c >= t[0]
-		*ret = t
-		-> true
-	else
-		-> false
-	;;
-}
-
-
-const isalpha = {c
-	var l
-
-	if isupper(c) || islower(c)
-		-> true
-	elif findc(c, ralpha2[:], ralpha2.len/2, 2, &l)
-		if (c >= l[0] && c <= l[1])
-			-> true
-		;;
-	elif findc(c, ralpha1[:], ralpha1.len, 1, &l)
-		if (c == l[0])
-			-> true
-		;;
-	;;
-	-> false
-}
-
-const isnum = {c
-	var l
-
-	if findc(c, rnums[:], rnums.len/2, 2, &l)
-		if(c >= l[0] && c <= l[1])
-			-> true
-		;;
-	;;
-	-> false
-}
-
-const isalnum = {c
-	-> isalpha(c) || isnum(c)
-}
-
-const isspace = {c
-	var l
-	var sl
-	var len
-
-	l = rspace2[:]
-	sl = rspace2[:]
-	len = rspace2.len/2
-	if findc(c, sl, len, 2, &l)
-		if(c >= l[0] && c <= l[1])
-			-> true
-		;;
-	;;
-	-> false
-}
-
-const islower = {c
-	var l
-
-	if findc(c, rtoupper2[:], rtoupper2.len, 2, &l)
-		if (c >= l[0] && c <= l[1])
-			-> true
-		;;
-	elif findc(c, rtoupper1[:], rtoupper1.len, 1, &l)
-		if (c == l[0])
-			-> true
-		;;
-	;;
-	-> false
-}
-
-const isupper = {c
-	var l
-
-	if findc(c, rtolower2[:], rtolower2.len, 2, &l)
-		if (c >= l[0] && c <= l[1])
-			-> true
-		;;
-	elif findc(c, rtolower1[:], rtolower1.len, 1, &l)
-		if (c == l[0])
-			-> true
-		;;
-	;;
-	-> false
-}
-
-const istitle = {c
-	-> isupper(c) && islower(c)
-}
-
-const tolower = {c
-	var l
-
-	if findc(c, rtolower2[:], rtolower2.len/3, 3, &l)
-		if c >= l[0] && c <= l[1]
-			-> c + l[2] - 500;
-		;;
-	elif findc(c, rtolower1[:], rtolower1.len/2, 2, &l) 
-		if c == l[0]
-			-> c + l[1] - 500;
-		;;
-	;;
-	-> c
-}
-
-const toupper = {c
-	var l
-
-	if findc(c, rtoupper2[:], rtoupper2.len/3, 3, &l);
-		if c >= l[0] && c <= l[1]
-			-> c + l[2] - 500;
-		;;
-	elif findc(c, rtoupper1[:], rtoupper1.len/2, 2, &l);
-		if c == l[0]
-			-> c + l[1] - 500;
-		;;
-	;;
-	-> c
-}
-
-const totitle = {c
-	var l
-
-	if findc(c, rtotitle1[:], rtotitle1.len/2, 2, &l);
-		if c == l[0]
-			-> c + l[1] - 500;
-		;;
-	;;
-	-> c
-}
-
--- a/die.myr
+++ /dev/null
@@ -1,19 +1,0 @@
-use "sys.use"
-use "types.use"
-
-pkg std = 
-	const die	: (msg : byte[:] -> void)
-	const assert	: (cond : bool, msg : byte[:] -> void)
-;;
-
-const die = {msg
-	write(2, msg)
-	kill(getpid(), 6)
-}
-
-const assert = {cond, msg
-	if cond
-		die(msg)
-	;;
-}
-
--- a/fmt.myr
+++ /dev/null
@@ -1,128 +1,0 @@
-use "die.use"
-use "sys.use"
-use "types.use"
-use "utf.use"
-use "varargs.use"
-
-pkg std =
-	const bfmt	: (buf : byte[:], fmt : byte[:], args:... -> size)
-	const bfmtv	: (buf : byte[:], fmt : byte[:], ap:valist -> size)
-	const put	: (fmt : byte[:], args:... -> size)
-;;
-
-const put = {fmt, args
-	var buf : byte[2048]
-	var n
-	
-	n = bfmtv(buf[:], fmt, vastart(&args))
-	write(1, buf[:n])
-	-> n
-}
-
-const bfmt = {buf, fmt, args
-	-> bfmtv(buf, fmt, vastart(&args))
-}
-
-const bfmtv = {buf, fmt, ap
-	var c
-	var n
-	var s_val : byte[:]
-	var b_val : int8
-	var w_val : int16
-	var i_val : int32
-	var l_val : int64
-	var p_val : byte*
-
-	n = 0
-	while fmt.len
-		(c, fmt) = striter(fmt)
-		if c == '%'
-			(c, fmt) = striter(fmt)
-			match c
-			's':
-				(s_val, ap) = vanext(ap)
-				n += strfmt(buf[n:], s_val)
-				;;
-			/* format integers */
-			'b':
-				(b_val, ap) = vanext(ap)
-				n += intfmt(buf[n:], b_val castto(int64), 10)
-				;;
-			'w':
-				(w_val, ap) = vanext(ap)
-				n += intfmt(buf[n:], w_val castto(int64), 10)
-				;;
-			'i':
-				(i_val, ap) = vanext(ap)
-				n += intfmt(buf[n:], i_val castto(int64), 10)
-				;;
-			'l':
-				(l_val, ap) = vanext(ap)
-				n += intfmt(buf[n:], l_val castto(int64), 10)
-				;;
-			'p':
-				(p_val, ap) = vanext(ap)
-				n += intfmt(buf[n:], p_val castto(int64), 16)
-				;;
-			;;
-		else
-			n += encode(buf[n:], c)
-		;;
-	;;
-	-> n
-}
-
-const strfmt = {buf, str
-	var i
-	
-	for i = 0; i < min(str.len, buf.len); i++
-		buf[i] = str[i]
-	;;
-	-> i
-}
-
-const intfmt = {buf, val, base
-	var digits = [
-		'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'
-	]
-	var isneg
-	var b : char[32]
-	var i
-	var j
-	var n
-
-	n = 0
-	i = 0
-	if val < 0
-		isneg = true
-	else
-		isneg = false
-	;;
-
-	if val == 0
-		b[0] = '0'
-		i++
-	;;
-	while val != 0
-		b[i] = digits[val % base]
-		val /= base
-		i++
-	;;
-	n = 0
-	if isneg
-		n += encode(buf[n:], '-')
-	;;
-	for j = i-1; j >= 0; j--
-		n += encode(buf[n:], b[j])
-	;;
-	-> n 
-}
-
-const min = {a : size, b : size
-	if a < b
-		-> a
-	else
-		-> b
-	;;
-}
-
--- /dev/null
+++ b/libmyr/Makefile
@@ -1,0 +1,11 @@
+# don't build anything for 'all'
+all: 
+	./bld.sh
+.PHONY: clean
+clean:
+	@for i in `awk '{print $$1}' tests`; do \
+	    echo rm -f $$i; \
+	    rm -f $$i; \
+	done
+
+install:
--- /dev/null
+++ b/libmyr/alloc.myr
@@ -1,0 +1,220 @@
+use "die.use"
+use "sys.use"
+use "types.use"
+
+pkg std =
+	generic alloc	: (		-> @a*)
+	generic free	: (v:@a*	-> void)
+
+	generic mkslice	: (len : size	-> @a[:])
+	generic freeslice: (sl : @a[:]	-> void)
+
+	const bytealloc	: (sz:size	-> byte*)
+	const bytefree	: (m:byte*, sz:size	-> void)
+;;
+
+/* null pointers */
+const Zbyte	= 0 castto(byte*)
+const Zslab	= 0 castto(slab*)
+const Zchunk	= 0 castto(chunk*)
+
+const Slabsz 	= 1048576	/* 1 meg slabs */
+const Cachemax	= 16	/* maximum number of slabs in the cache */
+const Bucketmax	= 32768	/* Slabsz / 8; a balance. */
+const Align	= 16	/* minimum allocation alignment */
+
+var buckets	: bucket[32] /* excessive */
+var initdone	: int
+
+type bucket = struct
+	sz	: size	/* aligned size */
+	nper	: size	/* max number of elements per slab */
+	slabs	: slab*	/* partially filled or free slabs */
+	cache	: slab* /* cache of empty slabs, to prevent thrashing */
+	ncache	: size  /* size of cache */
+;;
+
+type slab = struct
+	head		: byte*	/* head of virtual addresses, so we don't leak address space */
+	next		: slab*	/* the next slab on the chain */
+	freehd	: chunk*	/* the nodes we're allocating */
+	nfree	: size	/* the number of free nodes */
+;;
+
+type chunk = struct	/* NB: must be smaller than sizeof(slab) */
+	next	: chunk*	/* the next chunk in the free list */
+;;
+
+generic alloc = {-> @a*
+	-> bytealloc(sizeof(@a)) castto(@a*)
+}
+
+generic free = {v:@a* -> void
+	bytefree(v castto(byte*), sizeof(@a))
+}
+
+generic mkslice = {len
+	var p
+
+	p = bytealloc(len*sizeof(@a)) castto(@a*)
+	-> p[0:len]
+}
+
+generic freeslice = {sl
+	-> bytefree(sl castto(byte*), sl.len * sizeof(@a))
+}
+
+const bytealloc = {sz
+	var i
+	var bkt
+
+	if !initdone
+		for i = 0; i < buckets.len && (Align << i) <= Bucketmax; i++
+			bktinit(&buckets[i], Align << i)
+		;;
+		initdone = 1
+	;;
+
+	if (sz <= Bucketmax)
+		bkt = &buckets[bktnum(sz)]
+		-> bktalloc(bkt)
+	else
+		-> mmap(Zbyte, sz, Mprotrw, Mpriv | Manon, -1, 0)
+	;;
+}
+
+const bytefree = {m, sz
+	var bkt
+
+	if (sz < Bucketmax)
+		bkt = &buckets[bktnum(sz)]
+		bktfree(bkt, m)
+	else
+		munmap(m, sz)
+	;;
+}
+
+const bktinit = {b : bucket*, sz
+	b.sz = align(sz, Align)
+	b.nper = (Slabsz - sizeof(slab))/b.sz
+	b.slabs = Zslab
+	b.cache = Zslab
+	b.ncache = 0
+}
+
+const mkslab = {bkt : bucket*
+	var i
+	var p
+	var s
+	var b
+	var bnext
+	var off /* offset of chunk head */
+
+	if bkt.ncache > 0
+		s = bkt.cache
+		bkt.cache = s.next
+		bkt.ncache--
+	;;
+	/* tricky: we need power of two alignment, so we allocate double the
+	   needed size, chop off the unaligned ends, and waste the address
+	   space. Since the OS is "smart enough", this shouldn't actually
+	   cost us memory, and 64 bits of address space means that we're not
+	   going to have issues with running out of address space for a
+	   while. On a 32 bit system this would be a bad idea. */
+	p = mmap(Zbyte, Slabsz*2, Mprotrw, Mpriv | Manon, -1, 0)
+	if p == Mapbad
+		die("Unable to mmap")
+	;;
+
+	s = align(p castto(intptr), Slabsz) castto(slab*)
+	s.head = p
+	s.nfree = bkt.nper
+	/* skip past the slab header */
+	off = align(sizeof(slab), Align)
+	bnext = nextchunk(s castto(chunk*), off)
+	s.freehd = bnext
+	for i = 0; i < bkt.nper; i++
+		b = bnext
+		bnext = nextchunk(b, bkt.sz)
+		b.next = bnext
+	;;
+	b.next = Zchunk
+	-> s
+}
+
+const bktalloc = {bkt
+	var s
+	var b
+
+	/* find a slab */
+	s = bkt.slabs
+	if s == Zslab
+		s = mkslab(bkt)
+		if s == Zslab
+			die("No memory left")
+		;;
+		bkt.slabs = s
+	;;
+
+	/* grab the first chunk on the slab */
+	b = s.freehd
+	s.freehd = b.next
+	s.nfree--
+	if !s.nfree
+		bkt.slabs = s.next
+		s.next = Zslab
+	;;
+
+	-> b castto(byte*)
+}
+
+const bktfree = {bkt, m
+	var s
+	var b
+
+	s = mtrunc(m, Slabsz) castto(slab*)
+	b = m castto(chunk*)
+	if s.nfree == 0
+		s.next = bkt.slabs
+		bkt.slabs = s
+	elif s.nfree == bkt.nper
+		if bkt.ncache < Cachemax
+			s.next = bkt.cache
+			bkt.cache = s
+		else
+			/* we mapped 2*Slabsz so we could align it,
+			 so we need to unmap the same */
+			munmap(s.head, Slabsz*2)
+		;;
+	;;
+	s.nfree++
+	b.next = s.freehd
+	s.freehd = b
+}
+
+const bktnum = {sz
+	var i
+	var bktsz
+
+	bktsz = Align
+	for i = 0; bktsz <= Bucketmax; i++
+		if bktsz >= sz
+			-> i
+		;;
+		bktsz *= 2
+	;;
+	die("Size does not match any buckets")
+}
+
+/* chunks are variable sizes, so we can't just take a slice */
+const nextchunk = {b, sz
+	-> ((b castto(intptr)) + sz) castto(chunk*)
+}
+
+const align = {v, align
+	-> (v + align - 1) & ~(align - 1)
+}
+
+const mtrunc = {m, align
+	-> ((m castto(intptr)) & ~(align - 1)) castto(byte*)
+}
--- /dev/null
+++ b/libmyr/bld.sh
@@ -1,0 +1,71 @@
+#!/bin/bash
+
+# We have no dependency handling yet, so this is done via
+# a shell script. Also, we want to rebuild everything for
+# testing purposes on every run as things stand.
+
+export PATH=.:$PATH
+export MC=6m
+export MU=muse
+export CC=cc
+export ASOPT="-g"
+case `uname` in
+    Darwin) export SYS=osx;;
+    Linux) export SYS=linux;;
+esac
+
+function use {
+    for i in $@; do
+        N=`basename $i .myr`
+        N=${N%%-$SYS}
+
+        echo $MU -o $N.use $i && \
+        $MU -o $N.use $i
+    done
+}
+
+function build {
+    for i in $@; do
+        N=`basename $i .myr`
+
+        echo $MC $i && \
+            $MC -I. $i
+    done
+}
+
+function assem {
+    for i in $@; do
+        $CC $ASOPT -c $i
+    done
+}
+
+# Library source.
+ASM=syscall-$SYS.s
+MYR="types.myr \
+    sys-$SYS.myr \
+    die.myr \
+    varargs.myr \
+    alloc.myr\
+    utf.myr \
+    fmt.myr \
+    rand.myr \
+    chartype.myr"
+
+OBJ="$(echo $ASM | sed 's/\.s/.o /g') $(echo $MYR | sed 's/\.myr/.o /g')"
+USE="$(echo $MYR | sed 's/\.myr/.use /g' | sed "s/-$SYS//g")"
+rm $OBJ test libstd.a
+assem $ASM
+use $MYR
+build $MYR
+
+echo $MU -mo std $USE
+$MU -mo std $USE
+echo ar -rcs libstd.a $OBJ
+ar -rcs libstd.a $OBJ
+
+# build test program
+build test.myr
+COMP="$CC -o test test.o -L. -lstd"
+echo $COMP
+$COMP
+
--- /dev/null
+++ b/libmyr/chartype.myr
@@ -1,0 +1,1203 @@
+use "die.use"
+use "sys.use"
+
+/* 
+   Tables adapted from plan 9's runetype.c,
+   which lives in sys/src/libc/port/runetype.c
+*/
+
+pkg std =
+	const isalpha	: (c : char -> bool)
+	const isnum	: (c : char -> bool)
+	const isalnum	: (c : char -> bool)
+	const isspace	: (c : char -> bool)
+
+	const islower	: (c : char -> bool)
+	const isupper	: (c : char -> bool)
+	const istitle	: (c : char -> bool)
+
+	const tolower	: (c : char -> char)
+	const toupper	: (c : char -> char)
+	const totitle	: (c : char -> char)
+;;
+
+/*
+ * alpha ranges -
+ *	only covers ranges not in lower||upper
+ */
+const ralpha2 = [
+	0x00d8,	0x00f6,	/* Ø - ö */
+	0x00f8,	0x01f5,	/* ø - ǵ */
+	0x0250,	0x02a8,	/* ɐ - ʨ */
+	0x038e,	0x03a1,	/* Ύ - Ρ */
+	0x03a3,	0x03ce,	/* Σ - ώ */
+	0x03d0,	0x03d6,	/* ϐ - ϖ */
+	0x03e2,	0x03f3,	/* Ϣ - ϳ */
+	0x0490,	0x04c4,	/* Ґ - ӄ */
+	0x0561,	0x0587,	/* ա - և */
+	0x05d0,	0x05ea,	/* א - ת */
+	0x05f0,	0x05f2,	/* װ - ײ */
+	0x0621,	0x063a,	/* ء - غ */
+	0x0640,	0x064a,	/* ـ - ي */
+	0x0671,	0x06b7,	/* ٱ - ڷ */
+	0x06ba,	0x06be,	/* ں - ھ */
+	0x06c0,	0x06ce,	/* ۀ - ێ */
+	0x06d0,	0x06d3,	/* ې - ۓ */
+	0x0905,	0x0939,	/* अ - ह */
+	0x0958,	0x0961,	/* क़ - ॡ */
+	0x0985,	0x098c,	/* অ - ঌ */
+	0x098f,	0x0990,	/* এ - ঐ */
+	0x0993,	0x09a8,	/* ও - ন */
+	0x09aa,	0x09b0,	/* প - র */
+	0x09b6,	0x09b9,	/* শ - হ */
+	0x09dc,	0x09dd,	/* ড় - ঢ় */
+	0x09df,	0x09e1,	/* য় - ৡ */
+	0x09f0,	0x09f1,	/* ৰ - ৱ */
+	0x0a05,	0x0a0a,	/* ਅ - ਊ */
+	0x0a0f,	0x0a10,	/* ਏ - ਐ */
+	0x0a13,	0x0a28,	/* ਓ - ਨ */
+	0x0a2a,	0x0a30,	/* ਪ - ਰ */
+	0x0a32,	0x0a33,	/* ਲ - ਲ਼ */
+	0x0a35,	0x0a36,	/* ਵ - ਸ਼ */
+	0x0a38,	0x0a39,	/* ਸ - ਹ */
+	0x0a59,	0x0a5c,	/* ਖ਼ - ੜ */
+	0x0a85,	0x0a8b,	/* અ - ઋ */
+	0x0a8f,	0x0a91,	/* એ - ઑ */
+	0x0a93,	0x0aa8,	/* ઓ - ન */
+	0x0aaa,	0x0ab0,	/* પ - ર */
+	0x0ab2,	0x0ab3,	/* લ - ળ */
+	0x0ab5,	0x0ab9,	/* વ - હ */
+	0x0b05,	0x0b0c,	/* ଅ - ଌ */
+	0x0b0f,	0x0b10,	/* ଏ - ଐ */
+	0x0b13,	0x0b28,	/* ଓ - ନ */
+	0x0b2a,	0x0b30,	/* ପ - ର */
+	0x0b32,	0x0b33,	/* ଲ - ଳ */
+	0x0b36,	0x0b39,	/* ଶ - ହ */
+	0x0b5c,	0x0b5d,	/* ଡ଼ - ଢ଼ */
+	0x0b5f,	0x0b61,	/* ୟ - ୡ */
+	0x0b85,	0x0b8a,	/* அ - ஊ */
+	0x0b8e,	0x0b90,	/* எ - ஐ */
+	0x0b92,	0x0b95,	/* ஒ - க */
+	0x0b99,	0x0b9a,	/* ங - ச */
+	0x0b9e,	0x0b9f,	/* ஞ - ட */
+	0x0ba3,	0x0ba4,	/* ண - த */
+	0x0ba8,	0x0baa,	/* ந - ப */
+	0x0bae,	0x0bb5,	/* ம - வ */
+	0x0bb7,	0x0bb9,	/* ஷ - ஹ */
+	0x0c05,	0x0c0c,	/* అ - ఌ */
+	0x0c0e,	0x0c10,	/* ఎ - ఐ */
+	0x0c12,	0x0c28,	/* ఒ - న */
+	0x0c2a,	0x0c33,	/* ప - ళ */
+	0x0c35,	0x0c39,	/* వ - హ */
+	0x0c60,	0x0c61,	/* ౠ - ౡ */
+	0x0c85,	0x0c8c,	/* ಅ - ಌ */
+	0x0c8e,	0x0c90,	/* ಎ - ಐ */
+	0x0c92,	0x0ca8,	/* ಒ - ನ */
+	0x0caa,	0x0cb3,	/* ಪ - ಳ */
+	0x0cb5,	0x0cb9,	/* ವ - ಹ */
+	0x0ce0,	0x0ce1,	/* ೠ - ೡ */
+	0x0d05,	0x0d0c,	/* അ - ഌ */
+	0x0d0e,	0x0d10,	/* എ - ഐ */
+	0x0d12,	0x0d28,	/* ഒ - ന */
+	0x0d2a,	0x0d39,	/* പ - ഹ */
+	0x0d60,	0x0d61,	/* ൠ - ൡ */
+	0x0e01,	0x0e30,	/* ก - ะ */
+	0x0e32,	0x0e33,	/* า - ำ */
+	0x0e40,	0x0e46,	/* เ - ๆ */
+	0x0e5a,	0x0e5b,	/* ๚ - ๛ */
+	0x0e81,	0x0e82,	/* ກ - ຂ */
+	0x0e87,	0x0e88,	/* ງ - ຈ */
+	0x0e94,	0x0e97,	/* ດ - ທ */
+	0x0e99,	0x0e9f,	/* ນ - ຟ */
+	0x0ea1,	0x0ea3,	/* ມ - ຣ */
+	0x0eaa,	0x0eab,	/* ສ - ຫ */
+	0x0ead,	0x0eae,	/* ອ - ຮ */
+	0x0eb2,	0x0eb3,	/* າ - ຳ */
+	0x0ec0,	0x0ec4,	/* ເ - ໄ */
+	0x0edc,	0x0edd,	/* ໜ - ໝ */
+	0x0f18,	0x0f19,	/* ༘ - ༙ */
+	0x0f40,	0x0f47,	/* ཀ - ཇ */
+	0x0f49,	0x0f69,	/* ཉ - ཀྵ */
+	0x10d0,	0x10f6,	/* ა - ჶ */
+	0x1100,	0x1159,	/* ᄀ - ᅙ */
+	0x115f,	0x11a2,	/* ᅟ - ᆢ */
+	0x11a8,	0x11f9,	/* ᆨ - ᇹ */
+	0x1e00,	0x1e9b,	/* Ḁ - ẛ */
+	0x1f50,	0x1f57,	/* ὐ - ὗ */
+	0x1f80,	0x1fb4,	/* ᾀ - ᾴ */
+	0x1fb6,	0x1fbc,	/* ᾶ - ᾼ */
+	0x1fc2,	0x1fc4,	/* ῂ - ῄ */
+	0x1fc6,	0x1fcc,	/* ῆ - ῌ */
+	0x1fd0,	0x1fd3,	/* ῐ - ΐ */
+	0x1fd6,	0x1fdb,	/* ῖ - Ί */
+	0x1fe0,	0x1fec,	/* ῠ - Ῥ */
+	0x1ff2,	0x1ff4,	/* ῲ - ῴ */
+	0x1ff6,	0x1ffc,	/* ῶ - ῼ */
+	0x210a,	0x2113,	/* ℊ - ℓ */
+	0x2115,	0x211d,	/* ℕ - ℝ */
+	0x2120,	0x2122,	/* ℠ - ™ */
+	0x212a,	0x2131,	/* K - ℱ */
+	0x2133,	0x2138,	/* ℳ - ℸ */
+	0x3041,	0x3094,	/* ぁ - ゔ */
+	0x30a1,	0x30fa,	/* ァ - ヺ */
+	0x3105,	0x312c,	/* ㄅ - ㄬ */
+	0x3131,	0x318e,	/* ㄱ - ㆎ */
+	0x3192,	0x319f,	/* ㆒ - ㆟ */
+	0x3260,	0x327b,	/* ㉠ - ㉻ */
+	0x328a,	0x32b0,	/* ㊊ - ㊰ */
+	0x32d0,	0x32fe,	/* ㋐ - ㋾ */
+	0x3300,	0x3357,	/* ㌀ - ㍗ */
+	0x3371,	0x3376,	/* ㍱ - ㍶ */
+	0x337b,	0x3394,	/* ㍻ - ㎔ */
+	0x3399,	0x339e,	/* ㎙ - ㎞ */
+	0x33a9,	0x33ad,	/* ㎩ - ㎭ */
+	0x33b0,	0x33c1,	/* ㎰ - ㏁ */
+	0x33c3,	0x33c5,	/* ㏃ - ㏅ */
+	0x33c7,	0x33d7,	/* ㏇ - ㏗ */
+	0x33d9,	0x33dd,	/* ㏙ - ㏝ */
+	0x4e00,	0x9fff,	/* 一 - 鿿 */
+	0xac00,	0xd7a3,	/* 가 - 힣 */
+	0xf900,	0xfb06,	/* 豈 - st */
+	0xfb13,	0xfb17,	/* ﬓ - ﬗ */
+	0xfb1f,	0xfb28,	/* ײַ - ﬨ */
+	0xfb2a,	0xfb36,	/* שׁ - זּ */
+	0xfb38,	0xfb3c,	/* טּ - לּ */
+	0xfb40,	0xfb41,	/* נּ - סּ */
+	0xfb43,	0xfb44,	/* ףּ - פּ */
+	0xfb46,	0xfbb1,	/* צּ - ﮱ */
+	0xfbd3,	0xfd3d,	/* ﯓ - ﴽ */
+	0xfd50,	0xfd8f,	/* ﵐ - ﶏ */
+	0xfd92,	0xfdc7,	/* ﶒ - ﷇ */
+	0xfdf0,	0xfdf9,	/* ﷰ - ﷹ */
+	0xfe70,	0xfe72,	/* ﹰ - ﹲ */
+	0xfe76,	0xfefc,	/* ﹶ - ﻼ */
+	0xff66,	0xff6f,	/* ヲ - ッ */
+	0xff71,	0xff9d,	/* ア - ン */
+	0xffa0,	0xffbe,	/* ᅠ - ᄒ */
+	0xffc2,	0xffc7,	/* ᅡ - ᅦ */
+	0xffca,	0xffcf,	/* ᅧ - ᅬ */
+	0xffd2,	0xffd7,	/* ᅭ - ᅲ */
+	0xffda,	0xffdc	/* ᅳ - ᅵ */
+]
+
+/*
+ * alpha singlets -
+ *	only covers ranges not in lower||upper
+ */
+const ralpha1 = [
+	0x00aa,	/* ª */
+	0x00b5,	/* µ */
+	0x00ba,	/* º */
+	0x03da,	/* Ϛ */
+	0x03dc,	/* Ϝ */
+	0x03de,	/* Ϟ */
+	0x03e0,	/* Ϡ */
+	0x06d5,	/* ە */
+	0x09b2,	/* ল */
+	0x0a5e,	/* ਫ਼ */
+	0x0a8d,	/* ઍ */
+	0x0ae0,	/* ૠ */
+	0x0b9c,	/* ஜ */
+	0x0cde,	/* ೞ */
+	0x0e4f,	/* ๏ */
+	0x0e84,	/* ຄ */
+	0x0e8a,	/* ຊ */
+	0x0e8d,	/* ຍ */
+	0x0ea5,	/* ລ */
+	0x0ea7,	/* ວ */
+	0x0eb0,	/* ະ */
+	0x0ebd,	/* ຽ */
+	0x1fbe,	/* ι */
+	0x207f,	/* ⁿ */
+	0x20a8,	/* ₨ */
+	0x2102,	/* ℂ */
+	0x2107,	/* ℇ */
+	0x2124,	/* ℤ */
+	0x2126,	/* Ω */
+	0x2128,	/* ℨ */
+	0xfb3e,	/* מּ */
+	0xfe74	/* ﹴ */
+]
+
+/*
+ * space ranges
+ */
+const rspace2 = [
+	0x0009,	0x000a,	/* rand newline */
+	0x0020,	0x0020,	/* space */
+	0x0085, 0x0085,
+	0x00a0,	0x00a0,	/*   */
+	0x1680, 0x1680,
+	0x180e, 0x180e,
+	0x2000,	0x200b,	/*   - ​ */
+	0x2028,	0x2029,	/* 
 - 
 */
+	0x202f, 0x202f,
+	0x205f, 0x205f,
+	0x3000,	0x3000,	/*   */
+	0xfeff,	0xfeff	/*  */
+]
+
+/*
+ * lower case ranges
+ *	3rd col is conversion excess 500
+ */
+const rtoupper2 = [
+	0x0061,	0x007a, 468,	/* a-z A-Z */
+	0x00e0,	0x00f6, 468,	/* à-ö À-Ö */
+	0x00f8,	0x00fe, 468,	/* ø-þ Ø-Þ */
+	0x0256,	0x0257, 295,	/* ɖ-ɗ Ɖ-Ɗ */
+	0x0258,	0x0259, 298,	/* ɘ-ə Ǝ-Ə */
+	0x028a,	0x028b, 283,	/* ʊ-ʋ Ʊ-Ʋ */
+	0x03ad,	0x03af, 463,	/* έ-ί Έ-Ί */
+	0x03b1,	0x03c1, 468,	/* α-ρ Α-Ρ */
+	0x03c3,	0x03cb, 468,	/* σ-ϋ Σ-Ϋ */
+	0x03cd,	0x03ce, 437,	/* ύ-ώ Ύ-Ώ */
+	0x0430,	0x044f, 468,	/* а-я А-Я */
+	0x0451,	0x045c, 420,	/* ё-ќ Ё-Ќ */
+	0x045e,	0x045f, 420,	/* ў-џ Ў-Џ */
+	0x0561,	0x0586, 452,	/* ա-ֆ Ա-Ֆ */
+	0x1f00,	0x1f07, 508,	/* ἀ-ἇ Ἀ-Ἇ */
+	0x1f10,	0x1f15, 508,	/* ἐ-ἕ Ἐ-Ἕ */
+	0x1f20,	0x1f27, 508,	/* ἠ-ἧ Ἠ-Ἧ */
+	0x1f30,	0x1f37, 508,	/* ἰ-ἷ Ἰ-Ἷ */
+	0x1f40,	0x1f45, 508,	/* ὀ-ὅ Ὀ-Ὅ */
+	0x1f60,	0x1f67, 508,	/* ὠ-ὧ Ὠ-Ὧ */
+	0x1f70,	0x1f71, 574,	/* ὰ-ά Ὰ-Ά */
+	0x1f72,	0x1f75, 586,	/* ὲ-ή Ὲ-Ή */
+	0x1f76,	0x1f77, 600,	/* ὶ-ί Ὶ-Ί */
+	0x1f78,	0x1f79, 628,	/* ὸ-ό Ὸ-Ό */
+	0x1f7a,	0x1f7b, 612,	/* ὺ-ύ Ὺ-Ύ */
+	0x1f7c,	0x1f7d, 626,	/* ὼ-ώ Ὼ-Ώ */
+	0x1f80,	0x1f87, 508,	/* ᾀ-ᾇ ᾈ-ᾏ */
+	0x1f90,	0x1f97, 508,	/* ᾐ-ᾗ ᾘ-ᾟ */
+	0x1fa0,	0x1fa7, 508,	/* ᾠ-ᾧ ᾨ-ᾯ */
+	0x1fb0,	0x1fb1, 508,	/* ᾰ-ᾱ Ᾰ-Ᾱ */
+	0x1fd0,	0x1fd1, 508,	/* ῐ-ῑ Ῐ-Ῑ */
+	0x1fe0,	0x1fe1, 508,	/* ῠ-ῡ Ῠ-Ῡ */
+	0x2170,	0x217f, 484,	/* ⅰ-ⅿ Ⅰ-Ⅿ */
+	0x24d0,	0x24e9, 474,	/* ⓐ-ⓩ Ⓐ-Ⓩ */
+	0xff41,	0xff5a, 468	/* a-z A-Z */
+]
+
+/*
+ * lower case singlets
+ *	2nd col is conversion excess 500
+ */
+const rtoupper1 = [
+	0x00ff, 621,	/* ÿ Ÿ */
+	0x0101, 499,	/* ā Ā */
+	0x0103, 499,	/* ă Ă */
+	0x0105, 499,	/* ą Ą */
+	0x0107, 499,	/* ć Ć */
+	0x0109, 499,	/* ĉ Ĉ */
+	0x010b, 499,	/* ċ Ċ */
+	0x010d, 499,	/* č Č */
+	0x010f, 499,	/* ď Ď */
+	0x0111, 499,	/* đ Đ */
+	0x0113, 499,	/* ē Ē */
+	0x0115, 499,	/* ĕ Ĕ */
+	0x0117, 499,	/* ė Ė */
+	0x0119, 499,	/* ę Ę */
+	0x011b, 499,	/* ě Ě */
+	0x011d, 499,	/* ĝ Ĝ */
+	0x011f, 499,	/* ğ Ğ */
+	0x0121, 499,	/* ġ Ġ */
+	0x0123, 499,	/* ģ Ģ */
+	0x0125, 499,	/* ĥ Ĥ */
+	0x0127, 499,	/* ħ Ħ */
+	0x0129, 499,	/* ĩ Ĩ */
+	0x012b, 499,	/* ī Ī */
+	0x012d, 499,	/* ĭ Ĭ */
+	0x012f, 499,	/* į Į */
+	0x0131, 268,	/* ı I */
+	0x0133, 499,	/* ij IJ */
+	0x0135, 499,	/* ĵ Ĵ */
+	0x0137, 499,	/* ķ Ķ */
+	0x013a, 499,	/* ĺ Ĺ */
+	0x013c, 499,	/* ļ Ļ */
+	0x013e, 499,	/* ľ Ľ */
+	0x0140, 499,	/* ŀ Ŀ */
+	0x0142, 499,	/* ł Ł */
+	0x0144, 499,	/* ń Ń */
+	0x0146, 499,	/* ņ Ņ */
+	0x0148, 499,	/* ň Ň */
+	0x014b, 499,	/* ŋ Ŋ */
+	0x014d, 499,	/* ō Ō */
+	0x014f, 499,	/* ŏ Ŏ */
+	0x0151, 499,	/* ő Ő */
+	0x0153, 499,	/* œ Œ */
+	0x0155, 499,	/* ŕ Ŕ */
+	0x0157, 499,	/* ŗ Ŗ */
+	0x0159, 499,	/* ř Ř */
+	0x015b, 499,	/* ś Ś */
+	0x015d, 499,	/* ŝ Ŝ */
+	0x015f, 499,	/* ş Ş */
+	0x0161, 499,	/* š Š */
+	0x0163, 499,	/* ţ Ţ */
+	0x0165, 499,	/* ť Ť */
+	0x0167, 499,	/* ŧ Ŧ */
+	0x0169, 499,	/* ũ Ũ */
+	0x016b, 499,	/* ū Ū */
+	0x016d, 499,	/* ŭ Ŭ */
+	0x016f, 499,	/* ů Ů */
+	0x0171, 499,	/* ű Ű */
+	0x0173, 499,	/* ų Ų */
+	0x0175, 499,	/* ŵ Ŵ */
+	0x0177, 499,	/* ŷ Ŷ */
+	0x017a, 499,	/* ź Ź */
+	0x017c, 499,	/* ż Ż */
+	0x017e, 499,	/* ž Ž */
+	0x017f, 200,	/* ſ S */
+	0x0183, 499,	/* ƃ Ƃ */
+	0x0185, 499,	/* ƅ Ƅ */
+	0x0188, 499,	/* ƈ Ƈ */
+	0x018c, 499,	/* ƌ Ƌ */
+	0x0192, 499,	/* ƒ Ƒ */
+	0x0199, 499,	/* ƙ Ƙ */
+	0x01a1, 499,	/* ơ Ơ */
+	0x01a3, 499,	/* ƣ Ƣ */
+	0x01a5, 499,	/* ƥ Ƥ */
+	0x01a8, 499,	/* ƨ Ƨ */
+	0x01ad, 499,	/* ƭ Ƭ */
+	0x01b0, 499,	/* ư Ư */
+	0x01b4, 499,	/* ƴ Ƴ */
+	0x01b6, 499,	/* ƶ Ƶ */
+	0x01b9, 499,	/* ƹ Ƹ */
+	0x01bd, 499,	/* ƽ Ƽ */
+	0x01c5, 499,	/* Dž DŽ */
+	0x01c6, 498,	/* dž DŽ */
+	0x01c8, 499,	/* Lj LJ */
+	0x01c9, 498,	/* lj LJ */
+	0x01cb, 499,	/* Nj NJ */
+	0x01cc, 498,	/* nj NJ */
+	0x01ce, 499,	/* ǎ Ǎ */
+	0x01d0, 499,	/* ǐ Ǐ */
+	0x01d2, 499,	/* ǒ Ǒ */
+	0x01d4, 499,	/* ǔ Ǔ */
+	0x01d6, 499,	/* ǖ Ǖ */
+	0x01d8, 499,	/* ǘ Ǘ */
+	0x01da, 499,	/* ǚ Ǚ */
+	0x01dc, 499,	/* ǜ Ǜ */
+	0x01df, 499,	/* ǟ Ǟ */
+	0x01e1, 499,	/* ǡ Ǡ */
+	0x01e3, 499,	/* ǣ Ǣ */
+	0x01e5, 499,	/* ǥ Ǥ */
+	0x01e7, 499,	/* ǧ Ǧ */
+	0x01e9, 499,	/* ǩ Ǩ */
+	0x01eb, 499,	/* ǫ Ǫ */
+	0x01ed, 499,	/* ǭ Ǭ */
+	0x01ef, 499,	/* ǯ Ǯ */
+	0x01f2, 499,	/* Dz DZ */
+	0x01f3, 498,	/* dz DZ */
+	0x01f5, 499,	/* ǵ Ǵ */
+	0x01fb, 499,	/* ǻ Ǻ */
+	0x01fd, 499,	/* ǽ Ǽ */
+	0x01ff, 499,	/* ǿ Ǿ */
+	0x0201, 499,	/* ȁ Ȁ */
+	0x0203, 499,	/* ȃ Ȃ */
+	0x0205, 499,	/* ȅ Ȅ */
+	0x0207, 499,	/* ȇ Ȇ */
+	0x0209, 499,	/* ȉ Ȉ */
+	0x020b, 499,	/* ȋ Ȋ */
+	0x020d, 499,	/* ȍ Ȍ */
+	0x020f, 499,	/* ȏ Ȏ */
+	0x0211, 499,	/* ȑ Ȑ */
+	0x0213, 499,	/* ȓ Ȓ */
+	0x0215, 499,	/* ȕ Ȕ */
+	0x0217, 499,	/* ȗ Ȗ */
+	0x0253, 290,	/* ɓ Ɓ */
+	0x0254, 294,	/* ɔ Ɔ */
+	0x025b, 297,	/* ɛ Ɛ */
+	0x0260, 295,	/* ɠ Ɠ */
+	0x0263, 293,	/* ɣ Ɣ */
+	0x0268, 291,	/* ɨ Ɨ */
+	0x0269, 289,	/* ɩ Ɩ */
+	0x026f, 289,	/* ɯ Ɯ */
+	0x0272, 287,	/* ɲ Ɲ */
+	0x0283, 282,	/* ʃ Ʃ */
+	0x0288, 282,	/* ʈ Ʈ */
+	0x0292, 281,	/* ʒ Ʒ */
+	0x03ac, 462,	/* ά Ά */
+	0x03cc, 436,	/* ό Ό */
+	0x03d0, 438,	/* ϐ Β */
+	0x03d1, 443,	/* ϑ Θ */
+	0x03d5, 453,	/* ϕ Φ */
+	0x03d6, 446,	/* ϖ Π */
+	0x03e3, 499,	/* ϣ Ϣ */
+	0x03e5, 499,	/* ϥ Ϥ */
+	0x03e7, 499,	/* ϧ Ϧ */
+	0x03e9, 499,	/* ϩ Ϩ */
+	0x03eb, 499,	/* ϫ Ϫ */
+	0x03ed, 499,	/* ϭ Ϭ */
+	0x03ef, 499,	/* ϯ Ϯ */
+	0x03f0, 414,	/* ϰ Κ */
+	0x03f1, 420,	/* ϱ Ρ */
+	0x0461, 499,	/* ѡ Ѡ */
+	0x0463, 499,	/* ѣ Ѣ */
+	0x0465, 499,	/* ѥ Ѥ */
+	0x0467, 499,	/* ѧ Ѧ */
+	0x0469, 499,	/* ѩ Ѩ */
+	0x046b, 499,	/* ѫ Ѫ */
+	0x046d, 499,	/* ѭ Ѭ */
+	0x046f, 499,	/* ѯ Ѯ */
+	0x0471, 499,	/* ѱ Ѱ */
+	0x0473, 499,	/* ѳ Ѳ */
+	0x0475, 499,	/* ѵ Ѵ */
+	0x0477, 499,	/* ѷ Ѷ */
+	0x0479, 499,	/* ѹ Ѹ */
+	0x047b, 499,	/* ѻ Ѻ */
+	0x047d, 499,	/* ѽ Ѽ */
+	0x047f, 499,	/* ѿ Ѿ */
+	0x0481, 499,	/* ҁ Ҁ */
+	0x0491, 499,	/* ґ Ґ */
+	0x0493, 499,	/* ғ Ғ */
+	0x0495, 499,	/* ҕ Ҕ */
+	0x0497, 499,	/* җ Җ */
+	0x0499, 499,	/* ҙ Ҙ */
+	0x049b, 499,	/* қ Қ */
+	0x049d, 499,	/* ҝ Ҝ */
+	0x049f, 499,	/* ҟ Ҟ */
+	0x04a1, 499,	/* ҡ Ҡ */
+	0x04a3, 499,	/* ң Ң */
+	0x04a5, 499,	/* ҥ Ҥ */
+	0x04a7, 499,	/* ҧ Ҧ */
+	0x04a9, 499,	/* ҩ Ҩ */
+	0x04ab, 499,	/* ҫ Ҫ */
+	0x04ad, 499,	/* ҭ Ҭ */
+	0x04af, 499,	/* ү Ү */
+	0x04b1, 499,	/* ұ Ұ */
+	0x04b3, 499,	/* ҳ Ҳ */
+	0x04b5, 499,	/* ҵ Ҵ */
+	0x04b7, 499,	/* ҷ Ҷ */
+	0x04b9, 499,	/* ҹ Ҹ */
+	0x04bb, 499,	/* һ Һ */
+	0x04bd, 499,	/* ҽ Ҽ */
+	0x04bf, 499,	/* ҿ Ҿ */
+	0x04c2, 499,	/* ӂ Ӂ */
+	0x04c4, 499,	/* ӄ Ӄ */
+	0x04c8, 499,	/* ӈ Ӈ */
+	0x04cc, 499,	/* ӌ Ӌ */
+	0x04d1, 499,	/* ӑ Ӑ */
+	0x04d3, 499,	/* ӓ Ӓ */
+	0x04d5, 499,	/* ӕ Ӕ */
+	0x04d7, 499,	/* ӗ Ӗ */
+	0x04d9, 499,	/* ә Ә */
+	0x04db, 499,	/* ӛ Ӛ */
+	0x04dd, 499,	/* ӝ Ӝ */
+	0x04df, 499,	/* ӟ Ӟ */
+	0x04e1, 499,	/* ӡ Ӡ */
+	0x04e3, 499,	/* ӣ Ӣ */
+	0x04e5, 499,	/* ӥ Ӥ */
+	0x04e7, 499,	/* ӧ Ӧ */
+	0x04e9, 499,	/* ө Ө */
+	0x04eb, 499,	/* ӫ Ӫ */
+	0x04ef, 499,	/* ӯ Ӯ */
+	0x04f1, 499,	/* ӱ Ӱ */
+	0x04f3, 499,	/* ӳ Ӳ */
+	0x04f5, 499,	/* ӵ Ӵ */
+	0x04f9, 499,	/* ӹ Ӹ */
+	0x1e01, 499,	/* ḁ Ḁ */
+	0x1e03, 499,	/* ḃ Ḃ */
+	0x1e05, 499,	/* ḅ Ḅ */
+	0x1e07, 499,	/* ḇ Ḇ */
+	0x1e09, 499,	/* ḉ Ḉ */
+	0x1e0b, 499,	/* ḋ Ḋ */
+	0x1e0d, 499,	/* ḍ Ḍ */
+	0x1e0f, 499,	/* ḏ Ḏ */
+	0x1e11, 499,	/* ḑ Ḑ */
+	0x1e13, 499,	/* ḓ Ḓ */
+	0x1e15, 499,	/* ḕ Ḕ */
+	0x1e17, 499,	/* ḗ Ḗ */
+	0x1e19, 499,	/* ḙ Ḙ */
+	0x1e1b, 499,	/* ḛ Ḛ */
+	0x1e1d, 499,	/* ḝ Ḝ */
+	0x1e1f, 499,	/* ḟ Ḟ */
+	0x1e21, 499,	/* ḡ Ḡ */
+	0x1e23, 499,	/* ḣ Ḣ */
+	0x1e25, 499,	/* ḥ Ḥ */
+	0x1e27, 499,	/* ḧ Ḧ */
+	0x1e29, 499,	/* ḩ Ḩ */
+	0x1e2b, 499,	/* ḫ Ḫ */
+	0x1e2d, 499,	/* ḭ Ḭ */
+	0x1e2f, 499,	/* ḯ Ḯ */
+	0x1e31, 499,	/* ḱ Ḱ */
+	0x1e33, 499,	/* ḳ Ḳ */
+	0x1e35, 499,	/* ḵ Ḵ */
+	0x1e37, 499,	/* ḷ Ḷ */
+	0x1e39, 499,	/* ḹ Ḹ */
+	0x1e3b, 499,	/* ḻ Ḻ */
+	0x1e3d, 499,	/* ḽ Ḽ */
+	0x1e3f, 499,	/* ḿ Ḿ */
+	0x1e41, 499,	/* ṁ Ṁ */
+	0x1e43, 499,	/* ṃ Ṃ */
+	0x1e45, 499,	/* ṅ Ṅ */
+	0x1e47, 499,	/* ṇ Ṇ */
+	0x1e49, 499,	/* ṉ Ṉ */
+	0x1e4b, 499,	/* ṋ Ṋ */
+	0x1e4d, 499,	/* ṍ Ṍ */
+	0x1e4f, 499,	/* ṏ Ṏ */
+	0x1e51, 499,	/* ṑ Ṑ */
+	0x1e53, 499,	/* ṓ Ṓ */
+	0x1e55, 499,	/* ṕ Ṕ */
+	0x1e57, 499,	/* ṗ Ṗ */
+	0x1e59, 499,	/* ṙ Ṙ */
+	0x1e5b, 499,	/* ṛ Ṛ */
+	0x1e5d, 499,	/* ṝ Ṝ */
+	0x1e5f, 499,	/* ṟ Ṟ */
+	0x1e61, 499,	/* ṡ Ṡ */
+	0x1e63, 499,	/* ṣ Ṣ */
+	0x1e65, 499,	/* ṥ Ṥ */
+	0x1e67, 499,	/* ṧ Ṧ */
+	0x1e69, 499,	/* ṩ Ṩ */
+	0x1e6b, 499,	/* ṫ Ṫ */
+	0x1e6d, 499,	/* ṭ Ṭ */
+	0x1e6f, 499,	/* ṯ Ṯ */
+	0x1e71, 499,	/* ṱ Ṱ */
+	0x1e73, 499,	/* ṳ Ṳ */
+	0x1e75, 499,	/* ṵ Ṵ */
+	0x1e77, 499,	/* ṷ Ṷ */
+	0x1e79, 499,	/* ṹ Ṹ */
+	0x1e7b, 499,	/* ṻ Ṻ */
+	0x1e7d, 499,	/* ṽ Ṽ */
+	0x1e7f, 499,	/* ṿ Ṿ */
+	0x1e81, 499,	/* ẁ Ẁ */
+	0x1e83, 499,	/* ẃ Ẃ */
+	0x1e85, 499,	/* ẅ Ẅ */
+	0x1e87, 499,	/* ẇ Ẇ */
+	0x1e89, 499,	/* ẉ Ẉ */
+	0x1e8b, 499,	/* ẋ Ẋ */
+	0x1e8d, 499,	/* ẍ Ẍ */
+	0x1e8f, 499,	/* ẏ Ẏ */
+	0x1e91, 499,	/* ẑ Ẑ */
+	0x1e93, 499,	/* ẓ Ẓ */
+	0x1e95, 499,	/* ẕ Ẕ */
+	0x1ea1, 499,	/* ạ Ạ */
+	0x1ea3, 499,	/* ả Ả */
+	0x1ea5, 499,	/* ấ Ấ */
+	0x1ea7, 499,	/* ầ Ầ */
+	0x1ea9, 499,	/* ẩ Ẩ */
+	0x1eab, 499,	/* ẫ Ẫ */
+	0x1ead, 499,	/* ậ Ậ */
+	0x1eaf, 499,	/* ắ Ắ */
+	0x1eb1, 499,	/* ằ Ằ */
+	0x1eb3, 499,	/* ẳ Ẳ */
+	0x1eb5, 499,	/* ẵ Ẵ */
+	0x1eb7, 499,	/* ặ Ặ */
+	0x1eb9, 499,	/* ẹ Ẹ */
+	0x1ebb, 499,	/* ẻ Ẻ */
+	0x1ebd, 499,	/* ẽ Ẽ */
+	0x1ebf, 499,	/* ế Ế */
+	0x1ec1, 499,	/* ề Ề */
+	0x1ec3, 499,	/* ể Ể */
+	0x1ec5, 499,	/* ễ Ễ */
+	0x1ec7, 499,	/* ệ Ệ */
+	0x1ec9, 499,	/* ỉ Ỉ */
+	0x1ecb, 499,	/* ị Ị */
+	0x1ecd, 499,	/* ọ Ọ */
+	0x1ecf, 499,	/* ỏ Ỏ */
+	0x1ed1, 499,	/* ố Ố */
+	0x1ed3, 499,	/* ồ Ồ */
+	0x1ed5, 499,	/* ổ Ổ */
+	0x1ed7, 499,	/* ỗ Ỗ */
+	0x1ed9, 499,	/* ộ Ộ */
+	0x1edb, 499,	/* ớ Ớ */
+	0x1edd, 499,	/* ờ Ờ */
+	0x1edf, 499,	/* ở Ở */
+	0x1ee1, 499,	/* ỡ Ỡ */
+	0x1ee3, 499,	/* ợ Ợ */
+	0x1ee5, 499,	/* ụ Ụ */
+	0x1ee7, 499,	/* ủ Ủ */
+	0x1ee9, 499,	/* ứ Ứ */
+	0x1eeb, 499,	/* ừ Ừ */
+	0x1eed, 499,	/* ử Ử */
+	0x1eef, 499,	/* ữ Ữ */
+	0x1ef1, 499,	/* ự Ự */
+	0x1ef3, 499,	/* ỳ Ỳ */
+	0x1ef5, 499,	/* ỵ Ỵ */
+	0x1ef7, 499,	/* ỷ Ỷ */
+	0x1ef9, 499,	/* ỹ Ỹ */
+	0x1f51, 508,	/* ὑ Ὑ */
+	0x1f53, 508,	/* ὓ Ὓ */
+	0x1f55, 508,	/* ὕ Ὕ */
+	0x1f57, 508,	/* ὗ Ὗ */
+	0x1fb3, 509,	/* ᾳ ᾼ */
+	0x1fc3, 509,	/* ῃ ῌ */
+	0x1fe5, 507,	/* ῥ Ῥ */
+	0x1ff3, 509	/* ῳ ῼ */
+]
+
+const rnums = [
+	0x0030, 0x0039,
+	0x0660, 0x0669,
+	0x06f0, 0x06f9,
+	0x07c0, 0x07c9,
+	0x0966, 0x096f,
+	0x09e6, 0x09ef,
+	0x0a66, 0x0a6f,
+	0x0ae6, 0x0aef,
+	0x0b66, 0x0b6f,
+	0x0be6, 0x0bef,
+	0x0c66, 0x0c6f,
+	0x0ce6, 0x0cef,
+	0x0d66, 0x0d6f,
+	0x0e50, 0x0e59,
+	0x0ed0, 0x0ed9,
+	0x0f20, 0x0f29,
+	0x1040, 0x1049,
+	0x17e0, 0x17e9,
+	0x1810, 0x1819,
+	0x1946, 0x194f,
+	0x19d0, 0x19d9,
+	0x1b50, 0x1b59,
+	0xff10, 0xff19,
+	0x104a0, 0x104a9,
+	0x1d7ce, 0x1d7ff
+]
+
+/*
+ * upper case ranges
+ *	3rd col is conversion excess 500
+ */
+const rtolower2 = [
+	0x0041,	0x005a, 532,	/* A-Z a-z */
+	0x00c0,	0x00d6, 532,	/* À-Ö à-ö */
+	0x00d8,	0x00de, 532,	/* Ø-Þ ø-þ */
+	0x0189,	0x018a, 705,	/* Ɖ-Ɗ ɖ-ɗ */
+	0x018e,	0x018f, 702,	/* Ǝ-Ə ɘ-ə */
+	0x01b1,	0x01b2, 717,	/* Ʊ-Ʋ ʊ-ʋ */
+	0x0388,	0x038a, 537,	/* Έ-Ί έ-ί */
+	0x038e,	0x038f, 563,	/* Ύ-Ώ ύ-ώ */
+	0x0391,	0x03a1, 532,	/* Α-Ρ α-ρ */
+	0x03a3,	0x03ab, 532,	/* Σ-Ϋ σ-ϋ */
+	0x0401,	0x040c, 580,	/* Ё-Ќ ё-ќ */
+	0x040e,	0x040f, 580,	/* Ў-Џ ў-џ */
+	0x0410,	0x042f, 532,	/* А-Я а-я */
+	0x0531,	0x0556, 548,	/* Ա-Ֆ ա-ֆ */
+	0x10a0,	0x10c5, 548,	/* Ⴀ-Ⴥ ა-ჵ */
+	0x1f08,	0x1f0f, 492,	/* Ἀ-Ἇ ἀ-ἇ */
+	0x1f18,	0x1f1d, 492,	/* Ἐ-Ἕ ἐ-ἕ */
+	0x1f28,	0x1f2f, 492,	/* Ἠ-Ἧ ἠ-ἧ */
+	0x1f38,	0x1f3f, 492,	/* Ἰ-Ἷ ἰ-ἷ */
+	0x1f48,	0x1f4d, 492,	/* Ὀ-Ὅ ὀ-ὅ */
+	0x1f68,	0x1f6f, 492,	/* Ὠ-Ὧ ὠ-ὧ */
+	0x1f88,	0x1f8f, 492,	/* ᾈ-ᾏ ᾀ-ᾇ */
+	0x1f98,	0x1f9f, 492,	/* ᾘ-ᾟ ᾐ-ᾗ */
+	0x1fa8,	0x1faf, 492,	/* ᾨ-ᾯ ᾠ-ᾧ */
+	0x1fb8,	0x1fb9, 492,	/* Ᾰ-Ᾱ ᾰ-ᾱ */
+	0x1fba,	0x1fbb, 426,	/* Ὰ-Ά ὰ-ά */
+	0x1fc8,	0x1fcb, 414,	/* Ὲ-Ή ὲ-ή */
+	0x1fd8,	0x1fd9, 492,	/* Ῐ-Ῑ ῐ-ῑ */
+	0x1fda,	0x1fdb, 400,	/* Ὶ-Ί ὶ-ί */
+	0x1fe8,	0x1fe9, 492,	/* Ῠ-Ῡ ῠ-ῡ */
+	0x1fea,	0x1feb, 388,	/* Ὺ-Ύ ὺ-ύ */
+	0x1ff8,	0x1ff9, 372,	/* Ὸ-Ό ὸ-ό */
+	0x1ffa,	0x1ffb, 374,	/* Ὼ-Ώ ὼ-ώ */
+	0x2160,	0x216f, 516,	/* Ⅰ-Ⅿ ⅰ-ⅿ */
+	0x24b6,	0x24cf, 526,	/* Ⓐ-Ⓩ ⓐ-ⓩ */
+	0xff21,	0xff3a, 532	/* A-Z a-z */
+]
+
+/*
+ * upper case singlets
+ *	2nd col is conversion excess 500
+ */
+const rtolower1 = [
+	0x0100, 501,	/* Ā ā */
+	0x0102, 501,	/* Ă ă */
+	0x0104, 501,	/* Ą ą */
+	0x0106, 501,	/* Ć ć */
+	0x0108, 501,	/* Ĉ ĉ */
+	0x010a, 501,	/* Ċ ċ */
+	0x010c, 501,	/* Č č */
+	0x010e, 501,	/* Ď ď */
+	0x0110, 501,	/* Đ đ */
+	0x0112, 501,	/* Ē ē */
+	0x0114, 501,	/* Ĕ ĕ */
+	0x0116, 501,	/* Ė ė */
+	0x0118, 501,	/* Ę ę */
+	0x011a, 501,	/* Ě ě */
+	0x011c, 501,	/* Ĝ ĝ */
+	0x011e, 501,	/* Ğ ğ */
+	0x0120, 501,	/* Ġ ġ */
+	0x0122, 501,	/* Ģ ģ */
+	0x0124, 501,	/* Ĥ ĥ */
+	0x0126, 501,	/* Ħ ħ */
+	0x0128, 501,	/* Ĩ ĩ */
+	0x012a, 501,	/* Ī ī */
+	0x012c, 501,	/* Ĭ ĭ */
+	0x012e, 501,	/* Į į */
+	0x0130, 301,	/* İ i */
+	0x0132, 501,	/* IJ ij */
+	0x0134, 501,	/* Ĵ ĵ */
+	0x0136, 501,	/* Ķ ķ */
+	0x0139, 501,	/* Ĺ ĺ */
+	0x013b, 501,	/* Ļ ļ */
+	0x013d, 501,	/* Ľ ľ */
+	0x013f, 501,	/* Ŀ ŀ */
+	0x0141, 501,	/* Ł ł */
+	0x0143, 501,	/* Ń ń */
+	0x0145, 501,	/* Ņ ņ */
+	0x0147, 501,	/* Ň ň */
+	0x014a, 501,	/* Ŋ ŋ */
+	0x014c, 501,	/* Ō ō */
+	0x014e, 501,	/* Ŏ ŏ */
+	0x0150, 501,	/* Ő ő */
+	0x0152, 501,	/* Œ œ */
+	0x0154, 501,	/* Ŕ ŕ */
+	0x0156, 501,	/* Ŗ ŗ */
+	0x0158, 501,	/* Ř ř */
+	0x015a, 501,	/* Ś ś */
+	0x015c, 501,	/* Ŝ ŝ */
+	0x015e, 501,	/* Ş ş */
+	0x0160, 501,	/* Š š */
+	0x0162, 501,	/* Ţ ţ */
+	0x0164, 501,	/* Ť ť */
+	0x0166, 501,	/* Ŧ ŧ */
+	0x0168, 501,	/* Ũ ũ */
+	0x016a, 501,	/* Ū ū */
+	0x016c, 501,	/* Ŭ ŭ */
+	0x016e, 501,	/* Ů ů */
+	0x0170, 501,	/* Ű ű */
+	0x0172, 501,	/* Ų ų */
+	0x0174, 501,	/* Ŵ ŵ */
+	0x0176, 501,	/* Ŷ ŷ */
+	0x0178, 379,	/* Ÿ ÿ */
+	0x0179, 501,	/* Ź ź */
+	0x017b, 501,	/* Ż ż */
+	0x017d, 501,	/* Ž ž */
+	0x0181, 710,	/* Ɓ ɓ */
+	0x0182, 501,	/* Ƃ ƃ */
+	0x0184, 501,	/* Ƅ ƅ */
+	0x0186, 706,	/* Ɔ ɔ */
+	0x0187, 501,	/* Ƈ ƈ */
+	0x018b, 501,	/* Ƌ ƌ */
+	0x0190, 703,	/* Ɛ ɛ */
+	0x0191, 501,	/* Ƒ ƒ */
+	0x0193, 705,	/* Ɠ ɠ */
+	0x0194, 707,	/* Ɣ ɣ */
+	0x0196, 711,	/* Ɩ ɩ */
+	0x0197, 709,	/* Ɨ ɨ */
+	0x0198, 501,	/* Ƙ ƙ */
+	0x019c, 711,	/* Ɯ ɯ */
+	0x019d, 713,	/* Ɲ ɲ */
+	0x01a0, 501,	/* Ơ ơ */
+	0x01a2, 501,	/* Ƣ ƣ */
+	0x01a4, 501,	/* Ƥ ƥ */
+	0x01a7, 501,	/* Ƨ ƨ */
+	0x01a9, 718,	/* Ʃ ʃ */
+	0x01ac, 501,	/* Ƭ ƭ */
+	0x01ae, 718,	/* Ʈ ʈ */
+	0x01af, 501,	/* Ư ư */
+	0x01b3, 501,	/* Ƴ ƴ */
+	0x01b5, 501,	/* Ƶ ƶ */
+	0x01b7, 719,	/* Ʒ ʒ */
+	0x01b8, 501,	/* Ƹ ƹ */
+	0x01bc, 501,	/* Ƽ ƽ */
+	0x01c4, 502,	/* DŽ dž */
+	0x01c5, 501,	/* Dž dž */
+	0x01c7, 502,	/* LJ lj */
+	0x01c8, 501,	/* Lj lj */
+	0x01ca, 502,	/* NJ nj */
+	0x01cb, 501,	/* Nj nj */
+	0x01cd, 501,	/* Ǎ ǎ */
+	0x01cf, 501,	/* Ǐ ǐ */
+	0x01d1, 501,	/* Ǒ ǒ */
+	0x01d3, 501,	/* Ǔ ǔ */
+	0x01d5, 501,	/* Ǖ ǖ */
+	0x01d7, 501,	/* Ǘ ǘ */
+	0x01d9, 501,	/* Ǚ ǚ */
+	0x01db, 501,	/* Ǜ ǜ */
+	0x01de, 501,	/* Ǟ ǟ */
+	0x01e0, 501,	/* Ǡ ǡ */
+	0x01e2, 501,	/* Ǣ ǣ */
+	0x01e4, 501,	/* Ǥ ǥ */
+	0x01e6, 501,	/* Ǧ ǧ */
+	0x01e8, 501,	/* Ǩ ǩ */
+	0x01ea, 501,	/* Ǫ ǫ */
+	0x01ec, 501,	/* Ǭ ǭ */
+	0x01ee, 501,	/* Ǯ ǯ */
+	0x01f1, 502,	/* DZ dz */
+	0x01f2, 501,	/* Dz dz */
+	0x01f4, 501,	/* Ǵ ǵ */
+	0x01fa, 501,	/* Ǻ ǻ */
+	0x01fc, 501,	/* Ǽ ǽ */
+	0x01fe, 501,	/* Ǿ ǿ */
+	0x0200, 501,	/* Ȁ ȁ */
+	0x0202, 501,	/* Ȃ ȃ */
+	0x0204, 501,	/* Ȅ ȅ */
+	0x0206, 501,	/* Ȇ ȇ */
+	0x0208, 501,	/* Ȉ ȉ */
+	0x020a, 501,	/* Ȋ ȋ */
+	0x020c, 501,	/* Ȍ ȍ */
+	0x020e, 501,	/* Ȏ ȏ */
+	0x0210, 501,	/* Ȑ ȑ */
+	0x0212, 501,	/* Ȓ ȓ */
+	0x0214, 501,	/* Ȕ ȕ */
+	0x0216, 501,	/* Ȗ ȗ */
+	0x0386, 538,	/* Ά ά */
+	0x038c, 564,	/* Ό ό */
+	0x03e2, 501,	/* Ϣ ϣ */
+	0x03e4, 501,	/* Ϥ ϥ */
+	0x03e6, 501,	/* Ϧ ϧ */
+	0x03e8, 501,	/* Ϩ ϩ */
+	0x03ea, 501,	/* Ϫ ϫ */
+	0x03ec, 501,	/* Ϭ ϭ */
+	0x03ee, 501,	/* Ϯ ϯ */
+	0x0460, 501,	/* Ѡ ѡ */
+	0x0462, 501,	/* Ѣ ѣ */
+	0x0464, 501,	/* Ѥ ѥ */
+	0x0466, 501,	/* Ѧ ѧ */
+	0x0468, 501,	/* Ѩ ѩ */
+	0x046a, 501,	/* Ѫ ѫ */
+	0x046c, 501,	/* Ѭ ѭ */
+	0x046e, 501,	/* Ѯ ѯ */
+	0x0470, 501,	/* Ѱ ѱ */
+	0x0472, 501,	/* Ѳ ѳ */
+	0x0474, 501,	/* Ѵ ѵ */
+	0x0476, 501,	/* Ѷ ѷ */
+	0x0478, 501,	/* Ѹ ѹ */
+	0x047a, 501,	/* Ѻ ѻ */
+	0x047c, 501,	/* Ѽ ѽ */
+	0x047e, 501,	/* Ѿ ѿ */
+	0x0480, 501,	/* Ҁ ҁ */
+	0x0490, 501,	/* Ґ ґ */
+	0x0492, 501,	/* Ғ ғ */
+	0x0494, 501,	/* Ҕ ҕ */
+	0x0496, 501,	/* Җ җ */
+	0x0498, 501,	/* Ҙ ҙ */
+	0x049a, 501,	/* Қ қ */
+	0x049c, 501,	/* Ҝ ҝ */
+	0x049e, 501,	/* Ҟ ҟ */
+	0x04a0, 501,	/* Ҡ ҡ */
+	0x04a2, 501,	/* Ң ң */
+	0x04a4, 501,	/* Ҥ ҥ */
+	0x04a6, 501,	/* Ҧ ҧ */
+	0x04a8, 501,	/* Ҩ ҩ */
+	0x04aa, 501,	/* Ҫ ҫ */
+	0x04ac, 501,	/* Ҭ ҭ */
+	0x04ae, 501,	/* Ү ү */
+	0x04b0, 501,	/* Ұ ұ */
+	0x04b2, 501,	/* Ҳ ҳ */
+	0x04b4, 501,	/* Ҵ ҵ */
+	0x04b6, 501,	/* Ҷ ҷ */
+	0x04b8, 501,	/* Ҹ ҹ */
+	0x04ba, 501,	/* Һ һ */
+	0x04bc, 501,	/* Ҽ ҽ */
+	0x04be, 501,	/* Ҿ ҿ */
+	0x04c1, 501,	/* Ӂ ӂ */
+	0x04c3, 501,	/* Ӄ ӄ */
+	0x04c7, 501,	/* Ӈ ӈ */
+	0x04cb, 501,	/* Ӌ ӌ */
+	0x04d0, 501,	/* Ӑ ӑ */
+	0x04d2, 501,	/* Ӓ ӓ */
+	0x04d4, 501,	/* Ӕ ӕ */
+	0x04d6, 501,	/* Ӗ ӗ */
+	0x04d8, 501,	/* Ә ә */
+	0x04da, 501,	/* Ӛ ӛ */
+	0x04dc, 501,	/* Ӝ ӝ */
+	0x04de, 501,	/* Ӟ ӟ */
+	0x04e0, 501,	/* Ӡ ӡ */
+	0x04e2, 501,	/* Ӣ ӣ */
+	0x04e4, 501,	/* Ӥ ӥ */
+	0x04e6, 501,	/* Ӧ ӧ */
+	0x04e8, 501,	/* Ө ө */
+	0x04ea, 501,	/* Ӫ ӫ */
+	0x04ee, 501,	/* Ӯ ӯ */
+	0x04f0, 501,	/* Ӱ ӱ */
+	0x04f2, 501,	/* Ӳ ӳ */
+	0x04f4, 501,	/* Ӵ ӵ */
+	0x04f8, 501,	/* Ӹ ӹ */
+	0x1e00, 501,	/* Ḁ ḁ */
+	0x1e02, 501,	/* Ḃ ḃ */
+	0x1e04, 501,	/* Ḅ ḅ */
+	0x1e06, 501,	/* Ḇ ḇ */
+	0x1e08, 501,	/* Ḉ ḉ */
+	0x1e0a, 501,	/* Ḋ ḋ */
+	0x1e0c, 501,	/* Ḍ ḍ */
+	0x1e0e, 501,	/* Ḏ ḏ */
+	0x1e10, 501,	/* Ḑ ḑ */
+	0x1e12, 501,	/* Ḓ ḓ */
+	0x1e14, 501,	/* Ḕ ḕ */
+	0x1e16, 501,	/* Ḗ ḗ */
+	0x1e18, 501,	/* Ḙ ḙ */
+	0x1e1a, 501,	/* Ḛ ḛ */
+	0x1e1c, 501,	/* Ḝ ḝ */
+	0x1e1e, 501,	/* Ḟ ḟ */
+	0x1e20, 501,	/* Ḡ ḡ */
+	0x1e22, 501,	/* Ḣ ḣ */
+	0x1e24, 501,	/* Ḥ ḥ */
+	0x1e26, 501,	/* Ḧ ḧ */
+	0x1e28, 501,	/* Ḩ ḩ */
+	0x1e2a, 501,	/* Ḫ ḫ */
+	0x1e2c, 501,	/* Ḭ ḭ */
+	0x1e2e, 501,	/* Ḯ ḯ */
+	0x1e30, 501,	/* Ḱ ḱ */
+	0x1e32, 501,	/* Ḳ ḳ */
+	0x1e34, 501,	/* Ḵ ḵ */
+	0x1e36, 501,	/* Ḷ ḷ */
+	0x1e38, 501,	/* Ḹ ḹ */
+	0x1e3a, 501,	/* Ḻ ḻ */
+	0x1e3c, 501,	/* Ḽ ḽ */
+	0x1e3e, 501,	/* Ḿ ḿ */
+	0x1e40, 501,	/* Ṁ ṁ */
+	0x1e42, 501,	/* Ṃ ṃ */
+	0x1e44, 501,	/* Ṅ ṅ */
+	0x1e46, 501,	/* Ṇ ṇ */
+	0x1e48, 501,	/* Ṉ ṉ */
+	0x1e4a, 501,	/* Ṋ ṋ */
+	0x1e4c, 501,	/* Ṍ ṍ */
+	0x1e4e, 501,	/* Ṏ ṏ */
+	0x1e50, 501,	/* Ṑ ṑ */
+	0x1e52, 501,	/* Ṓ ṓ */
+	0x1e54, 501,	/* Ṕ ṕ */
+	0x1e56, 501,	/* Ṗ ṗ */
+	0x1e58, 501,	/* Ṙ ṙ */
+	0x1e5a, 501,	/* Ṛ ṛ */
+	0x1e5c, 501,	/* Ṝ ṝ */
+	0x1e5e, 501,	/* Ṟ ṟ */
+	0x1e60, 501,	/* Ṡ ṡ */
+	0x1e62, 501,	/* Ṣ ṣ */
+	0x1e64, 501,	/* Ṥ ṥ */
+	0x1e66, 501,	/* Ṧ ṧ */
+	0x1e68, 501,	/* Ṩ ṩ */
+	0x1e6a, 501,	/* Ṫ ṫ */
+	0x1e6c, 501,	/* Ṭ ṭ */
+	0x1e6e, 501,	/* Ṯ ṯ */
+	0x1e70, 501,	/* Ṱ ṱ */
+	0x1e72, 501,	/* Ṳ ṳ */
+	0x1e74, 501,	/* Ṵ ṵ */
+	0x1e76, 501,	/* Ṷ ṷ */
+	0x1e78, 501,	/* Ṹ ṹ */
+	0x1e7a, 501,	/* Ṻ ṻ */
+	0x1e7c, 501,	/* Ṽ ṽ */
+	0x1e7e, 501,	/* Ṿ ṿ */
+	0x1e80, 501,	/* Ẁ ẁ */
+	0x1e82, 501,	/* Ẃ ẃ */
+	0x1e84, 501,	/* Ẅ ẅ */
+	0x1e86, 501,	/* Ẇ ẇ */
+	0x1e88, 501,	/* Ẉ ẉ */
+	0x1e8a, 501,	/* Ẋ ẋ */
+	0x1e8c, 501,	/* Ẍ ẍ */
+	0x1e8e, 501,	/* Ẏ ẏ */
+	0x1e90, 501,	/* Ẑ ẑ */
+	0x1e92, 501,	/* Ẓ ẓ */
+	0x1e94, 501,	/* Ẕ ẕ */
+	0x1ea0, 501,	/* Ạ ạ */
+	0x1ea2, 501,	/* Ả ả */
+	0x1ea4, 501,	/* Ấ ấ */
+	0x1ea6, 501,	/* Ầ ầ */
+	0x1ea8, 501,	/* Ẩ ẩ */
+	0x1eaa, 501,	/* Ẫ ẫ */
+	0x1eac, 501,	/* Ậ ậ */
+	0x1eae, 501,	/* Ắ ắ */
+	0x1eb0, 501,	/* Ằ ằ */
+	0x1eb2, 501,	/* Ẳ ẳ */
+	0x1eb4, 501,	/* Ẵ ẵ */
+	0x1eb6, 501,	/* Ặ ặ */
+	0x1eb8, 501,	/* Ẹ ẹ */
+	0x1eba, 501,	/* Ẻ ẻ */
+	0x1ebc, 501,	/* Ẽ ẽ */
+	0x1ebe, 501,	/* Ế ế */
+	0x1ec0, 501,	/* Ề ề */
+	0x1ec2, 501,	/* Ể ể */
+	0x1ec4, 501,	/* Ễ ễ */
+	0x1ec6, 501,	/* Ệ ệ */
+	0x1ec8, 501,	/* Ỉ ỉ */
+	0x1eca, 501,	/* Ị ị */
+	0x1ecc, 501,	/* Ọ ọ */
+	0x1ece, 501,	/* Ỏ ỏ */
+	0x1ed0, 501,	/* Ố ố */
+	0x1ed2, 501,	/* Ồ ồ */
+	0x1ed4, 501,	/* Ổ ổ */
+	0x1ed6, 501,	/* Ỗ ỗ */
+	0x1ed8, 501,	/* Ộ ộ */
+	0x1eda, 501,	/* Ớ ớ */
+	0x1edc, 501,	/* Ờ ờ */
+	0x1ede, 501,	/* Ở ở */
+	0x1ee0, 501,	/* Ỡ ỡ */
+	0x1ee2, 501,	/* Ợ ợ */
+	0x1ee4, 501,	/* Ụ ụ */
+	0x1ee6, 501,	/* Ủ ủ */
+	0x1ee8, 501,	/* Ứ ứ */
+	0x1eea, 501,	/* Ừ ừ */
+	0x1eec, 501,	/* Ử ử */
+	0x1eee, 501,	/* Ữ ữ */
+	0x1ef0, 501,	/* Ự ự */
+	0x1ef2, 501,	/* Ỳ ỳ */
+	0x1ef4, 501,	/* Ỵ ỵ */
+	0x1ef6, 501,	/* Ỷ ỷ */
+	0x1ef8, 501,	/* Ỹ ỹ */
+	0x1f59, 492,	/* Ὑ ὑ */
+	0x1f5b, 492,	/* Ὓ ὓ */
+	0x1f5d, 492,	/* Ὕ ὕ */
+	0x1f5f, 492,	/* Ὗ ὗ */
+	0x1fbc, 491,	/* ᾼ ᾳ */
+	0x1fcc, 491,	/* ῌ ῃ */
+	0x1fec, 493,	/* Ῥ ῥ */
+	0x1ffc, 491	/* ῼ ῳ */
+]
+
+/*
+ * title characters are those between
+ * upper and lower case. ie DZ Dz dz
+ */
+const rtotitle1 = [
+	0x01c4, 501,	/* DŽ Dž */
+	0x01c6, 499,	/* dž Dž */
+	0x01c7, 501,	/* LJ Lj */
+	0x01c9, 499,	/* lj Lj */
+	0x01ca, 501,	/* NJ Nj */
+	0x01cc, 499,	/* nj Nj */
+	0x01f1, 501,	/* DZ Dz */
+	0x01f3, 499	/* dz Dz */
+]
+
+const findc = {c, t, sz, nelt, ret
+	var l
+	var m
+
+	/* we're processing in chunks of size 
+	   nelt, so 1 chunk is of length 'nelt' */
+	while t.len > nelt
+		sz /= 2
+		m = sz*nelt
+		l = t[m:]
+		if c >= l[0]
+			t = l[0:m]
+		else
+			t = t[0:m]
+		;;
+	;;
+
+	if t.len != 0 && c >= t[0]
+		*ret = t
+		-> true
+	else
+		-> false
+	;;
+}
+
+
+const isalpha = {c
+	var l
+
+	if isupper(c) || islower(c)
+		-> true
+	elif findc(c, ralpha2[:], ralpha2.len/2, 2, &l)
+		if (c >= l[0] && c <= l[1])
+			-> true
+		;;
+	elif findc(c, ralpha1[:], ralpha1.len, 1, &l)
+		if (c == l[0])
+			-> true
+		;;
+	;;
+	-> false
+}
+
+const isnum = {c
+	var l
+
+	if findc(c, rnums[:], rnums.len/2, 2, &l)
+		if(c >= l[0] && c <= l[1])
+			-> true
+		;;
+	;;
+	-> false
+}
+
+const isalnum = {c
+	-> isalpha(c) || isnum(c)
+}
+
+const isspace = {c
+	var l
+	var sl
+	var len
+
+	l = rspace2[:]
+	sl = rspace2[:]
+	len = rspace2.len/2
+	if findc(c, sl, len, 2, &l)
+		if(c >= l[0] && c <= l[1])
+			-> true
+		;;
+	;;
+	-> false
+}
+
+const islower = {c
+	var l
+
+	if findc(c, rtoupper2[:], rtoupper2.len, 2, &l)
+		if (c >= l[0] && c <= l[1])
+			-> true
+		;;
+	elif findc(c, rtoupper1[:], rtoupper1.len, 1, &l)
+		if (c == l[0])
+			-> true
+		;;
+	;;
+	-> false
+}
+
+const isupper = {c
+	var l
+
+	if findc(c, rtolower2[:], rtolower2.len, 2, &l)
+		if (c >= l[0] && c <= l[1])
+			-> true
+		;;
+	elif findc(c, rtolower1[:], rtolower1.len, 1, &l)
+		if (c == l[0])
+			-> true
+		;;
+	;;
+	-> false
+}
+
+const istitle = {c
+	-> isupper(c) && islower(c)
+}
+
+const tolower = {c
+	var l
+
+	if findc(c, rtolower2[:], rtolower2.len/3, 3, &l)
+		if c >= l[0] && c <= l[1]
+			-> c + l[2] - 500;
+		;;
+	elif findc(c, rtolower1[:], rtolower1.len/2, 2, &l) 
+		if c == l[0]
+			-> c + l[1] - 500;
+		;;
+	;;
+	-> c
+}
+
+const toupper = {c
+	var l
+
+	if findc(c, rtoupper2[:], rtoupper2.len/3, 3, &l);
+		if c >= l[0] && c <= l[1]
+			-> c + l[2] - 500;
+		;;
+	elif findc(c, rtoupper1[:], rtoupper1.len/2, 2, &l);
+		if c == l[0]
+			-> c + l[1] - 500;
+		;;
+	;;
+	-> c
+}
+
+const totitle = {c
+	var l
+
+	if findc(c, rtotitle1[:], rtotitle1.len/2, 2, &l);
+		if c == l[0]
+			-> c + l[1] - 500;
+		;;
+	;;
+	-> c
+}
+
--- /dev/null
+++ b/libmyr/die.myr
@@ -1,0 +1,19 @@
+use "sys.use"
+use "types.use"
+
+pkg std = 
+	const die	: (msg : byte[:] -> void)
+	const assert	: (cond : bool, msg : byte[:] -> void)
+;;
+
+const die = {msg
+	write(2, msg)
+	kill(getpid(), 6)
+}
+
+const assert = {cond, msg
+	if cond
+		die(msg)
+	;;
+}
+
--- /dev/null
+++ b/libmyr/fmt.myr
@@ -1,0 +1,131 @@
+use "die.use"
+use "sys.use"
+use "types.use"
+use "utf.use"
+use "varargs.use"
+
+pkg std =
+	const bfmt	: (buf : byte[:], fmt : byte[:], args:... -> size)
+	const bfmtv	: (buf : byte[:], fmt : byte[:], ap:valist -> size)
+	const put	: (fmt : byte[:], args:... -> size)
+;;
+
+const put = {fmt, args
+	var buf : byte[2048]
+	var n
+	
+	n = bfmtv(buf[:], fmt, vastart(&args))
+	write(1, buf[:n])
+	-> n
+}
+
+const bfmt = {buf, fmt, args
+	-> bfmtv(buf, fmt, vastart(&args))
+}
+
+const bfmtv = {buf, fmt, ap
+	var c
+	var n
+	var s_val : byte[:]
+	var b_val : int8
+	var w_val : int16
+	var i_val : int32
+	var l_val : int64
+	var p_val : byte*
+
+	n = 0
+	while fmt.len
+		(c, fmt) = striter(fmt)
+		if c == '%'
+			(c, fmt) = striter(fmt)
+			match c
+			's':
+				(s_val, ap) = vanext(ap)
+				n += strfmt(buf[n:], s_val)
+				;;
+			/* format integers */
+			'b':
+				(b_val, ap) = vanext(ap)
+				n += intfmt(buf[n:], b_val castto(int64), 10)
+				;;
+			'w':
+				(w_val, ap) = vanext(ap)
+				n += intfmt(buf[n:], w_val castto(int64), 10)
+				;;
+			'i':
+				(i_val, ap) = vanext(ap)
+				n += intfmt(buf[n:], i_val castto(int64), 10)
+				;;
+			'l':
+				(l_val, ap) = vanext(ap)
+				n += intfmt(buf[n:], l_val castto(int64), 10)
+				;;
+			'p':
+				(p_val, ap) = vanext(ap)
+				n += intfmt(buf[n:], p_val castto(int64), 16)
+				;;
+                        _:
+                                die("Unknown format specifier")
+                                ;;
+			;;
+		else
+			n += encode(buf[n:], c)
+		;;
+	;;
+	-> n
+}
+
+const strfmt = {buf, str
+	var i
+	
+	for i = 0; i < min(str.len, buf.len); i++
+		buf[i] = str[i]
+	;;
+	-> i
+}
+
+const intfmt = {buf, val, base
+	var digits = [
+		'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'
+	]
+	var isneg
+	var b : char[32]
+	var i
+	var j
+	var n
+
+	n = 0
+	i = 0
+	if val < 0
+		isneg = true
+	else
+		isneg = false
+	;;
+
+	if val == 0
+		b[0] = '0'
+		i++
+	;;
+	while val != 0
+		b[i] = digits[val % base]
+		val /= base
+		i++
+	;;
+	n = 0
+	if isneg
+		n += encode(buf[n:], '-')
+	;;
+	for j = i-1; j >= 0; j--
+		n += encode(buf[n:], b[j])
+	;;
+	-> n 
+}
+
+const min = {a : size, b : size
+	if a < b
+		-> a
+	else
+		-> b
+	;;
+}
+
--- /dev/null
+++ b/libmyr/rand.myr
@@ -1,0 +1,112 @@
+use "die.use"
+use "fmt.use"
+use "types.use"
+use "alloc.use"
+/*
+   Translated from C by Ori Bernstein
+ */
+
+/* 
+  A C-program for MT19937, with initialization improved 2002/1/26.
+  Coded by Takuji Nishimura and Makoto Matsumoto.
+  
+  Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+  All rights reserved.                          
+  
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+  
+    1. Redistributions of source code must retain the above copyright
+       notice, this list of conditions and the following disclaimer.
+ 
+    2. Redistributions in binary form must reproduce the above copyright
+       notice, this list of conditions and the following disclaimer in the
+       documentation and/or other materials provided with the distribution.
+ 
+    3. The names of its contributors may not be used to endorse or promote 
+       products derived from this software without specific prior written 
+       permission.
+ 
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ 
+  Any feedback is very welcome.
+  http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+  email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
+ */
+
+pkg std =
+	type rng
+
+	/* no mkrng() yet because we don't have anything to automatically
+	   seed it with yet */
+	const mksrng	: (seed : uint32 -> rng*)
+	const rand32	: (rng : rng* -> uint32)
+;;
+
+type rng = struct
+	state	: uint32[624]
+	i	: uint32
+;;
+
+const mksrng = {seed
+	var rng
+
+	rng = alloc()
+	init(rng, seed)
+	-> rng
+}
+
+const init = {rng, seed
+	var i
+
+	for i = 0; i < 624; i++
+		rng.state[i] = seed
+		seed = 1812433253 * (seed ^ (seed >> 30)) + i + 1
+	;;
+	rng.i = i
+}
+
+
+const rand32 = {rng
+	var x
+
+	if rng.i == 624
+		next(rng)
+	;;
+	x = rng.state[rng.i]
+	rng.i++
+
+	x ^= x >> 11
+	x ^= (x << 7) & 0x9D2C5680
+	x ^= (x << 15) & 0xEFC60000
+	-> x ^ (x >> 18)
+}
+
+
+const next = {rng
+	var k
+	var y
+
+	for k = 0; k < 227; k++
+		y = (rng.state[k] & 0x80000000) | (rng.state[k + 1] & 0x7FFFFFFF)
+		rng.state[k] = rng.state[k + 397] ^ (y >> 1) ^ ((y & 1) * 0x9908B0DF)
+	;;
+	for ; k < 623; k++
+		y = (rng.state[k] & 0x80000000) | (rng.state[k + 1] & 0x7FFFFFFF)
+		rng.state[k] = rng.state[k - 227] ^ (y >> 1) ^ ((y & 1) * 0x9908B0DF);
+	;;
+	y = (rng.state[623] & 0x80000000) | (rng.state[0] & 0x7FFFFFFF)
+	rng.state[623] = rng.state[396] ^ (y >> 1) ^ ((y & 1) * 0x9908B0DF);
+	rng.i = 0
+}
--- /dev/null
+++ b/libmyr/sys-linux.myr
@@ -1,0 +1,398 @@
+use "types.use"
+
+pkg std =
+	type scno = int64
+	type fdopt = int64
+	type mprot = int64
+	type mopt = int64
+	type statbuf = struct
+		 dev     : uint
+		 ino     : uint
+		 mode    : uint16
+		 nlink   : uint16
+		 uid     : uint16
+		 gid     : uint16
+		 rdev    : uint
+		 size    : uint
+		 blksize : uint
+		 blocks  : uint
+		 atime   : uint
+		 atimens : uint
+		 mtime   : uint
+		 mtimens : uint
+		 ctime   : uint
+		 ctimens : uint
+		 _unused1: uint
+		 _unused2: uint
+	;;
+
+	/* open options */
+	const Ordonly  	: fdopt = 0x0
+	const Owronly  	: fdopt = 0x1
+	const Ordwr    	: fdopt = 0x2
+	const Oappend  	: fdopt = 0x80
+	const Ocreat   	: fdopt = 0x40
+	const Onofollow	: fdopt = 0x20000
+	const Ondelay  	: fdopt = 0x800
+	const Otrunc   	: fdopt = 0x200
+
+	/* mmap protection */
+	const Mprotnone	: mprot = 0x0
+	const Mprotrd	: mprot = 0x1
+	const Mprotwr	: mprot = 0x2
+	const Mprotexec	: mprot = 0x4
+	const Mprotrw	: mprot = 0x3 /* convenience */
+	
+	/* mmap options */
+	const Mshared	: mopt = 0x1
+	const Mpriv	: mopt = 0x2
+	const Mfixed	: mopt = 0x10
+	const Mfile	: mopt = 0x0
+	const Manon	: mopt = 0x20
+	const M32bit	: mopt = 0x40
+
+	/* return value for a failed mapping */
+	const Mapbad	: byte* = -1 castto(byte*)
+
+	/* syscalls */
+	const Sysread			: scno = 0
+	const Syswrite			: scno = 1
+	const Sysopen			: scno = 2
+	const Sysclose			: scno = 3
+	const Sysstat			: scno = 4
+	const Sysfstat			: scno = 5
+	const Syslstat			: scno = 6
+	const Syspoll			: scno = 7
+	const Syslseek			: scno = 8
+	const Sysmmap			: scno = 9
+	const Sysmprotect		: scno = 10
+	const Sysmunmap			: scno = 11
+	const Sysbrk			: scno = 12
+	const Sysrt_sigaction		: scno = 13
+	const Sysrt_sigprocmask		: scno = 14
+	const Sysrt_sigreturn		: scno = 15
+	const Sysioctl			: scno = 16
+	const Syspread64		: scno = 17
+	const Syspwrite64		: scno = 18
+	const Sysreadv			: scno = 19
+	const Syswritev			: scno = 20
+	const Sysaccess			: scno = 21
+	const Syspipe			: scno = 22
+	const Sysselect			: scno = 23
+	const Syssched_yield		: scno = 24
+	const Sysmremap			: scno = 25
+	const Sysmsync			: scno = 26
+	const Sysmincore		: scno = 27
+	const Sysmadvise		: scno = 28
+	const Sysshmget			: scno = 29
+	const Sysshmat			: scno = 30
+	const Sysshmctl			: scno = 31
+	const Sysdup			: scno = 32
+	const Sysdup2			: scno = 33
+	const Syspause			: scno = 34
+	const Sysnanosleep		: scno = 35
+	const Sysgetitimer		: scno = 36
+	const Sysalarm			: scno = 37
+	const Syssetitimer		: scno = 38
+	const Sysgetpid			: scno = 39
+	const Syssendfile		: scno = 40
+	const Syssocket			: scno = 41
+	const Sysconnect		: scno = 42
+	const Sysaccept			: scno = 43
+	const Syssendto			: scno = 44
+	const Sysrecvfrom		: scno = 45
+	const Syssendmsg		: scno = 46
+	const Sysrecvmsg		: scno = 47
+	const Sysshutdown		: scno = 48
+	const Sysbind			: scno = 49
+	const Syslisten			: scno = 50
+	const Sysgetsockname		: scno = 51
+	const Sysgetpeername		: scno = 52
+	const Syssocketpair		: scno = 53
+	const Syssetsockopt		: scno = 54
+	const Sysgetsockopt		: scno = 55
+	const Sysclone			: scno = 56
+	const Sysfork			: scno = 57
+	const Sysvfork			: scno = 58
+	const Sysexecve			: scno = 59
+	const Sysexit			: scno = 60
+	const Syswait4			: scno = 61
+	const Syskill			: scno = 62
+	const Sysuname			: scno = 63
+	const Syssemget			: scno = 64
+	const Syssemop			: scno = 65
+	const Syssemctl			: scno = 66
+	const Sysshmdt			: scno = 67
+	const Sysmsgget			: scno = 68
+	const Sysmsgsnd			: scno = 69
+	const Sysmsgrcv			: scno = 70
+	const Sysmsgctl			: scno = 71
+	const Sysfcntl			: scno = 72
+	const Sysflock			: scno = 73
+	const Sysfsync			: scno = 74
+	const Sysfdatasync		: scno = 75
+	const Systruncate		: scno = 76
+	const Sysftruncate		: scno = 77
+	const Sysgetdents		: scno = 78
+	const Sysgetcwd			: scno = 79
+	const Syschdir			: scno = 80
+	const Sysfchdir			: scno = 81
+	const Sysrename			: scno = 82
+	const Sysmkdir			: scno = 83
+	const Sysrmdir			: scno = 84
+	const Syscreat			: scno = 85
+	const Syslink			: scno = 86
+	const Sysunlink			: scno = 87
+	const Syssymlink		: scno = 88
+	const Sysreadlink		: scno = 89
+	const Syschmod			: scno = 90
+	const Sysfchmod			: scno = 91
+	const Syschown			: scno = 92
+	const Sysfchown			: scno = 93
+	const Syslchown			: scno = 94
+	const Sysumask			: scno = 95
+	const Sysgettimeofday		: scno = 96
+	const Sysgetrlimit		: scno = 97
+	const Sysgetrusage		: scno = 98
+	const Syssysinfo		: scno = 99
+	const Systimes			: scno = 100
+	const Sysptrace			: scno = 101
+	const Sysgetuid			: scno = 102
+	const Syssyslog			: scno = 103
+	const Sysgetgid			: scno = 104
+	const Syssetuid			: scno = 105
+	const Syssetgid			: scno = 106
+	const Sysgeteuid		: scno = 107
+	const Sysgetegid		: scno = 108
+	const Syssetpgid		: scno = 109
+	const Sysgetppid		: scno = 110
+	const Sysgetpgrp		: scno = 111
+	const Syssetsid			: scno = 112
+	const Syssetreuid		: scno = 113
+	const Syssetregid		: scno = 114
+	const Sysgetgroups		: scno = 115
+	const Syssetgroups		: scno = 116
+	const Syssetresuid		: scno = 117
+	const Sysgetresuid		: scno = 118
+	const Syssetresgid		: scno = 119
+	const Sysgetresgid		: scno = 120
+	const Sysgetpgid		: scno = 121
+	const Syssetfsuid		: scno = 122
+	const Syssetfsgid		: scno = 123
+	const Sysgetsid			: scno = 124
+	const Syscapget			: scno = 125
+	const Syscapset			: scno = 126
+	const Sysrt_sigpending		: scno = 127
+	const Sysrt_sigtimedwait	: scno = 128
+	const Sysrt_sigqueueinfo	: scno = 129
+	const Sysrt_sigsuspend		: scno = 130
+	const Syssigaltstack		: scno = 131
+	const Sysutime			: scno = 132
+	const Sysmknod			: scno = 133
+	const Sysuselib			: scno = 134
+	const Syspersonality		: scno = 135
+	const Sysustat			: scno = 136
+	const Sysstatfs			: scno = 137
+	const Sysfstatfs		: scno = 138
+	const Syssysfs			: scno = 139
+	const Sysgetpriority		: scno = 140
+	const Syssetpriority		: scno = 141
+	const Syssched_setparam		: scno = 142
+	const Syssched_getparam		: scno = 143
+	const Syssched_setscheduler	: scno = 144
+	const Syssched_getscheduler	: scno = 145
+	const Syssched_get_priority_max	: scno = 146
+	const Syssched_get_priority_min	: scno = 147
+	const Syssched_rr_get_interval	: scno = 148
+	const Sysmlock			: scno = 149
+	const Sysmunlock		: scno = 150
+	const Sysmlockall		: scno = 151
+	const Sysmunlockall		: scno = 152
+	const Sysvhangup		: scno = 153
+	const Sysmodify_ldt		: scno = 154
+	const Syspivot_root		: scno = 155
+	const Sys_sysctl		: scno = 156
+	const Sysprctl			: scno = 157
+	const Sysarch_prctl		: scno = 158
+	const Sysadjtimex		: scno = 159
+	const Syssetrlimit		: scno = 160
+	const Syschroot			: scno = 161
+	const Syssync			: scno = 162
+	const Sysacct			: scno = 163
+	const Syssettimeofday		: scno = 164
+	const Sysmount			: scno = 165
+	const Sysumount2		: scno = 166
+	const Sysswapon			: scno = 167
+	const Sysswapoff		: scno = 168
+	const Sysreboot			: scno = 169
+	const Syssethostname		: scno = 170
+	const Syssetdomainname		: scno = 171
+	const Sysiopl			: scno = 172
+	const Sysioperm			: scno = 173
+	const Syscreate_module		: scno = 174
+	const Sysinit_module		: scno = 175
+	const Sysdelete_module		: scno = 176
+	const Sysget_kernel_syms	: scno = 177
+	const Sysquery_module		: scno = 178
+	const Sysquotactl		: scno = 179
+	const Sysnfsservctl		: scno = 180
+	const Sysgetpmsg		: scno = 181
+	const Sysputpmsg		: scno = 182
+	const Sysafs_syscall		: scno = 183
+	const Systuxcall		: scno = 184
+	const Syssecurity		: scno = 185
+	const Sysgettid			: scno = 186
+	const Sysreadahead		: scno = 187
+	const Syssetxattr		: scno = 188
+	const Syslsetxattr		: scno = 189
+	const Sysfsetxattr		: scno = 190
+	const Sysgetxattr		: scno = 191
+	const Syslgetxattr		: scno = 192
+	const Sysfgetxattr		: scno = 193
+	const Syslistxattr		: scno = 194
+	const Sysllistxattr		: scno = 195
+	const Sysflistxattr		: scno = 196
+	const Sysremovexattr		: scno = 197
+	const Syslremovexattr		: scno = 198
+	const Sysfremovexattr		: scno = 199
+	const Systkill			: scno = 200
+	const Systime			: scno = 201
+	const Sysfutex			: scno = 202
+	const Syssched_setaffinity	: scno = 203
+	const Syssched_getaffinity	: scno = 204
+	const Sysset_thread_area	: scno = 205
+	const Sysio_setup		: scno = 206
+	const Sysio_destroy		: scno = 207
+	const Sysio_getevents		: scno = 208
+	const Sysio_submit		: scno = 209
+	const Sysio_cancel		: scno = 210
+	const Sysget_thread_area	: scno = 211
+	const Syslookup_dcookie		: scno = 212
+	const Sysepoll_create		: scno = 213
+	const Sysepoll_ctl_old		: scno = 214
+	const Sysepoll_wait_old		: scno = 215
+	const Sysremap_file_pages	: scno = 216
+	const Sysgetdents64		: scno = 217
+	const Sysset_tid_address	: scno = 218
+	const Sysrestart_syscall	: scno = 219
+	const Syssemtimedop		: scno = 220
+	const Sysfadvise64		: scno = 221
+	const Systimer_create		: scno = 222
+	const Systimer_settime		: scno = 223
+	const Systimer_gettime		: scno = 224
+	const Systimer_getoverrun	: scno = 225
+	const Systimer_delete		: scno = 226
+	const Sysclock_settime		: scno = 227
+	const Sysclock_gettime		: scno = 228
+	const Sysclock_getres		: scno = 229
+	const Sysclock_nanosleep	: scno = 230
+	const Sysexit_group		: scno = 231
+	const Sysepoll_wait		: scno = 232
+	const Sysepoll_ctl		: scno = 233
+	const Systgkill			: scno = 234
+	const Sysutimes			: scno = 235
+	const Sysvserver		: scno = 236
+	const Sysmbind			: scno = 237
+	const Sysset_mempolicy		: scno = 238
+	const Sysget_mempolicy		: scno = 239
+	const Sysmq_open		: scno = 240
+	const Sysmq_unlink		: scno = 241
+	const Sysmq_timedsend		: scno = 242
+	const Sysmq_timedreceive	: scno = 243
+	const Sysmq_notify		: scno = 244
+	const Sysmq_getsetattr		: scno = 245
+	const Syskexec_load		: scno = 246
+	const Syswaitid			: scno = 247
+	const Sysadd_key		: scno = 248
+	const Sysrequest_key		: scno = 249
+	const Syskeyctl			: scno = 250
+	const Sysioprio_set		: scno = 251
+	const Sysioprio_get		: scno = 252
+	const Sysinotify_init		: scno = 253
+	const Sysinotify_add_watch	: scno = 254
+	const Sysinotify_rm_watch	: scno = 255
+	const Sysmigrate_pages		: scno = 256
+	const Sysopenat			: scno = 257
+	const Sysmkdirat		: scno = 258
+	const Sysmknodat		: scno = 259
+	const Sysfchownat		: scno = 260
+	const Sysfutimesat		: scno = 261
+	const Sysnewfstatat		: scno = 262
+	const Sysunlinkat		: scno = 263
+	const Sysrenameat		: scno = 264
+	const Syslinkat			: scno = 265
+	const Syssymlinkat		: scno = 266
+	const Sysreadlinkat		: scno = 267
+	const Sysfchmodat		: scno = 268
+	const Sysfaccessat		: scno = 269
+	const Syspselect6		: scno = 270
+	const Sysppoll			: scno = 271
+	const Sysunshare		: scno = 272
+	const Sysset_robust_list	: scno = 273
+	const Sysget_robust_list	: scno = 274
+	const Syssplice			: scno = 275
+	const Systee			: scno = 276
+	const Syssync_file_range	: scno = 277
+	const Sysvmsplice		: scno = 278
+	const Sysmove_pages		: scno = 279
+	const Sysutimensat		: scno = 280
+	const Sysepoll_pwait		: scno = 281
+	const Syssignalfd		: scno = 282
+	const Systimerfd_create		: scno = 283
+	const Syseventfd		: scno = 284
+	const Sysfallocate		: scno = 285
+	const Systimerfd_settime	: scno = 286
+	const Systimerfd_gettime	: scno = 287
+	const Sysaccept4		: scno = 288
+	const Syssignalfd4		: scno = 289
+	const Syseventfd2		: scno = 290
+	const Sysepoll_create1		: scno = 291
+	const Sysdup3			: scno = 292
+	const Syspipe2			: scno = 293
+	const Sysinotify_init1		: scno = 294
+	const Syspreadv			: scno = 295
+	const Syspwritev		: scno = 296
+	const Sysrt_tgsigqueueinfo	: scno = 297
+	const Sysperf_event_open	: scno = 298
+	const Sysrecvmmsg		: scno = 299
+	const Sysfanotify_init		: scno = 300
+	const Sysfanotify_mark		: scno = 301
+	const Sysprlimit64		: scno = 302
+	const Sysname_to_handle_at	: scno = 303
+	const Sysopen_by_handle_at	: scno = 304
+	const Sysclock_adjtime		: scno = 305
+	const Syssyncfs			: scno = 306
+	const Syssendmmsg		: scno = 307
+	const Syssetns			: scno = 308
+	const Sysgetcpu			: scno = 309
+	const Sysprocess_vm_readv	: scno = 310
+	const Sysprocess_vm_writev	: scno = 311
+
+	extern const syscall : (sc:scno, args:... -> int64)
+
+	const exit	: (status:int64 -> void)
+	const getpid	: ( -> int64)
+	const kill	: (pid:int64, sig:int64 -> int64)
+	const open	: (path:byte[:], opts:fdopt, mode:int64 -> int64)
+	const close	: (fd:int64 -> int64)
+	const creat	: (path:byte[:], mode:int64 -> int64)
+	const read	: (fd:int64, buf:byte[:] -> int64)
+	const write	: (fd:int64, buf:byte[:] -> int64)
+	const lseek	: (fd:int64, off:uint64, whence:int64 -> int64)
+	const fstat	: (fd:int64, sb:statbuf* -> int64)
+	const munmap	: (addr:byte*, len:size -> int64)
+	const mmap	: (addr:byte*, len:size, prot:mprot, flags:mopt, fd:int64, off:off -> byte*)
+;;
+
+const exit	= {status;		syscall(Sysexit, 1);}
+const getpid	= {;			-> syscall(Sysgetpid, 1);}
+const kill	= {pid, sig;		-> syscall(Syskill, pid, sig);}
+const open	= {path, opts, mode;	-> syscall(Sysopen, path castto(char*), opts);}
+const close	= {fd;			-> syscall(Sysclose, fd);}
+const creat	= {path, mode;		-> syscall(Syscreat, path castto(char*), mode);}
+const read	= {fd, buf;		-> syscall(Sysread, fd, buf castto(char*), buf.len);}
+const write	= {fd, buf;		-> syscall(Syswrite, fd, buf castto(char*), buf.len castto(size));}
+const lseek	= {fd, off, whence;	-> syscall(Syslseek, fd, off, whence);}
+const fstat	= {fd, sb;		-> syscall(Sysfstat, fd, sb);}
+const munmap	= {addr, len;		-> syscall(Sysmunmap, addr, len);}
+const mmap	= {addr, len, prot, flags, fd, off;	-> syscall(Sysmmap, addr, len, prot, flags, fd, off) castto(byte*);}
--- /dev/null
+++ b/libmyr/sys-osx.myr
@@ -1,0 +1,444 @@
+use "types.use"
+
+pkg std =
+	type scno = int64
+	type fdopt = int64
+	type mprot = int64
+	type mopt = int64
+
+	type timespec = struct
+		secs	: uint64
+		nsecs	: uint32
+	;;
+
+	type statbuf = struct
+		dev	: int32
+		mode	: uint16
+		nlink	: uint32
+		ino	: uint64 /* 32/64? which do I use? */
+		uid	: uint32
+		gid	: uint32
+		rdev	: int32
+		atimesspec	: timespec
+		mtimesspec	: timespec
+		ctimesspec	: timespec
+		btimesspec	: timespec
+		size	: off
+		blocks	: uint
+		blocksz	: uint
+		flags	: uint32
+		gen	: uint32
+		lspare	: int32
+		qspare0	: int64
+		qspare1	: int64
+	;;
+
+	/* open options */
+	const Ordonly  	: fdopt = 0x0
+	const Owronly  	: fdopt = 0x1
+	const Ordwr    	: fdopt = 0x2
+	const Ondelay  	: fdopt = 0x4
+	const Oappend  	: fdopt = 0x8
+	const Ocreat   	: fdopt = 0x200
+	const Onofollow	: fdopt = 0x100
+	const Otrunc   	: fdopt = 0x400
+
+	/* mmap protection */
+	const Mprotnone	: mprot = 0x0
+	const Mprotrd	: mprot = 0x1
+	const Mprotwr	: mprot = 0x2
+	const Mprotexec	: mprot = 0x4
+	const Mprotrw	: mprot = 0x3
+	
+	/* mmap options */
+	const Mshared	: mopt = 0x1
+	const Mpriv	: mopt = 0x2
+	const Mfixed	: mopt = 0x10
+	const Mfile	: mopt = 0x0
+	const Manon	: mopt = 0x1000
+	/* Only on Linux
+	const M32bit	: mopt = 0x40
+	*/
+
+
+	/* return value for a failed mapping */
+	const Mapbad	: byte* = -1 castto(byte*)
+
+	/* syscalls.
+	note, creat() implemented as open(path, Creat|Trunc|Wronly) */
+	const Syssyscall	: scno = 0x2000000
+	const Sysexit		: scno = 0x2000001
+	const Sysfork		: scno = 0x2000002
+	const Sysread		: scno = 0x2000003
+	const Syswrite		: scno = 0x2000004
+	const Sysopen		: scno = 0x2000005
+	const Sysclose		: scno = 0x2000006
+	const Syswait4		: scno = 0x2000007
+	const Syslink		: scno = 0x2000009
+	const Sysunlink		: scno = 0x200000a
+	const Syschdir		: scno = 0x200000c
+	const Sysfchdir		: scno = 0x200000d
+	const Sysmknod		: scno = 0x200000e
+	const Syschmod		: scno = 0x200000f
+	const Syschown		: scno = 0x2000010
+	const Sysgetfsstat	: scno = 0x2000012
+	const Sysgetpid		: scno = 0x2000014
+	const Syssetuid		: scno = 0x2000017
+	const Sysgetuid		: scno = 0x2000018
+	const Sysgeteuid	: scno = 0x2000019
+	const Sysptrace		: scno = 0x200001a
+	const Sysrecvmsg	: scno = 0x200001b
+	const Syssendmsg	: scno = 0x200001c
+	const Sysrecvfrom	: scno = 0x200001d
+	const Sysaccept		: scno = 0x200001e
+	const Sysgetpeername	: scno = 0x200001f
+	const Sysgetsockname	: scno = 0x2000020
+	const Sysaccess		: scno = 0x2000021
+	const Syschflags	: scno = 0x2000022
+	const Sysfchflags	: scno = 0x2000023
+	const Syssync		: scno = 0x2000024
+	const Syskill		: scno = 0x2000025
+	const Sysgetppid	: scno = 0x2000027
+	const Sysdup		: scno = 0x2000029
+	const Syspipe		: scno = 0x200002a
+	const Sysgetegid	: scno = 0x200002b
+	const Sysprofil		: scno = 0x200002c
+	const Syssigaction	: scno = 0x200002e
+	const Sysgetgid		: scno = 0x200002f
+	const Syssigprocmask	: scno = 0x2000030
+	const Sysgetlogin	: scno = 0x2000031
+	const Syssetlogin	: scno = 0x2000032
+	const Sysacct		: scno = 0x2000033
+	const Syssigpending	: scno = 0x2000034
+	const Syssigaltstack	: scno = 0x2000035
+	const Sysioctl		: scno = 0x2000036
+	const Sysreboot		: scno = 0x2000037
+	const Sysrevoke		: scno = 0x2000038
+	const Syssymlink	: scno = 0x2000039
+	const Sysreadlink	: scno = 0x200003a
+	const Sysexecve		: scno = 0x200003b
+	const Sysumask		: scno = 0x200003c
+	const Syschroot		: scno = 0x200003d
+	const Sysmsync		: scno = 0x2000041
+	const Sysvfork		: scno = 0x2000042
+	const Sysmunmap		: scno = 0x2000049
+	const Sysmprotect	: scno = 0x200004a
+	const Sysmadvise	: scno = 0x200004b
+	const Sysmincore	: scno = 0x200004e
+	const Sysgetgroups	: scno = 0x200004f
+	const Syssetgroups	: scno = 0x2000050
+	const Sysgetpgrp	: scno = 0x2000051
+	const Syssetpgid	: scno = 0x2000052
+	const Syssetitimer	: scno = 0x2000053
+	const Sysswapon		: scno = 0x2000055
+	const Sysgetitimer	: scno = 0x2000056
+	const Sysgetdtablesize	: scno = 0x2000059
+	const Sysdup2		: scno = 0x200005a
+	const Sysfcntl		: scno = 0x200005c
+	const Sysselect		: scno = 0x200005d
+	const Sysfsync		: scno = 0x200005f
+	const Syssetpriority	: scno = 0x2000060
+	const Syssocket		: scno = 0x2000061
+	const Sysconnect	: scno = 0x2000062
+	const Sysgetpriority	: scno = 0x2000064
+	const Sysbind		: scno = 0x2000068
+	const Syssetsockopt	: scno = 0x2000069
+	const Syslisten		: scno = 0x200006a
+	const Syssigsuspend	: scno = 0x200006f
+	const Sysgettimeofday	: scno = 0x2000074
+	const Sysgetrusage	: scno = 0x2000075
+	const Sysgetsockopt	: scno = 0x2000076
+	const Sysreadv		: scno = 0x2000078
+	const Syswritev		: scno = 0x2000079
+	const Syssettimeofday	: scno = 0x200007a
+	const Sysfchown		: scno = 0x200007b
+	const Sysfchmod		: scno = 0x200007c
+	const Syssetreuid	: scno = 0x200007e
+	const Syssetregid	: scno = 0x200007f
+	const Sysrename		: scno = 0x2000080
+	const Sysflock		: scno = 0x2000083
+	const Sysmkfifo		: scno = 0x2000084
+	const Syssendto		: scno = 0x2000085
+	const Sysshutdown	: scno = 0x2000086
+	const Syssocketpair	: scno = 0x2000087
+	const Sysmkdir		: scno = 0x2000088
+	const Sysrmdir		: scno = 0x2000089
+	const Sysutimes		: scno = 0x200008a
+	const Sysfutimes	: scno = 0x200008b
+	const Sysadjtime	: scno = 0x200008c
+	const Sysgethostuuid	: scno = 0x200008e
+	const Syssetsid		: scno = 0x2000093
+	const Sysgetpgid	: scno = 0x2000097
+	const Syssetprivexec	: scno = 0x2000098
+	const Syspread		: scno = 0x2000099
+	const Syspwrite		: scno = 0x200009a
+	const Sysnfssvc		: scno = 0x200009b
+	const Sysstatfs		: scno = 0x200009d
+	const Sysfstatfs	: scno = 0x200009e
+	const Sysunmount	: scno = 0x200009f
+	const Sysgetfh		: scno = 0x20000a1
+	const Sysquotactl	: scno = 0x20000a5
+	const Sysmount		: scno = 0x20000a7
+	const Syscsops		: scno = 0x20000a9
+	const Syswaitid		: scno = 0x20000ad
+	const Sysadd_profil	: scno = 0x20000b0
+	const Syskdebug_trace	: scno = 0x20000b4
+	const Syssetgid		: scno = 0x20000b5
+	const Syssetegid	: scno = 0x20000b6
+	const Sysseteuid	: scno = 0x20000b7
+	const Syssigreturn	: scno = 0x20000b8
+	const Syschud		: scno = 0x20000b9
+	const Sysfdatasync	: scno = 0x20000bb
+	const Sysstat		: scno = 0x20000bc
+	const Sysfstat		: scno = 0x20000bd
+	const Syslstat		: scno = 0x20000be
+	const Syspathconf	: scno = 0x20000bf
+	const Sysfpathconf	: scno = 0x20000c0
+	const Sysgetrlimit	: scno = 0x20000c2
+	const Syssetrlimit	: scno = 0x20000c3
+	const Sysgetdirentries	: scno = 0x20000c4
+	const Sysmmap		: scno = 0x20000c5
+	const Syslseek		: scno = 0x20000c7
+	const Systruncate	: scno = 0x20000c8
+	const Sysftruncate	: scno = 0x20000c9
+	const Sys__sysctl	: scno = 0x20000ca
+	const Sysmlock		: scno = 0x20000cb
+	const Sysmunlock	: scno = 0x20000cc
+	const Sysundelete	: scno = 0x20000cd
+	const SysATsocket	: scno = 0x20000ce
+	const SysATgetmsg	: scno = 0x20000cf
+	const SysATputmsg	: scno = 0x20000d0
+	const SysATPsndreq	: scno = 0x20000d1
+	const SysATPsndrsp	: scno = 0x20000d2
+	const SysATPgetreq	: scno = 0x20000d3
+	const SysATPgetrsp	: scno = 0x20000d4
+	const Sysmkcomplex	: scno = 0x20000d8
+	const Sysstatv		: scno = 0x20000d9
+	const Syslstatv		: scno = 0x20000da
+	const Sysfstatv		: scno = 0x20000db
+	const Sysgetattrlist	: scno = 0x20000dc
+	const Syssetattrlist	: scno = 0x20000dd
+	const Sysgetdirentriesattr	: scno = 0x20000de
+	const Sysexchangedata	: scno = 0x20000df
+	const Syssearchfs	: scno = 0x20000e1
+	const Sysdelete		: scno = 0x20000e2
+	const Syscopyfile	: scno = 0x20000e3
+	const Sysfgetattrlist	: scno = 0x20000e4
+	const Sysfsetattrlist	: scno = 0x20000e5
+	const Syspoll		: scno = 0x20000e6
+	const Syswatchevent	: scno = 0x20000e7
+	const Syswaitevent	: scno = 0x20000e8
+	const Sysmodwatch	: scno = 0x20000e9
+	const Sysgetxattr	: scno = 0x20000ea
+	const Sysfgetxattr	: scno = 0x20000eb
+	const Syssetxattr	: scno = 0x20000ec
+	const Sysfsetxattr	: scno = 0x20000ed
+	const Sysremovexattr	: scno = 0x20000ee
+	const Sysfremovexattr	: scno = 0x20000ef
+	const Syslistxattr	: scno = 0x20000f0
+	const Sysflistxattr	: scno = 0x20000f1
+	const Sysfsctl		: scno = 0x20000f2
+	const Sysinitgroups	: scno = 0x20000f3
+	const Sysposix_spawn	: scno = 0x20000f4
+	const Sysffsctl		: scno = 0x20000f5
+	const Sysnfsclnt	: scno = 0x20000f7
+	const Sysfhopen		: scno = 0x20000f8
+	const Sysminherit	: scno = 0x20000fa
+	const Syssemsys		: scno = 0x20000fb
+	const Sysmsgsys		: scno = 0x20000fc
+	const Sysshmsys		: scno = 0x20000fd
+	const Syssemctl		: scno = 0x20000fe
+	const Syssemget		: scno = 0x20000ff
+	const Syssemop		: scno = 0x2000100
+	const Sysmsgctl		: scno = 0x2000102
+	const Sysmsgget		: scno = 0x2000103
+	const Sysmsgsnd		: scno = 0x2000104
+	const Sysmsgrcv		: scno = 0x2000105
+	const Sysshmat		: scno = 0x2000106
+	const Sysshmctl		: scno = 0x2000107
+	const Sysshmdt		: scno = 0x2000108
+	const Sysshmget		: scno = 0x2000109
+	const Sysshm_open	: scno = 0x200010a
+	const Sysshm_unlink	: scno = 0x200010b
+	const Syssem_open	: scno = 0x200010c
+	const Syssem_close	: scno = 0x200010d
+	const Syssem_unlink	: scno = 0x200010e
+	const Syssem_wait	: scno = 0x200010f
+	const Syssem_trywait	: scno = 0x2000110
+	const Syssem_post	: scno = 0x2000111
+	const Syssem_getvalue	: scno = 0x2000112
+	const Syssem_init	: scno = 0x2000113
+	const Syssem_destroy	: scno = 0x2000114
+	const Sysopen_extended	: scno = 0x2000115
+	const Sysumask_extended	: scno = 0x2000116
+	const Sysstat_extended	: scno = 0x2000117
+	const Syslstat_extended	: scno = 0x2000118
+	const Sysfstat_extended	: scno = 0x2000119
+	const Syschmod_extended	: scno = 0x200011a
+	const Sysfchmod_extended	: scno = 0x200011b
+	const Sysaccess_extended	: scno = 0x200011c
+	const Syssettid		: scno = 0x200011d
+	const Sysgettid		: scno = 0x200011e
+	const Syssetsgroups	: scno = 0x200011f
+	const Sysgetsgroups	: scno = 0x2000120
+	const Syssetwgroups	: scno = 0x2000121
+	const Sysgetwgroups	: scno = 0x2000122
+	const Sysmkfifo_extended	: scno = 0x2000123
+	const Sysmkdir_extended	: scno = 0x2000124
+	const Sysidentitysvc	: scno = 0x2000125
+	const Sysshared_region_check_np	: scno = 0x2000126
+	const Sysshared_region_map_np	: scno = 0x2000127
+	const Sysvm_pressure_monitor	: scno = 0x2000128
+	const Syspsynch_rw_longrdlock	: scno = 0x2000129
+	const Syspsynch_rw_yieldwrlock	: scno = 0x200012a
+	const Syspsynch_rw_downgrade	: scno = 0x200012b
+	const Syspsynch_rw_upgrade	: scno = 0x200012c
+	const Syspsynch_mutexwait	: scno = 0x200012d
+	const Syspsynch_mutexdrop	: scno = 0x200012e
+	const Syspsynch_cvbroad	: scno = 0x200012f
+	const Syspsynch_cvsignal	: scno = 0x2000130
+	const Syspsynch_cvwait	: scno = 0x2000131
+	const Syspsynch_rw_rdlock	: scno = 0x2000132
+	const Syspsynch_rw_wrlock	: scno = 0x2000133
+	const Syspsynch_rw_unlock	: scno = 0x2000134
+	const Syspsynch_rw_unlock2	: scno = 0x2000135
+	const Sysgetsid		: scno = 0x2000136
+	const Syssettid_with_pid	: scno = 0x2000137
+	const Sysaio_fsync	: scno = 0x2000139
+	const Sysaio_return	: scno = 0x200013a
+	const Sysaio_suspend	: scno = 0x200013b
+	const Sysaio_cancel	: scno = 0x200013c
+	const Sysaio_error	: scno = 0x200013d
+	const Sysaio_read	: scno = 0x200013e
+	const Sysaio_write	: scno = 0x200013f
+	const Syslio_listio	: scno = 0x2000140
+	const Sysiopolicysys	: scno = 0x2000142
+	const Sysmlockall	: scno = 0x2000144
+	const Sysmunlockall	: scno = 0x2000145
+	const Sysissetugid	: scno = 0x2000147
+	const Sys__pthread_kill	: scno = 0x2000148
+	const Sys__pthread_sigmask	: scno = 0x2000149
+	const Sys__sigwait	: scno = 0x200014a
+	const Sys__disable_threadsignal	: scno = 0x200014b
+	const Sys__pthread_markcancel	: scno = 0x200014c
+	const Sys__pthread_canceled	: scno = 0x200014d
+	const Sys__semwait_signal	: scno = 0x200014e
+	const Sysproc_info	: scno = 0x2000150
+	const Syssendfile	: scno = 0x2000151
+	const Sysstat64		: scno = 0x2000152
+	const Sysfstat64	: scno = 0x2000153
+	const Syslstat64	: scno = 0x2000154
+	const Sysstat64_extended	: scno = 0x2000155
+	const Syslstat64_extended	: scno = 0x2000156
+	const Sysfstat64_extended	: scno = 0x2000157
+	const Sysgetdirentries64	: scno = 0x2000158
+	const Sysstatfs64	: scno = 0x2000159
+	const Sysfstatfs64	: scno = 0x200015a
+	const Sysgetfsstat64	: scno = 0x200015b
+	const Sys__pthread_chdir	: scno = 0x200015c
+	const Sys__pthread_fchdir	: scno = 0x200015d
+	const Sysaudit		: scno = 0x200015e
+	const Sysauditon	: scno = 0x200015f
+	const Sysgetauid	: scno = 0x2000161
+	const Syssetauid	: scno = 0x2000162
+	const Sysgetaudit	: scno = 0x2000163
+	const Syssetaudit	: scno = 0x2000164
+	const Sysgetaudit_addr	: scno = 0x2000165
+	const Syssetaudit_addr	: scno = 0x2000166
+	const Sysauditctl	: scno = 0x2000167
+	const Sysbsdthread_create	: scno = 0x2000168
+	const Sysbsdthread_terminate	: scno = 0x2000169
+	const Syskqueue		: scno = 0x200016a
+	const Syskevent		: scno = 0x200016b
+	const Syslchown		: scno = 0x200016c
+	const Sysstack_snapshot	: scno = 0x200016d
+	const Sysbsdthread_register	: scno = 0x200016e
+	const Sysworkq_open	: scno = 0x200016f
+	const Sysworkq_kernreturn	: scno = 0x2000170
+	const Syskevent64	: scno = 0x2000171
+	const Sys__old_semwait_signal	: scno = 0x2000172
+	const Sys__old_semwait_signal_nocancel	: scno = 0x2000173
+	const Systhread_selfid	: scno = 0x2000174
+	const Sys__mac_execve	: scno = 0x200017c
+	const Sys__mac_syscall	: scno = 0x200017d
+	const Sys__mac_get_file	: scno = 0x200017e
+	const Sys__mac_set_file	: scno = 0x200017f
+	const Sys__mac_get_link	: scno = 0x2000180
+	const Sys__mac_set_link	: scno = 0x2000181
+	const Sys__mac_get_proc	: scno = 0x2000182
+	const Sys__mac_set_proc	: scno = 0x2000183
+	const Sys__mac_get_fd	: scno = 0x2000184
+	const Sys__mac_set_fd	: scno = 0x2000185
+	const Sys__mac_get_pid	: scno = 0x2000186
+	const Sys__mac_get_lcid	: scno = 0x2000187
+	const Sys__mac_get_lctx	: scno = 0x2000188
+	const Sys__mac_set_lctx	: scno = 0x2000189
+	const Syssetlcid	: scno = 0x200018a
+	const Sysgetlcid	: scno = 0x200018b
+	const Sysread_nocancel	: scno = 0x200018c
+	const Syswrite_nocancel	: scno = 0x200018d
+	const Sysopen_nocancel	: scno = 0x200018e
+	const Sysclose_nocancel	: scno = 0x200018f
+	const Syswait4_nocancel	: scno = 0x2000190
+	const Sysrecvmsg_nocancel	: scno = 0x2000191
+	const Syssendmsg_nocancel	: scno = 0x2000192
+	const Sysrecvfrom_nocancel	: scno = 0x2000193
+	const Sysaccept_nocancel	: scno = 0x2000194
+	const Sysmsync_nocancel		: scno = 0x2000195
+	const Sysfcntl_nocancel		: scno = 0x2000196
+	const Sysselect_nocancel	: scno = 0x2000197
+	const Sysfsync_nocancel		: scno = 0x2000198
+	const Sysconnect_nocancel	: scno = 0x2000199
+	const Syssigsuspend_nocancel	: scno = 0x200019a
+	const Sysreadv_nocancel		: scno = 0x200019b
+	const Syswritev_nocancel	: scno = 0x200019c
+	const Syssendto_nocancel	: scno = 0x200019d
+	const Syspread_nocancel		: scno = 0x200019e
+	const Syspwrite_nocancel	: scno = 0x200019f
+	const Syswaitid_nocancel	: scno = 0x20001a0
+	const Syspoll_nocancel		: scno = 0x20001a1
+	const Sysmsgsnd_nocancel	: scno = 0x20001a2
+	const Sysmsgrcv_nocancel	: scno = 0x20001a3
+	const Syssem_wait_nocancel	: scno = 0x20001a4
+	const Sysaio_suspend_nocancel	: scno = 0x20001a5
+	const Sys__sigwait_nocancel	: scno = 0x20001a6
+	const Sys__semwait_signal_nocancel	: scno = 0x20001a7
+	const Sys__mac_mount		: scno = 0x20001a8
+	const Sys__mac_get_mount	: scno = 0x20001a9
+	const Sys__mac_getfsstat	: scno = 0x20001aa
+	const Sysfsgetpath		: scno = 0x20001ab
+	const Sysaudit_session_self	: scno = 0x20001ac
+	const Sysaudit_session_join	: scno = 0x20001ad
+	const Syspid_suspend		: scno = 0x20001ae
+	const Syspid_resume		: scno = 0x20001af
+	const Sysfileport_makeport	: scno = 0x20001b0
+	const Sysfileport_makefd	: scno = 0x20001b1
+
+	extern const syscall : (sc:scno, args:... -> int64)
+
+	const exit	: (status:int64 -> void)
+	const getpid	: ( -> int64)
+	const kill	: (pid:int64, sig:int64 -> int64)
+	const open	: (path:byte[:], opts:fdopt, mode:int64 -> int64)
+	const close	: (fd:int64 -> int64)
+	const creat	: (path:byte[:], mode:int64 -> int64)
+	const read	: (fd:int64, buf:byte[:] -> int64)
+	const write	: (fd:int64, buf:byte[:] -> int64)
+	const lseek	: (fd:int64, off:uint64, whence:int64 -> int64)
+	const fstat	: (fd:int64, sb:statbuf* -> int64)
+	const munmap	: (addr:byte*, len:size -> int64)
+	const mmap	: (addr:byte*, len:size, prot:mprot, flags:mopt, fd:int64, off:off -> byte*)
+;;
+
+const exit	= {status;		syscall(Sysexit, 1);}
+const getpid	= {;			-> syscall(Sysgetpid, 1);}
+const kill	= {pid, sig;		-> syscall(Syskill, pid, sig);}
+const open	= {path, opts, mode;	-> syscall(Sysopen, path castto(char*), opts);}
+const close	= {fd;			-> syscall(Sysclose, fd);}
+const creat	= {path, mode;		-> open(path, Ocreat | Otrunc | Owronly, mode);}
+const read	= {fd, buf;		-> syscall(Sysread, fd, buf castto(char*), buf.len);}
+const write	= {fd, buf;		-> syscall(Syswrite, fd, buf castto(char*), buf.len castto(size));}
+const lseek	= {fd, off, whence;	-> syscall(Syslseek, fd, off, whence);}
+const fstat	= {fd, sb;		-> syscall(Sysfstat, fd, sb);}
+const munmap	= {addr, len;		-> syscall(Sysmunmap, addr, len);}
+const mmap	= {addr, len, prot, flags, fd, off;	-> syscall(Sysmmap, addr, len, prot, flags, fd, off) castto(byte*);}
--- /dev/null
+++ b/libmyr/syscall-linux.s
@@ -1,0 +1,22 @@
+.globl std$syscall
+std$syscall:
+	pushq %rbp
+	/*
+	hack: We load 6 args regardless of
+	how many we actually have. This may
+	load junk values, but if the syscall
+	doesn't use them, it's going to be
+	harmless.
+	 */
+	movq 16(%rsp),%rax
+	movq 24(%rsp),%rdi
+	movq 32(%rsp),%rsi
+	movq 40(%rsp),%rdx
+	movq 48(%rsp),%r10
+	movq 56(%rsp),%r8
+	movq 64(%rsp),%r9
+
+	syscall
+
+	popq %rbp
+	ret
--- /dev/null
+++ b/libmyr/syscall-osx.s
@@ -1,0 +1,22 @@
+.globl _std$syscall
+_std$syscall:
+	pushq %rbp
+	/*
+	hack: We load 6 args regardless of
+	how many we actually have. This may
+	load junk values, but if the syscall
+	doesn't use them, it's going to be
+	harmless.
+	 */
+	movq 16(%rsp),%rax
+	movq 24(%rsp),%rdi
+	movq 32(%rsp),%rsi
+	movq 40(%rsp),%rdx
+	movq 48(%rsp),%r10
+	movq 56(%rsp),%r8
+	movq 64(%rsp),%r9
+
+	syscall
+
+	popq %rbp
+	ret
--- /dev/null
+++ b/libmyr/syscall.s
@@ -1,0 +1,32 @@
+.globl std$syscall
+std$syscall:
+	pushl %ebp
+	/*
+	   hack: 6 args uses %ebp, so we index
+	   relative to %esp.
+
+           hack: We load 6 args regardless of
+           how many we actually have. This may
+           load junk values, but if the syscall
+           doesn't use them, it's going to be
+           harmless.
+	 */
+	movl 8(%esp),%eax
+	movl 12(%esp),%ebx
+	movl 16(%esp),%ecx
+	movl 20(%esp),%edx
+	movl 24(%esp),%esi
+	movl 28(%esp),%edi
+	movl 32(%esp),%ebp
+        int $0x80
+	popl %ebp
+	ret
+
+.globl _std$syscall
+_std$syscall:
+        popl %ecx	/* return address */
+	popl %eax       /* call num */
+	pushl %ecx
+        int $0x80
+	pushl %ecx	/* put the return address back */
+	ret
--- /dev/null
+++ b/libmyr/test.myr
@@ -1,0 +1,69 @@
+use std
+
+const main = {
+	var x : byte*[1024]
+	var sz
+	var i
+
+	/* try the byte allocator for large variety of sizes. */
+	for sz = 1; sz < 65536; sz *= 2
+		for i = 0; i < 1024; i++
+			x[i] = std.bytealloc(sz)
+		;;
+		for i = 0; i < 1024; i++
+			std.bytefree(x[i], sz)
+		;;
+	;;
+	
+	/* make sure the generic allocator works */
+	for i = 0; i < 1024; i++
+		x[i] = std.alloc()
+	;;
+	for i = 0; i < 1024; i++
+		std.free(x[i])
+	;;
+	std.write(1, "Hello, 世界\n")
+	chartypes()
+	testrng()
+	std.put("format output %i %i %s %s\n", 123, 321, "asdf", "מִלָּה")
+	std.put("format with no args\n")
+}
+
+const chartypes = {
+	var s
+	var c
+	var buf : byte[32]
+
+	s = " 1世界 äa\n"
+	while s.len != 0
+		(c, s) = std.striter(s)
+		if std.isspace(c)
+			std.write(1, "Space\n")
+		elif std.isalpha(c)
+			std.write(1, "Alpha\n")
+		elif std.isnum(c)
+			std.write(1, "Num\n")
+		else
+			std.write(1, "Dunno\n")
+		;;
+		if !std.encode(buf[:std.charlen(c)], c)
+			std.write(1, "couldn't encode\n")
+		;;
+		std.write(1, buf[:std.charlen(c)])
+		std.write(1, "\n")
+	;;
+	if !std.encode(buf[0:3], -1)
+		std.write(1, "couldn't encode\n")
+	;;
+}
+
+const testrng = {
+	var r : std.rng*
+	var i
+
+	r = std.mksrng(10)
+	for i = 0; i < 10; i++
+		std.put("r[%i] = %l\n", i, std.rand32(r) castto(int64))
+	;;
+	std.put("\n");
+}
--- /dev/null
+++ b/libmyr/types.myr
@@ -1,0 +1,5 @@
+pkg std =
+	type size	= uint64	/* spans entire address space */
+	type off	= uint64	/* file offsets */
+	type intptr	= uint64	/* can hold any pointer losslessly */
+;;
--- /dev/null
+++ b/libmyr/utf.myr
@@ -1,0 +1,107 @@
+use "die.use"
+use "sys.use"
+use "types.use"
+
+pkg std =
+	const Badchar	: char = -1 castto(char)
+
+	const charlen	: (chr : char -> size)
+	const encode	: (buf : byte[:], chr : char -> size)
+	const decode	: (buf : byte[:] -> char)
+	const striter	: (str : byte[:] -> [char, byte[:]])
+
+	const strjoin	: (lst : byte[:][:], delim:byte[:] -> byte[:])
+	const strsep	: (str : byte[:], delim:byte[:] -> byte[:][:])
+	const strbjoin	: (lst : byte[:][:], delim:byte[:] -> byte[:])
+	const strbsep	: (str : byte[:], delim:byte[:] -> byte[:][:])
+;;
+
+const charlen = {c
+	if c < 0x80
+		-> 1
+	elif c < 0x800
+		-> 2
+	elif c < 0x10000
+		-> 3
+	elif c < 0x200000
+		-> 4
+	else
+		-> -1
+	;;
+}
+
+const encode = {buf, c
+	var len
+	var mark
+	var i
+
+	len = charlen(c)
+	if len < 0 || buf.len < len
+		-> -1
+	;;
+
+	if (len == 1)
+		mark = 0
+	else
+		mark = (((1 << (8 - len)) - 1) ^ 0xff) castto(char)
+	;;
+
+	for i = len - 1; i > 0; i--
+		buf[i] = (c & 0x3f | 0x80) castto(byte)
+		c >>= 6
+	;;
+
+	buf[0] = (c | mark) castto(byte)
+	-> len
+}
+
+const decode = {buf
+	var c
+	var b
+
+	(c, b) = striter(buf)
+	-> c
+}
+
+const striter = {str
+	var len
+	var mask
+	var chr
+	var i
+	var c
+	var tmp
+
+	if !str.len
+		/* empty string: no resync needed */
+		-> (Badchar, str)
+	;;
+	c = str[0]
+	len = 0
+	if c & 0x80 == 0	/* 0b0xxx_xxxx */
+		len = 1
+	elif c & 0xe0 == 0xc0	/* 0b110x_xxxx */
+		len = 2
+	elif c & 0xf0 == 0xe0 	/* 0b1110_xxxx */
+		len = 3
+	elif c & 0xf8 == 0xf0 	/* 0b1111_0xxx */
+		len = 4
+	else
+		/* skip one char forward so we can try
+		   resyncing the character stream */
+		-> (Badchar, str[1:])
+	;;
+
+	if len == 0 || len > str.len
+		/* again, we want to try to resync */
+		-> (Badchar, str[1:])
+	;;
+
+	mask = (1 << (8 - len)) - 1
+	chr = (c castto(uint32)) & mask
+	for i = 1; i < len; i++
+		tmp = str[i] castto(uint32)
+		chr = (chr << 6) | (tmp & 0x3f)
+	;;
+
+	-> (chr castto(char), str[len:])
+}
--- /dev/null
+++ b/libmyr/varargs.myr
@@ -1,0 +1,52 @@
+use "types.use"
+
+pkg std =
+	type valist
+
+	const vastart	: (args : ...* -> valist)
+	generic vanext	: (ap : valist -> [@a, valist])
+;;
+
+type valist = byte*
+
+/* 
+ * a valist is really just a pointer to the varargs.
+ * we assume that these sit on the stack nicely,
+ * and don't need special handling to get to.
+ * 
+ * This will be a problem when we switch to a
+ * register based convention. We might want to
+ * force varargs onto the stack regardless.
+ */
+const vastart = {args
+	-> args castto(valist)
+}
+
+generic vanext = {ap -> [@a, valist]
+	var v : @a
+	var align
+	var p
+
+	/*
+	 Assumptions about the ABI:
+	 * all types smaller than a word are
+	 * aligned to their own size. Larger
+	 * types are aligned to word size.
+	 */
+	if sizeof(@a) > 8
+		align = 8
+	else
+		align = sizeof(@a)
+	;;
+
+	/* apply the alignment to the arg pointer */
+	p = ap castto(intptr)
+	p = (p + align - 1) & ~(align - 1)
+	ap = p castto(valist)
+
+	v = *(ap castto(@a*))
+
+	/* only move on after we read through the value */
+	ap = ((p castto(intptr)) + sizeof(@a)) castto(valist)
+	-> (v, ap)
+}
--- a/rand.myr
+++ /dev/null
@@ -1,112 +1,0 @@
-use "die.use"
-use "fmt.use"
-use "types.use"
-use "alloc.use"
-/*
-   Translated from C by Ori Bernstein
- */
-
-/* 
-  A C-program for MT19937, with initialization improved 2002/1/26.
-  Coded by Takuji Nishimura and Makoto Matsumoto.
-  
-  Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
-  All rights reserved.                          
-  
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-  
-    1. Redistributions of source code must retain the above copyright
-       notice, this list of conditions and the following disclaimer.
- 
-    2. Redistributions in binary form must reproduce the above copyright
-       notice, this list of conditions and the following disclaimer in the
-       documentation and/or other materials provided with the distribution.
- 
-    3. The names of its contributors may not be used to endorse or promote 
-       products derived from this software without specific prior written 
-       permission.
- 
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- 
-  Any feedback is very welcome.
-  http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
-  email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
- */
-
-pkg std =
-	type rng
-
-	/* no mkrng() yet because we don't have anything to automatically
-	   seed it with yet */
-	const mksrng	: (seed : uint32 -> rng*)
-	const rand32	: (rng : rng* -> uint32)
-;;
-
-type rng = struct
-	state	: uint32[624]
-	i	: uint32
-;;
-
-const mksrng = {seed
-	var rng
-
-	rng = alloc()
-	init(rng, seed)
-	-> rng
-}
-
-const init = {rng, seed
-	var i
-
-	for i = 0; i < 624; i++
-		rng.state[i] = seed
-		seed = 1812433253 * (seed ^ (seed >> 30)) + i + 1
-	;;
-	rng.i = i
-}
-
-
-const rand32 = {rng
-	var x
-
-	if rng.i == 624
-		next(rng)
-	;;
-	x = rng.state[rng.i]
-	rng.i++
-
-	x ^= x >> 11
-	x ^= (x << 7) & 0x9D2C5680
-	x ^= (x << 15) & 0xEFC60000
-	-> x ^ (x >> 18)
-}
-
-
-const next = {rng
-	var k
-	var y
-
-	for k = 0; k < 227; k++
-		y = (rng.state[k] & 0x80000000) | (rng.state[k + 1] & 0x7FFFFFFF)
-		rng.state[k] = rng.state[k + 397] ^ (y >> 1) ^ ((y & 1) * 0x9908B0DF)
-	;;
-	for ; k < 623; k++
-		y = (rng.state[k] & 0x80000000) | (rng.state[k + 1] & 0x7FFFFFFF)
-		rng.state[k] = rng.state[k - 227] ^ (y >> 1) ^ ((y & 1) * 0x9908B0DF);
-	;;
-	y = (rng.state[623] & 0x80000000) | (rng.state[0] & 0x7FFFFFFF)
-	rng.state[623] = rng.state[396] ^ (y >> 1) ^ ((y & 1) * 0x9908B0DF);
-	rng.i = 0
-}
--- a/sys-linux.myr
+++ /dev/null
@@ -1,398 +1,0 @@
-use "types.use"
-
-pkg std =
-	type scno = int64
-	type fdopt = int64
-	type mprot = int64
-	type mopt = int64
-	type statbuf = struct
-		 dev     : uint
-		 ino     : uint
-		 mode    : uint16
-		 nlink   : uint16
-		 uid     : uint16
-		 gid     : uint16
-		 rdev    : uint
-		 size    : uint
-		 blksize : uint
-		 blocks  : uint
-		 atime   : uint
-		 atimens : uint
-		 mtime   : uint
-		 mtimens : uint
-		 ctime   : uint
-		 ctimens : uint
-		 _unused1: uint
-		 _unused2: uint
-	;;
-
-	/* open options */
-	const Ordonly  	: fdopt = 0x0
-	const Owronly  	: fdopt = 0x1
-	const Ordwr    	: fdopt = 0x2
-	const Oappend  	: fdopt = 0x80
-	const Ocreat   	: fdopt = 0x40
-	const Onofollow	: fdopt = 0x20000
-	const Ondelay  	: fdopt = 0x800
-	const Otrunc   	: fdopt = 0x200
-
-	/* mmap protection */
-	const Mprotnone	: mprot = 0x0
-	const Mprotrd	: mprot = 0x1
-	const Mprotwr	: mprot = 0x2
-	const Mprotexec	: mprot = 0x4
-	const Mprotrw	: mprot = 0x3 /* convenience */
-	
-	/* mmap options */
-	const Mshared	: mopt = 0x1
-	const Mpriv	: mopt = 0x2
-	const Mfixed	: mopt = 0x10
-	const Mfile	: mopt = 0x0
-	const Manon	: mopt = 0x20
-	const M32bit	: mopt = 0x40
-
-	/* return value for a failed mapping */
-	const Mapbad	: byte* = -1 castto(byte*)
-
-	/* syscalls */
-	const Sysread			: scno = 0
-	const Syswrite			: scno = 1
-	const Sysopen			: scno = 2
-	const Sysclose			: scno = 3
-	const Sysstat			: scno = 4
-	const Sysfstat			: scno = 5
-	const Syslstat			: scno = 6
-	const Syspoll			: scno = 7
-	const Syslseek			: scno = 8
-	const Sysmmap			: scno = 9
-	const Sysmprotect		: scno = 10
-	const Sysmunmap			: scno = 11
-	const Sysbrk			: scno = 12
-	const Sysrt_sigaction		: scno = 13
-	const Sysrt_sigprocmask		: scno = 14
-	const Sysrt_sigreturn		: scno = 15
-	const Sysioctl			: scno = 16
-	const Syspread64		: scno = 17
-	const Syspwrite64		: scno = 18
-	const Sysreadv			: scno = 19
-	const Syswritev			: scno = 20
-	const Sysaccess			: scno = 21
-	const Syspipe			: scno = 22
-	const Sysselect			: scno = 23
-	const Syssched_yield		: scno = 24
-	const Sysmremap			: scno = 25
-	const Sysmsync			: scno = 26
-	const Sysmincore		: scno = 27
-	const Sysmadvise		: scno = 28
-	const Sysshmget			: scno = 29
-	const Sysshmat			: scno = 30
-	const Sysshmctl			: scno = 31
-	const Sysdup			: scno = 32
-	const Sysdup2			: scno = 33
-	const Syspause			: scno = 34
-	const Sysnanosleep		: scno = 35
-	const Sysgetitimer		: scno = 36
-	const Sysalarm			: scno = 37
-	const Syssetitimer		: scno = 38
-	const Sysgetpid			: scno = 39
-	const Syssendfile		: scno = 40
-	const Syssocket			: scno = 41
-	const Sysconnect		: scno = 42
-	const Sysaccept			: scno = 43
-	const Syssendto			: scno = 44
-	const Sysrecvfrom		: scno = 45
-	const Syssendmsg		: scno = 46
-	const Sysrecvmsg		: scno = 47
-	const Sysshutdown		: scno = 48
-	const Sysbind			: scno = 49
-	const Syslisten			: scno = 50
-	const Sysgetsockname		: scno = 51
-	const Sysgetpeername		: scno = 52
-	const Syssocketpair		: scno = 53
-	const Syssetsockopt		: scno = 54
-	const Sysgetsockopt		: scno = 55
-	const Sysclone			: scno = 56
-	const Sysfork			: scno = 57
-	const Sysvfork			: scno = 58
-	const Sysexecve			: scno = 59
-	const Sysexit			: scno = 60
-	const Syswait4			: scno = 61
-	const Syskill			: scno = 62
-	const Sysuname			: scno = 63
-	const Syssemget			: scno = 64
-	const Syssemop			: scno = 65
-	const Syssemctl			: scno = 66
-	const Sysshmdt			: scno = 67
-	const Sysmsgget			: scno = 68
-	const Sysmsgsnd			: scno = 69
-	const Sysmsgrcv			: scno = 70
-	const Sysmsgctl			: scno = 71
-	const Sysfcntl			: scno = 72
-	const Sysflock			: scno = 73
-	const Sysfsync			: scno = 74
-	const Sysfdatasync		: scno = 75
-	const Systruncate		: scno = 76
-	const Sysftruncate		: scno = 77
-	const Sysgetdents		: scno = 78
-	const Sysgetcwd			: scno = 79
-	const Syschdir			: scno = 80
-	const Sysfchdir			: scno = 81
-	const Sysrename			: scno = 82
-	const Sysmkdir			: scno = 83
-	const Sysrmdir			: scno = 84
-	const Syscreat			: scno = 85
-	const Syslink			: scno = 86
-	const Sysunlink			: scno = 87
-	const Syssymlink		: scno = 88
-	const Sysreadlink		: scno = 89
-	const Syschmod			: scno = 90
-	const Sysfchmod			: scno = 91
-	const Syschown			: scno = 92
-	const Sysfchown			: scno = 93
-	const Syslchown			: scno = 94
-	const Sysumask			: scno = 95
-	const Sysgettimeofday		: scno = 96
-	const Sysgetrlimit		: scno = 97
-	const Sysgetrusage		: scno = 98
-	const Syssysinfo		: scno = 99
-	const Systimes			: scno = 100
-	const Sysptrace			: scno = 101
-	const Sysgetuid			: scno = 102
-	const Syssyslog			: scno = 103
-	const Sysgetgid			: scno = 104
-	const Syssetuid			: scno = 105
-	const Syssetgid			: scno = 106
-	const Sysgeteuid		: scno = 107
-	const Sysgetegid		: scno = 108
-	const Syssetpgid		: scno = 109
-	const Sysgetppid		: scno = 110
-	const Sysgetpgrp		: scno = 111
-	const Syssetsid			: scno = 112
-	const Syssetreuid		: scno = 113
-	const Syssetregid		: scno = 114
-	const Sysgetgroups		: scno = 115
-	const Syssetgroups		: scno = 116
-	const Syssetresuid		: scno = 117
-	const Sysgetresuid		: scno = 118
-	const Syssetresgid		: scno = 119
-	const Sysgetresgid		: scno = 120
-	const Sysgetpgid		: scno = 121
-	const Syssetfsuid		: scno = 122
-	const Syssetfsgid		: scno = 123
-	const Sysgetsid			: scno = 124
-	const Syscapget			: scno = 125
-	const Syscapset			: scno = 126
-	const Sysrt_sigpending		: scno = 127
-	const Sysrt_sigtimedwait	: scno = 128
-	const Sysrt_sigqueueinfo	: scno = 129
-	const Sysrt_sigsuspend		: scno = 130
-	const Syssigaltstack		: scno = 131
-	const Sysutime			: scno = 132
-	const Sysmknod			: scno = 133
-	const Sysuselib			: scno = 134
-	const Syspersonality		: scno = 135
-	const Sysustat			: scno = 136
-	const Sysstatfs			: scno = 137
-	const Sysfstatfs		: scno = 138
-	const Syssysfs			: scno = 139
-	const Sysgetpriority		: scno = 140
-	const Syssetpriority		: scno = 141
-	const Syssched_setparam		: scno = 142
-	const Syssched_getparam		: scno = 143
-	const Syssched_setscheduler	: scno = 144
-	const Syssched_getscheduler	: scno = 145
-	const Syssched_get_priority_max	: scno = 146
-	const Syssched_get_priority_min	: scno = 147
-	const Syssched_rr_get_interval	: scno = 148
-	const Sysmlock			: scno = 149
-	const Sysmunlock		: scno = 150
-	const Sysmlockall		: scno = 151
-	const Sysmunlockall		: scno = 152
-	const Sysvhangup		: scno = 153
-	const Sysmodify_ldt		: scno = 154
-	const Syspivot_root		: scno = 155
-	const Sys_sysctl		: scno = 156
-	const Sysprctl			: scno = 157
-	const Sysarch_prctl		: scno = 158
-	const Sysadjtimex		: scno = 159
-	const Syssetrlimit		: scno = 160
-	const Syschroot			: scno = 161
-	const Syssync			: scno = 162
-	const Sysacct			: scno = 163
-	const Syssettimeofday		: scno = 164
-	const Sysmount			: scno = 165
-	const Sysumount2		: scno = 166
-	const Sysswapon			: scno = 167
-	const Sysswapoff		: scno = 168
-	const Sysreboot			: scno = 169
-	const Syssethostname		: scno = 170
-	const Syssetdomainname		: scno = 171
-	const Sysiopl			: scno = 172
-	const Sysioperm			: scno = 173
-	const Syscreate_module		: scno = 174
-	const Sysinit_module		: scno = 175
-	const Sysdelete_module		: scno = 176
-	const Sysget_kernel_syms	: scno = 177
-	const Sysquery_module		: scno = 178
-	const Sysquotactl		: scno = 179
-	const Sysnfsservctl		: scno = 180
-	const Sysgetpmsg		: scno = 181
-	const Sysputpmsg		: scno = 182
-	const Sysafs_syscall		: scno = 183
-	const Systuxcall		: scno = 184
-	const Syssecurity		: scno = 185
-	const Sysgettid			: scno = 186
-	const Sysreadahead		: scno = 187
-	const Syssetxattr		: scno = 188
-	const Syslsetxattr		: scno = 189
-	const Sysfsetxattr		: scno = 190
-	const Sysgetxattr		: scno = 191
-	const Syslgetxattr		: scno = 192
-	const Sysfgetxattr		: scno = 193
-	const Syslistxattr		: scno = 194
-	const Sysllistxattr		: scno = 195
-	const Sysflistxattr		: scno = 196
-	const Sysremovexattr		: scno = 197
-	const Syslremovexattr		: scno = 198
-	const Sysfremovexattr		: scno = 199
-	const Systkill			: scno = 200
-	const Systime			: scno = 201
-	const Sysfutex			: scno = 202
-	const Syssched_setaffinity	: scno = 203
-	const Syssched_getaffinity	: scno = 204
-	const Sysset_thread_area	: scno = 205
-	const Sysio_setup		: scno = 206
-	const Sysio_destroy		: scno = 207
-	const Sysio_getevents		: scno = 208
-	const Sysio_submit		: scno = 209
-	const Sysio_cancel		: scno = 210
-	const Sysget_thread_area	: scno = 211
-	const Syslookup_dcookie		: scno = 212
-	const Sysepoll_create		: scno = 213
-	const Sysepoll_ctl_old		: scno = 214
-	const Sysepoll_wait_old		: scno = 215
-	const Sysremap_file_pages	: scno = 216
-	const Sysgetdents64		: scno = 217
-	const Sysset_tid_address	: scno = 218
-	const Sysrestart_syscall	: scno = 219
-	const Syssemtimedop		: scno = 220
-	const Sysfadvise64		: scno = 221
-	const Systimer_create		: scno = 222
-	const Systimer_settime		: scno = 223
-	const Systimer_gettime		: scno = 224
-	const Systimer_getoverrun	: scno = 225
-	const Systimer_delete		: scno = 226
-	const Sysclock_settime		: scno = 227
-	const Sysclock_gettime		: scno = 228
-	const Sysclock_getres		: scno = 229
-	const Sysclock_nanosleep	: scno = 230
-	const Sysexit_group		: scno = 231
-	const Sysepoll_wait		: scno = 232
-	const Sysepoll_ctl		: scno = 233
-	const Systgkill			: scno = 234
-	const Sysutimes			: scno = 235
-	const Sysvserver		: scno = 236
-	const Sysmbind			: scno = 237
-	const Sysset_mempolicy		: scno = 238
-	const Sysget_mempolicy		: scno = 239
-	const Sysmq_open		: scno = 240
-	const Sysmq_unlink		: scno = 241
-	const Sysmq_timedsend		: scno = 242
-	const Sysmq_timedreceive	: scno = 243
-	const Sysmq_notify		: scno = 244
-	const Sysmq_getsetattr		: scno = 245
-	const Syskexec_load		: scno = 246
-	const Syswaitid			: scno = 247
-	const Sysadd_key		: scno = 248
-	const Sysrequest_key		: scno = 249
-	const Syskeyctl			: scno = 250
-	const Sysioprio_set		: scno = 251
-	const Sysioprio_get		: scno = 252
-	const Sysinotify_init		: scno = 253
-	const Sysinotify_add_watch	: scno = 254
-	const Sysinotify_rm_watch	: scno = 255
-	const Sysmigrate_pages		: scno = 256
-	const Sysopenat			: scno = 257
-	const Sysmkdirat		: scno = 258
-	const Sysmknodat		: scno = 259
-	const Sysfchownat		: scno = 260
-	const Sysfutimesat		: scno = 261
-	const Sysnewfstatat		: scno = 262
-	const Sysunlinkat		: scno = 263
-	const Sysrenameat		: scno = 264
-	const Syslinkat			: scno = 265
-	const Syssymlinkat		: scno = 266
-	const Sysreadlinkat		: scno = 267
-	const Sysfchmodat		: scno = 268
-	const Sysfaccessat		: scno = 269
-	const Syspselect6		: scno = 270
-	const Sysppoll			: scno = 271
-	const Sysunshare		: scno = 272
-	const Sysset_robust_list	: scno = 273
-	const Sysget_robust_list	: scno = 274
-	const Syssplice			: scno = 275
-	const Systee			: scno = 276
-	const Syssync_file_range	: scno = 277
-	const Sysvmsplice		: scno = 278
-	const Sysmove_pages		: scno = 279
-	const Sysutimensat		: scno = 280
-	const Sysepoll_pwait		: scno = 281
-	const Syssignalfd		: scno = 282
-	const Systimerfd_create		: scno = 283
-	const Syseventfd		: scno = 284
-	const Sysfallocate		: scno = 285
-	const Systimerfd_settime	: scno = 286
-	const Systimerfd_gettime	: scno = 287
-	const Sysaccept4		: scno = 288
-	const Syssignalfd4		: scno = 289
-	const Syseventfd2		: scno = 290
-	const Sysepoll_create1		: scno = 291
-	const Sysdup3			: scno = 292
-	const Syspipe2			: scno = 293
-	const Sysinotify_init1		: scno = 294
-	const Syspreadv			: scno = 295
-	const Syspwritev		: scno = 296
-	const Sysrt_tgsigqueueinfo	: scno = 297
-	const Sysperf_event_open	: scno = 298
-	const Sysrecvmmsg		: scno = 299
-	const Sysfanotify_init		: scno = 300
-	const Sysfanotify_mark		: scno = 301
-	const Sysprlimit64		: scno = 302
-	const Sysname_to_handle_at	: scno = 303
-	const Sysopen_by_handle_at	: scno = 304
-	const Sysclock_adjtime		: scno = 305
-	const Syssyncfs			: scno = 306
-	const Syssendmmsg		: scno = 307
-	const Syssetns			: scno = 308
-	const Sysgetcpu			: scno = 309
-	const Sysprocess_vm_readv	: scno = 310
-	const Sysprocess_vm_writev	: scno = 311
-
-	extern const syscall : (sc:scno, args:... -> int64)
-
-	const exit	: (status:int64 -> void)
-	const getpid	: ( -> int64)
-	const kill	: (pid:int64, sig:int64 -> int64)
-	const open	: (path:byte[:], opts:fdopt, mode:int64 -> int64)
-	const close	: (fd:int64 -> int64)
-	const creat	: (path:byte[:], mode:int64 -> int64)
-	const read	: (fd:int64, buf:byte[:] -> int64)
-	const write	: (fd:int64, buf:byte[:] -> int64)
-	const lseek	: (fd:int64, off:uint64, whence:int64 -> int64)
-	const fstat	: (fd:int64, sb:statbuf* -> int64)
-	const munmap	: (addr:byte*, len:size -> int64)
-	const mmap	: (addr:byte*, len:size, prot:mprot, flags:mopt, fd:int64, off:off -> byte*)
-;;
-
-const exit	= {status;		syscall(Sysexit, 1);}
-const getpid	= {;			-> syscall(Sysgetpid, 1);}
-const kill	= {pid, sig;		-> syscall(Syskill, pid, sig);}
-const open	= {path, opts, mode;	-> syscall(Sysopen, path castto(char*), opts);}
-const close	= {fd;			-> syscall(Sysclose, fd);}
-const creat	= {path, mode;		-> syscall(Syscreat, path castto(char*), mode);}
-const read	= {fd, buf;		-> syscall(Sysread, fd, buf castto(char*), buf.len);}
-const write	= {fd, buf;		-> syscall(Syswrite, fd, buf castto(char*), buf.len castto(size));}
-const lseek	= {fd, off, whence;	-> syscall(Syslseek, fd, off, whence);}
-const fstat	= {fd, sb;		-> syscall(Sysfstat, fd, sb);}
-const munmap	= {addr, len;		-> syscall(Sysmunmap, addr, len);}
-const mmap	= {addr, len, prot, flags, fd, off;	-> syscall(Sysmmap, addr, len, prot, flags, fd, off) castto(byte*);}
--- a/sys-osx.myr
+++ /dev/null
@@ -1,444 +1,0 @@
-use "types.use"
-
-pkg std =
-	type scno = int64
-	type fdopt = int64
-	type mprot = int64
-	type mopt = int64
-
-	type timespec = struct
-		secs	: uint64
-		nsecs	: uint32
-	;;
-
-	type statbuf = struct
-		dev	: int32
-		mode	: uint16
-		nlink	: uint32
-		ino	: uint64 /* 32/64? which do I use? */
-		uid	: uint32
-		gid	: uint32
-		rdev	: int32
-		atimesspec	: timespec
-		mtimesspec	: timespec
-		ctimesspec	: timespec
-		btimesspec	: timespec
-		size	: off
-		blocks	: uint
-		blocksz	: uint
-		flags	: uint32
-		gen	: uint32
-		lspare	: int32
-		qspare0	: int64
-		qspare1	: int64
-	;;
-
-	/* open options */
-	const Ordonly  	: fdopt = 0x0
-	const Owronly  	: fdopt = 0x1
-	const Ordwr    	: fdopt = 0x2
-	const Ondelay  	: fdopt = 0x4
-	const Oappend  	: fdopt = 0x8
-	const Ocreat   	: fdopt = 0x200
-	const Onofollow	: fdopt = 0x100
-	const Otrunc   	: fdopt = 0x400
-
-	/* mmap protection */
-	const Mprotnone	: mprot = 0x0
-	const Mprotrd	: mprot = 0x1
-	const Mprotwr	: mprot = 0x2
-	const Mprotexec	: mprot = 0x4
-	const Mprotrw	: mprot = 0x3
-	
-	/* mmap options */
-	const Mshared	: mopt = 0x1
-	const Mpriv	: mopt = 0x2
-	const Mfixed	: mopt = 0x10
-	const Mfile	: mopt = 0x0
-	const Manon	: mopt = 0x1000
-	/* Only on Linux
-	const M32bit	: mopt = 0x40
-	*/
-
-
-	/* return value for a failed mapping */
-	const Mapbad	: byte* = -1 castto(byte*)
-
-	/* syscalls.
-	note, creat() implemented as open(path, Creat|Trunc|Wronly) */
-	const Syssyscall	: scno = 0x2000000
-	const Sysexit		: scno = 0x2000001
-	const Sysfork		: scno = 0x2000002
-	const Sysread		: scno = 0x2000003
-	const Syswrite		: scno = 0x2000004
-	const Sysopen		: scno = 0x2000005
-	const Sysclose		: scno = 0x2000006
-	const Syswait4		: scno = 0x2000007
-	const Syslink		: scno = 0x2000009
-	const Sysunlink		: scno = 0x200000a
-	const Syschdir		: scno = 0x200000c
-	const Sysfchdir		: scno = 0x200000d
-	const Sysmknod		: scno = 0x200000e
-	const Syschmod		: scno = 0x200000f
-	const Syschown		: scno = 0x2000010
-	const Sysgetfsstat	: scno = 0x2000012
-	const Sysgetpid		: scno = 0x2000014
-	const Syssetuid		: scno = 0x2000017
-	const Sysgetuid		: scno = 0x2000018
-	const Sysgeteuid	: scno = 0x2000019
-	const Sysptrace		: scno = 0x200001a
-	const Sysrecvmsg	: scno = 0x200001b
-	const Syssendmsg	: scno = 0x200001c
-	const Sysrecvfrom	: scno = 0x200001d
-	const Sysaccept		: scno = 0x200001e
-	const Sysgetpeername	: scno = 0x200001f
-	const Sysgetsockname	: scno = 0x2000020
-	const Sysaccess		: scno = 0x2000021
-	const Syschflags	: scno = 0x2000022
-	const Sysfchflags	: scno = 0x2000023
-	const Syssync		: scno = 0x2000024
-	const Syskill		: scno = 0x2000025
-	const Sysgetppid	: scno = 0x2000027
-	const Sysdup		: scno = 0x2000029
-	const Syspipe		: scno = 0x200002a
-	const Sysgetegid	: scno = 0x200002b
-	const Sysprofil		: scno = 0x200002c
-	const Syssigaction	: scno = 0x200002e
-	const Sysgetgid		: scno = 0x200002f
-	const Syssigprocmask	: scno = 0x2000030
-	const Sysgetlogin	: scno = 0x2000031
-	const Syssetlogin	: scno = 0x2000032
-	const Sysacct		: scno = 0x2000033
-	const Syssigpending	: scno = 0x2000034
-	const Syssigaltstack	: scno = 0x2000035
-	const Sysioctl		: scno = 0x2000036
-	const Sysreboot		: scno = 0x2000037
-	const Sysrevoke		: scno = 0x2000038
-	const Syssymlink	: scno = 0x2000039
-	const Sysreadlink	: scno = 0x200003a
-	const Sysexecve		: scno = 0x200003b
-	const Sysumask		: scno = 0x200003c
-	const Syschroot		: scno = 0x200003d
-	const Sysmsync		: scno = 0x2000041
-	const Sysvfork		: scno = 0x2000042
-	const Sysmunmap		: scno = 0x2000049
-	const Sysmprotect	: scno = 0x200004a
-	const Sysmadvise	: scno = 0x200004b
-	const Sysmincore	: scno = 0x200004e
-	const Sysgetgroups	: scno = 0x200004f
-	const Syssetgroups	: scno = 0x2000050
-	const Sysgetpgrp	: scno = 0x2000051
-	const Syssetpgid	: scno = 0x2000052
-	const Syssetitimer	: scno = 0x2000053
-	const Sysswapon		: scno = 0x2000055
-	const Sysgetitimer	: scno = 0x2000056
-	const Sysgetdtablesize	: scno = 0x2000059
-	const Sysdup2		: scno = 0x200005a
-	const Sysfcntl		: scno = 0x200005c
-	const Sysselect		: scno = 0x200005d
-	const Sysfsync		: scno = 0x200005f
-	const Syssetpriority	: scno = 0x2000060
-	const Syssocket		: scno = 0x2000061
-	const Sysconnect	: scno = 0x2000062
-	const Sysgetpriority	: scno = 0x2000064
-	const Sysbind		: scno = 0x2000068
-	const Syssetsockopt	: scno = 0x2000069
-	const Syslisten		: scno = 0x200006a
-	const Syssigsuspend	: scno = 0x200006f
-	const Sysgettimeofday	: scno = 0x2000074
-	const Sysgetrusage	: scno = 0x2000075
-	const Sysgetsockopt	: scno = 0x2000076
-	const Sysreadv		: scno = 0x2000078
-	const Syswritev		: scno = 0x2000079
-	const Syssettimeofday	: scno = 0x200007a
-	const Sysfchown		: scno = 0x200007b
-	const Sysfchmod		: scno = 0x200007c
-	const Syssetreuid	: scno = 0x200007e
-	const Syssetregid	: scno = 0x200007f
-	const Sysrename		: scno = 0x2000080
-	const Sysflock		: scno = 0x2000083
-	const Sysmkfifo		: scno = 0x2000084
-	const Syssendto		: scno = 0x2000085
-	const Sysshutdown	: scno = 0x2000086
-	const Syssocketpair	: scno = 0x2000087
-	const Sysmkdir		: scno = 0x2000088
-	const Sysrmdir		: scno = 0x2000089
-	const Sysutimes		: scno = 0x200008a
-	const Sysfutimes	: scno = 0x200008b
-	const Sysadjtime	: scno = 0x200008c
-	const Sysgethostuuid	: scno = 0x200008e
-	const Syssetsid		: scno = 0x2000093
-	const Sysgetpgid	: scno = 0x2000097
-	const Syssetprivexec	: scno = 0x2000098
-	const Syspread		: scno = 0x2000099
-	const Syspwrite		: scno = 0x200009a
-	const Sysnfssvc		: scno = 0x200009b
-	const Sysstatfs		: scno = 0x200009d
-	const Sysfstatfs	: scno = 0x200009e
-	const Sysunmount	: scno = 0x200009f
-	const Sysgetfh		: scno = 0x20000a1
-	const Sysquotactl	: scno = 0x20000a5
-	const Sysmount		: scno = 0x20000a7
-	const Syscsops		: scno = 0x20000a9
-	const Syswaitid		: scno = 0x20000ad
-	const Sysadd_profil	: scno = 0x20000b0
-	const Syskdebug_trace	: scno = 0x20000b4
-	const Syssetgid		: scno = 0x20000b5
-	const Syssetegid	: scno = 0x20000b6
-	const Sysseteuid	: scno = 0x20000b7
-	const Syssigreturn	: scno = 0x20000b8
-	const Syschud		: scno = 0x20000b9
-	const Sysfdatasync	: scno = 0x20000bb
-	const Sysstat		: scno = 0x20000bc
-	const Sysfstat		: scno = 0x20000bd
-	const Syslstat		: scno = 0x20000be
-	const Syspathconf	: scno = 0x20000bf
-	const Sysfpathconf	: scno = 0x20000c0
-	const Sysgetrlimit	: scno = 0x20000c2
-	const Syssetrlimit	: scno = 0x20000c3
-	const Sysgetdirentries	: scno = 0x20000c4
-	const Sysmmap		: scno = 0x20000c5
-	const Syslseek		: scno = 0x20000c7
-	const Systruncate	: scno = 0x20000c8
-	const Sysftruncate	: scno = 0x20000c9
-	const Sys__sysctl	: scno = 0x20000ca
-	const Sysmlock		: scno = 0x20000cb
-	const Sysmunlock	: scno = 0x20000cc
-	const Sysundelete	: scno = 0x20000cd
-	const SysATsocket	: scno = 0x20000ce
-	const SysATgetmsg	: scno = 0x20000cf
-	const SysATputmsg	: scno = 0x20000d0
-	const SysATPsndreq	: scno = 0x20000d1
-	const SysATPsndrsp	: scno = 0x20000d2
-	const SysATPgetreq	: scno = 0x20000d3
-	const SysATPgetrsp	: scno = 0x20000d4
-	const Sysmkcomplex	: scno = 0x20000d8
-	const Sysstatv		: scno = 0x20000d9
-	const Syslstatv		: scno = 0x20000da
-	const Sysfstatv		: scno = 0x20000db
-	const Sysgetattrlist	: scno = 0x20000dc
-	const Syssetattrlist	: scno = 0x20000dd
-	const Sysgetdirentriesattr	: scno = 0x20000de
-	const Sysexchangedata	: scno = 0x20000df
-	const Syssearchfs	: scno = 0x20000e1
-	const Sysdelete		: scno = 0x20000e2
-	const Syscopyfile	: scno = 0x20000e3
-	const Sysfgetattrlist	: scno = 0x20000e4
-	const Sysfsetattrlist	: scno = 0x20000e5
-	const Syspoll		: scno = 0x20000e6
-	const Syswatchevent	: scno = 0x20000e7
-	const Syswaitevent	: scno = 0x20000e8
-	const Sysmodwatch	: scno = 0x20000e9
-	const Sysgetxattr	: scno = 0x20000ea
-	const Sysfgetxattr	: scno = 0x20000eb
-	const Syssetxattr	: scno = 0x20000ec
-	const Sysfsetxattr	: scno = 0x20000ed
-	const Sysremovexattr	: scno = 0x20000ee
-	const Sysfremovexattr	: scno = 0x20000ef
-	const Syslistxattr	: scno = 0x20000f0
-	const Sysflistxattr	: scno = 0x20000f1
-	const Sysfsctl		: scno = 0x20000f2
-	const Sysinitgroups	: scno = 0x20000f3
-	const Sysposix_spawn	: scno = 0x20000f4
-	const Sysffsctl		: scno = 0x20000f5
-	const Sysnfsclnt	: scno = 0x20000f7
-	const Sysfhopen		: scno = 0x20000f8
-	const Sysminherit	: scno = 0x20000fa
-	const Syssemsys		: scno = 0x20000fb
-	const Sysmsgsys		: scno = 0x20000fc
-	const Sysshmsys		: scno = 0x20000fd
-	const Syssemctl		: scno = 0x20000fe
-	const Syssemget		: scno = 0x20000ff
-	const Syssemop		: scno = 0x2000100
-	const Sysmsgctl		: scno = 0x2000102
-	const Sysmsgget		: scno = 0x2000103
-	const Sysmsgsnd		: scno = 0x2000104
-	const Sysmsgrcv		: scno = 0x2000105
-	const Sysshmat		: scno = 0x2000106
-	const Sysshmctl		: scno = 0x2000107
-	const Sysshmdt		: scno = 0x2000108
-	const Sysshmget		: scno = 0x2000109
-	const Sysshm_open	: scno = 0x200010a
-	const Sysshm_unlink	: scno = 0x200010b
-	const Syssem_open	: scno = 0x200010c
-	const Syssem_close	: scno = 0x200010d
-	const Syssem_unlink	: scno = 0x200010e
-	const Syssem_wait	: scno = 0x200010f
-	const Syssem_trywait	: scno = 0x2000110
-	const Syssem_post	: scno = 0x2000111
-	const Syssem_getvalue	: scno = 0x2000112
-	const Syssem_init	: scno = 0x2000113
-	const Syssem_destroy	: scno = 0x2000114
-	const Sysopen_extended	: scno = 0x2000115
-	const Sysumask_extended	: scno = 0x2000116
-	const Sysstat_extended	: scno = 0x2000117
-	const Syslstat_extended	: scno = 0x2000118
-	const Sysfstat_extended	: scno = 0x2000119
-	const Syschmod_extended	: scno = 0x200011a
-	const Sysfchmod_extended	: scno = 0x200011b
-	const Sysaccess_extended	: scno = 0x200011c
-	const Syssettid		: scno = 0x200011d
-	const Sysgettid		: scno = 0x200011e
-	const Syssetsgroups	: scno = 0x200011f
-	const Sysgetsgroups	: scno = 0x2000120
-	const Syssetwgroups	: scno = 0x2000121
-	const Sysgetwgroups	: scno = 0x2000122
-	const Sysmkfifo_extended	: scno = 0x2000123
-	const Sysmkdir_extended	: scno = 0x2000124
-	const Sysidentitysvc	: scno = 0x2000125
-	const Sysshared_region_check_np	: scno = 0x2000126
-	const Sysshared_region_map_np	: scno = 0x2000127
-	const Sysvm_pressure_monitor	: scno = 0x2000128
-	const Syspsynch_rw_longrdlock	: scno = 0x2000129
-	const Syspsynch_rw_yieldwrlock	: scno = 0x200012a
-	const Syspsynch_rw_downgrade	: scno = 0x200012b
-	const Syspsynch_rw_upgrade	: scno = 0x200012c
-	const Syspsynch_mutexwait	: scno = 0x200012d
-	const Syspsynch_mutexdrop	: scno = 0x200012e
-	const Syspsynch_cvbroad	: scno = 0x200012f
-	const Syspsynch_cvsignal	: scno = 0x2000130
-	const Syspsynch_cvwait	: scno = 0x2000131
-	const Syspsynch_rw_rdlock	: scno = 0x2000132
-	const Syspsynch_rw_wrlock	: scno = 0x2000133
-	const Syspsynch_rw_unlock	: scno = 0x2000134
-	const Syspsynch_rw_unlock2	: scno = 0x2000135
-	const Sysgetsid		: scno = 0x2000136
-	const Syssettid_with_pid	: scno = 0x2000137
-	const Sysaio_fsync	: scno = 0x2000139
-	const Sysaio_return	: scno = 0x200013a
-	const Sysaio_suspend	: scno = 0x200013b
-	const Sysaio_cancel	: scno = 0x200013c
-	const Sysaio_error	: scno = 0x200013d
-	const Sysaio_read	: scno = 0x200013e
-	const Sysaio_write	: scno = 0x200013f
-	const Syslio_listio	: scno = 0x2000140
-	const Sysiopolicysys	: scno = 0x2000142
-	const Sysmlockall	: scno = 0x2000144
-	const Sysmunlockall	: scno = 0x2000145
-	const Sysissetugid	: scno = 0x2000147
-	const Sys__pthread_kill	: scno = 0x2000148
-	const Sys__pthread_sigmask	: scno = 0x2000149
-	const Sys__sigwait	: scno = 0x200014a
-	const Sys__disable_threadsignal	: scno = 0x200014b
-	const Sys__pthread_markcancel	: scno = 0x200014c
-	const Sys__pthread_canceled	: scno = 0x200014d
-	const Sys__semwait_signal	: scno = 0x200014e
-	const Sysproc_info	: scno = 0x2000150
-	const Syssendfile	: scno = 0x2000151
-	const Sysstat64		: scno = 0x2000152
-	const Sysfstat64	: scno = 0x2000153
-	const Syslstat64	: scno = 0x2000154
-	const Sysstat64_extended	: scno = 0x2000155
-	const Syslstat64_extended	: scno = 0x2000156
-	const Sysfstat64_extended	: scno = 0x2000157
-	const Sysgetdirentries64	: scno = 0x2000158
-	const Sysstatfs64	: scno = 0x2000159
-	const Sysfstatfs64	: scno = 0x200015a
-	const Sysgetfsstat64	: scno = 0x200015b
-	const Sys__pthread_chdir	: scno = 0x200015c
-	const Sys__pthread_fchdir	: scno = 0x200015d
-	const Sysaudit		: scno = 0x200015e
-	const Sysauditon	: scno = 0x200015f
-	const Sysgetauid	: scno = 0x2000161
-	const Syssetauid	: scno = 0x2000162
-	const Sysgetaudit	: scno = 0x2000163
-	const Syssetaudit	: scno = 0x2000164
-	const Sysgetaudit_addr	: scno = 0x2000165
-	const Syssetaudit_addr	: scno = 0x2000166
-	const Sysauditctl	: scno = 0x2000167
-	const Sysbsdthread_create	: scno = 0x2000168
-	const Sysbsdthread_terminate	: scno = 0x2000169
-	const Syskqueue		: scno = 0x200016a
-	const Syskevent		: scno = 0x200016b
-	const Syslchown		: scno = 0x200016c
-	const Sysstack_snapshot	: scno = 0x200016d
-	const Sysbsdthread_register	: scno = 0x200016e
-	const Sysworkq_open	: scno = 0x200016f
-	const Sysworkq_kernreturn	: scno = 0x2000170
-	const Syskevent64	: scno = 0x2000171
-	const Sys__old_semwait_signal	: scno = 0x2000172
-	const Sys__old_semwait_signal_nocancel	: scno = 0x2000173
-	const Systhread_selfid	: scno = 0x2000174
-	const Sys__mac_execve	: scno = 0x200017c
-	const Sys__mac_syscall	: scno = 0x200017d
-	const Sys__mac_get_file	: scno = 0x200017e
-	const Sys__mac_set_file	: scno = 0x200017f
-	const Sys__mac_get_link	: scno = 0x2000180
-	const Sys__mac_set_link	: scno = 0x2000181
-	const Sys__mac_get_proc	: scno = 0x2000182
-	const Sys__mac_set_proc	: scno = 0x2000183
-	const Sys__mac_get_fd	: scno = 0x2000184
-	const Sys__mac_set_fd	: scno = 0x2000185
-	const Sys__mac_get_pid	: scno = 0x2000186
-	const Sys__mac_get_lcid	: scno = 0x2000187
-	const Sys__mac_get_lctx	: scno = 0x2000188
-	const Sys__mac_set_lctx	: scno = 0x2000189
-	const Syssetlcid	: scno = 0x200018a
-	const Sysgetlcid	: scno = 0x200018b
-	const Sysread_nocancel	: scno = 0x200018c
-	const Syswrite_nocancel	: scno = 0x200018d
-	const Sysopen_nocancel	: scno = 0x200018e
-	const Sysclose_nocancel	: scno = 0x200018f
-	const Syswait4_nocancel	: scno = 0x2000190
-	const Sysrecvmsg_nocancel	: scno = 0x2000191
-	const Syssendmsg_nocancel	: scno = 0x2000192
-	const Sysrecvfrom_nocancel	: scno = 0x2000193
-	const Sysaccept_nocancel	: scno = 0x2000194
-	const Sysmsync_nocancel		: scno = 0x2000195
-	const Sysfcntl_nocancel		: scno = 0x2000196
-	const Sysselect_nocancel	: scno = 0x2000197
-	const Sysfsync_nocancel		: scno = 0x2000198
-	const Sysconnect_nocancel	: scno = 0x2000199
-	const Syssigsuspend_nocancel	: scno = 0x200019a
-	const Sysreadv_nocancel		: scno = 0x200019b
-	const Syswritev_nocancel	: scno = 0x200019c
-	const Syssendto_nocancel	: scno = 0x200019d
-	const Syspread_nocancel		: scno = 0x200019e
-	const Syspwrite_nocancel	: scno = 0x200019f
-	const Syswaitid_nocancel	: scno = 0x20001a0
-	const Syspoll_nocancel		: scno = 0x20001a1
-	const Sysmsgsnd_nocancel	: scno = 0x20001a2
-	const Sysmsgrcv_nocancel	: scno = 0x20001a3
-	const Syssem_wait_nocancel	: scno = 0x20001a4
-	const Sysaio_suspend_nocancel	: scno = 0x20001a5
-	const Sys__sigwait_nocancel	: scno = 0x20001a6
-	const Sys__semwait_signal_nocancel	: scno = 0x20001a7
-	const Sys__mac_mount		: scno = 0x20001a8
-	const Sys__mac_get_mount	: scno = 0x20001a9
-	const Sys__mac_getfsstat	: scno = 0x20001aa
-	const Sysfsgetpath		: scno = 0x20001ab
-	const Sysaudit_session_self	: scno = 0x20001ac
-	const Sysaudit_session_join	: scno = 0x20001ad
-	const Syspid_suspend		: scno = 0x20001ae
-	const Syspid_resume		: scno = 0x20001af
-	const Sysfileport_makeport	: scno = 0x20001b0
-	const Sysfileport_makefd	: scno = 0x20001b1
-
-	extern const syscall : (sc:scno, args:... -> int64)
-
-	const exit	: (status:int64 -> void)
-	const getpid	: ( -> int64)
-	const kill	: (pid:int64, sig:int64 -> int64)
-	const open	: (path:byte[:], opts:fdopt, mode:int64 -> int64)
-	const close	: (fd:int64 -> int64)
-	const creat	: (path:byte[:], mode:int64 -> int64)
-	const read	: (fd:int64, buf:byte[:] -> int64)
-	const write	: (fd:int64, buf:byte[:] -> int64)
-	const lseek	: (fd:int64, off:uint64, whence:int64 -> int64)
-	const fstat	: (fd:int64, sb:statbuf* -> int64)
-	const munmap	: (addr:byte*, len:size -> int64)
-	const mmap	: (addr:byte*, len:size, prot:mprot, flags:mopt, fd:int64, off:off -> byte*)
-;;
-
-const exit	= {status;		syscall(Sysexit, 1);}
-const getpid	= {;			-> syscall(Sysgetpid, 1);}
-const kill	= {pid, sig;		-> syscall(Syskill, pid, sig);}
-const open	= {path, opts, mode;	-> syscall(Sysopen, path castto(char*), opts);}
-const close	= {fd;			-> syscall(Sysclose, fd);}
-const creat	= {path, mode;		-> open(path, Ocreat | Otrunc | Owronly, mode);}
-const read	= {fd, buf;		-> syscall(Sysread, fd, buf castto(char*), buf.len);}
-const write	= {fd, buf;		-> syscall(Syswrite, fd, buf castto(char*), buf.len castto(size));}
-const lseek	= {fd, off, whence;	-> syscall(Syslseek, fd, off, whence);}
-const fstat	= {fd, sb;		-> syscall(Sysfstat, fd, sb);}
-const munmap	= {addr, len;		-> syscall(Sysmunmap, addr, len);}
-const mmap	= {addr, len, prot, flags, fd, off;	-> syscall(Sysmmap, addr, len, prot, flags, fd, off) castto(byte*);}
--- a/syscall-linux.s
+++ /dev/null
@@ -1,22 +1,0 @@
-.globl std$syscall
-std$syscall:
-	pushq %rbp
-	/*
-	hack: We load 6 args regardless of
-	how many we actually have. This may
-	load junk values, but if the syscall
-	doesn't use them, it's going to be
-	harmless.
-	 */
-	movq 16(%rsp),%rax
-	movq 24(%rsp),%rdi
-	movq 32(%rsp),%rsi
-	movq 40(%rsp),%rdx
-	movq 48(%rsp),%r10
-	movq 56(%rsp),%r8
-	movq 64(%rsp),%r9
-
-	syscall
-
-	popq %rbp
-	ret
--- a/syscall-osx.s
+++ /dev/null
@@ -1,22 +1,0 @@
-.globl _std$syscall
-_std$syscall:
-	pushq %rbp
-	/*
-	hack: We load 6 args regardless of
-	how many we actually have. This may
-	load junk values, but if the syscall
-	doesn't use them, it's going to be
-	harmless.
-	 */
-	movq 16(%rsp),%rax
-	movq 24(%rsp),%rdi
-	movq 32(%rsp),%rsi
-	movq 40(%rsp),%rdx
-	movq 48(%rsp),%r10
-	movq 56(%rsp),%r8
-	movq 64(%rsp),%r9
-
-	syscall
-
-	popq %rbp
-	ret
--- a/syscall.s
+++ /dev/null
@@ -1,32 +1,0 @@
-.globl std$syscall
-std$syscall:
-	pushl %ebp
-	/*
-	   hack: 6 args uses %ebp, so we index
-	   relative to %esp.
-
-           hack: We load 6 args regardless of
-           how many we actually have. This may
-           load junk values, but if the syscall
-           doesn't use them, it's going to be
-           harmless.
-	 */
-	movl 8(%esp),%eax
-	movl 12(%esp),%ebx
-	movl 16(%esp),%ecx
-	movl 20(%esp),%edx
-	movl 24(%esp),%esi
-	movl 28(%esp),%edi
-	movl 32(%esp),%ebp
-        int $0x80
-	popl %ebp
-	ret
-
-.globl _std$syscall
-_std$syscall:
-        popl %ecx	/* return address */
-	popl %eax       /* call num */
-	pushl %ecx
-        int $0x80
-	pushl %ecx	/* put the return address back */
-	ret
--- a/test.myr
+++ /dev/null
@@ -1,69 +1,0 @@
-use std
-
-const main = {
-	var x : byte*[1024]
-	var sz
-	var i
-
-	/* try the byte allocator for large variety of sizes. */
-	for sz = 1; sz < 65536; sz *= 2
-		for i = 0; i < 1024; i++
-			x[i] = std.bytealloc(sz)
-		;;
-		for i = 0; i < 1024; i++
-			std.bytefree(x[i], sz)
-		;;
-	;;
-	
-	/* make sure the generic allocator works */
-	for i = 0; i < 1024; i++
-		x[i] = std.alloc()
-	;;
-	for i = 0; i < 1024; i++
-		std.free(x[i])
-	;;
-	std.write(1, "Hello, 世界\n")
-	chartypes()
-	testrng()
-	std.put("format output %i %i %s %s\n", 123, 321, "asdf", "מִלָּה")
-	std.put("format with no args\n")
-}
-
-const chartypes = {
-	var s
-	var c
-	var buf : byte[32]
-
-	s = " 1世界 äa\n"
-	while s.len != 0
-		(c, s) = std.striter(s)
-		if std.isspace(c)
-			std.write(1, "Space\n")
-		elif std.isalpha(c)
-			std.write(1, "Alpha\n")
-		elif std.isnum(c)
-			std.write(1, "Num\n")
-		else
-			std.write(1, "Dunno\n")
-		;;
-		if !std.encode(buf[:std.charlen(c)], c)
-			std.write(1, "couldn't encode\n")
-		;;
-		std.write(1, buf[:std.charlen(c)])
-		std.write(1, "\n")
-	;;
-	if !std.encode(buf[0:3], -1)
-		std.write(1, "couldn't encode\n")
-	;;
-}
-
-const testrng = {
-	var r : std.rng*
-	var i
-
-	r = std.mksrng(10)
-	for i = 0; i < 10; i++
-		std.put("r[%i] = %l\n", i, std.rand32(r) castto(int64))
-	;;
-	std.put("\n");
-}
--- a/types.myr
+++ /dev/null
@@ -1,5 +1,0 @@
-pkg std =
-	type size	= uint64	/* spans entire address space */
-	type off	= uint64	/* file offsets */
-	type intptr	= uint64	/* can hold any pointer losslessly */
-;;
--- a/utf.myr
+++ /dev/null
@@ -1,107 +1,0 @@
-use "die.use"
-use "sys.use"
-use "types.use"
-
-pkg std =
-	const Badchar	: char = -1 castto(char)
-
-	const charlen	: (chr : char -> size)
-	const encode	: (buf : byte[:], chr : char -> size)
-	const decode	: (buf : byte[:] -> char)
-	const striter	: (str : byte[:] -> [char, byte[:]])
-
-	const strjoin	: (lst : byte[:][:], delim:byte[:] -> byte[:])
-	const strsep	: (str : byte[:], delim:byte[:] -> byte[:][:])
-	const strbjoin	: (lst : byte[:][:], delim:byte[:] -> byte[:])
-	const strbsep	: (str : byte[:], delim:byte[:] -> byte[:][:])
-;;
-
-const charlen = {c
-	if c < 0x80
-		-> 1
-	elif c < 0x800
-		-> 2
-	elif c < 0x10000
-		-> 3
-	elif c < 0x200000
-		-> 4
-	else
-		-> -1
-	;;
-}
-
-const encode = {buf, c
-	var len
-	var mark
-	var i
-
-	len = charlen(c)
-	if len < 0 || buf.len < len
-		-> -1
-	;;
-
-	if (len == 1)
-		mark = 0
-	else
-		mark = (((1 << (8 - len)) - 1) ^ 0xff) castto(char)
-	;;
-
-	for i = len - 1; i > 0; i--
-		buf[i] = (c & 0x3f | 0x80) castto(byte)
-		c >>= 6
-	;;
-
-	buf[0] = (c | mark) castto(byte)
-	-> len
-}
-
-const decode = {buf
-	var c
-	var b
-
-	(c, b) = striter(buf)
-	-> c
-}
-
-const striter = {str
-	var len
-	var mask
-	var chr
-	var i
-	var c
-	var tmp
-
-	if !str.len
-		/* empty string: no resync needed */
-		-> (Badchar, str)
-	;;
-	c = str[0]
-	len = 0
-	if c & 0x80 == 0	/* 0b0xxx_xxxx */
-		len = 1
-	elif c & 0xe0 == 0xc0	/* 0b110x_xxxx */
-		len = 2
-	elif c & 0xf0 == 0xe0 	/* 0b1110_xxxx */
-		len = 3
-	elif c & 0xf8 == 0xf0 	/* 0b1111_0xxx */
-		len = 4
-	else
-		/* skip one char forward so we can try
-		   resyncing the character stream */
-		-> (Badchar, str[1:])
-	;;
-
-	if len == 0 || len > str.len
-		/* again, we want to try to resync */
-		-> (Badchar, str[1:])
-	;;
-
-	mask = (1 << (8 - len)) - 1
-	chr = (c castto(uint32)) & mask
-	for i = 1; i < len; i++
-		tmp = str[i] castto(uint32)
-		chr = (chr << 6) | (tmp & 0x3f)
-	;;
-
-	-> (chr castto(char), str[len:])
-}
--- a/varargs.myr
+++ /dev/null
@@ -1,52 +1,0 @@
-use "types.use"
-
-pkg std =
-	type valist
-
-	const vastart	: (args : ...* -> valist)
-	generic vanext	: (ap : valist -> [@a, valist])
-;;
-
-type valist = byte*
-
-/* 
- * a valist is really just a pointer to the varargs.
- * we assume that these sit on the stack nicely,
- * and don't need special handling to get to.
- * 
- * This will be a problem when we switch to a
- * register based convention. We might want to
- * force varargs onto the stack regardless.
- */
-const vastart = {args
-	-> args castto(valist)
-}
-
-generic vanext = {ap -> [@a, valist]
-	var v : @a
-	var align
-	var p
-
-	/*
-	 Assumptions about the ABI:
-	 * all types smaller than a word are
-	 * aligned to their own size. Larger
-	 * types are aligned to word size.
-	 */
-	if sizeof(@a) > 8
-		align = 8
-	else
-		align = sizeof(@a)
-	;;
-
-	/* apply the alignment to the arg pointer */
-	p = ap castto(intptr)
-	p = (p + align - 1) & ~(align - 1)
-	ap = p castto(valist)
-
-	v = *(ap castto(@a*))
-
-	/* only move on after we read through the value */
-	ap = ((p castto(intptr)) + sizeof(@a)) castto(valist)
-	-> (v, ap)
-}