diff --git a/src/builtins/fns.c b/src/builtins/fns.c index 5521e5cd..13dcd3dc 100644 --- a/src/builtins/fns.c +++ b/src/builtins/fns.c @@ -1,5 +1,6 @@ #include "../core.h" #include "../utils/hash.h" +#include "../utils/calls.h" #include "../utils/mut.h" #include "../utils/talloc.h" #include "../builtins.h" diff --git a/src/builtins/fold.c b/src/builtins/fold.c index e03aa201..75fe441a 100644 --- a/src/builtins/fold.c +++ b/src/builtins/fold.c @@ -13,7 +13,6 @@ #include "../core.h" #include "../builtins.h" -#include "../utils/calls.h" #include "../utils/mut.h" #if SINGELI_X86_64 diff --git a/src/builtins/internal.c b/src/builtins/internal.c index b6359854..61ebebda 100644 --- a/src/builtins/internal.c +++ b/src/builtins/internal.c @@ -291,9 +291,6 @@ B internalTemp_c1(B t, B x) { return x; } -#ifdef TEST_MUT - #include "../utils/calls.h" -#endif B internalTemp_c2(B t, B w, B x) { #if NATIVE_COMPILER return c2(native_comp, w, x); diff --git a/src/builtins/md1.c b/src/builtins/md1.c index 7c82b4c5..4d8ff0ad 100644 --- a/src/builtins/md1.c +++ b/src/builtins/md1.c @@ -2,6 +2,7 @@ #include "../utils/each.h" #include "../utils/file.h" #include "../utils/time.h" +#include "../utils/calls.h" #include "../builtins.h" diff --git a/src/builtins/search.c b/src/builtins/search.c index 0c830751..eaf79b29 100644 --- a/src/builtins/search.c +++ b/src/builtins/search.c @@ -23,7 +23,6 @@ #include "../core.h" #include "../utils/hash.h" #include "../utils/talloc.h" -#include "../utils/calls.h" #define C2i(F, W, X) C2(F, m_i32(W), X) extern B eq_c2(B,B,B); diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index c601567b..2c212962 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -1,6 +1,5 @@ #include "../core.h" #include "../utils/hash.h" -#include "../utils/calls.h" #include "../utils/file.h" #include "../utils/wyhash.h" #include "../utils/time.h" diff --git a/src/core/stuff.c b/src/core/stuff.c index c5b285b7..5c233b33 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -1,5 +1,6 @@ #include "../core.h" #include "../utils/mut.h" +#include "../utils/calls.h" #include "../utils/utf.h" #include "../utils/talloc.h" #include "../builtins.h" diff --git a/src/core/stuff.h b/src/core/stuff.h index 29be290c..8c929527 100644 --- a/src/core/stuff.h +++ b/src/core/stuff.h @@ -31,6 +31,13 @@ static void decSh(Value* x) { if (RARE(PRNK(x)>1)) decShObj(shObjP(x)); } // some array stuff +typedef void (*M_CopyF)(void*, usz, B, usz, usz); +typedef void (*M_FillF)(void*, usz, B, usz); +extern M_CopyF copyFns[el_MAX]; +extern M_FillF fillFns[el_MAX]; +#define COPY_TO(WHERE, ELT, MS, X, XS, LEN) copyFns[ELT](WHERE, MS, X, XS, LEN) +#define FILL_TO(WHERE, ELT, MS, X, LEN) fillFns[ELT](WHERE, MS, X, LEN) + #define TYARR_SZ(T,IA) fsizeof(TyArr, a, T##Atom, IA) #define TYARR_SZ2(T,IA) TYARR_SZ(T,IA) #define TYARR_SZW(W,IA) (offsetof(TyArr, a) + (W)*(IA)) @@ -136,17 +143,11 @@ static bool eqShape(B w, B x) { assert(isArr(w)); assert(isArr(x)); return eqShPart(wsh, xsh, wr); } -typedef void (*M_CopyF)(void*, usz, B, usz, usz); -typedef void (*M_FillF)(void*, usz, B, usz); -extern M_CopyF copyFns[el_MAX]; -extern M_FillF fillFns[el_MAX]; -#define COPY_TO(WHERE, ELT, MS, X, XS, LEN) copyFns[ELT](WHERE, MS, X, XS, LEN) -#define FILL_TO(WHERE, ELT, MS, X, LEN) fillFns[ELT](WHERE, MS, X, LEN) - B bit_sel(B b, B e0, B e1); // consumes b; b must be bitarr; b⊏e0‿e1 Arr* allZeroes(usz ia); Arr* allOnes(usz ia); B bit_negate(B x); // consumes +void bit_negatePtr(u64* rp, u64* xp, usz count); // count is number of u64-s B widenBitArr(B x, ur axis); // consumes x, assumes bitarr; returns some array with cell size padded to the nearest of 8,16,32,64 if ≤64 bits, or a multiple of 64 bits otherwise B narrowWidenedBitArr(B x, ur axis, ur cr, usz* csh); // consumes x.val; undoes widenBitArr, overriding shape past axis to cr↑csh @@ -198,6 +199,9 @@ void fprint_fmt(FILE* f, char* p, ...); // function stuff +#define C1(F, X) F##_c1(m_f64(0), X) +#define C2(F,W,X) F##_c2(m_f64(0),W,X) + char* type_repr(u8 u); char* pfn_repr(u8 u); char* pm1_repr(u8 u); diff --git a/src/main.c b/src/main.c index 180b60d8..d3f12eff 100644 --- a/src/main.c +++ b/src/main.c @@ -64,7 +64,6 @@ static NOINLINE i64 readInt(char** p) { #if USE_REPLXX #include #include - #include "utils/calls.h" #include "utils/cstr.h" Replxx* global_replxx; static char* global_histfile; diff --git a/src/rtwrap.c b/src/rtwrap.c index ae2729ee..1ac8508b 100644 --- a/src/rtwrap.c +++ b/src/rtwrap.c @@ -4,7 +4,6 @@ #include "builtins.h" #endif #include "utils/time.h" -#include "utils/calls.h" #if defined(RT_WRAP) || defined(WRAP_NNBI) diff --git a/src/utils/calls.h b/src/utils/calls.h index 10a85528..57e9604a 100644 --- a/src/utils/calls.h +++ b/src/utils/calls.h @@ -1,7 +1,6 @@ #pragma once -#define C1(F, X) F##_c1(m_f64(0), X) -#define C2(F,W,X) F##_c2(m_f64(0),W,X) + #define M1C1(M,F, X) m1c1_unsafe(M##_c1, bi_##F, X) #define M1C2(M,F,W,X) m1c2_unsafe(M##_c2, bi_##F, W, X) static inline B m1c1_unsafe(D1C1 m, B f, B x) { Md1D d; d.f=f; return m(&d, x); } @@ -35,5 +34,3 @@ extern u8 eqFnData[]; typedef struct { EqFn fn; u8 data; } EqFnObj; #define EQFN_GET(W_ELT, X_ELT) ({ u8 eqfn_i_ = EQFN_INDEX(W_ELT, X_ELT); (EqFnObj){.fn=eqFns[eqfn_i_], .data=eqFnData[eqfn_i_]}; }) #define EQFN_CALL(FN, W, X, L) (FN).fn(W, X, L, (FN).data) - -void bit_negatePtr(u64* rp, u64* xp, usz count); // count is number of u64-s diff --git a/src/utils/each.c b/src/utils/each.c index 177b2154..5638f7dc 100644 --- a/src/utils/each.c +++ b/src/utils/each.c @@ -1,6 +1,5 @@ #include "../core.h" #include "each.h" -#include "calls.h" static inline B mv(B* p, usz n) { B r = p [n]; p [n] = m_f64(0); return r; } static inline B hmv(HArr_p p, usz n) { B r = p.a[n]; p.a[n] = m_f64(0); return r; } diff --git a/src/utils/mut.h b/src/utils/mut.h index f22d9340..12b9242e 100644 --- a/src/utils/mut.h +++ b/src/utils/mut.h @@ -1,5 +1,4 @@ #pragma once -#include "calls.h" /* Usage: diff --git a/src/utils/utf.c b/src/utils/utf.c index 30f4abad..82fc8063 100644 --- a/src/utils/utf.c +++ b/src/utils/utf.c @@ -1,6 +1,5 @@ #include "../core.h" #include "utf.h" -#include "calls.h" static i8 utf8lenb(u8 ch) { if (ch<128) return 1;