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)]
24#![allow(unnecessary_transmutes)]
25include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
26
27// We have directed bindgen to not generate copy for any times.  It unfortunately doesn't have an
28// easy mechanism to enable just for a few types.
29
30// Fortunately, it isn't difficult to mostly auto-derive copy/clone.
31macro_rules! derive_clone {
32    ($($t:ty),+ $(,)?) => {
33        $(
34            impl Clone for $t {
35                fn clone(&self) -> $t {
36                    *self
37                }
38            }
39        )+
40    };
41}
42
43macro_rules! derive_copy {
44    ($($t:ty),+ $(,)?) => {
45        $(
46            impl Copy for $t {}
47        )+
48    }
49}
50
51derive_copy!(z_spinlock_key);
52derive_clone!(z_spinlock_key);
53derive_copy!(k_timeout_t);
54derive_clone!(k_timeout_t);