Skip to content

Commit

Permalink
handle new access pattern in Rust code
Browse files Browse the repository at this point in the history
  • Loading branch information
lquenti committed Feb 26, 2024
1 parent a39e892 commit d74beda
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# debug files
results_debug/

# Generated by Cargo
# will have compiled files and executables
debug/
Expand Down
2 changes: 2 additions & 0 deletions blackheap-benchmarker/src/c_code/benchmarker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fn bindgen_test_layout_max_align_t() {
pub const access_pattern_ACCESS_PATTERN_CONST: access_pattern = 0;
pub const access_pattern_ACCESS_PATTERN_SEQUENTIAL: access_pattern = 1;
pub const access_pattern_ACCESS_PATTERN_RANDOM: access_pattern = 2;
pub const access_pattern_ACCESS_PATTERN_REVERSE: access_pattern = 3;
pub type access_pattern = ::std::os::raw::c_uint;
pub const error_codes_ERROR_CODES_SUCCESS: error_codes = 0;
pub const error_codes_ERROR_CODES_MALLOC_FAILED: error_codes = 1;
Expand All @@ -66,6 +67,7 @@ pub const error_codes_ERROR_CODES_REMOVE_FAILED: error_codes = 9;
pub const error_codes_ERROR_CODES_DROP_PAGE_CACHE_FAILED_NO_PERMISSIONS: error_codes = 10;
pub const error_codes_ERROR_CODES_DROP_PAGE_CACHE_FAILED_OTHER: error_codes = 11;
pub const error_codes_ERROR_CODES_INCORRECT_FILE_BUFFER_SIZE: error_codes = 12;
pub const error_codes_ERROR_CODES_TOO_SMALL_FILE_BUFFER: error_codes = 13;
pub type error_codes = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down
5 changes: 5 additions & 0 deletions blackheap-benchmarker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub enum AccessPattern {
Const,
Sequential,
Random,
Reverse,
}

impl AccessPattern {
Expand All @@ -18,6 +19,7 @@ impl AccessPattern {
Self::Const => b::access_pattern_ACCESS_PATTERN_CONST,
Self::Sequential => b::access_pattern_ACCESS_PATTERN_SEQUENTIAL,
Self::Random => b::access_pattern_ACCESS_PATTERN_RANDOM,
Self::Reverse => b::access_pattern_ACCESS_PATTERN_REVERSE,
}
}

Expand All @@ -26,6 +28,7 @@ impl AccessPattern {
b::access_pattern_ACCESS_PATTERN_CONST => Self::Const,
b::access_pattern_ACCESS_PATTERN_SEQUENTIAL => Self::Sequential,
b::access_pattern_ACCESS_PATTERN_RANDOM => Self::Random,
b::access_pattern_ACCESS_PATTERN_REVERSE => Self::Reverse,
_ => {
panic!("Unknown Access Pattern! Probably forgot to update Rust to C logic");
}
Expand All @@ -52,6 +55,7 @@ pub enum ErrorCodes {
DropPageCacheFailedNoPermissions,
DropPageCacheFailedOther,
IncorrectFileBufferSize,
TooSmallFileBuffer,
}

impl ErrorCodes {
Expand All @@ -74,6 +78,7 @@ impl ErrorCodes {
b::error_codes_ERROR_CODES_DROP_PAGE_CACHE_FAILED_OTHER
}
Self::IncorrectFileBufferSize => b::error_codes_ERROR_CODES_INCORRECT_FILE_BUFFER_SIZE,
Self::TooSmallFileBuffer => b::error_codes_ERROR_CODES_TOO_SMALL_FILE_BUFFER,
}
}

Expand Down

0 comments on commit d74beda

Please sign in to comment.