Skip to content

Commit b8fb0cf

Browse files
committed
rustrt: Convert statics to constants
1 parent d3eaf32 commit b8fb0cf

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

src/librustrt/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl ToCStr for String {
414414
}
415415

416416
// The length of the stack allocated buffer for `vec.with_c_str()`
417-
static BUF_LEN: uint = 128;
417+
const BUF_LEN: uint = 128;
418418

419419
impl<'a> ToCStr for &'a [u8] {
420420
fn to_c_str(&self) -> CString {

src/librustrt/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub trait Runtime {
100100

101101
/// The default error code of the rust runtime if the main task fails instead
102102
/// of exiting cleanly.
103-
pub static DEFAULT_ERROR_CODE: int = 101;
103+
pub const DEFAULT_ERROR_CODE: int = 101;
104104

105105
/// One-time runtime initialization.
106106
///

src/librustrt/libunwind.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ pub type _Unwind_Exception_Class = u64;
5757
pub type _Unwind_Word = libc::uintptr_t;
5858

5959
#[cfg(target_arch = "x86")]
60-
pub static unwinder_private_data_size: uint = 5;
60+
pub const unwinder_private_data_size: uint = 5;
6161

6262
#[cfg(target_arch = "x86_64")]
63-
pub static unwinder_private_data_size: uint = 6;
63+
pub const unwinder_private_data_size: uint = 6;
6464

6565
#[cfg(all(target_arch = "arm", not(target_os = "ios")))]
66-
pub static unwinder_private_data_size: uint = 20;
66+
pub const unwinder_private_data_size: uint = 20;
6767

6868
#[cfg(all(target_arch = "arm", target_os = "ios"))]
69-
pub static unwinder_private_data_size: uint = 5;
69+
pub const unwinder_private_data_size: uint = 5;
7070

7171
#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
72-
pub static unwinder_private_data_size: uint = 2;
72+
pub const unwinder_private_data_size: uint = 2;
7373

7474
#[repr(C)]
7575
pub struct _Unwind_Exception {

src/librustrt/mutex.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub struct LockGuard<'a> {
8888
lock: &'a StaticNativeMutex
8989
}
9090

91-
pub static NATIVE_MUTEX_INIT: StaticNativeMutex = StaticNativeMutex {
91+
pub const NATIVE_MUTEX_INIT: StaticNativeMutex = StaticNativeMutex {
9292
inner: imp::MUTEX_INIT,
9393
};
9494

@@ -353,9 +353,9 @@ mod imp {
353353
pub type pthread_mutex_t = *mut libc::c_void;
354354
pub type pthread_cond_t = *mut libc::c_void;
355355

356-
pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t =
356+
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t =
357357
0 as pthread_mutex_t;
358-
pub static PTHREAD_COND_INITIALIZER: pthread_cond_t =
358+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t =
359359
0 as pthread_cond_t;
360360
}
361361

@@ -390,11 +390,11 @@ mod imp {
390390
__opaque: [u8, ..__PTHREAD_COND_SIZE__],
391391
}
392392

393-
pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
393+
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
394394
__sig: _PTHREAD_MUTEX_SIG_INIT,
395395
__opaque: [0, ..__PTHREAD_MUTEX_SIZE__],
396396
};
397-
pub static PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
397+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
398398
__sig: _PTHREAD_COND_SIG_INIT,
399399
__opaque: [0, ..__PTHREAD_COND_SIZE__],
400400
};
@@ -406,25 +406,25 @@ mod imp {
406406

407407
// minus 8 because we have an 'align' field
408408
#[cfg(target_arch = "x86_64")]
409-
static __SIZEOF_PTHREAD_MUTEX_T: uint = 40 - 8;
409+
const __SIZEOF_PTHREAD_MUTEX_T: uint = 40 - 8;
410410
#[cfg(target_arch = "x86")]
411-
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
411+
const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
412412
#[cfg(target_arch = "arm")]
413-
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
413+
const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
414414
#[cfg(target_arch = "mips")]
415-
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
415+
const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
416416
#[cfg(target_arch = "mipsel")]
417-
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
417+
const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
418418
#[cfg(target_arch = "x86_64")]
419-
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
419+
const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
420420
#[cfg(target_arch = "x86")]
421-
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
421+
const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
422422
#[cfg(target_arch = "arm")]
423-
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
423+
const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
424424
#[cfg(target_arch = "mips")]
425-
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
425+
const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
426426
#[cfg(target_arch = "mipsel")]
427-
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
427+
const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
428428

429429
#[repr(C)]
430430
pub struct pthread_mutex_t {
@@ -437,11 +437,11 @@ mod imp {
437437
size: [u8, ..__SIZEOF_PTHREAD_COND_T],
438438
}
439439

440-
pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
440+
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
441441
__align: 0,
442442
size: [0, ..__SIZEOF_PTHREAD_MUTEX_T],
443443
};
444-
pub static PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
444+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
445445
__align: 0,
446446
size: [0, ..__SIZEOF_PTHREAD_COND_T],
447447
};
@@ -455,10 +455,10 @@ mod imp {
455455
#[repr(C)]
456456
pub struct pthread_cond_t { value: libc::c_int }
457457

458-
pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
458+
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
459459
value: 0,
460460
};
461-
pub static PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
461+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
462462
value: 0,
463463
};
464464
}
@@ -468,7 +468,7 @@ mod imp {
468468
cond: UnsafeCell<pthread_cond_t>,
469469
}
470470

471-
pub static MUTEX_INIT: Mutex = Mutex {
471+
pub const MUTEX_INIT: Mutex = Mutex {
472472
lock: UnsafeCell { value: PTHREAD_MUTEX_INITIALIZER },
473473
cond: UnsafeCell { value: PTHREAD_COND_INITIALIZER },
474474
};
@@ -523,19 +523,19 @@ mod imp {
523523
use libc;
524524

525525
type LPCRITICAL_SECTION = *mut c_void;
526-
static SPIN_COUNT: DWORD = 4000;
526+
const SPIN_COUNT: DWORD = 4000;
527527
#[cfg(target_arch = "x86")]
528-
static CRIT_SECTION_SIZE: uint = 24;
528+
const CRIT_SECTION_SIZE: uint = 24;
529529
#[cfg(target_arch = "x86_64")]
530-
static CRIT_SECTION_SIZE: uint = 40;
530+
const CRIT_SECTION_SIZE: uint = 40;
531531

532532
pub struct Mutex {
533533
// pointers for the lock/cond handles, atomically updated
534534
lock: atomic::AtomicUint,
535535
cond: atomic::AtomicUint,
536536
}
537537

538-
pub static MUTEX_INIT: Mutex = Mutex {
538+
pub const MUTEX_INIT: Mutex = Mutex {
539539
lock: atomic::INIT_ATOMIC_UINT,
540540
cond: atomic::INIT_ATOMIC_UINT,
541541
};

src/librustrt/stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
// corresponding prolog, decision was taken to disable segmented
4747
// stack support on iOS.
4848

49-
pub static RED_ZONE: uint = 20 * 1024;
49+
pub const RED_ZONE: uint = 20 * 1024;
5050

5151
/// This function is invoked from rust's current __morestack function. Segmented
5252
/// stacks are currently not enabled as segmented stacks, but rather one giant

src/librustrt/unwind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub type Callback = fn(msg: &Any + Send, file: &'static str, line: uint);
9191
// Variables used for invoking callbacks when a task starts to unwind.
9292
//
9393
// For more information, see below.
94-
static MAX_CALLBACKS: uint = 16;
94+
const MAX_CALLBACKS: uint = 16;
9595
static mut CALLBACKS: [atomic::AtomicUint, ..MAX_CALLBACKS] =
9696
[atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
9797
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,

src/librustrt/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ use libc;
2323
//
2424
// FIXME: Once the runtime matures remove the `true` below to turn off rtassert,
2525
// etc.
26-
pub static ENFORCE_SANITY: bool = true || !cfg!(rtopt) || cfg!(rtdebug) ||
26+
pub const ENFORCE_SANITY: bool = true || !cfg!(rtopt) || cfg!(rtdebug) ||
2727
cfg!(rtassert);
2828

2929
pub struct Stdio(libc::c_int);
3030

3131
#[allow(non_uppercase_statics)]
32-
pub static Stdout: Stdio = Stdio(libc::STDOUT_FILENO);
32+
pub const Stdout: Stdio = Stdio(libc::STDOUT_FILENO);
3333
#[allow(non_uppercase_statics)]
34-
pub static Stderr: Stdio = Stdio(libc::STDERR_FILENO);
34+
pub const Stderr: Stdio = Stdio(libc::STDERR_FILENO);
3535

3636
impl fmt::FormatWriter for Stdio {
3737
fn write(&mut self, data: &[u8]) -> fmt::Result {

0 commit comments

Comments
 (0)