Browse Source

Use bitflags for ElfSectionFlags

Philipp Oppermann 9 years ago
parent
commit
078aaf6219
3 changed files with 15 additions and 7 deletions
  1. 4 0
      Cargo.toml
  2. 8 7
      src/elf_sections.rs
  3. 3 0
      src/lib.rs

+ 4 - 0
Cargo.toml

@@ -2,3 +2,7 @@
 name = "multiboot2"
 version = "0.1.0"
 authors = ["Philipp Oppermann <dev@phil-opp.com>"]
+
+[dependencies.bitflags]
+git = "https://github.com/phil-opp/bitflags.git"
+branch = "no_std"

+ 8 - 7
src/elf_sections.rs

@@ -79,11 +79,12 @@ pub enum ElfSectionType {
     // plus processor-specific use from 0x70000000 to 0x7FFFFFFF
 }
 
-#[repr(u32)]
-pub enum ElfSectionFlags {
-    Writable = 0x1,
-    Allocated = 0x2,
-    Executable = 0x4,
-    // plus environment-specific use at 0x0F000000
-    // plus processor-specific use at 0xF0000000
+bitflags! {
+    flags ElfSectionFlags: u64 {
+        const WRITABLE = 0x1,
+        const ALLOCATED = 0x2,
+        const EXECUTABLE = 0x4,
+        // plus environment-specific use at 0x0F000000
+        // plus processor-specific use at 0xF0000000
+    }
 }

+ 3 - 0
src/lib.rs

@@ -4,6 +4,9 @@
 pub use elf_sections::{ElfSectionsTag, ElfSection, ElfSectionIter, ElfSectionType, ElfSectionFlags};
 pub use memory_map::{MemoryMapTag, MemoryArea, MemoryAreaIter};
 
+#[macro_use]
+extern crate bitflags;
+
 mod elf_sections;
 mod memory_map;