From 99feb308bd6d912b2c876a8f34930ebeba4d4af1 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Fri, 9 Aug 2019 22:08:44 +0300 Subject: [PATCH] Hoist argcount() into its own header file Muffles compiler warnings about unused function. --- c/argcount.h | 6 ++++++ c/builtins.c | 2 ++ c/flisp.c | 3 ++- c/flisp.h | 6 ------ c/iostream.c | 2 ++ c/string.c | 2 ++ c/table.c | 2 ++ 7 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 c/argcount.h diff --git a/c/argcount.h b/c/argcount.h new file mode 100644 index 0000000..aebb8cb --- /dev/null +++ b/c/argcount.h @@ -0,0 +1,6 @@ +static void argcount(char *fname, uint32_t nargs, uint32_t c) +{ + if (__unlikely(nargs != c)) + lerrorf(ArgError, "%s: too %s arguments", fname, + nargs < c ? "few" : "many"); +} diff --git a/c/builtins.c b/c/builtins.c index e36d35d..dd7e35c 100644 --- a/c/builtins.c +++ b/c/builtins.c @@ -33,6 +33,8 @@ #include "flisp.h" +#include "argcount.h" + size_t llength(value_t v) { size_t n = 0; diff --git a/c/flisp.c b/c/flisp.c index 6f74317..eb29a27 100644 --- a/c/flisp.c +++ b/c/flisp.c @@ -62,7 +62,9 @@ #include "ieee754.h" #include "flisp.h" + #include "opcodes.h" +#include "argcount.h" static char *builtin_names[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -924,7 +926,6 @@ no_kw: return nargs; } - #if defined(__amd64__) || defined(_M_AMD64) #define ARCH_X86_64 #define __CPU__ 686 diff --git a/c/flisp.h b/c/flisp.h index b524050..a778d28 100644 --- a/c/flisp.h +++ b/c/flisp.h @@ -201,12 +201,6 @@ void bounds_error(char *fname, value_t arr, value_t ind) __attribute__((__noreturn__)); extern value_t ArgError, IOError, KeyError, MemoryError, EnumerationError; extern value_t UnboundError; -static void argcount(char *fname, uint32_t nargs, uint32_t c) -{ - if (__unlikely(nargs != c)) - lerrorf(ArgError, "%s: too %s arguments", fname, - nargs < c ? "few" : "many"); -} struct cvtable { void (*print)(value_t self, struct ios *f); diff --git a/c/iostream.c b/c/iostream.c index 6a47718..89eb8d4 100644 --- a/c/iostream.c +++ b/c/iostream.c @@ -23,6 +23,8 @@ #include "flisp.h" +#include "argcount.h" + static value_t iostreamsym, rdsym, wrsym, apsym, crsym, truncsym; static value_t instrsym, outstrsym; struct fltype *iostreamtype; diff --git a/c/string.c b/c/string.c index 9552ce4..62a8a2f 100644 --- a/c/string.c +++ b/c/string.c @@ -32,6 +32,8 @@ #include "flisp.h" +#include "argcount.h" + value_t fl_stringp(value_t *args, uint32_t nargs) { argcount("string?", nargs, 1); diff --git a/c/table.c b/c/table.c index cc9e078..f8220fe 100644 --- a/c/table.c +++ b/c/table.c @@ -22,6 +22,8 @@ #include "llt.h" #include "flisp.h" + +#include "argcount.h" #include "equalhash.h" static value_t tablesym;