]> git.sesse.net Git - bcachefs-tools-debian/blob - rust-src/bch_bindgen/src/opts.rs
d38d469ce654f2a64d1a945d87fa45bb8c936b11
[bcachefs-tools-debian] / rust-src / bch_bindgen / src / opts.rs
1 #[macro_export]
2 macro_rules! opt_set {
3     ($opts:ident, $n:ident, $v:expr) => {
4         bch_bindgen::paste! {
5             $opts.$n = $v;
6             $opts.[<set_ $n _defined>](1)
7         }
8     };
9 }
10
11 #[macro_export]
12 macro_rules! opt_defined {
13     ($opts:ident, $n:ident) => {
14         bch_bindgen::paste! {
15             $opts.[< $n _defined>]()
16         }
17     };
18 }
19
20 #[macro_export]
21 macro_rules! opt_get {
22     ($opts:ident, $n:ident) => {
23         if bch_bindgen::opt_defined!($opts, $n) == 0 {
24             bch_bindgen::paste! {
25                 unsafe {
26                     bch_bindgen::bcachefs::bch2_opts_default.$n
27                 }
28             }
29         } else {
30             bch_bindgen::paste! {
31                 $opts.$n
32             }
33         }
34     };
35 }