Re: External functions returning C_DOUBLE are called twice (bug?)
- Posted by ghaberek (admin) Dec 17, 2020
- 1042 views
Browsing through be_callc.c, I'm pretty sure the culprit is this call_routine() macro on line 1480.
#define call_routine(type) \ if( is_double ) double_result = dcall_x86_64( long_proc_address, (double*)dbl_op, arg_op SIGNATURE_PARAM);\ if( is_float ) float_result = fcall_x86_64( long_proc_address, (double*)dbl_op, arg_op SIGNATURE_PARAM);\ else int_result = icall_x86_64( long_proc_address, (double*)dbl_op, arg_op, int_args SIGNATURE_PARAM )
For the first if statement, if is_double is TRUE, it will trigger the call to dcall_x86_64(). Then the second if statement triggers its else block because is_float is FALSE.
So really that ought to be...
#define call_routine(type) \ if ( is_double ) double_result = dcall_x86_64( long_proc_address, (double*)dbl_op, arg_op SIGNATURE_PARAM);\ else if( is_float ) float_result = fcall_x86_64( long_proc_address, (double*)dbl_op, arg_op SIGNATURE_PARAM);\ else int_result = icall_x86_64( long_proc_address, (double*)dbl_op, arg_op, int_args SIGNATURE_PARAM )
I'll test this change and see what happens.
-Greg