1 #define CELL_MAX (CELL)(-1)
2 #define FIXNUM_MAX (((F_FIXNUM)1 << (WORD_SIZE - TAG_BITS - 1)) - 1)
3 #define FIXNUM_MIN (-((F_FIXNUM)1 << (WORD_SIZE - TAG_BITS - 1)))
4 #define ARRAY_SIZE_MAX ((CELL)1 << (WORD_SIZE - TAG_BITS - 2))
6 DLLEXPORT F_FIXNUM
to_fixnum(CELL tagged
);
7 DLLEXPORT CELL
to_cell(CELL tagged
);
9 void primitive_bignum_to_fixnum(void);
10 void primitive_float_to_fixnum(void);
12 void primitive_fixnum_add(void);
13 void primitive_fixnum_subtract(void);
14 void primitive_fixnum_multiply(void);
16 DLLEXPORT F_FASTCALL
void overflow_fixnum_add(F_FIXNUM x
, F_FIXNUM y
);
17 DLLEXPORT F_FASTCALL
void overflow_fixnum_subtract(F_FIXNUM x
, F_FIXNUM y
);
18 DLLEXPORT F_FASTCALL
void overflow_fixnum_multiply(F_FIXNUM x
, F_FIXNUM y
);
20 void primitive_fixnum_divint(void);
21 void primitive_fixnum_divmod(void);
22 void primitive_fixnum_shift(void);
28 INLINE CELL
tag_bignum(F_ARRAY
* bignum
)
30 return RETAG(bignum
,BIGNUM_TYPE
);
33 void primitive_fixnum_to_bignum(void);
34 void primitive_float_to_bignum(void);
35 void primitive_bignum_eq(void);
36 void primitive_bignum_add(void);
37 void primitive_bignum_subtract(void);
38 void primitive_bignum_multiply(void);
39 void primitive_bignum_divint(void);
40 void primitive_bignum_divmod(void);
41 void primitive_bignum_mod(void);
42 void primitive_bignum_and(void);
43 void primitive_bignum_or(void);
44 void primitive_bignum_xor(void);
45 void primitive_bignum_shift(void);
46 void primitive_bignum_less(void);
47 void primitive_bignum_lesseq(void);
48 void primitive_bignum_greater(void);
49 void primitive_bignum_greatereq(void);
50 void primitive_bignum_not(void);
51 void primitive_bignum_bitp(void);
52 void primitive_bignum_log2(void);
53 void primitive_byte_array_to_bignum(void);
55 INLINE CELL
allot_integer(F_FIXNUM x
)
57 if(x
< FIXNUM_MIN
|| x
> FIXNUM_MAX
)
58 return tag_bignum(fixnum_to_bignum(x
));
63 INLINE CELL
allot_cell(CELL x
)
65 if(x
> (CELL
)FIXNUM_MAX
)
66 return tag_bignum(cell_to_bignum(x
));
72 DLLEXPORT
void box_signed_1(s8 n
);
73 DLLEXPORT
void box_unsigned_1(u8 n
);
74 DLLEXPORT
void box_signed_2(s16 n
);
75 DLLEXPORT
void box_unsigned_2(u16 n
);
76 DLLEXPORT
void box_signed_4(s32 n
);
77 DLLEXPORT
void box_unsigned_4(u32 n
);
78 DLLEXPORT
void box_signed_cell(F_FIXNUM integer
);
79 DLLEXPORT
void box_unsigned_cell(CELL cell
);
80 DLLEXPORT
void box_signed_8(s64 n
);
81 DLLEXPORT s64
to_signed_8(CELL obj
);
83 DLLEXPORT
void box_unsigned_8(u64 n
);
84 DLLEXPORT u64
to_unsigned_8(CELL obj
);
86 CELL
unbox_array_size(void);
88 void primitive_from_fraction(void);
90 INLINE
double untag_float_fast(CELL tagged
)
92 return ((F_FLOAT
*)UNTAG(tagged
))->n
;
95 INLINE
double untag_float(CELL tagged
)
97 type_check(FLOAT_TYPE
,tagged
);
98 return untag_float_fast(tagged
);
101 INLINE CELL
allot_float(double n
)
103 F_FLOAT
* flo
= allot_object(FLOAT_TYPE
,sizeof(F_FLOAT
));
105 return RETAG(flo
,FLOAT_TYPE
);
108 INLINE F_FIXNUM
float_to_fixnum(CELL tagged
)
110 return (F_FIXNUM
)untag_float_fast(tagged
);
113 INLINE F_ARRAY
*float_to_bignum(CELL tagged
)
115 return double_to_bignum(untag_float_fast(tagged
));
118 INLINE
double fixnum_to_float(CELL tagged
)
120 return (double)untag_fixnum_fast(tagged
);
123 INLINE
double bignum_to_float(CELL tagged
)
125 return bignum_to_double(untag_object(tagged
));
128 DLLEXPORT
void box_float(float flo
);
129 DLLEXPORT
float to_float(CELL value
);
130 DLLEXPORT
void box_double(double flo
);
131 DLLEXPORT
double to_double(CELL value
);
133 void primitive_fixnum_to_float(void);
134 void primitive_bignum_to_float(void);
135 void primitive_str_to_float(void);
136 void primitive_float_to_str(void);
137 void primitive_float_to_bits(void);
139 void primitive_float_eq(void);
140 void primitive_float_add(void);
141 void primitive_float_subtract(void);
142 void primitive_float_multiply(void);
143 void primitive_float_divfloat(void);
144 void primitive_float_mod(void);
145 void primitive_float_less(void);
146 void primitive_float_lesseq(void);
147 void primitive_float_greater(void);
148 void primitive_float_greatereq(void);
150 void primitive_float_bits(void);
151 void primitive_bits_float(void);
152 void primitive_double_bits(void);
153 void primitive_bits_double(void);
155 void primitive_from_rect(void);