@@ -14,24 +14,22 @@ mod test_utils;
1414#[ cfg( not( test) ) ]
1515#[ panic_handler]
1616fn panic ( _info : & core:: panic:: PanicInfo ) -> ! {
17+ // TODO: just call libc::abort - fails to link
18+ // unsafe { libc::abort() }
1719 unsafe { core:: intrinsics:: abort ( ) }
1820}
1921
22+ // TODO: there has to be a way to avoid this
2023#[ cfg( not( test) ) ]
2124#[ lang = "eh_personality" ]
2225extern "C" fn eh_personality ( ) { }
2326
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.
3228//
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+
3533export ! {
3634 fn acos( x: f64 ) -> f64 : ( 42. ) -> 42. ;
3735 fn acosf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
@@ -41,6 +39,7 @@ export! {
4139 fn asinf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
4240 fn asinh( x: f64 ) -> f64 : ( 42. ) -> 42. ;
4341 fn asinhf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
42+ // FIXME: fails to link. Missing symbol: _memcpy
4443 // fn atan(x: f64) -> f64: (42.) -> 42.;
4544 fn atanf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
4645 fn atanh( x: f64 ) -> f64 : ( 42. ) -> 42. ;
@@ -51,6 +50,7 @@ export! {
5150 fn ceilf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
5251 fn copysign( x: f64 , y: f64 ) -> f64 : ( 42. , 42. ) -> 42. ;
5352 fn copysignf( x: f32 , y: f32 ) -> f32 : ( 42. , 42. ) -> 42. ;
53+ // FIXME: fails to link. Missing symbols
5454 //fn cos(x: f64) -> f64: (42.) -> 42.;
5555 //fn cosf(x: f32) -> f32: (42.) -> 42.;
5656 fn cosh( x: f64 ) -> f64 : ( 42. ) -> 42. ;
@@ -83,7 +83,7 @@ export! {
8383 fn fmod( x: f64 , y: f64 ) -> f64 : ( 42. , 42. ) -> 42. ;
8484 fn fmodf( x: f32 , y: f32 ) -> f32 : ( 42. , 42. ) -> 42. ;
8585
86- // different ABI than in C
86+ // TODO: different ABI than in C - need a more elaborate wrapper
8787 // fn frexp(x: f64) -> (f64, i32): (42.) -> (42., 42);
8888 // fn frexpf(x: f32) -> (f32, i32): (42.) -> (42., 42);
8989
@@ -92,7 +92,7 @@ export! {
9292 fn ilogb( x: f64 ) -> i32 : ( 42. ) -> 42 ;
9393 fn ilogbf( x: f32 ) -> i32 : ( 42. ) -> 42 ;
9494
95- // FIXME: fail to link:
95+ // FIXME: fails to link. Missing symbols
9696 // fn j0(x: f64) -> f64: (42.) -> 42.;
9797 // fn j0f(x: f32) -> f32: (42.) -> 42.;
9898 // fn j1(x: f64) -> f64: (42.) -> 42.;
@@ -105,7 +105,7 @@ export! {
105105 fn lgamma( x: f64 ) -> f64 : ( 42. ) -> 42. ;
106106 fn lgammaf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
107107
108- // different ABI
108+ // TODO: different ABI than in C - need a more elaborate wrapper
109109 // fn lgamma_r(x: f64) -> (f64, i32): (42.) -> (42., 42);
110110 // fn lgammaf_r(x: f32) -> (f32, i32): (42.) -> (42., 42);
111111
@@ -119,10 +119,10 @@ export! {
119119 fn log2f( x: f32 ) -> f32 : ( 42. ) -> 42. ;
120120 fn pow( x: f64 , y: f64 ) -> f64 : ( 42. , 42. ) -> 42. ;
121121 fn powf( x: f32 , y: f32 ) -> f32 : ( 42. , 42. ) -> 42. ;
122+
123+ // FIXME: different ABI than in C - need a more elaborate wrapper
122124 // fn modf(x: f64) -> (f64, f64): (42.) -> (42., 42.);
123125 // fn modff(x: f32) -> (f32, f32): (42.) -> (42., 42.);
124-
125- // different ABI
126126 // remquo
127127 // remquof
128128
@@ -131,21 +131,24 @@ export! {
131131 fn scalbn( x: f64 , n: i32 ) -> f64 : ( 42. , 42 ) -> 42. ;
132132 fn scalbnf( x: f32 , n: i32 ) -> f32 : ( 42. , 42 ) -> 42. ;
133133
134- // different ABI
134+ // FIXME: different ABI than in C - need a more elaborate wrapper
135135 // fn sincos
136136 // fn sincosf
137137
138+ // FIXME: missing symbols - fails to link
138139 // fn sin(x: f64) -> f64: (42.) -> 42.;
139140 // fn sinf(x: f32) -> f32: (42.) -> 42.;
140141
141142 fn sinh( x: f64 ) -> f64 : ( 42. ) -> 42. ;
142143 fn sinhf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
143144 fn sqrt( x: f64 ) -> f64 : ( 42. ) -> 42. ;
144145 fn sqrtf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
146+ // FIXME: missing symbols - fails to link
145147 // fn tan(x: f64) -> f64: (42.) -> 42.;
146148 // fn tanf(x: f32) -> f32: (42.) -> 42.;
147149 fn tanh( x: f64 ) -> f64 : ( 42. ) -> 42. ;
148150 fn tanhf( x: f32 ) -> f32 : ( 42. ) -> 42. ;
151+ // FIXME: missing symbols - fails to link
149152 // fn tgamma(x: f64) -> f64: (42.) -> 42.;
150153 // fn tgammaf(x: f32) -> f32: (42.) -> 42.;
151154 fn trunc( x: f64 ) -> f64 : ( 42. ) -> 42. ;
0 commit comments