I had somehow assumed that the interface between linux poplog
and C worked, because all sorts of things have been using it,
including all the X window facilities, such as XVed, rclib,
propsheet and other things.
So I assumed that the recently reported problem about a fortran function
failing to return a single float result to pop11 on linux even though
double floats all work fine was specific to fortran.
But I've just done a simple test which indicates that there is a problem
with the C interface also. (I am not a C programmer -- so I may have
made a mistake).
This is what I did, copying and modifying an earlier test program
provided by David Young:
I created a file called floatbaz.c containing only:
double dbaz(double x)
{return x-100.0;}
float baz(float x)
{return x-100.0;}
int ibaz(int x)
{return x-100;}
I compiled this with
gcc -o floatbaz.so -fpic -shared floatbaz.c
which produced a file: floatbaz.so
I then did this in pop11:
exload floatbaz [floatbaz]
(language C)
dbaz(1):dfloat,
baz(1):float,
ibaz(1):int
endexload;
;;; testing dbaz produces expected result
exacc dbaz(301.0) =>
** 201.0
;;; testing baz produces wrong result
exacc baz(301.0) =>
** 0.0
exacc baz(1.0) =>
** 0.0
;;; testing ibaz produces expected result
exacc ibaz(301) =>
** 201
So integer results and double float results work fine, but not
single float results. Changing the exload command to use sfloat
baz(1):sfloat,
makes no difference.
So the problem is there in C too (if what I have done is OK).
I apologise for not checking this earlier.
This is actually reassuring as it is likely that some relatively simple
fix to do with converting a machine float to a pop11 decimal will
fix the problem, whereas something that worked for C and not for Fortran
would be more difficult.
It looks as if this bit of the linux Poplog port was never tested
properly.
Aaron
|