ref: f0a22a73b7f964b5edd6d7397468b48c344843c0
parent: 310ccf23d770b7f9e7589c3ef2611c1565009a7e
author: mag <[email protected]>
date: Tue May 16 09:22:08 EDT 2023
cvalues.h
--- a/Makefile
+++ b/Makefile
@@ -78,14 +78,18 @@
.c.o:
${CC} -o $@ -c $< ${CFLAGS}
-builtins.o: operators.h
-cvalues.o: operators.h
-equal.o: operators.h
-print.o: operators.h
-string.o: operators.h
+builtins.o: builtins.c operators.h cvalues.h
+cvalues.o: cvalues.c operators.h cvalues.h
+equal.o: equal.c operators.h cvalues.h
+print.o: print.c operators.h cvalues.h
+read.o: read.c cvalues.h
+string.o: string.c operators.h cvalues.h
+iostream.o: iostream.c cvalues.h
+table.o: table.c cvalues.h
+types.o: types.c cvalues.h
-flisp.o: flisp.c flisp.h operators.h maxstack.inc opcodes.h builtin_fns.h
-flmain.o: flmain.c boot.h flisp.h
+flisp.o: flisp.c flisp.h operators.h cvalues.h maxstack.inc opcodes.h builtin_fns.h
+flmain.o: flmain.c boot.h flisp.h cvalues.h
boot.h: flisp.boot
sed 's,\\,\\\\,g;s,",\\",g;s,^,",g;s,$$,\\n",g' flisp.boot >$@
--- a/builtins.c
+++ b/builtins.c
@@ -5,6 +5,7 @@
#include "llt.h"
#include "flisp.h"
#include "operators.h"
+#include "cvalues.h"
size_t
llength(value_t v)
--- a/cvalues.c
+++ b/cvalues.c
@@ -1,6 +1,7 @@
#include "llt.h"
#include "flisp.h"
#include "operators.h"
+#include "cvalues.h"
value_t int8sym, uint8sym, int16sym, uint16sym, int32sym, uint32sym;
value_t int64sym, uint64sym, mpintsym;
--- /dev/null
+++ b/cvalues.h
@@ -1,0 +1,72 @@
+#ifndef CVALUES_H
+#define CVALUES_H
+
+#ifdef BITS64
+#define NWORDS(sz) (((sz)+7)>>3)
+#else
+#define NWORDS(sz) (((sz)+3)>>2)
+#endif
+
+extern value_t int8sym, uint8sym, int16sym, uint16sym, int32sym, uint32sym;
+extern value_t int64sym, uint64sym, mpintsym;
+extern value_t longsym, ulongsym, bytesym, wcharsym;
+extern value_t structsym, arraysym, enumsym, cfunctionsym, voidsym, pointersym;
+extern value_t stringtypesym, wcstringtypesym, emptystringsym;
+extern value_t unionsym, floatsym, doublesym;
+
+extern fltype_t *bytetype, *wchartype;
+extern fltype_t *stringtype, *wcstringtype;
+extern fltype_t *builtintype;
+
+extern htable_t TypeTable;
+extern htable_t reverse_dlsym_lookup_table;
+extern fltype_t *mpinttype;
+
+value_t cvalue(fltype_t *type, size_t sz);
+void add_finalizer(cvalue_t *cv);
+void cv_autorelease(cvalue_t *cv);
+void cv_pin(cvalue_t *cv);
+size_t ctype_sizeof(value_t type, int *palign);
+value_t cvalue_copy(value_t v);
+value_t cvalue_from_data(fltype_t *type, void *data, size_t sz);
+value_t cvalue_from_ref(fltype_t *type, void *ptr, size_t sz, value_t parent);
+value_t cbuiltin(char *name, builtin_t f);
+size_t cvalue_arraylen(value_t v);
+value_t size_wrap(size_t sz);
+size_t toulong(value_t n);
+off_t tooffset(value_t n);
+value_t cvalue_string(size_t sz);
+value_t cvalue_static_cstring(const char *str);
+value_t string_from_cstr(char *str);
+value_t string_from_cstrn(char *str, size_t n);
+int fl_isstring(value_t v);
+value_t cvalue_compare(value_t a, value_t b);
+int numeric_compare(value_t a, value_t b, int eq, int eqnans, int typeerr);
+void to_sized_ptr(value_t v, char **pdata, size_t *psz);
+value_t mk_double(double n);
+value_t mk_float(float n);
+value_t mk_int32(int32_t n);
+value_t mk_uint32(uint32_t n);
+value_t mk_int64(int64_t n);
+value_t mk_uint64(uint64_t n);
+value_t mk_wchar(int32_t n);
+value_t return_from_uint64(uint64_t Uaccum);
+value_t return_from_int64(int64_t Saccum);
+void cvalues_init(void);
+value_t fl_idiv2(value_t a, value_t b);
+value_t fl_div2(value_t a, value_t b);
+value_t fl_mul_any(value_t *args, uint32_t nargs, int64_t Saccum);
+value_t fl_neg(value_t n);
+value_t fl_add_any(value_t *args, uint32_t nargs, fixnum_t carryIn);
+value_t cvalue_array_aset(value_t *args);
+value_t cvalue_array_aref(value_t *args);
+value_t cvalue_relocate(value_t v);
+void sweep_finalizers(void);
+int cvalue_array_init(fltype_t *ft, value_t arg, void *dest);
+int cvalue_enum_init(fltype_t *ft, value_t arg, void *dest);
+value_t mk_mpint(mpint *n);
+int isarray(value_t v);
+_Noreturn void DivideByZeroError(void);
+
+#endif
+
--- a/equal.c
+++ b/equal.c
@@ -2,6 +2,7 @@
#include "flisp.h"
#include "operators.h"
#include "opcodes.h"
+#include "cvalues.h"
#define BOUNDED_COMPARE_BOUND 128
#define BOUNDED_HASH_BOUND 16384
--- a/flisp.c
+++ b/flisp.c
@@ -8,6 +8,7 @@
#include "llt.h"
#include "flisp.h"
#include "operators.h"
+#include "cvalues.h"
#include "opcodes.h"
int
--- a/flisp.h
+++ b/flisp.h
@@ -342,47 +342,6 @@
void fl_print_child(ios_t *f, value_t v);
//--------------------------------------------------print.c
-//--------------------------------------------------cvalues.c
-extern value_t int8sym, uint8sym, int16sym, uint16sym, int32sym, uint32sym;
-extern value_t int64sym, uint64sym, mpintsym;
-extern value_t longsym, ulongsym, bytesym, wcharsym;
-extern value_t structsym, arraysym, enumsym, cfunctionsym, voidsym, pointersym;
-extern value_t stringtypesym, wcstringtypesym, emptystringsym;
-extern value_t unionsym, floatsym, doublesym;
-extern fltype_t *bytetype, *wchartype;
-extern fltype_t *stringtype, *wcstringtype;
-extern fltype_t *builtintype;
-value_t cvalue(fltype_t *type, size_t sz);
-void add_finalizer(cvalue_t *cv);
-void cv_autorelease(cvalue_t *cv);
-void cv_pin(cvalue_t *cv);
-size_t ctype_sizeof(value_t type, int *palign);
-value_t cvalue_copy(value_t v);
-value_t cvalue_from_data(fltype_t *type, void *data, size_t sz);
-value_t cvalue_from_ref(fltype_t *type, void *ptr, size_t sz, value_t parent);
-value_t cbuiltin(char *name, builtin_t f);
-size_t cvalue_arraylen(value_t v);
-value_t size_wrap(size_t sz);
-size_t toulong(value_t n);
-off_t tooffset(value_t n);
-value_t cvalue_string(size_t sz);
-value_t cvalue_static_cstring(const char *str);
-value_t string_from_cstr(char *str);
-value_t string_from_cstrn(char *str, size_t n);
-int fl_isstring(value_t v);
-value_t cvalue_compare(value_t a, value_t b);
-int numeric_compare(value_t a, value_t b, int eq, int eqnans, int typeerr);
-void to_sized_ptr(value_t v, char **pdata, size_t *psz);
-value_t mk_double(double n);
-value_t mk_float(float n);
-value_t mk_int32(int32_t n);
-value_t mk_uint32(uint32_t n);
-value_t mk_int64(int64_t n);
-value_t mk_uint64(uint64_t n);
-value_t mk_wchar(int32_t n);
-value_t return_from_uint64(uint64_t Uaccum);
-value_t return_from_int64(int64_t Saccum);
-//--------------------------------------------------cvalues.c
//--------------------------------------------------iostream.c
int fl_isiostream(value_t v);
@@ -396,26 +355,7 @@
fltype_t *define_opaque_type(value_t sym, size_t sz, cvtable_t *vtab, cvinitfunc_t init);
//--------------------------------------------------types.c
-//--------------------------------------------------operators.c
-//double conv_to_double(void *data, numerictype_t tag);
-//void conv_from_double(void *data, double d, numerictype_t tag);
-//mpint *conv_to_mpint(void *data, numerictype_t tag);
-//int64_t conv_to_int64(void *data, numerictype_t tag);
-//uint64_t conv_to_uint64(void *data, numerictype_t tag);
-//int32_t conv_to_int32(void *data, numerictype_t tag);
-//uint32_t conv_to_uint32(void *data, numerictype_t tag);
-//
-//#if defined(ULONG64)
-//#define conv_to_long conv_to_int64
-//#define conv_to_ulong conv_to_uint64
-//#else
-//#define conv_to_long conv_to_int32
-//#define conv_to_ulong conv_to_uint32
-//#endif
-//--------------------------------------------------operators.c
-
-
-//--------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------
// New declarations here.. needed to permit files splitting
// (and grouped by files).
//--------------------------------------------------------------------------------
@@ -483,39 +423,6 @@
#define BUILTIN_FN(l, c) extern BUILTIN(l, c);
#include "builtin_fns.h"
#undef BUILTIN_FN
-
-//--------------------------------------------------cvalues.c
-void cvalues_init(void);
-value_t fl_idiv2(value_t a, value_t b);
-value_t fl_div2(value_t a, value_t b);
-value_t fl_mul_any(value_t *args, uint32_t nargs, int64_t Saccum);
-value_t fl_neg(value_t n);
-value_t fl_add_any(value_t *args, uint32_t nargs, fixnum_t carryIn);
-value_t cvalue_array_aset(value_t *args);
-value_t cvalue_array_aref(value_t *args);
-value_t cvalue_relocate(value_t v);
-void sweep_finalizers(void);
-
-extern htable_t TypeTable;
-extern htable_t reverse_dlsym_lookup_table;
-extern fltype_t *mpinttype;
-
-int cvalue_array_init(fltype_t *ft, value_t arg, void *dest);
-int cvalue_enum_init(fltype_t *ft, value_t arg, void *dest);
-
-value_t mk_mpint(mpint *n);
-
-#ifdef BITS64
-#define NWORDS(sz) (((sz)+7)>>3)
-#else
-#define NWORDS(sz) (((sz)+3)>>2)
-#endif
-
-int isarray(value_t v);
-_Noreturn void DivideByZeroError(void);
-
-//--------------------------------------------------cvalues.c
-
//--------------------------------------------------read.c
int isnumtok(char *tok, value_t *pval);
--- a/flmain.c
+++ b/flmain.c
@@ -1,5 +1,6 @@
#include "llt.h"
#include "flisp.h"
+#include "cvalues.h"
static value_t
argv_list(int argc, char *argv[])
--- a/iostream.c
+++ b/iostream.c
@@ -1,5 +1,6 @@
#include "llt.h"
#include "flisp.h"
+#include "cvalues.h"
static value_t iostreamsym, rdsym, wrsym, apsym, crsym, truncsym;
static value_t instrsym, outstrsym;
--- a/operators.h
+++ b/operators.h
@@ -5,15 +5,15 @@
double conv_to_double(void *data, numerictype_t tag);
void conv_from_double(void *dest, double d, numerictype_t tag);
-int64_t conv_to_int64(void *data, numerictype_t tag);
-uint64_t conv_to_uint64(void *data, numerictype_t tag);
-int32_t conv_to_int32(void *data, numerictype_t tag);
-uint32_t conv_to_uint32(void *data, numerictype_t tag);
-
int cmp_same_lt(void *a, void *b, numerictype_t tag);
int cmp_same_eq(void *a, void *b, numerictype_t tag);
int cmp_lt(void *a, numerictype_t atag, void *b, numerictype_t btag);
int cmp_eq(void *a, numerictype_t atag, void *b, numerictype_t btag, int equalnans);
+
+int64_t conv_to_int64(void *data, numerictype_t tag);
+uint64_t conv_to_uint64(void *data, numerictype_t tag);
+int32_t conv_to_int32(void *data, numerictype_t tag);
+uint32_t conv_to_uint32(void *data, numerictype_t tag);
#if defined(ULONG64)
#define conv_to_long conv_to_int64
--- a/print.c
+++ b/print.c
@@ -2,7 +2,7 @@
#include "flisp.h"
#include "operators.h"
#include "opcodes.h"
-
+#include "cvalues.h"
#include "ieee754.h"
htable_t printconses;
--- a/read.c
+++ b/read.c
@@ -1,5 +1,6 @@
#include "llt.h"
#include "flisp.h"
+#include "cvalues.h"
enum {
TOK_NONE, TOK_OPEN, TOK_CLOSE, TOK_DOT, TOK_QUOTE, TOK_SYM, TOK_NUM,
--- a/string.c
+++ b/string.c
@@ -4,6 +4,7 @@
#include "llt.h"
#include "flisp.h"
#include "operators.h"
+#include "cvalues.h"
BUILTIN("string?", stringp)
{
--- a/table.c
+++ b/table.c
@@ -1,6 +1,7 @@
#include "llt.h"
#include "flisp.h"
#include "equalhash.h"
+#include "cvalues.h"
static value_t tablesym;
static fltype_t *tabletype;
--- a/types.c
+++ b/types.c
@@ -1,5 +1,6 @@
#include "llt.h"
#include "flisp.h"
+#include "cvalues.h"
#include "equalhash.h"