mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
64-bit compatibility for int value types
This commit is contained in:
parent
bcb9f3d677
commit
88f1192c5e
3 changed files with 5 additions and 5 deletions
|
@ -14,7 +14,7 @@
|
|||
object l = Cyc_length2(data, args); \
|
||||
if (num_args > obj_obj2int(l)) { \
|
||||
char buf[128]; \
|
||||
snprintf(buf, 127, "Expected %d arguments but received %d.", num_args, obj_obj2int(l)); \
|
||||
snprintf(buf, 127, "Expected %d arguments but received %ld.", num_args, obj_obj2int(l)); \
|
||||
Cyc_rt_raise_msg(data, buf); \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -211,8 +211,8 @@ typedef long tag_type;
|
|||
|
||||
// TODO: does this break negative numbers (IE, overwrite sign bit in 2's comp?)? may need a more sophisticated scheme to handle 31-bit numbers. also, ideally want to use 63 bits on a 64-bit system
|
||||
#define obj_is_int(x) ((unsigned long)(x) & (unsigned long)1)
|
||||
#define obj_obj2int(x) ((int)(x)>>1)
|
||||
#define obj_int2obj(c) ((void *)((((int)c)<<1) | 1))
|
||||
#define obj_obj2int(x) ((long)(x)>>1)
|
||||
#define obj_int2obj(c) ((void *)((((long)c)<<1) | 1))
|
||||
|
||||
#define obj_is_char(x) (((unsigned long)(x) & (unsigned long)3) == 2)
|
||||
#define obj_obj2char(x) (char)((long)(x)>>2)
|
||||
|
|
|
@ -533,7 +533,7 @@ object Cyc_display(object x, FILE *port)
|
|||
int i = 0;
|
||||
if (nullp(x)) {fprintf(port, "()"); return quote_void;}
|
||||
if (obj_is_char(x)) {fprintf(port, "%c", obj_obj2char(x)); return quote_void;}
|
||||
if (obj_is_int(x)) { fprintf(port, "%d", obj_obj2int(x)); return quote_void; }
|
||||
if (obj_is_int(x)) { fprintf(port, "%ld", obj_obj2int(x)); return quote_void; }
|
||||
switch (type_of(x))
|
||||
{case macro_tag:
|
||||
fprintf(port, "<macro %p>",(void *)((closure) x)->fn);
|
||||
|
@ -1018,7 +1018,7 @@ object Cyc_number2string(void *data, object cont, object n) {
|
|||
char buffer[1024];
|
||||
Cyc_check_num(data, n);
|
||||
if (obj_is_int(n)) {
|
||||
snprintf(buffer, 1024, "%d", obj_obj2int(n));
|
||||
snprintf(buffer, 1024, "%ld", obj_obj2int(n));
|
||||
}else if (type_of(n) == integer_tag) {
|
||||
snprintf(buffer, 1024, "%d", ((integer_type *)n)->value);
|
||||
} else if (type_of(n) == double_tag) {
|
||||
|
|
Loading…
Add table
Reference in a new issue