| 1 | |
| 2 |
|
| 3 | |
| 4 |
|
| 5 | |
| 6 | |
| 7 | |
| 8 |
|
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | #[macro_export]
|
| 21 | macro_rules! static_branch_unlikely {
|
| 22 | ($key:path, $keytyp:ty, $field:ident) => {{
|
| 23 | let _key: *const $keytyp = ::core::ptr::addr_of!($key);
|
| 24 | let _key: *const $crate::bindings::static_key_false = ::core::ptr::addr_of!((*_key).$field);
|
| 25 | let _key: *const $crate::bindings::static_key = _key.cast();
|
| 26 |
|
| 27 | #[cfg(not(CONFIG_JUMP_LABEL))]
|
| 28 | {
|
| 29 | $crate::bindings::static_key_count(_key.cast_mut()) > 0
|
| 30 | }
|
| 31 |
|
| 32 | #[cfg(CONFIG_JUMP_LABEL)]
|
| 33 | $crate::jump_label::arch_static_branch! { $key, $keytyp, $field, false }
|
| 34 | }};
|
| 35 | }
|
| 36 | pub use static_branch_unlikely;
|
| 37 |
|
| 38 | |
| 39 | #[cfg(CONFIG_JUMP_LABEL)]
|
| 40 | const _: &str = include!(concat!(
|
| 41 | env!("OBJTREE"),
|
| 42 | "/rust/kernel/generated_arch_static_branch_asm.rs"
|
| 43 | ));
|
| 44 |
|
| 45 | #[macro_export]
|
| 46 | #[doc(hidden)]
|
| 47 | #[cfg(not(testlib))]
|
| 48 | #[cfg(CONFIG_JUMP_LABEL)]
|
| 49 | macro_rules! arch_static_branch {
|
| 50 | ($key:path, $keytyp:ty, $field:ident, $branch:expr) => {'my_label: {
|
| 51 | $crate::asm!(
|
| 52 | include!(concat!(env!("OBJTREE"), "/rust/kernel/generated_arch_static_branch_asm.rs"));
|
| 53 | l_yes = label {
|
| 54 | break 'my_label true;
|
| 55 | },
|
| 56 | symb = sym $key,
|
| 57 | off = const ::core::mem::offset_of!($keytyp, $field),
|
| 58 | branch = const $crate::jump_label::bool_to_int($branch),
|
| 59 | );
|
| 60 |
|
| 61 | break 'my_label false;
|
| 62 | }};
|
| 63 | }
|
| 64 |
|
| 65 | #[macro_export]
|
| 66 | #[doc(hidden)]
|
| 67 | #[cfg(testlib)]
|
| 68 | #[cfg(CONFIG_JUMP_LABEL)]
|
| 69 | macro_rules! arch_static_branch {
|
| 70 | ($key:path, $keytyp:ty, $field:ident, $branch:expr) => {
|
| 71 | |
| 72 | false
|
| 73 | };
|
| 74 | }
|
| 75 |
|
| 76 | #[cfg(CONFIG_JUMP_LABEL)]
|
| 77 | pub use arch_static_branch;
|
| 78 |
|
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | #[doc(hidden)]
|
| 84 | pub const fn bool_to_int(b: bool) -> i32 {
|
| 85 | b as i32
|
| 86 | }
|