shithub: sl

ref: 22b11e5411affc4a91204eb45590bd1796274e35
dir: /src/cvalues.h/

View raw version
#pragma once

#if defined(BITS64)
#define NWORDS(sz) (((sz)+7)>>3)
#else
#define NWORDS(sz) (((sz)+3)>>2)
#endif

void add_finalizer(cvalue_t *cv);
void sweep_finalizers(void);
void cv_autorelease(cvalue_t *cv);
value_t cvalue_(sltype_t *type, size_t sz, bool nofinalizer);
#define cvalue(type, sz) cvalue_(type, sz, false)
#define cvalue_nofinalizer(type, sz) cvalue_(type, sz, true)
value_t cvalue_from_ref(sltype_t *type, void *ptr, size_t sz);
value_t cvalue_string(size_t sz);
value_t cvalue_static_cstring(const char *str);
value_t string_from_cstrn(char *str, size_t n);
value_t string_from_cstr(char *str);
bool sl_isstring(value_t v) sl_purefn;
void cv_pin(cvalue_t *cv);
value_t size_wrap(size_t sz);
size_t tosize(value_t n);
off_t tooffset(value_t n);
bool isarray(value_t v) sl_purefn;
void cvalue_array_init(sltype_t *ft, value_t arg, void *dest);
size_t cvalue_arraylen(value_t v) sl_purefn;
size_t ctype_sizeof(value_t type);
void to_sized_ptr(value_t v, u8int **pdata, size_t *psz);
value_t cvalue_relocate(value_t v);
value_t cvalue_copy(value_t v);
value_t cvalue_compare(value_t a, value_t b) sl_purefn;
value_t cvalue_array_aref(value_t *args);
value_t cvalue_array_aset(value_t *args);
value_t cbuiltin(const char *name, builtin_t f);
value_t return_from_u64(u64int Uaccum);
value_t return_from_s64(s64int Saccum);
value_t sl_add_any(value_t *args, u32int nargs);
value_t sl_neg(value_t n);
value_t sl_mul_any(value_t *args, u32int nargs);
bool num_to_ptr(value_t a, fixnum_t *pi, numerictype_t *pt, void **pp);
_Noreturn void divide_by_0_error(void);
value_t sl_div2(value_t a, value_t b);
value_t sl_idiv2(value_t a, value_t b);
void cvalues_init(void);

value_t mk_double(double n);
value_t mk_float(float n);
value_t mk_s32(s32int n);
value_t mk_u32(u32int n);
value_t mk_s64(s64int n);
value_t mk_u64(u64int n);
value_t mk_rune(Rune n);
value_t mk_mp(mpint *n);

size_t llength(value_t v) sl_purefn;