Skip to content

Commit

Permalink
Compilation for 32-bit architectures on nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos committed Mar 19, 2018
1 parent c581667 commit 58cd68a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions crates/pagecache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ lock_free_delays = ["rand"]
failpoints = ["fail"]
no_metrics = ["historian/bypass"]
no_logs = ["log/max_level_off"]
nightly = []

[dependencies.historian]
version = "3.0"
Expand Down
20 changes: 15 additions & 5 deletions crates/pagecache/src/io/iobuf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use std::sync::{Condvar, Mutex};
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize};
use std::sync::atomic::{AtomicBool, AtomicUsize};
#[cfg(feature = "nightly")]
use std::sync::atomic::AtomicI64;
#[cfg(not(feature = "nightly"))]
use std::sync::atomic::AtomicIsize;
use std::sync::atomic::Ordering::SeqCst;

#[cfg(feature = "failpoints")]
Expand All @@ -13,6 +17,10 @@ use self::reader::LogReader;
use super::*;

type Header = u64;
#[cfg(not(feature = "nightly"))]
type AtomicLsn = AtomicIsize;
#[cfg(feature = "nightly")]
type AtomicLsn = AtomicI64;

macro_rules! io_fail {
($self:expr, $e:expr) => {
Expand Down Expand Up @@ -52,8 +60,8 @@ pub(super) struct IoBufs {
// stable storage. This may be lower than the length of the underlying
// file, and there may be buffers that have been written out-of-order
// to stable storage due to interesting thread interleavings.
stable_lsn: AtomicIsize,
max_reserved_lsn: AtomicIsize,
stable_lsn: AtomicLsn,
max_reserved_lsn: AtomicLsn,
segment_accountant: Mutex<SegmentAccountant>,

// used for signifying that we're simulating a crash
Expand Down Expand Up @@ -166,8 +174,8 @@ impl IoBufs {
written_bufs: AtomicUsize::new(0),
intervals: Mutex::new(vec![]),
interval_updated: Condvar::new(),
stable_lsn: AtomicIsize::new(stable),
max_reserved_lsn: AtomicIsize::new(stable),
stable_lsn: AtomicLsn::new(stable),
max_reserved_lsn: AtomicLsn::new(stable),
config: config,
segment_accountant: Mutex::new(segment_accountant),
#[cfg(feature = "failpoints")]
Expand Down Expand Up @@ -259,6 +267,8 @@ impl IoBufs {

let io_bufs = self.config.io_bufs;

// right shift 32 on 32-bit pointer systems panics
#[cfg(target_pointer_width = "64")]
assert_eq!((raw_buf.len() + MSG_HEADER_LEN) >> 32, 0);

let buf = self.encapsulate(raw_buf);
Expand Down
3 changes: 3 additions & 0 deletions crates/pagecache/src/io/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,9 @@ pub fn raw_segment_iter_from(

Ok(LogIter {
config: config.clone(),
#[cfg(feature = "nightly")]
max_lsn: std::i64::MAX,
#[cfg(not(feature = "nightly"))]
max_lsn: std::isize::MAX,
cur_lsn: SEG_HEADER_LEN as Lsn,
segment_base: None,
Expand Down
4 changes: 4 additions & 0 deletions crates/pagecache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
#![cfg_attr(feature="clippy", allow(inline_always))]
#![cfg_attr(feature="nightly", feature(integer_atomics))]

#[macro_use]
extern crate serde_derive;
Expand Down Expand Up @@ -75,6 +76,9 @@ pub type SegmentID = usize;
pub type LogID = u64;

/// A logical sequence number.
#[cfg(feature = "nightly")]
pub type Lsn = i64;
#[cfg(not(feature = "nightly"))]
pub type Lsn = isize;

/// A page identifier.
Expand Down
1 change: 1 addition & 0 deletions crates/sled/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ check_snapshot_integrity = []
no_logs = ["log/max_level_off", "pagecache/no_logs"]
rayon = ["pagecache/rayon"]
zstd = ["pagecache/zstd"]
nightly = ["pagecache/nightly"]

[profile.release]
debug = 2
Expand Down

0 comments on commit 58cd68a

Please sign in to comment.