xref: /aosp_15_r20/external/bazelbuild-rules_rust/test/no_std/lib.rs (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifan #![no_std]
2*d4726bddSHONG Yifan // These features are needed to support no_std + alloc
3*d4726bddSHONG Yifan #![feature(lang_items)]
4*d4726bddSHONG Yifan #![feature(alloc_error_handler)]
5*d4726bddSHONG Yifan #![feature(core_intrinsics)]
6*d4726bddSHONG Yifan #![allow(unused_imports)]
7*d4726bddSHONG Yifan use custom_alloc;
8*d4726bddSHONG Yifan 
9*d4726bddSHONG Yifan #[cfg(all(not(feature = "std"), not(test)))]
10*d4726bddSHONG Yifan mod no_std;
11*d4726bddSHONG Yifan 
12*d4726bddSHONG Yifan #[cfg(not(feature = "std"))]
13*d4726bddSHONG Yifan #[no_mangle]
return_5_in_no_std() -> i3214*d4726bddSHONG Yifan pub extern "C" fn return_5_in_no_std() -> i32 {
15*d4726bddSHONG Yifan     5
16*d4726bddSHONG Yifan }
17*d4726bddSHONG Yifan 
18*d4726bddSHONG Yifan #[cfg(feature = "std")]
19*d4726bddSHONG Yifan #[no_mangle]
return_5_in_no_std() -> i3220*d4726bddSHONG Yifan pub extern "C" fn return_5_in_no_std() -> i32 {
21*d4726bddSHONG Yifan     6
22*d4726bddSHONG Yifan }
23