rustrt: Convert statics to constants

This commit is contained in:
Alex Crichton 2014-10-06 16:35:11 -07:00
parent d3eaf32900
commit b8fb0cf789
7 changed files with 36 additions and 36 deletions

View File

@ -414,7 +414,7 @@ impl ToCStr for String {
}
// The length of the stack allocated buffer for `vec.with_c_str()`
static BUF_LEN: uint = 128;
const BUF_LEN: uint = 128;
impl<'a> ToCStr for &'a [u8] {
fn to_c_str(&self) -> CString {

View File

@ -100,7 +100,7 @@ pub trait Runtime {
/// The default error code of the rust runtime if the main task fails instead
/// of exiting cleanly.
pub static DEFAULT_ERROR_CODE: int = 101;
pub const DEFAULT_ERROR_CODE: int = 101;
/// One-time runtime initialization.
///

View File

@ -57,19 +57,19 @@ pub type _Unwind_Exception_Class = u64;
pub type _Unwind_Word = libc::uintptr_t;
#[cfg(target_arch = "x86")]
pub static unwinder_private_data_size: uint = 5;
pub const unwinder_private_data_size: uint = 5;
#[cfg(target_arch = "x86_64")]
pub static unwinder_private_data_size: uint = 6;
pub const unwinder_private_data_size: uint = 6;
#[cfg(all(target_arch = "arm", not(target_os = "ios")))]
pub static unwinder_private_data_size: uint = 20;
pub const unwinder_private_data_size: uint = 20;
#[cfg(all(target_arch = "arm", target_os = "ios"))]
pub static unwinder_private_data_size: uint = 5;
pub const unwinder_private_data_size: uint = 5;
#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
pub static unwinder_private_data_size: uint = 2;
pub const unwinder_private_data_size: uint = 2;
#[repr(C)]
pub struct _Unwind_Exception {

View File

@ -88,7 +88,7 @@ pub struct LockGuard<'a> {
lock: &'a StaticNativeMutex
}
pub static NATIVE_MUTEX_INIT: StaticNativeMutex = StaticNativeMutex {
pub const NATIVE_MUTEX_INIT: StaticNativeMutex = StaticNativeMutex {
inner: imp::MUTEX_INIT,
};
@ -353,9 +353,9 @@ mod imp {
pub type pthread_mutex_t = *mut libc::c_void;
pub type pthread_cond_t = *mut libc::c_void;
pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t =
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t =
0 as pthread_mutex_t;
pub static PTHREAD_COND_INITIALIZER: pthread_cond_t =
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t =
0 as pthread_cond_t;
}
@ -390,11 +390,11 @@ mod imp {
__opaque: [u8, ..__PTHREAD_COND_SIZE__],
}
pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
__sig: _PTHREAD_MUTEX_SIG_INIT,
__opaque: [0, ..__PTHREAD_MUTEX_SIZE__],
};
pub static PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
__sig: _PTHREAD_COND_SIG_INIT,
__opaque: [0, ..__PTHREAD_COND_SIZE__],
};
@ -406,25 +406,25 @@ mod imp {
// minus 8 because we have an 'align' field
#[cfg(target_arch = "x86_64")]
static __SIZEOF_PTHREAD_MUTEX_T: uint = 40 - 8;
const __SIZEOF_PTHREAD_MUTEX_T: uint = 40 - 8;
#[cfg(target_arch = "x86")]
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
#[cfg(target_arch = "arm")]
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
#[cfg(target_arch = "mips")]
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
#[cfg(target_arch = "mipsel")]
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
#[cfg(target_arch = "x86_64")]
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
#[cfg(target_arch = "x86")]
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
#[cfg(target_arch = "arm")]
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
#[cfg(target_arch = "mips")]
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
#[cfg(target_arch = "mipsel")]
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
#[repr(C)]
pub struct pthread_mutex_t {
@ -437,11 +437,11 @@ mod imp {
size: [u8, ..__SIZEOF_PTHREAD_COND_T],
}
pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
__align: 0,
size: [0, ..__SIZEOF_PTHREAD_MUTEX_T],
};
pub static PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
__align: 0,
size: [0, ..__SIZEOF_PTHREAD_COND_T],
};
@ -455,10 +455,10 @@ mod imp {
#[repr(C)]
pub struct pthread_cond_t { value: libc::c_int }
pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
value: 0,
};
pub static PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
value: 0,
};
}
@ -468,7 +468,7 @@ mod imp {
cond: UnsafeCell<pthread_cond_t>,
}
pub static MUTEX_INIT: Mutex = Mutex {
pub const MUTEX_INIT: Mutex = Mutex {
lock: UnsafeCell { value: PTHREAD_MUTEX_INITIALIZER },
cond: UnsafeCell { value: PTHREAD_COND_INITIALIZER },
};
@ -523,11 +523,11 @@ mod imp {
use libc;
type LPCRITICAL_SECTION = *mut c_void;
static SPIN_COUNT: DWORD = 4000;
const SPIN_COUNT: DWORD = 4000;
#[cfg(target_arch = "x86")]
static CRIT_SECTION_SIZE: uint = 24;
const CRIT_SECTION_SIZE: uint = 24;
#[cfg(target_arch = "x86_64")]
static CRIT_SECTION_SIZE: uint = 40;
const CRIT_SECTION_SIZE: uint = 40;
pub struct Mutex {
// pointers for the lock/cond handles, atomically updated
@ -535,7 +535,7 @@ mod imp {
cond: atomic::AtomicUint,
}
pub static MUTEX_INIT: Mutex = Mutex {
pub const MUTEX_INIT: Mutex = Mutex {
lock: atomic::INIT_ATOMIC_UINT,
cond: atomic::INIT_ATOMIC_UINT,
};

View File

@ -46,7 +46,7 @@
// corresponding prolog, decision was taken to disable segmented
// stack support on iOS.
pub static RED_ZONE: uint = 20 * 1024;
pub const RED_ZONE: uint = 20 * 1024;
/// This function is invoked from rust's current __morestack function. Segmented
/// stacks are currently not enabled as segmented stacks, but rather one giant

View File

@ -91,7 +91,7 @@ pub type Callback = fn(msg: &Any + Send, file: &'static str, line: uint);
// Variables used for invoking callbacks when a task starts to unwind.
//
// For more information, see below.
static MAX_CALLBACKS: uint = 16;
const MAX_CALLBACKS: uint = 16;
static mut CALLBACKS: [atomic::AtomicUint, ..MAX_CALLBACKS] =
[atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,

View File

@ -23,15 +23,15 @@ use libc;
//
// FIXME: Once the runtime matures remove the `true` below to turn off rtassert,
// etc.
pub static ENFORCE_SANITY: bool = true || !cfg!(rtopt) || cfg!(rtdebug) ||
pub const ENFORCE_SANITY: bool = true || !cfg!(rtopt) || cfg!(rtdebug) ||
cfg!(rtassert);
pub struct Stdio(libc::c_int);
#[allow(non_uppercase_statics)]
pub static Stdout: Stdio = Stdio(libc::STDOUT_FILENO);
pub const Stdout: Stdio = Stdio(libc::STDOUT_FILENO);
#[allow(non_uppercase_statics)]
pub static Stderr: Stdio = Stdio(libc::STDERR_FILENO);
pub const Stderr: Stdio = Stdio(libc::STDERR_FILENO);
impl fmt::FormatWriter for Stdio {
fn write(&mut self, data: &[u8]) -> fmt::Result {