-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
main.rs
47 lines (32 loc) · 857 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#![no_main]
#![no_std]
#![cfg_attr(feature = "used_linker", feature(used_with_arg))]
#![allow(unknown_lints, non_local_definitions)] // FIXME
extern crate panic_semihosting;
use cortex_m_rt::entry;
use cortex_m_semihosting::{debug, hprintln};
use linkme::distributed_slice;
#[distributed_slice]
static SHENANIGANS: [i32];
#[distributed_slice(SHENANIGANS)]
static N: i32 = 9;
#[distributed_slice(SHENANIGANS)]
static NN: i32 = 99;
#[distributed_slice(SHENANIGANS)]
static NNN: i32 = 999;
#[entry]
fn main() -> ! {
assert_eq!(SHENANIGANS.len(), 3);
let mut sum = 0;
for n in SHENANIGANS {
sum += n;
}
assert_eq!(sum, 9 + 99 + 999);
#[distributed_slice]
static EMPTY: [i32] = [..];
assert!(EMPTY.is_empty());
hprintln!("success!");
// exit QEMU
debug::exit(debug::EXIT_SUCCESS);
loop {}
}