From a02557230bddfc447d83197764be8be2b8a3c598 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Mon, 26 Aug 2019 22:12:15 +0300 Subject: [PATCH] Consolidate (almost) all #include's into new "scheme.h" --- c/argcount.h | 7 +------ c/bitvector-ops.c | 8 ++++++-- c/bitvector.c | 8 ++++++-- c/buf.c | 7 +++---- c/builtins.c | 19 +------------------ c/dump.c | 6 +++--- c/env_unix.c | 20 +------------------- c/env_windows.c | 20 +------------------- c/equalhash.c | 15 +-------------- c/flisp.c | 24 +----------------------- c/flmain.c | 16 +--------------- c/hashing.c | 9 +++------ c/htable.c | 6 +++--- c/int2str.c | 8 ++++++-- c/ios.c | 13 +------------ c/iostream.c | 20 +------------------- c/libraries.c | 27 +-------------------------- c/lltinit.c | 7 ++----- c/os_darwin.c | 12 +++++++++++- c/os_dragonfly.c | 2 +- c/os_freebsd.c | 2 +- c/os_haiku.c | 2 +- c/os_linux.c | 2 +- c/os_minix.c | 2 +- c/os_netbsd.c | 2 +- c/os_openbsd.c | 2 +- c/os_sunos.c | 2 +- c/os_unix.c | 21 +-------------------- c/os_unix_process.c | 21 +-------------------- c/os_windows.c | 20 +------------------- c/ptrhash.c | 13 ++++++++----- c/random.c | 7 ++----- c/socket.c | 6 +++--- c/string.c | 19 +------------------ c/table.c | 19 +------------------ c/text_ini.c | 21 +-------------------- c/time_unix.c | 5 ++++- c/time_windows.c | 2 +- c/utf8.c | 6 +++--- scripts/build.sh | 2 ++ 40 files changed, 90 insertions(+), 340 deletions(-) diff --git a/c/argcount.h b/c/argcount.h index 7dad18c..08a3670 100644 --- a/c/argcount.h +++ b/c/argcount.h @@ -1,6 +1 @@ -static void argcount(const char *fname, uint32_t nargs, uint32_t c) -{ - if (__unlikely(nargs != c)) - lerrorf(ArgError, "%s: too %s arguments", fname, - nargs < c ? "few" : "many"); -} +void argcount(const char *fname, uint32_t nargs, uint32_t c); diff --git a/c/bitvector-ops.c b/c/bitvector-ops.c index 4325aca..1cfd05f 100644 --- a/c/bitvector-ops.c +++ b/c/bitvector-ops.c @@ -1,4 +1,9 @@ +#include + #include +#include +#include +#include #include #include #include @@ -7,8 +12,7 @@ #include #endif -#include "dtypes.h" -#include "bitvector.h" +#include "scheme.h" #ifdef __INTEL_COMPILER #define count_bits(b) _popcnt32(b) diff --git a/c/bitvector.c b/c/bitvector.c index 407b705..72ade30 100644 --- a/c/bitvector.c +++ b/c/bitvector.c @@ -29,7 +29,12 @@ and_to, or_to, and xor_to allow overlap. */ +#include + #include +#include +#include +#include #include #include #include @@ -38,8 +43,7 @@ #include #endif -#include "dtypes.h" -#include "bitvector.h" +#include "scheme.h" uint32_t *bitvector_resize(uint32_t *b, uint64_t oldsz, uint64_t newsz, int initzero) diff --git a/c/buf.c b/c/buf.c index 570251d..a16f255 100644 --- a/c/buf.c +++ b/c/buf.c @@ -4,16 +4,15 @@ #include #include +#include +#include #include #include #include #include #include -#include "dtypes.h" -#include "ios.h" - -#include "buf.h" +#include "scheme.h" struct buf *buf_new(void) { return calloc(1, sizeof(struct buf)); } diff --git a/c/builtins.c b/c/builtins.c index 8f01c8f..761e3cc 100644 --- a/c/builtins.c +++ b/c/builtins.c @@ -15,24 +15,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" -#include "libraries.h" +#include "scheme.h" size_t llength(value_t v) { diff --git a/c/dump.c b/c/dump.c index caec3dc..862f518 100644 --- a/c/dump.c +++ b/c/dump.c @@ -1,12 +1,12 @@ #include +#include +#include #include #include #include -#include "dtypes.h" -#include "ios.h" -#include "utils.h" +#include "scheme.h" static char hexdig[] = "0123456789abcdef"; diff --git a/c/env_unix.c b/c/env_unix.c index fb33ff0..9ad68d6 100644 --- a/c/env_unix.c +++ b/c/env_unix.c @@ -16,25 +16,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" +#include "scheme.h" static const struct utsname *get_global_uname(void) { diff --git a/c/env_windows.c b/c/env_windows.c index 0e929b9..236e658 100644 --- a/c/env_windows.c +++ b/c/env_windows.c @@ -12,25 +12,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" +#include "scheme.h" const char *env_get_os_name(void) { return "windows"; } diff --git a/c/equalhash.c b/c/equalhash.c index 46a4266..d033f35 100644 --- a/c/equalhash.c +++ b/c/equalhash.c @@ -10,21 +10,8 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" +#include "scheme.h" -#include "flisp.h" #include "equalhash.h" #include "htable_inc.h" diff --git a/c/flisp.c b/c/flisp.c index 89fd236..9a02319 100644 --- a/c/flisp.c +++ b/c/flisp.c @@ -45,29 +45,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "ieee754.h" - -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" -#include "env.h" -#include "opcodes.h" +#include "scheme.h" #include "../scheme-boot/boot_image.h" diff --git a/c/flmain.c b/c/flmain.c index a009065..c1cd8b0 100644 --- a/c/flmain.c +++ b/c/flmain.c @@ -9,21 +9,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "flisp.h" +#include "scheme.h" extern void write_defaults_indent(struct ios *f, value_t v); diff --git a/c/hashing.c b/c/hashing.c index 3da7fbd..d8eb87c 100644 --- a/c/hashing.c +++ b/c/hashing.c @@ -5,17 +5,14 @@ #include #include +#include #include #include #include +#include #include -#include "dtypes.h" -#include "utils.h" -#include "hashing.h" -#include "timefuncs.h" -#include "ios.h" -#include "random.h" +#include "scheme.h" uintptr_t nextipow2(uintptr_t i) { diff --git a/c/htable.c b/c/htable.c index b2582cb..b4fbbf5 100644 --- a/c/htable.c +++ b/c/htable.c @@ -4,14 +4,14 @@ #include #include +#include +#include #include #include #include #include -#include "dtypes.h" -#include "htable.h" -#include "hashing.h" +#include "scheme.h" struct htable *htable_new(struct htable *h, size_t size) { diff --git a/c/int2str.c b/c/int2str.c index 20c09c7..589abb1 100644 --- a/c/int2str.c +++ b/c/int2str.c @@ -1,8 +1,12 @@ +#include + +#include +#include +#include #include #include -#include "dtypes.h" -#include "utils.h" +#include "scheme.h" char *uint2str(char *dest, size_t len, uint64_t num, uint32_t base) { diff --git a/c/ios.c b/c/ios.c index 01fa0c9..7eab7d1 100644 --- a/c/ios.c +++ b/c/ios.c @@ -12,8 +12,6 @@ #include #include -#include "dtypes.h" - #ifdef _WIN32 #include #include @@ -26,16 +24,7 @@ #include #endif -#include "htable.h" -#include "htableh_inc.h" -#include "ios.h" - -#include "flisp.h" - -#include "error.h" -#include "timefuncs.h" -#include "utf8.h" -#include "utils.h" +#include "scheme.h" #define MOST_OF(x) ((x) - ((x) >> 4)) diff --git a/c/iostream.c b/c/iostream.c index c117d2b..d627cfe 100644 --- a/c/iostream.c +++ b/c/iostream.c @@ -9,25 +9,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" +#include "scheme.h" static value_t iostreamsym, rdsym, wrsym, apsym, crsym, truncsym; value_t instrsym, outstrsym; diff --git a/c/libraries.c b/c/libraries.c index 4e17855..261abe7 100644 --- a/c/libraries.c +++ b/c/libraries.c @@ -17,32 +17,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "ieee754.h" - -#include "flisp.h" - -#include "buf.h" -#include "env.h" -#include "error.h" -#include "opcodes.h" - -#include "builtins.h" -#include "libraries.h" -#include "stringfuncs.h" +#include "scheme.h" struct builtin_procedure { char *name; diff --git a/c/lltinit.c b/c/lltinit.c index be0ce5a..34bf280 100644 --- a/c/lltinit.c +++ b/c/lltinit.c @@ -2,16 +2,13 @@ #include #include +#include #include #include #include #include -#include "dtypes.h" -#include "timefuncs.h" -#include "ios.h" -#include "random.h" -#include "utf8.h" +#include "scheme.h" double D_PNAN; double D_NNAN; diff --git a/c/os_darwin.c b/c/os_darwin.c index 1c5f598..85fd613 100644 --- a/c/os_darwin.c +++ b/c/os_darwin.c @@ -1,6 +1,16 @@ +#include + #include -#include "os.h" +#include +#include +#include +#include +#include +#include +#include + +#include "scheme.h" char *get_exename(char *buf, size_t size) { diff --git a/c/os_dragonfly.c b/c/os_dragonfly.c index c835ab2..e24d248 100644 --- a/c/os_dragonfly.c +++ b/c/os_dragonfly.c @@ -2,7 +2,7 @@ #include -#include "os.h" +#include "scheme.h" char *get_exename(char *buf, size_t size) { diff --git a/c/os_freebsd.c b/c/os_freebsd.c index c835ab2..e24d248 100644 --- a/c/os_freebsd.c +++ b/c/os_freebsd.c @@ -2,7 +2,7 @@ #include -#include "os.h" +#include "scheme.h" char *get_exename(char *buf, size_t size) { diff --git a/c/os_haiku.c b/c/os_haiku.c index 51320d6..951458c 100644 --- a/c/os_haiku.c +++ b/c/os_haiku.c @@ -1,6 +1,6 @@ #include -#include "os.h" +#include "scheme.h" char *get_exename(char *buf, size_t size) { diff --git a/c/os_linux.c b/c/os_linux.c index 83fdcad..6a690bf 100644 --- a/c/os_linux.c +++ b/c/os_linux.c @@ -2,7 +2,7 @@ #include #include -#include "os.h" +#include "scheme.h" char *get_exename(char *buf, size_t size) { diff --git a/c/os_minix.c b/c/os_minix.c index 51320d6..951458c 100644 --- a/c/os_minix.c +++ b/c/os_minix.c @@ -1,6 +1,6 @@ #include -#include "os.h" +#include "scheme.h" char *get_exename(char *buf, size_t size) { diff --git a/c/os_netbsd.c b/c/os_netbsd.c index 1256376..aa89982 100644 --- a/c/os_netbsd.c +++ b/c/os_netbsd.c @@ -2,7 +2,7 @@ #include -#include "os.h" +#include "scheme.h" char *get_exename(char *buf, size_t size) { diff --git a/c/os_openbsd.c b/c/os_openbsd.c index de08e6a..e5c2458 100644 --- a/c/os_openbsd.c +++ b/c/os_openbsd.c @@ -10,7 +10,7 @@ #include #include -#include "os.h" +#include "scheme.h" char *get_exename(char *buf, size_t size) { diff --git a/c/os_sunos.c b/c/os_sunos.c index 51320d6..951458c 100644 --- a/c/os_sunos.c +++ b/c/os_sunos.c @@ -1,6 +1,6 @@ #include -#include "os.h" +#include "scheme.h" char *get_exename(char *buf, size_t size) { diff --git a/c/os_unix.c b/c/os_unix.c index 5fd3c57..80d836c 100644 --- a/c/os_unix.c +++ b/c/os_unix.c @@ -16,26 +16,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" -#include "os.h" +#include "scheme.h" void path_to_dirname(char *path) { diff --git a/c/os_unix_process.c b/c/os_unix_process.c index 7c2435a..e0e6998 100644 --- a/c/os_unix_process.c +++ b/c/os_unix_process.c @@ -16,26 +16,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" -#include "os.h" +#include "scheme.h" static void warn(const char *msg) { fprintf(stderr, "%s\n", msg); } diff --git a/c/os_windows.c b/c/os_windows.c index 8d61346..c20ad71 100644 --- a/c/os_windows.c +++ b/c/os_windows.c @@ -16,25 +16,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" -#include "os.h" +#include "scheme.h" void path_to_dirname(char *path) { diff --git a/c/ptrhash.c b/c/ptrhash.c index 208d585..14da186 100644 --- a/c/ptrhash.c +++ b/c/ptrhash.c @@ -7,14 +7,19 @@ #include #include +#include +#include +#include #include #include #include #include -#include "dtypes.h" -#include "htable.h" -#include "htableh_inc.h" +#include "scheme.h" + +#include "equalhash.h" + +#include "htable_inc.h" #define OP_EQ(x, y) ((x) == (y)) @@ -43,6 +48,4 @@ static uint32_t _pinthash(uint32_t a) } #endif -#include "htable_inc.h" - HTIMPL(ptrhash, _pinthash, OP_EQ) diff --git a/c/random.c b/c/random.c index 5a694a9..9dd94da 100644 --- a/c/random.c +++ b/c/random.c @@ -3,15 +3,12 @@ */ #include +#include #include #include #include -#include "dtypes.h" -#include "ieee754.h" -#include "utils.h" -#include "random.h" -#include "timefuncs.h" +#include "scheme.h" #include "mt19937ar.h" diff --git a/c/socket.c b/c/socket.c index 59626c8..81c3628 100644 --- a/c/socket.c +++ b/c/socket.c @@ -9,15 +9,15 @@ #include #include #include +#include #include +#include #include #include #include #include -#include "dtypes.h" - -#include "socket.h" +#include "scheme.h" int mysocket(int domain, int type, int protocol) { diff --git a/c/string.c b/c/string.c index 99eac91..7cb8763 100644 --- a/c/string.c +++ b/c/string.c @@ -17,24 +17,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" +#include "scheme.h" extern void display_defaults(struct ios *f, value_t v); diff --git a/c/table.c b/c/table.c index f9b6266..8c25e85 100644 --- a/c/table.c +++ b/c/table.c @@ -9,25 +9,8 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" +#include "scheme.h" -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" #include "equalhash.h" static value_t tablesym; diff --git a/c/text_ini.c b/c/text_ini.c index 50d877f..39b6888 100644 --- a/c/text_ini.c +++ b/c/text_ini.c @@ -12,26 +12,7 @@ #include #include -#include "dtypes.h" -#include "utils.h" -#include "utf8.h" -#include "ios.h" -#include "socket.h" -#include "timefuncs.h" -#include "hashing.h" -#include "htable.h" -#include "htableh_inc.h" -#include "bitvector.h" -#include "os.h" -#include "random.h" -#include "llt.h" - -#include "flisp.h" - -#include "error.h" - -#include "argcount.h" -#include "buf.h" +#include "scheme.h" static void push(value_t *tailp, value_t elt) { diff --git a/c/time_unix.c b/c/time_unix.c index f54c881..5412db8 100644 --- a/c/time_unix.c +++ b/c/time_unix.c @@ -1,12 +1,15 @@ #include +#include #include +#include +#include #include #include #include #include -#include "timefuncs.h" +#include "scheme.h" double tv2float(struct timeval *tv) { diff --git a/c/time_windows.c b/c/time_windows.c index d704205..32070d7 100644 --- a/c/time_windows.c +++ b/c/time_windows.c @@ -3,7 +3,7 @@ #include #include -#include "timefuncs.h" +#include "scheme.h" #if 0 double tvals2float(struct tm *t, struct timeb *tstruct) diff --git a/c/utf8.c b/c/utf8.c index 6aac0dc..29b58a1 100644 --- a/c/utf8.c +++ b/c/utf8.c @@ -14,6 +14,8 @@ */ #include +#include +#include #include #include #include @@ -28,9 +30,7 @@ #define snprintf _snprintf #endif -#include "dtypes.h" - -#include "utf8.h" +#include "scheme.h" static const uint32_t offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 0x03C82080UL, diff --git a/scripts/build.sh b/scripts/build.sh index a9e86dd..77e65ff 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -3,6 +3,7 @@ set -eu os="$(uname | tr A-Z- a-z_)" o_files="" o_files="$o_files algo_color.o" +o_files="$o_files argcount.o" o_files="$o_files bitvector-ops.o" o_files="$o_files bitvector.o" o_files="$o_files buf.o" @@ -85,6 +86,7 @@ echo "Entering directory '$PWD'" set -x $CC $CFLAGS -c ../c/algo_color.c +$CC $CFLAGS -c ../c/argcount.c $CC $CFLAGS -c ../c/bitvector-ops.c $CC $CFLAGS -c ../c/bitvector.c $CC $CFLAGS -c ../c/buf.c