@@ -14,24 +14,22 @@ mod test_utils;
14
14
#[ cfg( not( test) ) ]
15
15
#[ panic_handler]
16
16
fn panic ( _info : & core:: panic:: PanicInfo ) -> ! {
17
+ // TODO: just call libc::abort - fails to link
18
+ // unsafe { libc::abort() }
17
19
unsafe { core:: intrinsics:: abort ( ) }
18
20
}
19
21
22
+ // TODO: there has to be a way to avoid this
20
23
#[ cfg( not( test) ) ]
21
24
#[ lang = "eh_personality" ]
22
25
extern "C" fn eh_personality ( ) { }
23
26
24
- // All functions to be exported by the C ABI.
25
- // Includes a test input/output pair for testing.
26
- // The test output will be used to override the
27
- // result of the function, and the test input
28
- // is used to call the overriden function from C.
29
- // This is needed to make sure that we are linking
30
- // against this libm during testing, and not the
31
- // system's libm.
27
+ // This macro exports the functions that are part of the C ABI.
32
28
//
33
- //
34
- // FIXME: missing symbols: _memcpy, _memset, etc.
29
+ // It generates tests that replace the implementation of the
30
+ // function with a specific value, that then is used to check
31
+ // that the library is properly linked.
32
+
35
33
export ! {
36
34
fn acos( x: f64 ) -> f64 : ( 42. ) -> 42. ;
37
35
fn acosf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
@@ -41,6 +39,7 @@ export! {
41
39
fn asinf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
42
40
fn asinh( x: f64 ) -> f64 : ( 42. ) -> 42. ;
43
41
fn asinhf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
42
+ // FIXME: fails to link. Missing symbol: _memcpy
44
43
// fn atan(x: f64) -> f64: (42.) -> 42.;
45
44
fn atanf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
46
45
fn atanh( x: f64 ) -> f64 : ( 42. ) -> 42. ;
@@ -51,6 +50,7 @@ export! {
51
50
fn ceilf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
52
51
fn copysign( x: f64 , y: f64 ) -> f64 : ( 42. , 42. ) -> 42. ;
53
52
fn copysignf( x: f32 , y: f32 ) -> f32 : ( 42. , 42. ) -> 42. ;
53
+ // FIXME: fails to link. Missing symbols
54
54
//fn cos(x: f64) -> f64: (42.) -> 42.;
55
55
//fn cosf(x: f32) -> f32: (42.) -> 42.;
56
56
fn cosh( x: f64 ) -> f64 : ( 42. ) -> 42. ;
@@ -83,7 +83,7 @@ export! {
83
83
fn fmod( x: f64 , y: f64 ) -> f64 : ( 42. , 42. ) -> 42. ;
84
84
fn fmodf( x: f32 , y: f32 ) -> f32 : ( 42. , 42. ) -> 42. ;
85
85
86
- // different ABI than in C
86
+ // TODO: different ABI than in C - need a more elaborate wrapper
87
87
// fn frexp(x: f64) -> (f64, i32): (42.) -> (42., 42);
88
88
// fn frexpf(x: f32) -> (f32, i32): (42.) -> (42., 42);
89
89
@@ -92,7 +92,7 @@ export! {
92
92
fn ilogb( x: f64 ) -> i32 : ( 42. ) -> 42 ;
93
93
fn ilogbf( x: f32 ) -> i32 : ( 42. ) -> 42 ;
94
94
95
- // FIXME: fail to link:
95
+ // FIXME: fails to link. Missing symbols
96
96
// fn j0(x: f64) -> f64: (42.) -> 42.;
97
97
// fn j0f(x: f32) -> f32: (42.) -> 42.;
98
98
// fn j1(x: f64) -> f64: (42.) -> 42.;
@@ -105,7 +105,7 @@ export! {
105
105
fn lgamma( x: f64 ) -> f64 : ( 42. ) -> 42. ;
106
106
fn lgammaf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
107
107
108
- // different ABI
108
+ // TODO: different ABI than in C - need a more elaborate wrapper
109
109
// fn lgamma_r(x: f64) -> (f64, i32): (42.) -> (42., 42);
110
110
// fn lgammaf_r(x: f32) -> (f32, i32): (42.) -> (42., 42);
111
111
@@ -119,10 +119,10 @@ export! {
119
119
fn log2f( x: f32 ) -> f32 : ( 42. ) -> 42. ;
120
120
fn pow( x: f64 , y: f64 ) -> f64 : ( 42. , 42. ) -> 42. ;
121
121
fn powf( x: f32 , y: f32 ) -> f32 : ( 42. , 42. ) -> 42. ;
122
+
123
+ // FIXME: different ABI than in C - need a more elaborate wrapper
122
124
// fn modf(x: f64) -> (f64, f64): (42.) -> (42., 42.);
123
125
// fn modff(x: f32) -> (f32, f32): (42.) -> (42., 42.);
124
-
125
- // different ABI
126
126
// remquo
127
127
// remquof
128
128
@@ -131,21 +131,24 @@ export! {
131
131
fn scalbn( x: f64 , n: i32 ) -> f64 : ( 42. , 42 ) -> 42. ;
132
132
fn scalbnf( x: f32 , n: i32 ) -> f32 : ( 42. , 42 ) -> 42. ;
133
133
134
- // different ABI
134
+ // FIXME: different ABI than in C - need a more elaborate wrapper
135
135
// fn sincos
136
136
// fn sincosf
137
137
138
+ // FIXME: missing symbols - fails to link
138
139
// fn sin(x: f64) -> f64: (42.) -> 42.;
139
140
// fn sinf(x: f32) -> f32: (42.) -> 42.;
140
141
141
142
fn sinh( x: f64 ) -> f64 : ( 42. ) -> 42. ;
142
143
fn sinhf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
143
144
fn sqrt( x: f64 ) -> f64 : ( 42. ) -> 42. ;
144
145
fn sqrtf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
146
+ // FIXME: missing symbols - fails to link
145
147
// fn tan(x: f64) -> f64: (42.) -> 42.;
146
148
// fn tanf(x: f32) -> f32: (42.) -> 42.;
147
149
fn tanh( x: f64 ) -> f64 : ( 42. ) -> 42. ;
148
150
fn tanhf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
151
+ // FIXME: missing symbols - fails to link
149
152
// fn tgamma(x: f64) -> f64: (42.) -> 42.;
150
153
// fn tgammaf(x: f32) -> f32: (42.) -> 42.;
151
154
fn trunc( x: f64 ) -> f64 : ( 42. ) -> 42. ;
0 commit comments