@@ -16,6 +16,40 @@ typedef enum {
16
16
static float_format_type double_format , float_format ;
17
17
static float_format_type detected_double_format , detected_float_format ;
18
18
19
+ __attribute__((constructor ))
20
+ static void init_formats (void ) {
21
+ #if SIZEOF_DOUBLE == 8
22
+ {
23
+ double x = 9006104071832581.0 ;
24
+ if (memcmp (& x , "\x43\x3f\xff\x01\x02\x03\x04\x05" , 8 ) == 0 )
25
+ detected_double_format = ieee_big_endian_format ;
26
+ else if (memcmp (& x , "\x05\x04\x03\x02\x01\xff\x3f\x43" , 8 ) == 0 )
27
+ detected_double_format = ieee_little_endian_format ;
28
+ else
29
+ detected_double_format = unknown_format ;
30
+ }
31
+ #else
32
+ detected_double_format = unknown_format ;
33
+ #endif
34
+
35
+ #if SIZEOF_FLOAT == 4
36
+ {
37
+ float y = 16711938.0 ;
38
+ if (memcmp (& y , "\x4b\x7f\x01\x02" , 4 ) == 0 )
39
+ detected_float_format = ieee_big_endian_format ;
40
+ else if (memcmp (& y , "\x02\x01\x7f\x4b" , 4 ) == 0 )
41
+ detected_float_format = ieee_little_endian_format ;
42
+ else
43
+ detected_float_format = unknown_format ;
44
+ }
45
+ #else
46
+ detected_float_format = unknown_format ;
47
+ #endif
48
+
49
+ double_format = detected_double_format ;
50
+ float_format = detected_float_format ;
51
+ }
52
+
19
53
UPCALL_ID (PyFloat_AsDouble );
20
54
double PyFloat_AsDouble (PyObject * op ) {
21
55
return ((double (* )(void * ))_jls_PyFloat_AsDouble )(native_to_java (op ));
0 commit comments