]> git.lizzy.rs Git - rust.git/commitdiff
rustrt: Convert statics to constants
authorAlex Crichton <alex@alexcrichton.com>
Mon, 6 Oct 2014 23:35:11 +0000 (16:35 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 9 Oct 2014 16:44:51 +0000 (09:44 -0700)
src/librustrt/c_str.rs
src/librustrt/lib.rs
src/librustrt/libunwind.rs
src/librustrt/mutex.rs
src/librustrt/stack.rs
src/librustrt/unwind.rs
src/librustrt/util.rs

index 934fb0ddd3ce43dd7a4531a0bb9fca1e437ec47e..a5ac70286fe81e7454a71efed8d19c5f60fa1ba6 100644 (file)
@@ -414,7 +414,7 @@ unsafe fn with_c_str_unchecked<T>(&self, f: |*const libc::c_char| -> T) -> T {
 }
 
 // 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 {
index d3ea07291a423cfc16f250feeb18efab3ecfe343..26fc399968cd578bd59243ecfc30d3057dc26e38 100644 (file)
@@ -100,7 +100,7 @@ fn spawn_sibling(self: Box<Self>,
 
 /// 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.
 ///
index bb7a1227e0e4708c1c70ffb327a1541fd04fb502..6867cb2e76b344822aa45fa58e44cc1233749d12 100644 (file)
@@ -57,19 +57,19 @@ pub enum _Unwind_Reason_Code {
 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 {
index 28b0256f2e6e378bffc4435b23f7d3f795caeeab..d10ba69386695277e1d82b8546815c651daf1b09 100644 (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 os {
         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 @@ pub struct pthread_cond_t {
             __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 os {
 
         // 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 @@ pub struct pthread_cond_t {
             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 @@ pub struct pthread_mutex_t { value: libc::c_int }
         #[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 @@ pub struct Mutex {
         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 @@ pub struct Mutex {
         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,
     };
index 5c94ef61bfdb7ceb68f56c6cdf1b8adbe76b21b1..4034000e28f33e22adbfad9af7f14f028bb61a47 100644 (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
index f07e8ecc335d7c0fda54b1807a6ff27c4e5fbe02..2a2fa29eca0b29bd4ead1b4c96e3d3f2a1b08487 100644 (file)
@@ -91,7 +91,7 @@ struct Exception {
 // 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,
index ab1ef2fc5aa689256ed7a1d8ace7cd185f8536ac..a94da33e543572bfe6d241db4f51c2caeb1907cc 100644 (file)
 //
 // 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 {