Skip to content

Commit

Permalink
protocol: Remove hardcoded page size
Browse files Browse the repository at this point in the history
Signed-off-by: dom.song <[email protected]>
  • Loading branch information
peng6662001 authored and rbradford committed Jun 28, 2023
1 parent c14517f commit 08a42bf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use bitflags::bitflags;
use libc::{c_void, iovec, EINVAL};
use libc::{sysconf, _SC_PAGESIZE};
use std::ffi::CString;
use std::fs::File;
use std::io::{IoSlice, Read, Write};
Expand Down Expand Up @@ -90,8 +91,14 @@ const fn default_max_data_xfer_size() -> u32 {
1048576
}

const fn default_migration_capabilities() -> MigrationCapabilities {
MigrationCapabilities { pgsize: 4096 }
#[inline(always)]
fn pagesize() -> u32 {
// SAFETY: sysconf
unsafe { sysconf(_SC_PAGESIZE) as u32 }
}

fn default_migration_capabilities() -> MigrationCapabilities {
MigrationCapabilities { pgsize: pagesize() }
}

bitflags! {
Expand Down

0 comments on commit 08a42bf

Please sign in to comment.