shithub: femtolisp

ref: 19bd6a97e2538709bd9df13098db7c3a16c25680
dir: /cvalues.h/

View raw version
#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