mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +02:00
Issue #510 - Stage macos compat fix
Apparently mp_set_double does not compile on OSX. Need to fix up this portion of the code.
This commit is contained in:
parent
3e3f0114e5
commit
29a27098a8
1 changed files with 73 additions and 0 deletions
73
runtime.c
73
runtime.c
|
@ -8572,3 +8572,76 @@ void Cyc_get_ratio(void *data, object cont, object n, int numerator)
|
|||
return_closcall1(data, cont, &val);
|
||||
}
|
||||
}
|
||||
|
||||
void Cyc_exact(void *data, object cont, object z)
|
||||
{
|
||||
int i = 0;
|
||||
Cyc_check_num(data, z);
|
||||
if (obj_is_int(z)) {
|
||||
i = obj_obj2int(z);
|
||||
} else if (type_of(z) == integer_tag) {
|
||||
i = (int)round(((integer_type *)z)->value);
|
||||
} else if (type_of(z) == bignum_tag) {
|
||||
return_closcall1(data, cont, z);
|
||||
} else if (type_of(z) == complex_num_tag) {
|
||||
double dreal = round(creal(((complex_num_type *) z)->value));
|
||||
double dimag = round(cimag(((complex_num_type *) z)->value));
|
||||
make_complex_num(num, dreal, dimag);
|
||||
return_closcall1(data, cont, &num);
|
||||
} else {
|
||||
double d = ((double_type *)z)->value;
|
||||
if (isnan(d)) {
|
||||
Cyc_rt_raise2(data, "Expected number but received", z);
|
||||
} else if (d == INFINITY) {
|
||||
Cyc_rt_raise2(data, "Expected number but received", z);
|
||||
} else if (d == -INFINITY) {
|
||||
Cyc_rt_raise2(data, "Expected number but received", z);
|
||||
} else if (d > CYC_FIXNUM_MAX || d < CYC_FIXNUM_MIN){
|
||||
alloc_bignum(data, bn);
|
||||
BIGNUM_CALL(mp_set_double(&bignum_value(bn), d));
|
||||
return_closcall1(data, cont, bn);
|
||||
// TODO: mp_set_double not supported on macos !?!
|
||||
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559)
|
||||
#endif
|
||||
}
|
||||
i = (int)round(((double_type *)z)->value);
|
||||
}
|
||||
return_closcall1(data, cont, obj_int2obj(i));
|
||||
}
|
||||
|
||||
object Cyc_exact_no_cps(void *data, object ptr, object z)
|
||||
{
|
||||
int i = 0;
|
||||
Cyc_check_num(data, z);
|
||||
if (obj_is_int(z)) {
|
||||
i = obj_obj2int(z);
|
||||
} else if (type_of(z) == integer_tag) {
|
||||
i = (int)round(((integer_type *)z)->value);
|
||||
} else if (type_of(z) == bignum_tag) {
|
||||
return z;
|
||||
} else if (type_of(z) == complex_num_tag) {
|
||||
double dreal = round(creal(((complex_num_type *) z)->value));
|
||||
double dimag = round(cimag(((complex_num_type *) z)->value));
|
||||
double complex unboxed = dreal + (dimag * I);
|
||||
assign_complex_num(ptr, unboxed);
|
||||
return ptr;
|
||||
} else {
|
||||
double d = ((double_type *)z)->value;
|
||||
if (isnan(d)) {
|
||||
Cyc_rt_raise2(data, "Expected number but received", z);
|
||||
} else if (d == INFINITY) {
|
||||
Cyc_rt_raise2(data, "Expected number but received", z);
|
||||
} else if (d == -INFINITY) {
|
||||
Cyc_rt_raise2(data, "Expected number but received", z);
|
||||
} else if (d > CYC_FIXNUM_MAX || d < CYC_FIXNUM_MIN){
|
||||
alloc_bignum(data, bn);
|
||||
BIGNUM_CALL(mp_set_double(&bignum_value(bn), d));
|
||||
return bn;
|
||||
// TODO: mp_set_double not supported on macos !?!
|
||||
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559)
|
||||
#endif
|
||||
}
|
||||
i = (int)round(((double_type *)z)->value);
|
||||
}
|
||||
return obj_int2obj(i);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue