Update bitflags to 0.9.1 (#347)

Signed-off-by: Tim Crawford <crawfxrd@gmail.com>
This commit is contained in:
Tim Crawford
2017-08-05 00:33:56 -04:00
committed by Philipp Oppermann
parent 7b04934cab
commit e54cfa4378
7 changed files with 44 additions and 44 deletions

View File

@@ -5,7 +5,7 @@ version = "0.1.0"
[dependencies] [dependencies]
bit_field = "0.7.0" bit_field = "0.7.0"
bitflags = "0.7.0" bitflags = "0.9.1"
multiboot2 = "0.1.0" multiboot2 = "0.1.0"
once = "0.3.2" once = "0.3.2"
rlibc = "1.0" rlibc = "1.0"

View File

@@ -614,12 +614,12 @@ We get the following output:
// in src/interrupts/mod.rs // in src/interrupts/mod.rs
bitflags! { bitflags! {
flags PageFaultErrorCode: u64 { struct PageFaultErrorCode: u64 {
const PROTECTION_VIOLATION = 1 << 0, const PROTECTION_VIOLATION = 1 << 0;
const CAUSED_BY_WRITE = 1 << 1, const CAUSED_BY_WRITE = 1 << 1;
const USER_MODE = 1 << 2, const USER_MODE = 1 << 2;
const MALFORMED_TABLE = 1 << 3, const MALFORMED_TABLE = 1 << 3;
const INSTRUCTION_FETCH = 1 << 4, const INSTRUCTION_FETCH = 1 << 4;
} }
} }
``` ```

View File

@@ -633,7 +633,7 @@ Let's try `make run` again:
Compiling spin v0.4.5 Compiling spin v0.4.5
Compiling once v0.3.2 Compiling once v0.3.2
Compiling x86 v0.8.0 Compiling x86 v0.8.0
Compiling bitflags v0.7.0 Compiling bitflags v0.9.1
Compiling raw-cpuid v2.0.1 Compiling raw-cpuid v2.0.1
Compiling rlibc v0.1.5 Compiling rlibc v0.1.5
Compiling linked_list_allocator v0.2.3 Compiling linked_list_allocator v0.2.3

View File

@@ -97,7 +97,7 @@ To model the various flags, we will use the [bitflags] crate. To add it as a dep
```toml ```toml
[dependencies] [dependencies]
... ...
bitflags = "0.7.0" bitflags = "0.9.1"
``` ```
To import the macro, we need to use `#[macro_use]` above the `extern crate` definition: To import the macro, we need to use `#[macro_use]` above the `extern crate` definition:
@@ -112,23 +112,23 @@ Now we can model the various flags:
```rust ```rust
bitflags! { bitflags! {
pub flags EntryFlags: u64 { pub struct EntryFlags: u64 {
const PRESENT = 1 << 0, const PRESENT = 1 << 0;
const WRITABLE = 1 << 1, const WRITABLE = 1 << 1;
const USER_ACCESSIBLE = 1 << 2, const USER_ACCESSIBLE = 1 << 2;
const WRITE_THROUGH = 1 << 3, const WRITE_THROUGH = 1 << 3;
const NO_CACHE = 1 << 4, const NO_CACHE = 1 << 4;
const ACCESSED = 1 << 5, const ACCESSED = 1 << 5;
const DIRTY = 1 << 6, const DIRTY = 1 << 6;
const HUGE_PAGE = 1 << 7, const HUGE_PAGE = 1 << 7;
const GLOBAL = 1 << 8, const GLOBAL = 1 << 8;
const NO_EXECUTE = 1 << 63, const NO_EXECUTE = 1 << 63;
} }
} }
``` ```
To extract the flags from the entry we create an `Entry::flags` method that uses [from_bits_truncate]: To extract the flags from the entry we create an `Entry::flags` method that uses [from_bits_truncate]:
[from_bits_truncate]: https://doc.rust-lang.org/bitflags/bitflags/macro.bitflags!.html#methods [from_bits_truncate]: https://doc.rust-lang.org/bitflags/bitflags/index.html#methods-1
```rust ```rust
pub fn flags(&self) -> EntryFlags { pub fn flags(&self) -> EntryFlags {

View File

@@ -558,12 +558,12 @@ The flag bits are common between all descriptor types, so we create a general `D
// in src/interrupts/gdt.rs // in src/interrupts/gdt.rs
bitflags! { bitflags! {
flags DescriptorFlags: u64 { struct DescriptorFlags: u64 {
const CONFORMING = 1 << 42, const CONFORMING = 1 << 42;
const EXECUTABLE = 1 << 43, const EXECUTABLE = 1 << 43;
const USER_SEGMENT = 1 << 44, const USER_SEGMENT = 1 << 44;
const PRESENT = 1 << 47, const PRESENT = 1 << 47;
const LONG_MODE = 1 << 53, const LONG_MODE = 1 << 53;
} }
} }
``` ```

View File

@@ -85,11 +85,11 @@ impl Descriptor {
} }
bitflags! { bitflags! {
flags DescriptorFlags: u64 { struct DescriptorFlags: u64 {
const CONFORMING = 1 << 42, const CONFORMING = 1 << 42;
const EXECUTABLE = 1 << 43, const EXECUTABLE = 1 << 43;
const USER_SEGMENT = 1 << 44, const USER_SEGMENT = 1 << 44;
const PRESENT = 1 << 47, const PRESENT = 1 << 47;
const LONG_MODE = 1 << 53, const LONG_MODE = 1 << 53;
} }
} }

View File

@@ -42,17 +42,17 @@ impl Entry {
} }
bitflags! { bitflags! {
pub flags EntryFlags: u64 { pub struct EntryFlags: u64 {
const PRESENT = 1 << 0, const PRESENT = 1 << 0;
const WRITABLE = 1 << 1, const WRITABLE = 1 << 1;
const USER_ACCESSIBLE = 1 << 2, const USER_ACCESSIBLE = 1 << 2;
const WRITE_THROUGH = 1 << 3, const WRITE_THROUGH = 1 << 3;
const NO_CACHE = 1 << 4, const NO_CACHE = 1 << 4;
const ACCESSED = 1 << 5, const ACCESSED = 1 << 5;
const DIRTY = 1 << 6, const DIRTY = 1 << 6;
const HUGE_PAGE = 1 << 7, const HUGE_PAGE = 1 << 7;
const GLOBAL = 1 << 8, const GLOBAL = 1 << 8;
const NO_EXECUTE = 1 << 63, const NO_EXECUTE = 1 << 63;
} }
} }