Skip to content

Commit

Permalink
Move static and const declarations
Browse files Browse the repository at this point in the history
Move the static and const declarations to the top of the file
  • Loading branch information
dlrobertson committed Sep 19, 2016
1 parent ca63fdb commit fbafaf1
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/platform/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,26 @@ use std::thread;

const MAX_FDS_IN_CMSG: u32 = 64;

const SCM_RIGHTS: c_int = 0x01;

// The value Linux returns for SO_SNDBUF
// is not the size we are actually allowed to use...
// Empirically, we have to deduct 32 bytes from that.
const RESERVED_SIZE: usize = 32;

#[cfg(target_os="android")]
const TEMP_FILE_TEMPLATE: &'static str = "/sdcard/servo/ipc-channel-shared-memory.XXXXXX";

#[cfg(not(target_os="android"))]
const TEMP_FILE_TEMPLATE: &'static str = "/tmp/ipc-channel-shared-memory.XXXXXX";

lazy_static! {
static ref SYSTEM_SENDBUF_SIZE: usize = {
let (tx, _) = channel().expect("Failed to obtain a socket for checking maximum send size");
tx.get_system_sendbuf_size().expect("Failed to obtain maximum send size for socket")
};
}

// The value Linux returns for SO_SNDBUF
// is not the size we are actually allowed to use...
// Empirically, we have to deduct 32 bytes from that.
const RESERVED_SIZE: usize = 32;

pub fn channel() -> Result<(OsIpcSender, OsIpcReceiver),UnixError> {
let mut results = [0, 0];
unsafe {
Expand Down Expand Up @@ -825,12 +833,6 @@ fn recv(fd: c_int, blocking_mode: BlockingMode)
Ok((main_data_buffer, channels, shared_memory_regions))
}

#[cfg(target_os="android")]
const TEMP_FILE_TEMPLATE: &'static str = "/sdcard/servo/ipc-channel-shared-memory.XXXXXX";

#[cfg(not(target_os="android"))]
const TEMP_FILE_TEMPLATE: &'static str = "/tmp/ipc-channel-shared-memory.XXXXXX";

#[cfg(target_os="android")]
fn maybe_unlink(_: *const c_char) -> c_int {
// Calling `unlink` on a file stored on an sdcard immediately deletes it.
Expand Down

0 comments on commit fbafaf1

Please sign in to comment.