File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
src/test/run-make/wasm-stringify-ints-small Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ -include ../../run-make-fulldeps/tools.mk
2+
3+ ifeq ($(TARGET ) ,wasm32-unknown-unknown)
4+ all :
5+ $(RUSTC ) foo.rs -C lto -O --target wasm32-unknown-unknown
6+ wc -c < $(TMPDIR ) /foo.wasm
7+ [ " ` wc -c < $( TMPDIR) /foo.wasm` " -lt " 21000" ]
8+ else
9+ all :
10+ endif
Original file line number Diff line number Diff line change 1+ #![ crate_type = "cdylib" ]
2+
3+ extern "C" {
4+ fn observe ( ptr : * const u8 , len : usize ) ;
5+
6+ fn get_u8 ( ) -> u8 ;
7+ fn get_i8 ( ) -> i8 ;
8+ fn get_u16 ( ) -> u16 ;
9+ fn get_i16 ( ) -> i16 ;
10+ fn get_u32 ( ) -> u32 ;
11+ fn get_i32 ( ) -> i32 ;
12+ fn get_u64 ( ) -> u64 ;
13+ fn get_i64 ( ) -> i64 ;
14+ fn get_usize ( ) -> usize ;
15+ fn get_isize ( ) -> isize ;
16+ }
17+
18+ macro_rules! stringify {
19+ ( $( $f: ident) * ) => {
20+ $(
21+ let s = $f( ) . to_string( ) ;
22+ observe( s. as_ptr( ) , s. len( ) ) ;
23+ ) *
24+ } ;
25+ }
26+
27+ #[ no_mangle]
28+ pub unsafe extern "C" fn foo ( ) {
29+ stringify ! ( get_u8) ;
30+ stringify ! ( get_i8) ;
31+ stringify ! ( get_u16) ;
32+ stringify ! ( get_i16) ;
33+ stringify ! ( get_u32) ;
34+ stringify ! ( get_i32) ;
35+ stringify ! ( get_u64) ;
36+ stringify ! ( get_i64) ;
37+ stringify ! ( get_usize) ;
38+ stringify ! ( get_isize) ;
39+ }
You can’t perform that action at this time.
0 commit comments