summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--6/Makefile2
-rw-r--r--6/blob.c1
-rw-r--r--6/gen.c1
-rw-r--r--6/gengas.c1
-rw-r--r--6/genp9.c1
-rw-r--r--6/isel.c1
-rw-r--r--6/locs.c1
-rw-r--r--6/main.c1
-rw-r--r--6/peep.c1
-rw-r--r--6/ra.c1
-rw-r--r--6/simp.c1
-rw-r--r--6/typeinfo.c1
-rw-r--r--Makefile1
-rw-r--r--mi/Makefile2
-rw-r--r--mi/cfg.c1
-rw-r--r--mi/dfcheck.c1
-rw-r--r--mi/flatten.c1
-rw-r--r--mi/match.c1
-rw-r--r--mi/reaching.c1
-rw-r--r--muse/Makefile2
-rw-r--r--muse/muse.c1
-rw-r--r--parse/Makefile30
-rw-r--r--parse/bitset.c1
-rw-r--r--parse/dump.c1
-rw-r--r--parse/fold.c1
-rw-r--r--parse/gram.y1
-rw-r--r--parse/infer.c1
-rw-r--r--parse/names.c1
-rw-r--r--parse/node.c1
-rw-r--r--parse/parse.h135
-rw-r--r--parse/specialize.c1
-rw-r--r--parse/stab.c1
-rw-r--r--parse/tok.c1
-rw-r--r--parse/type.c1
-rw-r--r--parse/use.c1
-rw-r--r--util/htab.c (renamed from parse/htab.c)2
-rw-r--r--util/util.c (renamed from parse/util.c)39
-rw-r--r--util/util.h129
38 files changed, 186 insertions, 185 deletions
diff --git a/6/Makefile b/6/Makefile
index 6055a80..41c8a06 100644
--- a/6/Makefile
+++ b/6/Makefile
@@ -12,7 +12,7 @@ OBJ= \
simp.o \
typeinfo.o \
-DEPS=../parse/libparse.a ../mi/libmi.a
+DEPS=../parse/libparse.a ../mi/libmi.a ../util/libutil.a
include ../config.mk
include ../mk/c.mk
diff --git a/6/blob.c b/6/blob.c
index e7b6754..db06220 100644
--- a/6/blob.c
+++ b/6/blob.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/6/gen.c b/6/gen.c
index af307b5..25df139 100644
--- a/6/gen.c
+++ b/6/gen.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/6/gengas.c b/6/gengas.c
index d731b0b..7581e29 100644
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/6/genp9.c b/6/genp9.c
index 68e9d1b..5d9a27e 100644
--- a/6/genp9.c
+++ b/6/genp9.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/6/isel.c b/6/isel.c
index 4042428..2b04437 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -11,6 +11,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/6/locs.c b/6/locs.c
index f99953d..8e909e5 100644
--- a/6/locs.c
+++ b/6/locs.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/6/main.c b/6/main.c
index dbd77aa..c67adf8 100644
--- a/6/main.c
+++ b/6/main.c
@@ -13,6 +13,7 @@
#include <sys/time.h>
#include <sys/wait.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/6/peep.c b/6/peep.c
index cb31911..e4aeb9c 100644
--- a/6/peep.c
+++ b/6/peep.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/6/ra.c b/6/ra.c
index a9a8f2a..085f04c 100644
--- a/6/ra.c
+++ b/6/ra.c
@@ -7,6 +7,7 @@
#include <limits.h>
#include <string.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/6/simp.c b/6/simp.c
index 7871b63..1c0b1d8 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/6/typeinfo.c b/6/typeinfo.c
index b02a5b2..8073713 100644
--- a/6/typeinfo.c
+++ b/6/typeinfo.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "asm.h"
diff --git a/Makefile b/Makefile
index 293734c..b18508c 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,7 @@ SUB = parse \
6 \
muse \
rt \
+ util \
doc
EXTRA=buildmyr
diff --git a/mi/Makefile b/mi/Makefile
index 2942d83..985064a 100644
--- a/mi/Makefile
+++ b/mi/Makefile
@@ -7,6 +7,6 @@ OBJ=\
reaching.o \
-DEPS=../parse/libparse.a
+DEPS=../parse/libparse.a ../util/libutil.a
include ../mk/c.mk
diff --git a/mi/cfg.c b/mi/cfg.c
index a269997..2009960 100644
--- a/mi/cfg.c
+++ b/mi/cfg.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
diff --git a/mi/dfcheck.c b/mi/dfcheck.c
index a785fc3..5aeb174 100644
--- a/mi/dfcheck.c
+++ b/mi/dfcheck.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
diff --git a/mi/flatten.c b/mi/flatten.c
index c1a7aa2..cc0a6a8 100644
--- a/mi/flatten.c
+++ b/mi/flatten.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
#include "../config.h"
diff --git a/mi/match.c b/mi/match.c
index 95e09f7..beecdbb 100644
--- a/mi/match.c
+++ b/mi/match.c
@@ -9,6 +9,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
diff --git a/mi/reaching.c b/mi/reaching.c
index aaaaedc..8442b19 100644
--- a/mi/reaching.c
+++ b/mi/reaching.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "mi.h"
diff --git a/muse/Makefile b/muse/Makefile
index 1ec6377..1d23803 100644
--- a/muse/Makefile
+++ b/muse/Makefile
@@ -2,7 +2,7 @@ INSTBIN=muse
BIN=muse
OBJ=muse.o
-DEPS=../parse/libparse.a
+DEPS=../parse/libparse.a ../util/libutil.a
include ../mk/c.mk
include ../config.mk
diff --git a/muse/muse.c b/muse/muse.c
index e534303..8b884ab 100644
--- a/muse/muse.c
+++ b/muse/muse.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "../config.h"
diff --git a/parse/Makefile b/parse/Makefile
index 1eaac98..4df4b0c 100644
--- a/parse/Makefile
+++ b/parse/Makefile
@@ -1,21 +1,23 @@
LIB=libparse.a
-OBJ=bitset.o \
- dump.o \
- fold.o \
- gram.o \
- htab.o \
- infer.o \
- names.o \
- node.o \
- specialize.o \
- stab.o \
- tok.o \
- type.o \
- use.o \
- util.o
+OBJ=\
+ bitset.o \
+ dump.o \
+ err.o \
+ fold.o \
+ gram.o \
+ infer.o \
+ names.o \
+ node.o \
+ specialize.o \
+ stab.o \
+ tok.o \
+ type.o \
+ use.o \
GENHDR=gram.h
CLEAN=gram.c gram.h
+DEPS=../util/libutil.a
+
include ../mk/lexyacc.mk
include ../mk/c.mk
diff --git a/parse/bitset.c b/parse/bitset.c
index ac72f6e..ea3c398 100644
--- a/parse/bitset.c
+++ b/parse/bitset.c
@@ -6,6 +6,7 @@
#include <limits.h>
#include <string.h>
+#include "util.h"
#include "parse.h"
#define Sizetbits (CHAR_BIT * sizeof(size_t)) /* used in graph reprs */
diff --git a/parse/dump.c b/parse/dump.c
index c9eb139..7cb7713 100644
--- a/parse/dump.c
+++ b/parse/dump.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
/* outputs a fully qualified name */
diff --git a/parse/fold.c b/parse/fold.c
index 8edd836..8c58312 100644
--- a/parse/fold.c
+++ b/parse/fold.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
static int getintlit(Node *n, vlong *v)
diff --git a/parse/gram.y b/parse/gram.y
index 732ad9b..5509e90 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -14,6 +14,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
diff --git a/parse/infer.c b/parse/infer.c
index 4f4809a..350ea5e 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -12,6 +12,7 @@
#include <unistd.h>
#include <assert.h>
+#include "util.h"
#include "parse.h"
typedef struct Inferstate Inferstate;
diff --git a/parse/names.c b/parse/names.c
index 31f2b4d..f1da72c 100644
--- a/parse/names.c
+++ b/parse/names.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
char *opstr[] = {
diff --git a/parse/node.c b/parse/node.c
index 038eec7..59bfcd2 100644
--- a/parse/node.c
+++ b/parse/node.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
Node **nodes;
diff --git a/parse/parse.h b/parse/parse.h
index 55b530f..1d3599e 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -1,23 +1,6 @@
-#ifdef __GNUC__
-#define FATAL __attribute__((noreturn))
-#else
-#define FATAL
-#endif
-
#define Abiversion 10
-typedef uint8_t byte;
-typedef unsigned int uint;
-typedef unsigned long ulong;
-typedef long long vlong;
-typedef unsigned long long uvlong;
-
typedef struct Srcloc Srcloc;
-typedef struct Bitset Bitset;
-typedef struct Optctx Optctx;
-typedef struct Strbuf Strbuf;
-typedef struct Htab Htab;
-typedef struct Str Str;
typedef struct Tysubst Tysubst;
typedef struct Tok Tok;
@@ -71,22 +54,11 @@ typedef enum {
#define Zloc ((Srcloc){-1, 0})
-struct Strbuf {
- char *buf;
- size_t sz;
- size_t len;
-};
-
struct Srcloc {
int line;
int file;
};
-struct Str {
- size_t len;
- char *buf;
-};
-
typedef enum {
Visintern,
Visexport,
@@ -99,22 +71,6 @@ typedef enum {
Dclextern = 1 << 1,
} Dclflags;
-struct Bitset {
- size_t nchunks;
- size_t *chunks;
-};
-
-struct Htab {
- size_t nelt;
- size_t ndead;
- size_t sz;
- ulong (*hash)(void *k);
- int (*cmp)(void *a, void *b);
- void **keys;
- void **vals;
- ulong *hashes;
- char *dead;
-};
struct Tok {
int type;
@@ -381,22 +337,6 @@ struct Node {
};
};
-struct Optctx {
- /* public exports */
- char *optarg;
- char **args;
- size_t nargs;
-
- /* internal state */
- char *optstr;
- char **optargs;
- size_t noptargs;
- size_t argidx;
- int optdone; /* seen -- */
- int finished;
- char *curarg;
-};
-
/* globals */
extern Srcloc curloc;
extern char *filename;
@@ -451,24 +391,9 @@ static inline int bshas(Bitset *bs, size_t elt)
0;
}
-Htab *mkht(ulong (*hash)(void *key), int (*cmp)(void *k1, void *k2));
-void htfree(Htab *ht);
-int htput(Htab *ht, void *k, void *v);
-void htdel(Htab *ht, void *k);
-void *htget(Htab *ht, void *k);
-int hthas(Htab *ht, void *k);
-void **htkeys(Htab *ht, size_t *nkeys);
/* useful key types */
int liteq(Node *a, Node *b);
int litvaleq(Node *a, Node *b);
-ulong strhash(void *key);
-int streq(void *a, void *b);
-ulong strlithash(void *key);
-int strliteq(void *a, void *b);
-ulong ptrhash(void *key);
-int ptreq(void *a, void *b);
-ulong inthash(uint64_t key);
-int inteq(uint64_t a, uint64_t b);
ulong tyhash(void *t);
int tyeq(void *a, void *b);
ulong namehash(void *t);
@@ -476,26 +401,17 @@ int nameeq(void *a, void *b);
ulong nsnamehash(void *t);
int nsnameeq(void *a, void *b);
-/* util functions */
+/* parsing etc */
+void tokinit(char *file);
+int yylex(void);
+int yyparse(void);
+
+/* locations */
char *fname(Srcloc l);
int lnum(Srcloc l);
-void *zalloc(size_t size);
-void *xalloc(size_t size);
-void *zrealloc(void *p, size_t oldsz, size_t size);
-void *xrealloc(void *p, size_t size);
-void die(char *msg, ...) FATAL;
void fatal(Node *n, char *fmt, ...) FATAL;
void lfatal(Srcloc l, char *fmt, ...) FATAL;
void lfatalv(Srcloc l, char *fmt, va_list ap) FATAL;
-char *strdupn(char *s, size_t len);
-char *strjoin(char *u, char *v);
-void *memdup(void *mem, size_t len);
-size_t bprintf(char *buf, size_t len, char *fmt, ...);
-
-/* parsing etc */
-void tokinit(char *file);
-int yylex(void);
-int yyparse(void);
/* stab creation */
Stab *mkstab(int isfunc);
@@ -665,48 +581,9 @@ void *lpop(void *l, size_t *len);
void ldel(void *l, size_t *len, size_t idx);
void lfree(void *l, size_t *len);
-/* serializing/unserializing */
-void be64(vlong v, byte buf[8]);
-vlong host64(byte buf[8]);
-void be32(long v, byte buf[4]);
-long host32(byte buf[4]);
-static inline intptr_t ptoi(void *p) { return (intptr_t)p; }
-static inline void *itop(intptr_t i) { return (void *)i; }
-
-void wrbuf(FILE *fd, void *buf, size_t sz);
-void rdbuf(FILE *fd, void *buf, size_t sz);
-char rdbyte(FILE *fd);
-void wrbyte(FILE *fd, char val);
-char rdbyte(FILE *fd);
-void wrint(FILE *fd, long val);
-long rdint(FILE *fd);
-void wrstr(FILE *fd, char *val);
-char *rdstr(FILE *fd);
-void wrlenstr(FILE *fd, Str str);
-void rdlenstr(FILE *fd, Str *str);
-void wrflt(FILE *fd, double val);
-double rdflt(FILE *fd);
-void wrbool(FILE *fd, int val);
-int rdbool(FILE *fd);
-
-size_t max(size_t a, size_t b);
-size_t min(size_t a, size_t b);
-size_t align(size_t sz, size_t a);
-
-/* string buffer */
-Strbuf *mksb();
-char *sbfin(Strbuf *sb);
-void sbputs(Strbuf *sb, char *s);
-void sbputb(Strbuf *sb, char b);
-
/* suffix replacement */
char *swapsuffix(char *buf, size_t sz, char *s, char *suf, char *swap);
-/* indented printf */
-void indentf(int depth, char *fmt, ...);
-void findentf(FILE *fd, int depth, char *fmt, ...);
-void vfindentf(FILE *fd, int depth, char *fmt, va_list ap);
-
/* Options to control the compilation */
extern char debugopt[128];
extern int asmonly;
diff --git a/parse/specialize.c b/parse/specialize.c
index 72f922f..4df9729 100644
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
static Node *specializenode(Node *g, Tysubst *tsmap);
diff --git a/parse/stab.c b/parse/stab.c
index 2d55f99..f23b1fd 100644
--- a/parse/stab.c
+++ b/parse/stab.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
/* Allows us to look up types/traits by name nodes */
diff --git a/parse/tok.c b/parse/tok.c
index 17fef0f..7ab2874 100644
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -11,6 +11,7 @@
#include <errno.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
#include "gram.h"
diff --git a/parse/type.c b/parse/type.c
index d711b6b..ea1c2ea 100644
--- a/parse/type.c
+++ b/parse/type.c
@@ -11,6 +11,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
typedef struct Typename Typename;
diff --git a/parse/use.c b/parse/use.c
index 3ab6ff5..f0c154c 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "util.h"
#include "parse.h"
static void wrtype(FILE *fd, Type *val);
diff --git a/parse/htab.c b/util/htab.c
index a8f3633..7c616b7 100644
--- a/parse/htab.c
+++ b/util/htab.c
@@ -6,7 +6,7 @@
#include <limits.h>
#include <string.h>
-#include "parse.h"
+#include "util.h"
#define Initsz 16
diff --git a/parse/util.c b/util/util.c
index 33c2e0e..2e95786 100644
--- a/parse/util.c
+++ b/util/util.c
@@ -11,7 +11,7 @@
#include <fcntl.h>
#include <unistd.h>
-#include "parse.h"
+#include "util.h"
/* malloc wrappers */
void *zalloc(size_t sz)
@@ -52,43 +52,6 @@ void *xrealloc(void *mem, size_t sz)
return mem;
}
-/* errors */
-void die(char *msg, ...)
-{
- va_list ap;
-
- va_start(ap, msg);
- vfprintf(stderr, msg, ap);
- fprintf(stderr, "\n");
- va_end(ap);
- abort();
-}
-
-void fatal(Node *n, char *msg, ...)
-{
- va_list ap;
-
- va_start(ap, msg);
- lfatalv(n->loc, msg, ap);
- va_end(ap);
-}
-
-void lfatal(Srcloc l, char *msg, ...)
-{
- va_list ap;
-
- va_start(ap, msg);
- lfatalv(l, msg, ap);
- va_end(ap);
-}
-
-void lfatalv(Srcloc l, char *msg, va_list ap)
-{
- fprintf(stdout, "%s:%d: ", fname(l), lnum(l));
- vfprintf(stdout, msg, ap);
- fprintf(stdout, "\n");
- exit(1);
-}
/* Some systems don't have strndup. */
char *strdupn(char *s, size_t len)
diff --git a/util/util.h b/util/util.h
new file mode 100644
index 0000000..e16848d
--- /dev/null
+++ b/util/util.h
@@ -0,0 +1,129 @@
+#ifdef __GNUC__
+#define FATAL __attribute__((noreturn))
+#else
+#define FATAL
+#endif
+
+typedef uint8_t byte;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+
+typedef struct Htab Htab;
+typedef struct Bitset Bitset;
+typedef struct Optctx Optctx;
+typedef struct Str Str;
+typedef struct Strbuf Strbuf;
+
+struct Htab {
+ size_t nelt;
+ size_t ndead;
+ size_t sz;
+ ulong (*hash)(void *k);
+ int (*cmp)(void *a, void *b);
+ void **keys;
+ void **vals;
+ ulong *hashes;
+ char *dead;
+};
+
+struct Bitset {
+ size_t nchunks;
+ size_t *chunks;
+};
+
+struct Optctx {
+ /* public exports */
+ char *optarg;
+ char **args;
+ size_t nargs;
+
+ /* internal state */
+ char *optstr;
+ char **optargs;
+ size_t noptargs;
+ size_t argidx;
+ int optdone; /* seen -- */
+ int finished;
+ char *curarg;
+};
+
+struct Str {
+ size_t len;
+ char *buf;
+};
+
+struct Strbuf {
+ char *buf;
+ size_t sz;
+ size_t len;
+};
+
+/* string buffer */
+Strbuf *mksb();
+char *sbfin(Strbuf *sb);
+void sbputs(Strbuf *sb, char *s);
+void sbputb(Strbuf *sb, char b);
+
+/* hash tables */
+Htab *mkht(ulong (*hash)(void *key), int (*cmp)(void *k1, void *k2));
+void htfree(Htab *ht);
+int htput(Htab *ht, void *k, void *v);
+void htdel(Htab *ht, void *k);
+void *htget(Htab *ht, void *k);
+int hthas(Htab *ht, void *k);
+void **htkeys(Htab *ht, size_t *nkeys);
+ulong strhash(void *key);
+int streq(void *a, void *b);
+ulong strlithash(void *key);
+int strliteq(void *a, void *b);
+ulong ptrhash(void *key);
+int ptreq(void *a, void *b);
+ulong inthash(uint64_t key);
+int inteq(uint64_t a, uint64_t b);
+
+/* util functions */
+void *zalloc(size_t size);
+void *xalloc(size_t size);
+void *zrealloc(void *p, size_t oldsz, size_t size);
+void *xrealloc(void *p, size_t size);
+void die(char *msg, ...) FATAL;
+char *strdupn(char *s, size_t len);
+char *strjoin(char *u, char *v);
+void *memdup(void *mem, size_t len);
+size_t bprintf(char *buf, size_t len, char *fmt, ...);
+
+/* indented printf */
+void indentf(int depth, char *fmt, ...);
+void findentf(FILE *fd, int depth, char *fmt, ...);
+void vfindentf(FILE *fd, int depth, char *fmt, va_list ap);
+
+/* serializing/unserializing */
+void be64(vlong v, byte buf[8]);
+vlong host64(byte buf[8]);
+void be32(long v, byte buf[4]);
+long host32(byte buf[4]);
+static inline intptr_t ptoi(void *p) { return (intptr_t)p; }
+static inline void *itop(intptr_t i) { return (void *)i; }
+
+void wrbuf(FILE *fd, void *buf, size_t sz);
+void rdbuf(FILE *fd, void *buf, size_t sz);
+char rdbyte(FILE *fd);
+void wrbyte(FILE *fd, char val);
+char rdbyte(FILE *fd);
+void wrint(FILE *fd, long val);
+long rdint(FILE *fd);
+void wrstr(FILE *fd, char *val);
+char *rdstr(FILE *fd);
+void wrlenstr(FILE *fd, Str str);
+void rdlenstr(FILE *fd, Str *str);
+void wrflt(FILE *fd, double val);
+double rdflt(FILE *fd);
+void wrbool(FILE *fd, int val);
+int rdbool(FILE *fd);
+
+size_t max(size_t a, size_t b);
+size_t min(size_t a, size_t b);
+size_t align(size_t sz, size_t a);
+