ref: fb6911294e7fe271ef2da5281330dc92b44195f8
parent: b0300f7bdec6a4c6795496b99db3248aca6d5022
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Mar 18 17:34:36 EDT 2025
csl_v → sl_cv
--- a/src/builtins.c
+++ b/src/builtins.c
@@ -83,7 +83,7 @@
argcount(nargs, 1);
sl_v a = args[0];
- csl_v *cv;
+ sl_cv *cv;
if(iscons(a)){
usize n = 0;
--- a/src/cvalues.c
+++ b/src/cvalues.c
@@ -7,7 +7,7 @@
enum {
MAX_INL_SIZE = 384,
- CVALUE_NWORDS = sizeof(csl_v)/sizeof(sl_v),
+ CVALUE_NWORDS = sizeof(sl_cv)/sizeof(sl_v),
CV_OWNED = 1<<0,
};
@@ -18,7 +18,7 @@
static void cvalue_init(sl_type *type, sl_v v, void *dest);
void
-add_finalizer(csl_v *cv)
+add_finalizer(sl_cv *cv)
{
if(slg.nfinalizers == slg.maxfinalizers){
slg.maxfinalizers *= 2;
@@ -32,9 +32,9 @@
void
sweep_finalizers(void)
{
- csl_v **lst = slg.finalizers;
+ sl_cv **lst = slg.finalizers;
usize n = 0, ndel = 0, l = slg.nfinalizers;
- csl_v *tmp;
+ sl_cv *tmp;
#define SWAP_sf(a, b) (tmp = a, a = b, b = tmp, 1)
if(l == 0)
return;
@@ -61,7 +61,7 @@
// compute the size of the metadata object for a cvalue
static usize
-cv_nwords(csl_v *cv)
+cv_nwords(sl_cv *cv)
{
if(!isinlined(cv))
return CVALUE_NWORDS;
@@ -72,7 +72,7 @@
}
void
-cv_autorelease(csl_v *cv)
+cv_autorelease(sl_cv *cv)
{
cv->type = (sl_type*)(((uintptr)cv->type) | CV_OWNED);
add_finalizer(cv);
@@ -102,7 +102,7 @@
sz++;
str = true;
}
- csl_v *pcv;
+ sl_cv *pcv;
if(sz <= MAX_INL_SIZE){
usize nw = CVALUE_NWORDS + NWORDS(sz);
pcv = alloc_words(nw);
@@ -136,7 +136,7 @@
sl_v
cvalue_from_ref(sl_type *type, void *ptr, usize sz)
{
- csl_v *pcv;
+ sl_cv *pcv;
assert(type != nil);
assert(ptr != nil);
@@ -185,7 +185,7 @@
// convert to malloc representation (fixed address)
void
-cv_pin(csl_v *cv)
+cv_pin(sl_cv *cv)
{
if(!isinlined(cv))
return;
@@ -275,7 +275,7 @@
if(isfixnum(arg)){
n = vtomp(numval(arg), nil);
}else if(iscvalue(arg)){
- csl_v *cv = ptr(arg);
+ sl_cv *cv = ptr(arg);
void *p = cv_data(cv);
n = conv_to_mp(p, cp_numtype(cv));
}else if(iscprim(arg)){
@@ -415,7 +415,7 @@
return;
}
if(iscvalue(arg)){
- csl_v *cv = ptr(arg);
+ sl_cv *cv = ptr(arg);
if(isarr(arg)){
sl_type *aet = cv_class(cv)->eltype;
if(aet == eltype){
@@ -494,7 +494,7 @@
usize
cvalue_arrlen(sl_v v)
{
- csl_v *cv = ptr(v);
+ sl_cv *cv = ptr(v);
return cv_len(cv)/cv_class(cv)->elsz;
}
@@ -526,7 +526,7 @@
to_sized_ptr(sl_v v, u8int **pdata, usize *psz)
{
if(iscvalue(v)){
- csl_v *pcv = ptr(v);
+ sl_cv *pcv = ptr(v);
sl_ios *x;
if(isio(v) && (x = value2c(sl_ios*, v))->bm == bm_mem){
*pdata = x->buf;
@@ -588,8 +588,8 @@
cvalue_relocate(sl_v v)
{
usize nw;
- csl_v *cv = ptr(v);
- csl_v *nv;
+ sl_cv *cv = ptr(v);
+ sl_cv *nv;
sl_v ncv;
nw = cv_nwords(cv);
@@ -612,9 +612,9 @@
{
assert(iscvalue(v));
PUSH(v);
- csl_v *cv = ptr(v);
+ sl_cv *cv = ptr(v);
usize nw = cv_nwords(cv);
- csl_v *ncv = alloc_words(nw);
+ sl_cv *ncv = alloc_words(nw);
v = POP();
cv = ptr(v);
memcpy(ncv, cv, nw * sizeof(sl_v));
@@ -699,8 +699,8 @@
sl_v
cvalue_compare(sl_v a, sl_v b)
{
- csl_v *ca = ptr(a);
- csl_v *cb = ptr(b);
+ sl_cv *ca = ptr(a);
+ sl_cv *cb = ptr(b);
char *adata = cv_data(ca);
char *bdata = cv_data(cb);
usize asz = cv_len(ca);
@@ -720,7 +720,7 @@
check_addr_args(sl_v arr, sl_v ind, u8int **data, int *index)
{
int numel;
- csl_v *cv = ptr(arr);
+ sl_cv *cv = ptr(arr);
*data = cv_data(cv);
numel = cv_len(cv)/cv_class(cv)->elsz;
*index = tosize(ind);
@@ -787,7 +787,7 @@
sl_v
cbuiltin(const char *name, builtin_t f)
{
- csl_v *cv;
+ sl_cv *cv;
cv = MEM_CALLOC(CVALUE_NWORDS-1, sizeof(*cv));
assert(cv != nil);
cv->type = sl_builtintype;
@@ -922,7 +922,7 @@
num_to_ptr(sl_v a, sl_fx *pi, sl_numtype *pt, void **pp)
{
sl_cprim *cp;
- csl_v *cv;
+ sl_cv *cv;
if(isfixnum(a)){
*pi = numval(a);
*pp = pi;
@@ -1232,7 +1232,7 @@
}
}
if(iscvalue(a)){
- csl_v *cv = ptr(a);
+ sl_cv *cv = ptr(a);
ta = cp_numtype(cv);
aptr = cv_data(cv);
if(ta == T_MP){
--- a/src/cvalues.h
+++ b/src/cvalues.h
@@ -6,9 +6,9 @@
#define NWORDS(sz) (((sz)+3)>>2)
#endif
-void add_finalizer(csl_v *cv);
+void add_finalizer(sl_cv *cv);
void sweep_finalizers(void);
-void cv_autorelease(csl_v *cv);
+void cv_autorelease(sl_cv *cv);
sl_v cvalue_(sl_type *type, usize sz, bool nofinalizer);
#define cvalue(type, sz) cvalue_(type, sz, false)
#define cvalue_nofinalizer(type, sz) cvalue_(type, sz, true)
@@ -18,7 +18,7 @@
sl_v str_from_cstrn(char *str, usize n);
sl_v str_from_cstr(char *str);
bool sl_isstr(sl_v v) sl_purefn;
-void cv_pin(csl_v *cv);
+void cv_pin(sl_cv *cv);
sl_v size_wrap(usize sz);
usize tosize(sl_v n);
soffset tooffset(sl_v n);
--- a/src/equal.c
+++ b/src/equal.c
@@ -69,7 +69,7 @@
bounded_compare(sl_v a, sl_v b, int bound, bool eq)
{
sl_v d;
- csl_v *cv;
+ sl_cv *cv;
compare_top:
if(a == b)
@@ -323,7 +323,7 @@
}u;
sl_numtype nt;
usize i, len;
- csl_v *cv;
+ sl_cv *cv;
sl_cprim *cp;
void *data;
uintptr h = 0;
--- a/src/io.c
+++ b/src/io.c
@@ -348,7 +348,7 @@
{
argcount(nargs, 2);
sl_v str = cvalue_str(80);
- csl_v *cv = ptr(str);
+ sl_cv *cv = ptr(str);
u8int *data = cv_data(cv);
sl_ios dest;
ios_mem(&dest, 0);
--- a/src/print.c
+++ b/src/print.c
@@ -105,7 +105,7 @@
print_traverse(f->vals);
print_traverse(f->env);
}else if(iscvalue(v)){
- csl_v *cv = ptr(v);
+ sl_cv *cv = ptr(v);
// don't consider shared references to ""
if(!cv_isstr(cv) || cv_len(cv) != 0)
mark_cons(v);
@@ -844,7 +844,7 @@
static void
cvalue_print(sl_ios *f, sl_v v)
{
- csl_v *cv = ptr(v);
+ sl_cv *cv = ptr(v);
void *data = cptr(v);
sl_v label;
--- a/src/sl.c
+++ b/src/sl.c
@@ -199,7 +199,7 @@
SAFECAST_OP(cons, sl_cons*, ptr)
SAFECAST_OP(sym, sl_sym*, ptr)
SAFECAST_OP(fixnum, sl_fx, numval)
-//SAFECAST_OP(cvalue, csl_v*, ptr)
+//SAFECAST_OP(cvalue, sl_cv*, ptr)
SAFECAST_OP(str, char*, cvalue_data)
#undef isstr
@@ -583,7 +583,7 @@
sl_v f = saveSP[-n-1];
sl_v v;
if(iscbuiltin(f))
- v = ((csl_v*)ptr(f))->cbuiltin(saveSP-n, n);
+ v = ((sl_cv*)ptr(f))->cbuiltin(saveSP-n, n);
else if(isfn(f))
v = apply_cl(n);
else if(sl_likely(isbuiltin(f))){
@@ -958,7 +958,7 @@
type_error("str", args[0]);
if(sl_unlikely(!isvec(args[1])))
type_error("vec", args[1]);
- csl_v *arr = ptr(args[0]);
+ sl_cv *arr = ptr(args[0]);
cv_pin(arr);
u8int *data = cv_data(arr);
if(slg.loading){
--- a/src/sl.h
+++ b/src/sl.h
@@ -301,7 +301,7 @@
};
usize len; // length of *data in bytes
u8int _space[]; // variable size
-}sl_aligned(8) csl_v;
+}sl_aligned(8) sl_cv;
typedef struct {
sl_type *type;
@@ -316,14 +316,14 @@
}sl_aligned(8) sl_fn;
#define CPRIM_NWORDS sizeof(sl_cprim)/sizeof(sl_v)
-#define cv_class(cv) ((sl_type*)(((uintptr)((csl_v*)cv)->type)&~(uintptr)3))
-#define cv_len(cv) (((csl_v*)(cv))->len)
+#define cv_class(cv) ((sl_type*)(((uintptr)((sl_cv*)cv)->type)&~(uintptr)3))
+#define cv_len(cv) (((sl_cv*)(cv))->len)
#define cv_type(cv) (cv_class(cv)->type)
-#define cv_data(cv) (((csl_v*)(cv))->data)
+#define cv_data(cv) (((sl_cv*)(cv))->data)
#define cv_isstr(cv) (cv_class(cv)->eltype == sl_bytetype)
#define cv_isPOD(cv) (cv_class(cv)->init != nil)
-#define cvalue_data(v) cv_data((csl_v*)ptr(v))
-#define cvalue_len(v) cv_len((csl_v*)ptr(v))
+#define cvalue_data(v) cv_data((sl_cv*)ptr(v))
+#define cvalue_len(v) cv_len((sl_cv*)ptr(v))
#define value2c(type, v) ((type)cvalue_data(v))
#define cp_class(cp) (((sl_cprim*)(cp))->type)
#define cp_type(cp) (cp_class(cp)->type)
@@ -387,7 +387,7 @@
u8int *curheap;
u8int *lim;
usize malloc_pressure;
- csl_v **finalizers;
+ sl_cv **finalizers;
usize nfinalizers;
usize maxfinalizers;
Tbl *symbols;
--- a/src/sl_arith_any.h
+++ b/src/sl_arith_any.h
@@ -13,7 +13,7 @@
sl_numtype pt;
void *a;
sl_cprim *cp;
- csl_v *cv;
+ sl_cv *cv;
u32int i, j;
FOR_ARGS(i, 0, arg, args){
--- a/src/str.c
+++ b/src/str.c
@@ -309,7 +309,7 @@
nd = rbuf;
nd[ndbytes] = 0;
}else if(sl_isstr(v)){
- csl_v *cv = ptr(v);
+ sl_cv *cv = ptr(v);
ndbytes = cv_len(cv);
nd = (char*)cv_data(cv);
}else{
--- a/src/table.c
+++ b/src/table.c
@@ -123,7 +123,7 @@
equalhash_put(h, (void*)args[1], (void*)args[2]);
// register finalizer if we outgrew inline space
if(table0 == &h->_space[0] && h->table != &h->_space[0]){
- csl_v *cv = ptr(args[0]);
+ sl_cv *cv = ptr(args[0]);
add_finalizer(cv);
cv->len = sizeof(sl_htable) - inline_space;
}
--- a/src/vm.h
+++ b/src/vm.h
@@ -88,7 +88,7 @@
}else if(sl_likely(iscbuiltin(v))){
sl.sp = sp;
sp -= n;
- sp[-1] = ((csl_v*)ptr(v))->cbuiltin(sp, n);
+ sp[-1] = ((sl_cv*)ptr(v))->cbuiltin(sp, n);
NEXT_OP;
}
sl.sp = sp;