Replace ptrint_t with standard intptr_t
This commit is contained in:
parent
b35ab48437
commit
36fd757689
|
@ -111,7 +111,7 @@ static size_t cv_nwords(struct cvalue *cv)
|
|||
|
||||
static void autorelease(struct cvalue *cv)
|
||||
{
|
||||
cv->type = (struct fltype *)(((uptrint_t)cv->type) | CV_OWNED_BIT);
|
||||
cv->type = (struct fltype *)(((uintptr_t)cv->type) | CV_OWNED_BIT);
|
||||
add_finalizer(cv);
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ void cv_autorelease(struct cvalue *cv) { autorelease(cv); }
|
|||
|
||||
static value_t cprim(struct fltype *type, size_t sz)
|
||||
{
|
||||
assert(!ismanaged((uptrint_t)type));
|
||||
assert(!ismanaged((uintptr_t)type));
|
||||
assert(sz == type->size);
|
||||
struct cprim *pcp =
|
||||
(struct cprim *)alloc_words(CPRIM_NWORDS - 1 + NWORDS(sz));
|
||||
|
@ -192,7 +192,7 @@ value_t cvalue_from_ref(struct fltype *type, void *ptr, size_t sz,
|
|||
pcv->len = sz;
|
||||
pcv->type = type;
|
||||
if (parent != NIL) {
|
||||
pcv->type = (struct fltype *)(((uptrint_t)pcv->type) | CV_PARENT_BIT);
|
||||
pcv->type = (struct fltype *)(((uintptr_t)pcv->type) | CV_PARENT_BIT);
|
||||
pcv->parent = parent;
|
||||
}
|
||||
cv = tagptr(pcv, TAG_CVALUE);
|
||||
|
@ -674,7 +674,7 @@ value_t cvalue_copy(value_t v)
|
|||
autorelease(ncv);
|
||||
if (hasparent(cv)) {
|
||||
ncv->type =
|
||||
(struct fltype *)(((uptrint_t)ncv->type) & ~CV_PARENT_BIT);
|
||||
(struct fltype *)(((uintptr_t)ncv->type) & ~CV_PARENT_BIT);
|
||||
ncv->parent = NIL;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -106,22 +106,17 @@ typedef int bool_t;
|
|||
#define NBITS 64
|
||||
typedef int64_t offset_t;
|
||||
typedef uint64_t index_t;
|
||||
typedef int64_t ptrint_t; // pointer-size int
|
||||
typedef uint64_t u_ptrint_t;
|
||||
#else
|
||||
#define TOP_BIT 0x80000000
|
||||
#define NBITS 32
|
||||
typedef int32_t offset_t;
|
||||
typedef uint32_t index_t;
|
||||
typedef int32_t ptrint_t;
|
||||
typedef uint32_t u_ptrint_t;
|
||||
#endif
|
||||
|
||||
typedef uint8_t uint8_t;
|
||||
typedef uint16_t uint16_t;
|
||||
typedef uint32_t uint32_t;
|
||||
typedef uint64_t uint64_t;
|
||||
typedef u_ptrint_t uptrint_t;
|
||||
|
||||
#define LLT_ALIGN(x, sz) (((x) + (sz - 1)) & (-sz))
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ value_t fl_equal(value_t a, value_t b)
|
|||
#endif
|
||||
|
||||
// *oob: output argument, means we hit the limit specified by 'bound'
|
||||
static uptrint_t bounded_hash(value_t a, int bound, int *oob)
|
||||
static uintptr_t bounded_hash(value_t a, int bound, int *oob)
|
||||
{
|
||||
*oob = 0;
|
||||
union {
|
||||
|
@ -315,7 +315,7 @@ static uptrint_t bounded_hash(value_t a, int bound, int *oob)
|
|||
struct cvalue *cv;
|
||||
struct cprim *cp;
|
||||
void *data;
|
||||
uptrint_t h = 0;
|
||||
uintptr_t h = 0;
|
||||
int oob2, tg = tag(a);
|
||||
switch (tg) {
|
||||
case TAG_NUM:
|
||||
|
@ -388,10 +388,10 @@ int equal_lispvalue(value_t a, value_t b)
|
|||
return (numval(compare_(a, b, 1)) == 0);
|
||||
}
|
||||
|
||||
uptrint_t hash_lispvalue(value_t a)
|
||||
uintptr_t hash_lispvalue(value_t a)
|
||||
{
|
||||
int oob = 0;
|
||||
uptrint_t n = bounded_hash(a, BOUNDED_HASH_BOUND, &oob);
|
||||
uintptr_t n = bounded_hash(a, BOUNDED_HASH_BOUND, &oob);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
38
c/flisp.c
38
c/flisp.c
|
@ -271,7 +271,7 @@ static struct symbol *mk_symbol(char *str)
|
|||
|
||||
sym =
|
||||
(struct symbol *)malloc(sizeof(struct symbol) - sizeof(void *) + len + 1);
|
||||
assert(((uptrint_t)sym & 0x7) == 0); // make sure malloc aligns 8
|
||||
assert(((uintptr_t)sym & 0x7) == 0); // make sure malloc aligns 8
|
||||
sym->left = sym->right = NULL;
|
||||
sym->flags = 0;
|
||||
if (fl_is_keyword_name(str, len)) {
|
||||
|
@ -446,7 +446,7 @@ void fl_free_gc_handles(uint32_t n)
|
|||
static value_t relocate(value_t v)
|
||||
{
|
||||
value_t a, d, nc, first, *pcdr;
|
||||
uptrint_t t = tag(v);
|
||||
uintptr_t t = tag(v);
|
||||
|
||||
if (t == TAG_CONS) {
|
||||
// iterative implementation allows arbitrarily long cons chains
|
||||
|
@ -880,16 +880,16 @@ static uint32_t process_keys(value_t kwtable, uint32_t nreq, uint32_t nkw,
|
|||
if (i >= nargs)
|
||||
goto no_kw;
|
||||
// now process keywords
|
||||
uptrint_t n = vector_size(kwtable) / 2;
|
||||
uintptr_t n = vector_size(kwtable) / 2;
|
||||
do {
|
||||
i++;
|
||||
if (i >= nargs)
|
||||
lerrorf(ArgError, "keyword %s requires an argument",
|
||||
symbol_name(v));
|
||||
value_t hv = fixnum(((struct symbol *)ptr(v))->hash);
|
||||
uptrint_t x = 2 * (labs(numval(hv)) % n);
|
||||
uintptr_t x = 2 * (labs(numval(hv)) % n);
|
||||
if (vector_elt(kwtable, x) == v) {
|
||||
uptrint_t idx = numval(vector_elt(kwtable, x + 1));
|
||||
uintptr_t idx = numval(vector_elt(kwtable, x + 1));
|
||||
assert(idx < nkw);
|
||||
idx += nopt;
|
||||
if (args[idx] == UNBOUND) {
|
||||
|
@ -986,7 +986,7 @@ apply_cl_top:
|
|||
captured = 0;
|
||||
func = Stack[SP - nargs - 1];
|
||||
ip = cv_data((struct cvalue *)ptr(fn_bcode(func)));
|
||||
assert(!ismanaged((uptrint_t)ip));
|
||||
assert(!ismanaged((uintptr_t)ip));
|
||||
while (SP + GET_INT32(ip) > N_STACK) {
|
||||
grow_stack();
|
||||
}
|
||||
|
@ -1139,7 +1139,7 @@ apply_cl_top:
|
|||
func = Stack[SP - n - 1];
|
||||
if (tag(func) == TAG_FUNCTION) {
|
||||
if (func > (N_BUILTINS << 3)) {
|
||||
Stack[curr_frame - 2] = (uptrint_t)ip;
|
||||
Stack[curr_frame - 2] = (uintptr_t)ip;
|
||||
nargs = n;
|
||||
goto apply_cl_top;
|
||||
} else {
|
||||
|
@ -1193,48 +1193,48 @@ apply_cl_top:
|
|||
OP(OP_CALLL) n = GET_INT32(ip);
|
||||
ip += 4;
|
||||
goto do_call;
|
||||
OP(OP_JMP) ip += (ptrint_t)GET_INT16(ip);
|
||||
OP(OP_JMP) ip += (intptr_t)GET_INT16(ip);
|
||||
NEXT_OP;
|
||||
OP(OP_BRF)
|
||||
v = POP();
|
||||
if (v == FL_F)
|
||||
ip += (ptrint_t)GET_INT16(ip);
|
||||
ip += (intptr_t)GET_INT16(ip);
|
||||
else
|
||||
ip += 2;
|
||||
NEXT_OP;
|
||||
OP(OP_BRT)
|
||||
v = POP();
|
||||
if (v != FL_F)
|
||||
ip += (ptrint_t)GET_INT16(ip);
|
||||
ip += (intptr_t)GET_INT16(ip);
|
||||
else
|
||||
ip += 2;
|
||||
NEXT_OP;
|
||||
OP(OP_JMPL) ip += (ptrint_t)GET_INT32(ip);
|
||||
OP(OP_JMPL) ip += (intptr_t)GET_INT32(ip);
|
||||
NEXT_OP;
|
||||
OP(OP_BRFL)
|
||||
v = POP();
|
||||
if (v == FL_F)
|
||||
ip += (ptrint_t)GET_INT32(ip);
|
||||
ip += (intptr_t)GET_INT32(ip);
|
||||
else
|
||||
ip += 4;
|
||||
NEXT_OP;
|
||||
OP(OP_BRTL)
|
||||
v = POP();
|
||||
if (v != FL_F)
|
||||
ip += (ptrint_t)GET_INT32(ip);
|
||||
ip += (intptr_t)GET_INT32(ip);
|
||||
else
|
||||
ip += 4;
|
||||
NEXT_OP;
|
||||
OP(OP_BRNE)
|
||||
if (Stack[SP - 2] != Stack[SP - 1])
|
||||
ip += (ptrint_t)GET_INT16(ip);
|
||||
ip += (intptr_t)GET_INT16(ip);
|
||||
else
|
||||
ip += 2;
|
||||
POPN(2);
|
||||
NEXT_OP;
|
||||
OP(OP_BRNEL)
|
||||
if (Stack[SP - 2] != Stack[SP - 1])
|
||||
ip += (ptrint_t)GET_INT32(ip);
|
||||
ip += (intptr_t)GET_INT32(ip);
|
||||
else
|
||||
ip += 4;
|
||||
POPN(2);
|
||||
|
@ -1242,28 +1242,28 @@ apply_cl_top:
|
|||
OP(OP_BRNN)
|
||||
v = POP();
|
||||
if (v != NIL)
|
||||
ip += (ptrint_t)GET_INT16(ip);
|
||||
ip += (intptr_t)GET_INT16(ip);
|
||||
else
|
||||
ip += 2;
|
||||
NEXT_OP;
|
||||
OP(OP_BRNNL)
|
||||
v = POP();
|
||||
if (v != NIL)
|
||||
ip += (ptrint_t)GET_INT32(ip);
|
||||
ip += (intptr_t)GET_INT32(ip);
|
||||
else
|
||||
ip += 4;
|
||||
NEXT_OP;
|
||||
OP(OP_BRN)
|
||||
v = POP();
|
||||
if (v == NIL)
|
||||
ip += (ptrint_t)GET_INT16(ip);
|
||||
ip += (intptr_t)GET_INT16(ip);
|
||||
else
|
||||
ip += 2;
|
||||
NEXT_OP;
|
||||
OP(OP_BRNL)
|
||||
v = POP();
|
||||
if (v == NIL)
|
||||
ip += (ptrint_t)GET_INT32(ip);
|
||||
ip += (intptr_t)GET_INT32(ip);
|
||||
else
|
||||
ip += 4;
|
||||
NEXT_OP;
|
||||
|
|
12
c/flisp.h
12
c/flisp.h
|
@ -1,4 +1,4 @@
|
|||
typedef uptrint_t value_t;
|
||||
typedef uintptr_t value_t;
|
||||
typedef intptr_t fixnum_t;
|
||||
typedef uintptr_t ufixnum_t;
|
||||
#ifdef BITS64
|
||||
|
@ -13,7 +13,7 @@ struct cons {
|
|||
};
|
||||
|
||||
struct symbol {
|
||||
uptrint_t flags;
|
||||
uintptr_t flags;
|
||||
value_t binding; // global value binding
|
||||
struct fltype *type;
|
||||
uint32_t hash;
|
||||
|
@ -149,7 +149,7 @@ size_t llength(value_t v);
|
|||
value_t fl_compare(value_t a, value_t b); // -1, 0, or 1
|
||||
value_t fl_equal(value_t a, value_t b); // T or nil
|
||||
int equal_lispvalue(value_t a, value_t b);
|
||||
uptrint_t hash_lispvalue(value_t a);
|
||||
uintptr_t hash_lispvalue(value_t a);
|
||||
int isnumtok_base(char *tok, value_t *pval, int base);
|
||||
|
||||
/* safe casts */
|
||||
|
@ -288,10 +288,10 @@ struct function {
|
|||
|
||||
#define CV_OWNED_BIT 0x1
|
||||
#define CV_PARENT_BIT 0x2
|
||||
#define owned(cv) ((uptrint_t)(cv)->type & CV_OWNED_BIT)
|
||||
#define hasparent(cv) ((uptrint_t)(cv)->type & CV_PARENT_BIT)
|
||||
#define owned(cv) ((uintptr_t)(cv)->type & CV_OWNED_BIT)
|
||||
#define hasparent(cv) ((uintptr_t)(cv)->type & CV_PARENT_BIT)
|
||||
#define isinlined(cv) ((cv)->data == &(cv)->_space[0])
|
||||
#define cv_class(cv) ((struct fltype *)(((uptrint_t)(cv)->type) & ~3))
|
||||
#define cv_class(cv) ((struct fltype *)(((uintptr_t)(cv)->type) & ~3))
|
||||
#define cv_len(cv) ((cv)->len)
|
||||
#define cv_type(cv) (cv_class(cv)->type)
|
||||
#define cv_data(cv) ((cv)->data)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
void **tab = h->table; \
|
||||
void **ol; \
|
||||
\
|
||||
hv = HFUNC((uptrint_t)key); \
|
||||
hv = HFUNC((uintptr_t)key); \
|
||||
retry_bp: \
|
||||
iter = 0; \
|
||||
index = (index_t)(hv & (sz - 1)) * 2; \
|
||||
|
@ -99,7 +99,7 @@
|
|||
size_t sz = hash_size(h); \
|
||||
size_t maxprobe = max_probe(sz); \
|
||||
void **tab = h->table; \
|
||||
size_t index = (index_t)(HFUNC((uptrint_t)key) & (sz - 1)) * 2; \
|
||||
size_t index = (index_t)(HFUNC((uintptr_t)key) & (sz - 1)) * 2; \
|
||||
sz *= 2; \
|
||||
size_t orig = index; \
|
||||
size_t iter = 0; \
|
||||
|
|
Loading…
Reference in New Issue