summary refs log tree commit diff
path: root/seccomp/arm
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2019-03-12 17:12:28 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-03-17 14:38:45 -0700
commitc324429b467d530fbeadef1fc9b527bb23ce1632 (patch)
tree0bd748676eaa4c97dc6647c7d25a8ce1abdb3d86 /seccomp/arm
parentfba396e42f07ed4b49479117a6f4646fed32c467 (diff)
downloadcrosvm-c324429b467d530fbeadef1fc9b527bb23ce1632.tar
crosvm-c324429b467d530fbeadef1fc9b527bb23ce1632.tar.gz
crosvm-c324429b467d530fbeadef1fc9b527bb23ce1632.tar.bz2
crosvm-c324429b467d530fbeadef1fc9b527bb23ce1632.tar.lz
crosvm-c324429b467d530fbeadef1fc9b527bb23ce1632.tar.xz
crosvm-c324429b467d530fbeadef1fc9b527bb23ce1632.tar.zst
crosvm-c324429b467d530fbeadef1fc9b527bb23ce1632.zip
bitfield: Support BitFieldSpecifier for enums
Previously, the getter and setter functions generated for a bitfield
struct by #[bitfield] all operated on primitive types like bool, u8, u16
etc.

This CL adds support for getters and setters defined in terms of
user-defined enums.

We make an enum bitfield-compatible by adding #[bitfield]. The number of
variants must be a power of 2.

    #[bitfield]
    enum TwoBits {
        Zero = 0b00,
        One = 0b01,
        Two = 0b10,
        Three = 0b11,
    }

And then it may be used to specify a field in a bitfield struct.

    #[bitfield]
    struct Struct {
        prefix: BitField1,
        two_bits: TwoBits,
        suffix: BitField5,
    }

The generated getters and setters for this struct would have the
following signatures:

    impl Struct {
        fn get_prefix(&self) -> u8;
        fn set_prefix(&mut self, val: u8);

        fn get_two_bits(&self) -> TwoBits;
        fn set_two_bits(&mut self, val: TwoBits);

        fn get_suffix(&self) -> u8;
        fn set_suffix(&mut self, val: u8);
    }

TEST=`cargo test` the bit_field and bit_field_derive crates
TEST=`cargo check` crosvm

Change-Id: Ibc8923e2877fda6ae8da5767731edcb68721a434
Reviewed-on: https://chromium-review.googlesource.com/1519686
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
Diffstat (limited to 'seccomp/arm')
0 files changed, 0 insertions, 0 deletions