Test t_callc.e, ARCH's and C_ULONGLONG
- Posted by agrellum Oct 11, 2017
- 1074 views
First off, I do not feel well and this helps me past time.
I have compiled openeuphoria manys time and many ways with : gcc (GCC) 4.9.4 and gcc-7 (OpenIndiana 7.2.0-OI-1) 7.2.0 as : HOST_ARCH=ix86 MFLAG=-m32 and : HOST_ARCH=ix86_64 MFLAG=-m64 With gcc-7 which now defaults to -std=c11 I must prefix all inlines in : be_callc.c, be_machine.c and be_socket.c with: __attribute__ ((gnu_inline)) inline and this allows me to use INFINITY in be_machine.c without patch. BEST COMPILES, WITH THE MOST TESTS PASSING: HOST_ARCH=ix86 MFLAG=-m32C_ULONGLONG call in t_callc.e on line 83 will pass in m64 compile but to many other tests fail elsewhere.
80 atom r_max_uint_fn 81 for i = 1 to length(minus_1_values) do 82 r_max_uint_fn = define_c_func( "", call_back( routine_id("minus_1_fn") ), {}, unsigned_types[i] ) 83 test_equal( sprintf("return type %s makes unsigned value", {unsigned_type_names[i]}), minus_1_values[i], c_func(r_max_uint_fn, {}) ) 84 end for
WHAT HAPPENS using m32:
When t_callc.e gets to C_ULONGLONG on line 83 it goes to b_callc.e :
It is all good until line 1517 :
1507 else if (return_type == C_ULONGLONG ){ 1508 1509 #if UINTPTR_MAX == UINT32_MAX 1510 unsigned long long int uint64_t_result; 1511 #else 1512 #define uint64_t_result int_result 1513 #endif 1514 #if __ARM_PCS_VFP == 1 1515 uint64_t_result = icall_x86_64( long_proc_address, (double*)dbl_op, arg_op, int_args SIGNATURE_PARAM ); 1516 #endif 1517 call_routine(uint64_t); 1518 if( uint64_t_result <= (unsigned long long int)MAXINT ){ 1519 return (intptr_t) uint64_t_result; 1520 } 1521 else{ 1522 return NewDouble( (eudouble)(uint64_t) uint64_t_result ); 1523 } 1524 }
Line 1517 then goes to call_routine defined at line 1461 on my system and compile :
1460 #define call_routine(type) \ 1461 if (cdecl_call) {\ 1462 type ## _result = (*((type ( __cdecl *)())long_proc_address))();\ 1463 pop();\ 1464 }\ 1465 else\ 1466 type ## _result = (*((type (__stdcall *)())long_proc_address))()
Wrong value is returned.
Also, is line 98 right in test818.c
97 MAKE_GET_VAL_FN(long long, C_LONGLONG, _BFF_FD, C000_LONGLONG_VALUE - 20) 98 MAKE_GET_VAL_FN(unsigned long long, C_ULONGLONG, _BFF_FD, C000_LONGLONG_VALUE - 20)
Should it be C000_LONGLONG_VALUE or C000_ULONGLONG_VALUE?