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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! # C2Rust transpiled header contents (static inline functions
//!
//! Types in here are distinct from those created in the main module (using bindgen); unifying
//! those will be part of [bindgen's #1334], but it's a long way there.
//!
//! [bindgen's #1334]: https://github.com/rust-lang/rust-bindgen/issues/1344
//!
//! Use these functions through the re-export in the main module, for the C headers may flip-flop
//! between static inline and linked.
//!
//! ---
//!
//! Some special treatment has been applied in the course of the transpilation process:
//!
//! * All functions were made `pub`
//! * All functions have their `extern "C"` removed. Any C component would already use it via their
//! original definitions, there is no need to re-export them or to restrain their ABI (as they
//! are here for efficient inlining into Rust code only).
//! * For C const initializers (eg. `#define MUTEX_INIT { { NULL } }`), there is no way for a
//! transpiler to recognize which type this is actually for. That information is tracked manually
//! in `build.rs` as a list of known initializers. They get turned into const functions in the
//! style of `fn init_MUTEX_INIT() -> mutex_t`.
//!
// While it'd be tempting to clean them all up in RIOT by a large constification haul, now is not
// the time for that
// Probably __attribute__((used)) doesn't get translated
extern "C"
/// Compatibility macro that looks up assembly in the deprecated `llvm_asm!` style in a manually
/// manged list of known short snippets mapped to `asm!` equivalents.
///
/// As this is tailored for RIOT's C2Rust output, code not found in the list is not rejected at
/// compile time, but mapped to the external (and nonexistent) symbol
/// [llvm_asm_is_not_supported_any_more]. This allows otherwise unused code (which is there either
/// because the bulk-used CMSIS just defines it and it is unused by RIOT, or just because it
/// doesn't happen to be used by any actually used function) to just slip through without causing
/// much fuss.
///
/// This is defined right in the inline module, because using it from another module would make the
/// imports ambiguous versus the builtin `llvm_asm!` macro.
;
// (The following are typically found in programs that use riot_wrappers::interrupt::free or
// anyting else that toggles interrupts).
=> ;
=> ;
=> ;
=> ;
// From RISC-V's interrupt handling
=> ;
=> ;
=> ;
=> ;
}
use cty as libc;
use *;
// This is a replacement for the `pub type __locale_t` and the IO lines that C2Rust generates
// because of something from stdlib; it is stripped out of the compiled code and turned into a u8
// pointer for lack of better ideas. (Leaving it as a pub struct would require unstable Rust).
//
// The type is hugely sized to ensure that things crash (or preferably don't build) if at any point
// Rust code tries to touch an instance of it, eg. by allocating one on the stack or statically.
include!;
include!;