diff options
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | include/base.h | 38 | ||||
-rw-r--r-- | include/libbio.h | 24 | ||||
-rw-r--r-- | include/libmath/blas.h | 12 | ||||
-rw-r--r-- | include/libutf.h | 2 | ||||
-rw-r--r-- | include/u.h | 130 | ||||
-rw-r--r-- | share/dynamic.mk | 12 | ||||
-rw-r--r-- | src/base/bufio/reader.c | 2 | ||||
-rw-r--r-- | src/base/bufio/unget.c | 2 | ||||
-rw-r--r-- | src/base/coro/coro.c | 2 | ||||
-rw-r--r-- | src/base/flate/reader.c | 4 | ||||
-rw-r--r-- | src/base/flate/writer.c | 4 | ||||
-rw-r--r-- | src/base/gz/flush.c | 2 | ||||
-rw-r--r-- | src/base/gz/get.c | 2 | ||||
-rw-r--r-- | src/base/gz/open.c | 2 | ||||
-rw-r--r-- | src/base/gz/printf.c | 2 | ||||
-rw-r--r-- | src/base/gz/put.c | 2 | ||||
-rw-r--r-- | src/base/gz/putstring.c | 2 | ||||
-rw-r--r-- | src/base/io/interface.c | 4 | ||||
-rw-r--r-- | src/base/io/open.c | 2 | ||||
-rw-r--r-- | src/base/io/stat.c | 2 | ||||
-rw-r--r-- | src/base/io/unget.c | 2 | ||||
-rw-r--r-- | src/base/mmap/mmap.c | 2 | ||||
-rw-r--r-- | src/cmd/term/term.c | 2 | ||||
-rw-r--r-- | src/libbio/fasta.c | 30 | ||||
-rw-r--r-- | src/libbio/newick.c | 10 | ||||
-rw-r--r-- | src/libbio/phylo.c | 26 | ||||
-rw-r--r-- | src/libmath/blas2body | 2 |
28 files changed, 196 insertions, 139 deletions
@@ -4,8 +4,11 @@ AR := ar AS := nasm PKG := PKG_CONFIG_PATH=lib/pkgconfig pkg-config -WL_PROTO:=$(shell $(PKG) --variable=pkgdatadir wayland-protocols) -WL_SCAN:=$(shell $(PKG) --variable=wayland_scanner wayland-scanner) +OS := linux +ARCH := amd64 + +#WL_PROTO:=$(shell $(PKG) --variable=pkgdatadir wayland-protocols) +#WL_SCAN:=$(shell $(PKG) --variable=wayland_scanner wayland-scanner) # All needed build directories INC_DIR := include @@ -24,7 +27,7 @@ CFINI := `gcc --print-file-name=crtendS.o` $(LIB_DIR)/crt/x86_64/crtn.o CFLAGS := -g -march=native -fno-strict-aliasing -fwrapv -fms-extensions -Wno-microsoft-anon-tag STATIC := -nodefaultlibs -nostartfiles -nostdinc -static AFLAGS := -f elf64 -INCS := -I $(INC_DIR) -isystem $(INC_DIR)/vendor/libc +INCS := -I $(SYS_DIR)/$(OS)/$(ARCH) -I $(INC_DIR) -isystem $(INC_DIR)/vendor/libc ELIBS := -L$(LIB_DIR) -lc # Named generic rules (must be evaluated lazily) diff --git a/include/base.h b/include/base.h index ca229b3..822cc09 100644 --- a/include/base.h +++ b/include/base.h @@ -86,7 +86,7 @@ typedef struct Coro Coro; Coro* coro·make(uintptr stk, uintptr (*func)(Coro*, uintptr)); uintptr coro·yield(Coro *c, uintptr arg); -error coro·free(Coro *c); +int coro·free(Coro *c); // ----------------------------------------------------------------------------- // strings @@ -144,13 +144,13 @@ enum /* file handling */ io·Stream *io·open(byte *name, byte *mode); int io·fd(io·Stream *s); -error io·stat(io·Stream *s, io·Stat *buf); -error io·close(io·Stream *s); +int io·stat(io·Stream *s, io·Stat *buf); +int io·close(io·Stream *s); byte io·getbyte(io·Stream *s); -error io·ungetbyte(io·Stream *s, byte c); +int io·ungetbyte(io·Stream *s, byte c); int io·read(io·Stream *s, int sz, int n, void *buf); int io·readln(io·Stream *s, int n, byte *buf); -error io·putbyte(io·Stream *s, byte c); +int io·putbyte(io·Stream *s, byte c); int io·putstring(io·Stream *s, string str); int io·write(io·Stream *s, int sz, int n, void *buf); int io·flush(io·Stream *s); @@ -172,7 +172,7 @@ extern io·Reader sys·Reader; typedef struct io·Peeker { byte (*get)(void*); - error (*unget)(void*, byte); + int (*unget)(void*, byte); } io·Peeker; extern io·Peeker sys·Peeker; @@ -205,8 +205,8 @@ extern io·Writer sys·Writer; typedef struct io·Putter { - error (*put) (void*, byte); - int (*puts)(void*, string); + int (*put) (void*, byte); + int (*puts)(void*, string); } io·Putter; extern io·Putter sys·Putter; @@ -254,10 +254,10 @@ struct io·Buffer byte buf[bufio·size + bufio·ungets]; }; -error bufio·initreader(io·Buffer *buf, io·Reader rdr, void *h); +int bufio·initreader(io·Buffer *buf, io·Reader rdr, void *h); void bufio·finireader(io·Buffer *buf); int bufio·getbyte(io·Buffer *buf); -error bufio·ungetbyte(io·Buffer *buf, byte c); +int bufio·ungetbyte(io·Buffer *buf, byte c); int bufio·read(io·Buffer *buf, int sz, int n, void *out); // ----------------------------------------------------------------------------- @@ -273,7 +273,7 @@ typedef struct mmap·Reader } mmap·Reader; mmap·Reader mmap·open(byte *name); -error mmap·close(mmap·Reader rdr); +int mmap·close(mmap·Reader rdr); // ----------------------------------------------------------------------------- // filesystem @@ -315,11 +315,11 @@ typedef struct flate·Writer flate·Writer; flate·Reader *flate·openreader(io·Reader rdr, void* r, mem·Allocator mem, void* m); int flate·read(flate·Reader *rdr, int sz, int n, void *buf); -error flate·closereader(flate·Reader *rdr); +int flate·closereader(flate·Reader *rdr); flate·Writer *flate·openwriter(io·Writer wtr, void* w, mem·Allocator mem, void* m); int flate·write(flate·Writer *wtr, int sz, int n, void *buf); -error flate·closewriter(flate·Writer *wtr); +int flate·closewriter(flate·Writer *wtr); // ----------------------------------------------------------------------------- // libgz @@ -339,16 +339,16 @@ extern io·PutWriter gz·PutWriter; extern io·ReadWriter gz·ReadWriter; gz·Stream *gz·open(byte *path, byte *mode); -error gz·close(gz·Stream* s); +int gz·close(gz·Stream* s); int gz·read(gz·Stream *s, int sz, int n, void* buf); int gz·readln(gz·Stream *s, int n, byte *buf); byte gz·getbyte(gz·Stream *s); -error gz·ungetbyte(gz·Stream *s, byte c); +int gz·ungetbyte(gz·Stream *s, byte c); int gz·write(gz·Stream *s, int sz, int n, void* buf); -error gz·putbyte(gz·Stream *s, byte str); -error gz·putstring(gz·Stream *s, byte *str); +int gz·putbyte(gz·Stream *s, byte str); +int gz·putstring(gz·Stream *s, byte *str); int gz·printf(gz·Stream *s, byte *fmt, ...); -error gz·flush(gz·Stream *s); +int gz·flush(gz·Stream *s); int gz·seek(gz·Stream *s, long off, enum SeekPos whence); long gz·tell(gz·Stream *s); @@ -388,7 +388,7 @@ void sort·string(uintptr n, byte* arr[]); // ----------------------------------------------------------------------------- // fast random number generation -error rng·init(uint64 seed); +int rng·init(uint64 seed); double rng·random(void); double rng·exponential(double lambda); bool rng·bernoulli(double f); diff --git a/include/libbio.h b/include/libbio.h index 9438b74..2e043fb 100644 --- a/include/libbio.h +++ b/include/libbio.h @@ -23,15 +23,15 @@ typedef struct bio·Tree } bio·Tree; /* clade manipulation */ -error phylo·addchild(bio·Node* parent, bio·Node* child); -error phylo·rmchild(bio·Node* parent, bio·Node* child); +int phylo·addchild(bio·Node* parent, bio·Node* child); +int phylo·rmchild(bio·Node* parent, bio·Node* child); /* clade statistics */ -error phylo·countnodes(bio·Node *node, int *n); -error phylo·countleafs(bio·Node *node, int *n); +int phylo·countnodes(bio·Node *node, int *n); +int phylo·countleafs(bio·Node *node, int *n); /* topological sorting */ -error phylo·ladderize(bio·Node *root); +int phylo·ladderize(bio·Node *root); double phylo·diameter(bio·Tree tree, int *len, bio·Node **path); /* generic computation on tree */ @@ -42,8 +42,8 @@ void *phylo·preorder(bio·Node *clade, void *(*op)(bio·Node*, void*), void *ct void phylo·getleafs(bio·Tree tree, bio·Node **leafs); /* newick i/o */ -error bio·readnewick(io·Peeker io, void* rdr, bio·Tree* tree); -error bio·writenewick(bio·Tree tree, io·Putter out, void*); +int bio·readnewick(io·Peeker io, void* rdr, bio·Tree* tree); +int bio·writenewick(bio·Tree tree, io·Putter out, void*); // ----------------------------------------------------------------------- // Sequences @@ -60,10 +60,10 @@ typedef struct bio·Seq } bio·Seq; bio·SeqReader *bio·openseq(io·Reader io, void *rdr, mem·Allocator mem, void *heap); -error bio·closeseq(bio·SeqReader *rdr); +int bio·closeseq(bio·SeqReader *rdr); -error bio·readfasta(bio·SeqReader *rdr, bio·Seq *seq); -error bio·readfastq(bio·SeqReader *rdr, bio·Seq *seq); +int bio·readfasta(bio·SeqReader *rdr, bio·Seq *seq); +int bio·readfastq(bio·SeqReader *rdr, bio·Seq *seq); -error bio·writefasta(io·Writer io, void *wtr, bio·Seq seq); -error bio·writefastq(io·Writer io, void *wtr, bio·Seq seq); +int bio·writefasta(io·Writer io, void *wtr, bio·Seq seq); +int bio·writefastq(io·Writer io, void *wtr, bio·Seq seq); diff --git a/include/libmath/blas.h b/include/libmath/blas.h index b8930a8..ba2cdcc 100644 --- a/include/libmath/blas.h +++ b/include/libmath/blas.h @@ -17,7 +17,7 @@ enum // level 1 void blas·frot(int len, float *x, int incx, float *y, int incy, float cos, float sin); void blas·frotg(float *a, float *b, float *cos, float *sin); -error blas·frotm(int len, float *x, int incx, float *y, int incy, float p[5]); +int blas·frotm(int len, float *x, int incx, float *y, int incy, float p[5]); void blas·fscale(int len, float a, float *x, int inc); void blas·fcopy(int len, float *x, int incx, float *y, int incy); void blas·fswap(int len, float *x, int incx, float *y, int incy); @@ -29,7 +29,7 @@ int blas·fargmax(int len, float *x, int inc); int blas·fargmin(int len, float *x, int inc); // level 2 -error blas·fgemv(uint f, int nrow, int ncol, float a, float *m, int incm, float *x, int incx, float b, float *y, int incy); +int blas·fgemv(uint f, int nrow, int ncol, float a, float *m, int incm, float *x, int incx, float b, float *y, int incy); void blas·fsymv(uint f, int n, float a, float* m, int incm, float *x, int incx, float b, float *y, int incy); void blas·fspmv(uint f, int n, float a, float* m, float *x, int incx, float b, float *y, int incm); void blas·ftrmv(uint f, int n, float* m, int incm, float *x, int incx); @@ -45,14 +45,14 @@ void blas·fgemm(uint tr1, uint tr2, int n1, int n2, int n3, float a, float *m void blas·ftrmm(uint f, int nrow, int ncol, float a, float *m1, float *m2); void blas·ftrsm(uint f, int nrow, int ncol, float a, float *m1, float *m2); -/* - * Doubles +/* + * Doubles */ // level 1 void blas·drot(int len, double *x, int incx, double *y, int incy, double cos, double sin); void blas·drotg(double *a, double *b, double *cos, double *sin); -error blas·drotm(int len, double *x, int incx, double *y, int incy, double p[5]); +int blas·drotm(int len, double *x, int incx, double *y, int incy, double p[5]); void blas·dscale(int len, double a, double *x, int inc); void blas·dcopy(int len, double *x, int incx, double *y, int incy); void blas·dswap(int len, double *x, int incx, double *y, int incy); @@ -64,7 +64,7 @@ int blas·dargmax(int len, double *x, int inc); int blas·dargmin(int len, double *x, int inc); // level 2 -error blas·dgemv(uint f, int nrow, int ncol, double a, double *m, int incm, double *x, int incx, double b, double *y, int incy); +int blas·dgemv(uint f, int nrow, int ncol, double a, double *m, int incm, double *x, int incx, double b, double *y, int incy); void blas·dsymv(uint f, int n, double a, double* m, int incm, double *x, int incx, double b, double *y, int incy); void blas·dspmv(uint f, int n, double a, double* m, double *x, int incx, double b, double *y, int incy); void blas·dtrmv(uint f, int n, double *m, int incm, double *x, int incx); diff --git a/include/libutf.h b/include/libutf.h index 25d6dee..846296c 100644 --- a/include/libutf.h +++ b/include/libutf.h @@ -1,7 +1,5 @@ #pragma once -typedef uint32 rune; - #define UTFmax 4 #define RuneErr 0xFFFDu #define RuneMax 0x10FFFFu diff --git a/include/u.h b/include/u.h index 3cf3c7b..cf5f53c 100644 --- a/include/u.h +++ b/include/u.h @@ -1,64 +1,120 @@ #pragma once
-// ------------------------------------------------------------------------
-// Freestanding headers
-
-#include <stdarg.h>
-#include <stdint.h>
-#include <stddef.h>
-#include <stdbool.h>
-#include <float.h>
-#include <limits.h>
+#include <bits.h>
// ------------------------------------------------------------------------
-// Modern type aliases
+// types
-typedef char byte;
-typedef unsigned char ubyte, uchar;
-typedef signed char sbyte, schar;
+/* useful aliases */
+typedef char byte;
+typedef signed char schar, sbyte;
+typedef unsigned char uchar, ubyte;
+typedef signed short sshort;
typedef unsigned short ushort;
-typedef signed short sshort;
-typedef unsigned int uint;
-typedef signed int sint;
+typedef signed int sint;
+typedef unsigned int uint;
+typedef signed long slong;
typedef unsigned long ulong;
-typedef signed long slong;
-typedef unsigned long ulong;
-typedef signed long slong;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef signed long long svlong;
-typedef long long vlong;
-typedef unsigned long long uvlong;
-typedef signed long long svlong;
+typedef _Bool bool;
-typedef uint8_t uint8;
-typedef uint16_t uint16;
-typedef uint32_t uint32;
-typedef uint64_t uint64;
+/* fixed width */
+typedef signed INT8 int8;
+typedef signed INT16 int16;
+typedef signed INT32 int32;
+typedef signed INT64 int64;
-typedef int8_t int8;
-typedef int16_t int16;
-typedef int32_t int32;
-typedef int64_t int64;
+typedef unsigned INT8 uint8;
+typedef unsigned INT16 uint16;
+typedef unsigned INT32 uint32;
+typedef unsigned INT64 uint64;
-typedef float float32;
-typedef double float64;
+typedef uint32 rune;
-typedef uintptr_t uintptr;
-typedef intptr_t intptr;
+/* pointer address */
+typedef ADDR intptr;
+typedef unsigned ADDR uintptr;
-typedef int error;
+#undef INT8
+#undef INT16
+#undef INT32
+#undef INT64
+#undef ADDR
-#define nil NULL
+// ------------------------------------------------------------------
+// global constants
+
+#define true 1
+#define false 0
+#define nil ((void*)0)
+
+/* limits */
+#define CHAR_BIT 8
+#define SCHAR_MIN (-128)
+#define SCHAR_MAX 127
+#define UCHAR_MAX 255
+
+#if '\xff' > 0
+# define CHAR_MIN 0
+# define CHAR_MAX UCHAR_MAX
+#else
+# define CHAR_MIN SCHAR_MIN
+# define CHAR_MAX SCHAR_MAX
+#endif
+
+#define SHRT_MIN (-1-0x7fff)
+#define SHRT_MAX 0x7fff
+#define USHRT_MAX 0xffff
+#define INT_MIN (-1-0x7fffffff)
+#define INT_MAX 0x7fffffff
+#define UINT_MAX 0xffffffffU
+#define LONG_MIN (-LONG_MAX-1)
+#define ULONG_MAX (2UL*LONG_MAX+1)
+#define LLONG_MIN (-LLONG_MAX-1)
+#define LLONG_MAX 0x7fffffffffffffffLL
+#define ULLONG_MAX (2ULL*LLONG_MAX+1)
+
+#define INT8_MIN (-1-0x7f)
+#define INT16_MIN (-1-0x7fff)
+#define INT32_MIN (-1-0x7fffffff)
+#define INT64_MIN (-1-0x7fffffffffffffff)
+
+#define INT8_MAX (0x7f)
+#define INT16_MAX (0x7fff)
+#define INT32_MAX (0x7fffffff)
+#define INT64_MAX (0x7fffffffffffffff)
+
+#define UINT8_MAX (0xff)
+#define UINT16_MAX (0xffff)
+#define UINT32_MAX (0xffffffffu)
+#define UINT64_MAX (0xffffffffffffffffu)
+
+#define PATH_MAX 4096
// ------------------------------------------------------------------
-// Global macros
+// global macros
+
+/* offsets */
+#define offsetof(t, d) __builtin_offsetof(t, d)
+
+/* variable arguments */
+#define va_start(v,a) __builtin_va_start(v,a)
+#define va_end(v) __builtin_va_end(v)
+#define va_arg(v,t) __builtin_va_arg(v,t)
+#define va_copy(d,s) __builtin_va_copy(d,s)
+/* array helpers */
#define arrlen(Array) (sizeof(Array) / sizeof((Array)[0]))
#define arrend(Array) ((Array) + arrlen(Array))
+/* simple thresholding */
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define CLAMP(x, lo, hi) (((x) < (lo)) ? (lo) : (((x) > (hi)) ? (hi) : (x)))
diff --git a/share/dynamic.mk b/share/dynamic.mk index c19e235..7839fe4 100644 --- a/share/dynamic.mk +++ b/share/dynamic.mk @@ -2,10 +2,10 @@ $(BINS_$(d)): STATIC = $(BINS_$(d)): CINIT = $(BINS_$(d)): CFINI = $(BINS_$(d)): ELIBS = -$(BINS_$(d)): INCS = -I $(INC_DIR) +$(BINS_$(d)): INCS = -I $(SYS_DIR)/$(OS)/$(ARCH) -I $(INC_DIR) -$(UNTS_$(d)): STATIC = -$(UNTS_$(d)): CINIT = -$(UNTS_$(d)): CFINI = -$(UNTS_$(d)): ELIBS = -$(UNTS_$(d)): INCS = -I $(INC_DIR) +$(TEST_$(d)): STATIC = +$(TEST_$(d)): CINIT = +$(TEST_$(d)): CFINI = +$(TEST_$(d)): ELIBS = +$(TEST_$(d)): INCS = -I $(SYS_DIR)/$(OS)/$(ARCH) -I $(INC_DIR) diff --git a/src/base/bufio/reader.c b/src/base/bufio/reader.c index afdaf60..39ea63e 100644 --- a/src/base/bufio/reader.c +++ b/src/base/bufio/reader.c @@ -1,6 +1,6 @@ #include "internal.h" -error +int bufio·initreader(io·Buffer *buf, io·Reader rdr, void *h) { if (buf->state) { diff --git a/src/base/bufio/unget.c b/src/base/bufio/unget.c index 3fd16de..1951384 100644 --- a/src/base/bufio/unget.c +++ b/src/base/bufio/unget.c @@ -1,6 +1,6 @@ #include "internal.h" -error +int bufio·ungetbyte(io·Buffer *buf, byte c) { if(!(buf->state & bufio·rdr)) { diff --git a/src/base/coro/coro.c b/src/base/coro/coro.c index 2255c99..5d3bb27 100644 --- a/src/base/coro/coro.c +++ b/src/base/coro/coro.c @@ -16,7 +16,7 @@ coro·make(uintptr stk, uintptr (*func)(Coro*, uintptr)) return co; } -error +int coro·free(Coro *co) { enum diff --git a/src/base/flate/reader.c b/src/base/flate/reader.c index 84f0d80..bbcf5fe 100644 --- a/src/base/flate/reader.c +++ b/src/base/flate/reader.c @@ -3,7 +3,7 @@ flate·Reader* flate·openreader(io·Reader rdr, void* r, mem·Allocator mem, void* m) { - error err; + int err; flate·Reader *zrdr; zrdr = mem.alloc(m, 1, sizeof(*zrdr)); @@ -41,7 +41,7 @@ ERROR: return nil; } -error +int flate·closereader(flate·Reader *rdr) { int err; diff --git a/src/base/flate/writer.c b/src/base/flate/writer.c index f339ae0..3d7acb0 100644 --- a/src/base/flate/writer.c +++ b/src/base/flate/writer.c @@ -3,7 +3,7 @@ flate·Writer* flate·openwriter(io·Writer wtr, void* w, mem·Allocator mem, void* m) { - error err; + int err; flate·Writer *zwtr; zwtr = mem.alloc(m, 1, sizeof(*zwtr)); @@ -39,7 +39,7 @@ ERROR: return nil; } -error +int flate·closewriter(flate·Writer *wtr) { int err; diff --git a/src/base/gz/flush.c b/src/base/gz/flush.c index 011a3ab..72d9af7 100644 --- a/src/base/gz/flush.c +++ b/src/base/gz/flush.c @@ -1,6 +1,6 @@ #include "internal.h" -error +int gz·flush(gz·Stream *s) { return gzflush(s, Z_FINISH); diff --git a/src/base/gz/get.c b/src/base/gz/get.c index 24ba23a..9114048 100644 --- a/src/base/gz/get.c +++ b/src/base/gz/get.c @@ -10,7 +10,7 @@ gz·getbyte(gz·Stream *s) return b[0]; } -error +int gz·ungetbyte(gz·Stream *s, byte c) { return gzungetc(c, s); diff --git a/src/base/gz/open.c b/src/base/gz/open.c index c84ce5e..50bc94f 100644 --- a/src/base/gz/open.c +++ b/src/base/gz/open.c @@ -6,7 +6,7 @@ gz·open(byte *path, byte *mode) return gzopen(path, mode); } -error +int gz·close(gz·Stream* s) { return gzclose(s); diff --git a/src/base/gz/printf.c b/src/base/gz/printf.c index d7f75cf..d753497 100644 --- a/src/base/gz/printf.c +++ b/src/base/gz/printf.c @@ -3,7 +3,7 @@ int gz·printf(gz·Stream *s, byte *fmt, ...) { - error err; + int err; va_list args; va_start(args, fmt); diff --git a/src/base/gz/put.c b/src/base/gz/put.c index fa9807d..b887ad2 100644 --- a/src/base/gz/put.c +++ b/src/base/gz/put.c @@ -1,6 +1,6 @@ #include "internal.h" -error +int gz·putbyte(gz·Stream *s, byte c) { return gzputc(s, c); diff --git a/src/base/gz/putstring.c b/src/base/gz/putstring.c index 64ff470..68034fc 100644 --- a/src/base/gz/putstring.c +++ b/src/base/gz/putstring.c @@ -1,6 +1,6 @@ #include "internal.h" -error +int gz·putstring(gz·Stream *s, byte *str) { return gzputs(s, str); diff --git a/src/base/io/interface.c b/src/base/io/interface.c index bead9e1..bc9d5ff 100644 --- a/src/base/io/interface.c +++ b/src/base/io/interface.c @@ -15,7 +15,7 @@ byte } static -error +int ·unget(void *rdr, byte c) { return io·ungetbyte((io·Stream *)rdr, c); @@ -29,7 +29,7 @@ int } static -error +int ·put(void *wtr, byte c) { return io·putbyte((io·Stream *)wtr, c); diff --git a/src/base/io/open.c b/src/base/io/open.c index e50e334..71e88d4 100644 --- a/src/base/io/open.c +++ b/src/base/io/open.c @@ -6,7 +6,7 @@ io·open(byte *name, byte *mode) return fopen(name, mode); } -error +int io·close(io·Stream *s) { return fclose(s); diff --git a/src/base/io/stat.c b/src/base/io/stat.c index d86f1ee..063ff8f 100644 --- a/src/base/io/stat.c +++ b/src/base/io/stat.c @@ -1,6 +1,6 @@ #include "internal.h" -error +int io·stat(io·Stream *s, io·Stat *buf) { return fstat(fileno(s), buf); diff --git a/src/base/io/unget.c b/src/base/io/unget.c index 5ec3536..5c37433 100644 --- a/src/base/io/unget.c +++ b/src/base/io/unget.c @@ -1,6 +1,6 @@ #include "internal.h" -error +int io·ungetbyte(io·Stream *s, byte c) { return ungetc(c, s); diff --git a/src/base/mmap/mmap.c b/src/base/mmap/mmap.c index ce3011c..e5cedbb 100644 --- a/src/base/mmap/mmap.c +++ b/src/base/mmap/mmap.c @@ -31,7 +31,7 @@ ERROR: return (mmap·Reader){ 0 }; } -error +int mmap·close(mmap·Reader rdr) { munmap(rdr.b, rdr.len); diff --git a/src/cmd/term/term.c b/src/cmd/term/term.c index 50ab29c..9e13ebd 100644 --- a/src/cmd/term/term.c +++ b/src/cmd/term/term.c @@ -525,7 +525,7 @@ sigchld(int a) void stty(char **args) { - char cmd[_POSIX_ARG_MAX], **p, *q, *s; + char cmd[PATH_MAX], **p, *q, *s; size_t n, siz; if ((n = strlen(stty_args)) > sizeof(cmd)-1) diff --git a/src/libbio/fasta.c b/src/libbio/fasta.c index 3788544..eb0d090 100644 --- a/src/libbio/fasta.c +++ b/src/libbio/fasta.c @@ -23,7 +23,7 @@ reset(struct SeqBuf *sb) } static -error +int grow(struct SeqBuf **sb, int min) { void* heap; @@ -56,7 +56,7 @@ grow(struct SeqBuf **sb, int min) } static -error +int put(struct SeqBuf **sb, byte c) { int err; @@ -79,7 +79,7 @@ put(struct SeqBuf **sb, byte c) } static -error +int push(struct SeqBuf **sb, int n, void *buf) { int d, err; @@ -117,7 +117,7 @@ struct bio·SeqReader { }; static -error +int fill(bio·SeqReader *rdr) { int n; @@ -141,7 +141,7 @@ fill(bio·SeqReader *rdr) bio·SeqReader* bio·openseq(io·Reader rdr, void *io, mem·Allocator mem, void *heap) { - error err; + int err; bio·SeqReader *r; r = mem.alloc(heap, 1, sizeof(bio·SeqReader)); @@ -168,7 +168,7 @@ ERROR: return nil; } -error +int bio·closeseq(bio·SeqReader *rdr) { mem·Allocator mem; @@ -185,11 +185,11 @@ bio·closeseq(bio·SeqReader *rdr) static -error +int readfasta(bio·SeqReader *rdr, bio·Seq *seq, byte hdr, byte stop) { - error err; - byte *beg; + int err; + byte *beg; if(rdr->eof && rdr->b == rdr->bend-1) return EOF; @@ -256,10 +256,10 @@ SUCCESS: * fasta files */ -error +int bio·readfasta(bio·SeqReader *rdr, bio·Seq *seq) { - error err; + int err; err = readfasta(rdr, seq, '>', '>'); if(err && err != EOF) { @@ -279,12 +279,12 @@ bio·readfasta(bio·SeqReader *rdr, bio·Seq *seq) * fastq files */ -error +int bio·readfastq(bio·SeqReader *rdr, bio·Seq *seq) { int n; byte *beg; - error err; + int err; err = readfasta(rdr, seq, '@', '+'); if(err) { @@ -352,7 +352,7 @@ SUCCESS: // ----------------------------------------------------------------------- // sequence writing -error +int bio·writefasta(io·Writer io, void *wtr, bio·Seq seq) { int i, j, d; @@ -385,7 +385,7 @@ bio·writefasta(io·Writer io, void *wtr, bio·Seq seq) return 0; } -error +int bio·writefastq(io·Writer io, void *wtr, bio·Seq seq) { panicf("need to implement"); diff --git a/src/libbio/newick.c b/src/libbio/newick.c index 5e6d30a..bc768fd 100644 --- a/src/libbio/newick.c +++ b/src/libbio/newick.c @@ -174,10 +174,10 @@ struct Parser }; static -error +int parse(struct Parser *p) { - error err; + int err; bio·Node *node; bio·Node *root; struct Token tok; @@ -332,7 +332,7 @@ ERROR: int bio·readnewick(io·Peeker stream, void *s, bio·Tree *tree) { - error err; + int err; struct Parser p; if (!tree) { @@ -369,7 +369,7 @@ bio·readnewick(io·Peeker stream, void *s, bio·Tree *tree) // Write static -error +int dump(bio·Node *node, void *impl, io·Putter out) { byte b[24]; @@ -403,7 +403,7 @@ dump(bio·Node *node, void *impl, io·Putter out) return 0; } -error +int bio·writenewick(bio·Tree tree, io·Putter out, void* impl) { dump(tree.root, impl, out); diff --git a/src/libbio/phylo.c b/src/libbio/phylo.c index d50934f..41b0f04 100644 --- a/src/libbio/phylo.c +++ b/src/libbio/phylo.c @@ -8,7 +8,7 @@ // NOTE: As of now these don't update nnode & nleaf stats. // It is the caller's responsibility to refresh counts. -error +int phylo·addchild(bio·Node* parent, bio·Node* child) { bio·Node *it, *sibling; @@ -28,7 +28,7 @@ SUCCESS: return 0; } -error +int phylo·rmchild(bio·Node *parent, bio·Node *child) { bio·Node *it, *prev; @@ -59,11 +59,11 @@ FOUND: // ----------------------------------------------------------------------- // subtree statistics -error +int phylo·countnodes(bio·Node *node, int *n) { - int m; - error err; + int m; + int err; bio·Node *child; m = *n; @@ -79,10 +79,10 @@ phylo·countnodes(bio·Node *node, int *n) return 0; } -error +int phylo·countleafs(bio·Node *node, int *n) { - error err; + int err; bio·Node *child; if (!node->nchild) { @@ -182,11 +182,11 @@ sortnodelist(bio·Node **head, bio·Node *next) *head = tmp.sibling; } -error +int phylo·ladderize(bio·Node *root) { - int i; - error err; + int i; + int err; bio·Node *child, *sorted, *sibling; if (!root->nchild) return 0; @@ -347,10 +347,10 @@ phylo·diameter(bio·Tree tree, int *len, bio·Node **path) * reroot a tree on a new node */ static -error +int rotateparent(bio·Node *node, bio·Node *to) { - error err; + int err; // NOTE: will this ever be taken? if (node->parent == to) { @@ -385,7 +385,7 @@ RMCHILD: } #define PREC .00000001 -error +int phylo·reroot(bio·Tree *tree, bio·Node *node, double d) { bio·Node *new; diff --git a/src/libmath/blas2body b/src/libmath/blas2body index 45baf67..e3794f9 100644 --- a/src/libmath/blas2body +++ b/src/libmath/blas2body @@ -1,5 +1,5 @@ /* general matrix multiply */ -error +int func(gemv)(uint flag, INT nrow, INT ncol, FLOAT a, FLOAT *m, INT incm, FLOAT *x, INT incx, FLOAT b, FLOAT *y, INT incy) { INT r, c, nr, nc; |