zephyr_sys/lib.rs
1// Copyright (c) 2024 Linaro LTD
2// SPDX-License-Identifier: Apache-2.0
3
4//! Zephyr application support for Rust
5//!
6//! This crates provides the core functionality for applications written in Rust that run on top of
7//! Zephyr.
8
9#![no_std]
10// Allow rust naming convention violations.
11#![allow(non_snake_case)]
12#![allow(non_upper_case_globals)]
13#![allow(non_camel_case_types)]
14// Zephyr makes use of zero-sized structs, which Rustc considers invalid. Suppress this warning.
15// Note, however, that this suppresses any warnings in the bindings about improper C types.
16#![allow(improper_ctypes)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::bare_urls)]
19// Disable various clippy warnings as they will not be fixable in the bindgen generated code.
20#![allow(clippy::missing_safety_doc)]
21#![allow(clippy::transmute_int_to_bool)]
22#![allow(clippy::useless_transmute)]
23#![allow(clippy::len_without_is_empty)]
24include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
25
26// We have directed bindgen to not generate copy for any times. It unfortunately doesn't have an
27// easy mechanism to enable just for a few types.
28
29// Fortunately, it isn't difficult to mostly auto-derive copy/clone.
30macro_rules! derive_clone {
31 ($($t:ty),+ $(,)?) => {
32 $(
33 impl Clone for $t {
34 fn clone(&self) -> $t {
35 *self
36 }
37 }
38 )+
39 };
40}
41
42macro_rules! derive_copy {
43 ($($t:ty),+ $(,)?) => {
44 $(
45 impl Copy for $t {}
46 )+
47 }
48}
49
50derive_copy!(z_spinlock_key);
51derive_clone!(z_spinlock_key);
52derive_copy!(k_timeout_t);
53derive_clone!(k_timeout_t);