Hi List,
in libaldor, the file sal_fltgmp.as uses GMP functions in 'coerce' as
follows:
struct Fmt13 {
FiWord X0_pr;
FiWord X1_sz;
FiWord X2_expo;
FiWord X3_lmbs;
};
[...]
struct Fmt32 {
FiDFlo X0_float;
};
[...]
static FiWord
CF24_coerce(FiEnv e1, FiWord P0_a)
{
[...]
PFmt13 T2, T3;
PFmt32 T1;
[...]
T1 = fi0RecNew(struct Fmt32 , CENSUS_Rec);
[...]
T3 = fi0RecNew(struct Fmt13 , CENSUS_Rec);
[...]
T2 = T3;
L1: __gmpf_init((FiWord) T2);
__gmpf_set_d((FiWord) T2, T1);
[...]
}
1) Fmt13 is not what __gmpf_init expects. What the function expects is
more like
struct mpf_struct {
int X0_pr;
int X1_sz;
int X2_expo;
Pointer X3_lmbs;
};
This is fine on 32 bit platforms, but on 64 bit platforms with the
LP64 data model, this breaks horribly.
2) __gmpf_set_d expects the same struct as above as first argument and a
plain double as second argument. T1, however, is a pointer to a struct
containing a plain double. It will *always* receive garbage. Passing
T1->X0_float would work, but currently, there is no support for
something like that.
This seems to be an inherent problem with the way Aldor generates C code.
How should this be solved? I really don't have many ideas on this one.
The compiler expects the functions to nicely work with those arguments,
but they don't. The only solution I can think of is wrapping all foreign
functions.
--
Pippijn van Steenhoven
_______________________________________________
Aldor-l mailing list
Aldor-l@...
http://aldor.org/mailman/listinfo/aldor-l_aldor.org