test/loader/loaded.rad 586 B raw
1
//! A package executed by both hosted compilation and the kernel loader.
2
3
/// Counter owned by each package instance.
4
unsafe static counter: i64 = 1;
5
/// Read-only table of slices into this instance's initialized data, which the loader relocates.
6
constant FACTORS: [*[u8]; 2] = ["6", "7"];
7
8
/// Compute a result through a package-local call.
9
unsafe fn calculate(value: i64) -> i64 {
10
    set counter += value * (FACTORS[0][0] as i64 - 48);
11
    return counter;
12
}
13
14
/// Return the result checked by both execution paths.
15
@default unsafe fn main() -> i32 {
16
    return calculate(7) as i32;
17
}