about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-06-25 19:03:12 -0700
committerBrian Anderson <banderson@mozilla.com>2013-06-25 19:32:00 -0700
commit5d3ca4b8439d043dc77c19424348fac670acc46f (patch)
tree32ce48a428a42a09b93950a6d91f327a132b2214 /src/libstd
parentc06ee9f7a7fe1ad311c9fd0eb57e00646297cdbd (diff)
parentefd1438770ae371406327304cb6ad4501db256ae (diff)
downloadrust-5d3ca4b8439d043dc77c19424348fac670acc46f.tar.gz
rust-5d3ca4b8439d043dc77c19424348fac670acc46f.zip
Merge remote-tracking branch 'mozilla/master' into incoming
Conflicts:
	src/librustc/middle/astencode.rs
	src/librustc/middle/check_const.rs
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/at_vec.rs13
-rw-r--r--src/libstd/cleanup.rs30
-rw-r--r--src/libstd/container.rs12
-rw-r--r--src/libstd/gc.rs28
-rw-r--r--src/libstd/hashmap.rs57
-rw-r--r--src/libstd/iterator.rs5
-rw-r--r--src/libstd/libc.rs1188
-rw-r--r--src/libstd/managed.rs2
-rw-r--r--src/libstd/os.rs2
-rw-r--r--src/libstd/reflect.rs6
-rw-r--r--src/libstd/repr.rs20
-rw-r--r--src/libstd/rt/global_heap.rs10
-rw-r--r--src/libstd/std.rs (renamed from src/libstd/core.rc)0
-rw-r--r--src/libstd/sys.rs31
-rw-r--r--src/libstd/task/spawn.rs2
-rw-r--r--src/libstd/to_str.rs4
-rw-r--r--src/libstd/trie.rs48
-rw-r--r--src/libstd/unstable/atomics.rs1
-rw-r--r--src/libstd/unstable/exchange_alloc.rs10
-rw-r--r--src/libstd/unstable/intrinsics.rs182
-rw-r--r--src/libstd/vec.rs139
21 files changed, 1147 insertions, 643 deletions
diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs
index b871ed3d57a..5a2f948600a 100644
--- a/src/libstd/at_vec.rs
+++ b/src/libstd/at_vec.rs
@@ -25,13 +25,16 @@ use vec::ImmutableVector;
 
 pub mod rustrt {
     use libc;
-    use sys;
     use vec;
+    #[cfg(stage0)]
+    use intrinsic::{TyDesc};
+    #[cfg(not(stage0))]
+    use unstable::intrinsics::{TyDesc};
 
     #[abi = "cdecl"]
     #[link_name = "rustrt"]
     pub extern {
-        pub unsafe fn vec_reserve_shared_actual(t: *sys::TypeDesc,
+        pub unsafe fn vec_reserve_shared_actual(t: *TyDesc,
                                                 v: **vec::raw::VecRepr,
                                                 n: libc::size_t);
     }
@@ -197,6 +200,10 @@ pub mod raw {
     use uint;
     use unstable::intrinsics::{move_val_init};
     use vec;
+    #[cfg(stage0)]
+    use intrinsic::{get_tydesc};
+    #[cfg(not(stage0))]
+    use unstable::intrinsics::{get_tydesc};
 
     pub type VecRepr = vec::raw::VecRepr;
     pub type SliceRepr = vec::raw::SliceRepr;
@@ -258,7 +265,7 @@ pub mod raw {
         // Only make the (slow) call into the runtime if we have to
         if capacity(*v) < n {
             let ptr: **VecRepr = transmute(v);
-            rustrt::vec_reserve_shared_actual(sys::get_type_desc::<T>(),
+            rustrt::vec_reserve_shared_actual(get_tydesc::<T>(),
                                               ptr, n as libc::size_t);
         }
     }
diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs
index d1460b7a3c9..ee9fdd3c620 100644
--- a/src/libstd/cleanup.rs
+++ b/src/libstd/cleanup.rs
@@ -10,24 +10,19 @@
 
 #[doc(hidden)];
 
-use libc::{c_char, c_void, intptr_t, uintptr_t};
-use ptr::mut_null;
+use libc::{c_char, intptr_t, uintptr_t};
+use ptr::{mut_null};
 use repr::BoxRepr;
-use sys::TypeDesc;
 use cast::transmute;
+use unstable::intrinsics::TyDesc;
 #[cfg(not(test))] use unstable::lang::clear_task_borrow_list;
 
-#[cfg(not(test))] use ptr::to_unsafe_ptr;
-
 /**
  * Runtime structures
  *
  * NB: These must match the representation in the C++ runtime.
  */
 
-type DropGlue<'self> = &'self fn(**TypeDesc, *c_void);
-type FreeGlue<'self> = &'self fn(**TypeDesc, *c_void);
-
 type TaskID = uintptr_t;
 
 struct StackSegment { priv opaque: () }
@@ -164,6 +159,19 @@ fn debug_mem() -> bool {
     false
 }
 
+#[inline]
+#[cfg(not(stage0))]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    // This function should be inlined when stage0 is gone
+    ((*tydesc).drop_glue)(data);
+}
+
+#[inline]
+#[cfg(stage0)]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    ((*tydesc).drop_glue)(0 as **TyDesc, data);
+}
+
 /// Destroys all managed memory (i.e. @ boxes) held by the current task.
 #[cfg(not(test))]
 #[lang="annihilate"]
@@ -205,9 +213,9 @@ pub unsafe fn annihilate() {
     // callback, as the original value may have been freed.
     for each_live_alloc(false) |box, uniq| {
         if !uniq {
-            let tydesc: *TypeDesc = transmute(copy (*box).header.type_desc);
-            let drop_glue: DropGlue = transmute(((*tydesc).drop_glue, 0));
-            drop_glue(to_unsafe_ptr(&tydesc), transmute(&(*box).data));
+            let tydesc = (*box).header.type_desc;
+            let data = transmute(&(*box).data);
+            call_drop_glue(tydesc, data);
         }
     }
 
diff --git a/src/libstd/container.rs b/src/libstd/container.rs
index c1b656f1cd9..d6f4c26715a 100644
--- a/src/libstd/container.rs
+++ b/src/libstd/container.rs
@@ -34,18 +34,6 @@ pub trait Map<K, V>: Mutable {
     /// Return true if the map contains a value for the specified key
     fn contains_key(&self, key: &K) -> bool;
 
-    /// Visits all keys and values
-    fn each<'a>(&'a self, f: &fn(&K, &'a V) -> bool) -> bool;
-
-    /// Visit all keys
-    fn each_key(&self, f: &fn(&K) -> bool) -> bool;
-
-    /// Visit all values
-    fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool) -> bool;
-
-    /// Iterate over the map and mutate the contained values
-    fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) -> bool;
-
     /// Return a reference to the value corresponding to the key
     fn find<'a>(&'a self, key: &K) -> Option<&'a V>;
 
diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs
index 611b95a7745..c9e33219fa5 100644
--- a/src/libstd/gc.rs
+++ b/src/libstd/gc.rs
@@ -40,12 +40,13 @@ with destructors.
 use cast;
 use container::{Map, Set};
 use io;
-use libc::{size_t, uintptr_t};
+use libc::{uintptr_t};
 use option::{None, Option, Some};
 use ptr;
 use hashmap::HashSet;
 use stackwalk::walk_stack;
 use sys;
+use unstable::intrinsics::{TyDesc};
 
 pub use stackwalk::Word;
 
@@ -58,18 +59,12 @@ pub struct StackSegment {
 }
 
 pub mod rustrt {
-    use libc::size_t;
     use stackwalk::Word;
     use super::StackSegment;
 
     #[link_name = "rustrt"]
     pub extern {
         #[rust_stack]
-        pub unsafe fn rust_call_tydesc_glue(root: *Word,
-                                            tydesc: *Word,
-                                            field: size_t);
-
-        #[rust_stack]
         pub unsafe fn rust_gc_metadata() -> *Word;
 
         pub unsafe fn rust_get_stack_segment() -> *StackSegment;
@@ -125,7 +120,7 @@ unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> {
     return None;
 }
 
-type Visitor<'self> = &'self fn(root: **Word, tydesc: *Word) -> bool;
+type Visitor<'self> = &'self fn(root: **Word, tydesc: *TyDesc) -> bool;
 
 // Walks the list of roots for the given safe point, and calls visitor
 // on each root.
@@ -139,7 +134,7 @@ unsafe fn _walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
     let stack_roots: *u32 = bump(sp_meta, 2);
     let reg_roots: *u8 = bump(stack_roots, num_stack_roots);
     let addrspaces: *Word = align_to_pointer(bump(reg_roots, num_reg_roots));
-    let tydescs: ***Word = bump(addrspaces, num_stack_roots);
+    let tydescs: ***TyDesc = bump(addrspaces, num_stack_roots);
 
     // Stack roots
     let mut sri = 0;
@@ -321,6 +316,19 @@ fn expect_sentinel() -> bool { true }
 #[cfg(nogc)]
 fn expect_sentinel() -> bool { false }
 
+#[inline]
+#[cfg(not(stage0))]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    // This function should be inlined when stage0 is gone
+    ((*tydesc).drop_glue)(data);
+}
+
+#[inline]
+#[cfg(stage0)]
+unsafe fn call_drop_glue(tydesc: *TyDesc, data: *i8) {
+    ((*tydesc).drop_glue)(0 as **TyDesc, data);
+}
+
 // Entry point for GC-based cleanup. Walks stack looking for exchange
 // heap and stack allocations requiring drop, and runs all
 // destructors.
@@ -364,7 +372,7 @@ pub fn cleanup_stack_for_failure() {
                 // FIXME #4420: Destroy this box
                 // FIXME #4330: Destroy this box
             } else {
-                rustrt::rust_call_tydesc_glue(*root, tydesc, 3 as size_t);
+                call_drop_glue(tydesc, *root as *i8);
             }
         }
     }
diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs
index 7d55947e818..bfa0f2fa124 100644
--- a/src/libstd/hashmap.rs
+++ b/src/libstd/hashmap.rs
@@ -307,34 +307,6 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
         }
     }
 
-    /// Visit all key-value pairs
-    fn each<'a>(&'a self, blk: &fn(&K, &'a V) -> bool) -> bool {
-        self.iter().advance(|(k, v)| blk(k, v))
-    }
-
-    /// Visit all keys
-    fn each_key(&self, blk: &fn(k: &K) -> bool) -> bool {
-        self.iter().advance(|(k, _)| blk(k))
-    }
-
-    /// Visit all values
-    fn each_value<'a>(&'a self, blk: &fn(v: &'a V) -> bool) -> bool {
-        self.iter().advance(|(_, v)| blk(v))
-    }
-
-    /// Iterate over the map and mutate the contained values
-    fn mutate_values(&mut self, blk: &fn(&K, &mut V) -> bool) -> bool {
-        for uint::range(0, self.buckets.len()) |i| {
-            match self.buckets[i] {
-              Some(Bucket{key: ref key, value: ref mut value, _}) => {
-                if !blk(key, value) { return false; }
-              }
-              None => ()
-            }
-        }
-        return true;
-    }
-
     /// Return a reference to the value corresponding to the key
     fn find<'a>(&'a self, k: &K) -> Option<&'a V> {
         match self.bucket_for_key(k) {
@@ -516,6 +488,29 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
         }
     }
 
+    /// Visit all keys
+    pub fn each_key(&self, blk: &fn(k: &K) -> bool) -> bool {
+        self.iter().advance(|(k, _)| blk(k))
+    }
+
+    /// Visit all values
+    pub fn each_value<'a>(&'a self, blk: &fn(v: &'a V) -> bool) -> bool {
+        self.iter().advance(|(_, v)| blk(v))
+    }
+
+    /// Iterate over the map and mutate the contained values
+    pub fn mutate_values(&mut self, blk: &fn(&K, &mut V) -> bool) -> bool {
+        for uint::range(0, self.buckets.len()) |i| {
+            match self.buckets[i] {
+              Some(Bucket{key: ref key, value: ref mut value, _}) => {
+                if !blk(key, value) { return false; }
+              }
+              None => ()
+            }
+        }
+        return true;
+    }
+
     /// An iterator visiting all key-value pairs in arbitrary order.
     /// Iterator element type is (&'a K, &'a V).
     pub fn iter<'a>(&'a self) -> HashMapIterator<'a, K, V> {
@@ -718,12 +713,6 @@ impl<T:Hash + Eq> HashSet<T> {
       self.map.contains_key_equiv(value)
     }
 
-    /// Visit all elements in arbitrary order
-    /// FIXME: #6978: Remove when all callers are converted
-    pub fn each(&self, f: &fn(&T) -> bool) -> bool {
-        self.iter().advance(f)
-    }
-
     /// An iterator visiting all elements in arbitrary order.
     /// Iterator element type is &'a T.
     pub fn iter<'a>(&'a self) -> HashSetIterator<'a, T> {
diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs
index d96191f296d..9177ecabed6 100644
--- a/src/libstd/iterator.rs
+++ b/src/libstd/iterator.rs
@@ -43,7 +43,6 @@ pub trait Iterator<A> {
     /// Return a lower bound and upper bound on the remaining length of the iterator.
     ///
     /// The common use case for the estimate is pre-allocating space to store the results.
-    #[cfg(not(stage0))]
     fn size_hint(&self) -> (Option<uint>, Option<uint>) { (None, None) }
 }
 
@@ -610,7 +609,6 @@ impl<A, T: Iterator<A>, U: Iterator<A>> Iterator<A> for ChainIterator<A, T, U> {
     }
 
     #[inline]
-    #[cfg(not(stage0))]
     fn size_hint(&self) -> (Option<uint>, Option<uint>) {
         let (a_lower, a_upper) = self.a.size_hint();
         let (b_lower, b_upper) = self.b.size_hint();
@@ -664,7 +662,6 @@ impl<'self, A, B, T: Iterator<A>> Iterator<B> for MapIterator<'self, A, B, T> {
     }
 
     #[inline]
-    #[cfg(not(stage0))]
     fn size_hint(&self) -> (Option<uint>, Option<uint>) {
         self.iter.size_hint()
     }
@@ -690,7 +687,6 @@ impl<'self, A, T: Iterator<A>> Iterator<A> for FilterIterator<'self, A, T> {
     }
 
     #[inline]
-    #[cfg(not(stage0))]
     fn size_hint(&self) -> (Option<uint>, Option<uint>) {
         let (_, upper) = self.iter.size_hint();
         (None, upper) // can't know a lower bound, due to the predicate
@@ -716,7 +712,6 @@ impl<'self, A, B, T: Iterator<A>> Iterator<B> for FilterMapIterator<'self, A, B,
     }
 
     #[inline]
-    #[cfg(not(stage0))]
     fn size_hint(&self) -> (Option<uint>, Option<uint>) {
         let (_, upper) = self.iter.size_hint();
         (None, upper) // can't know a lower bound, due to the predicate
diff --git a/src/libstd/libc.rs b/src/libstd/libc.rs
index 988fb5cc9b1..523645e69a5 100644
--- a/src/libstd/libc.rs
+++ b/src/libstd/libc.rs
@@ -102,10 +102,12 @@ pub use libc::funcs::posix88::stdio::*;
 pub use libc::funcs::posix88::fcntl::*;
 pub use libc::funcs::posix88::dirent::*;
 pub use libc::funcs::posix88::unistd::*;
+pub use libc::funcs::posix88::mman::*;
 
 pub use libc::funcs::posix01::stat_::*;
 pub use libc::funcs::posix01::unistd::*;
 pub use libc::funcs::posix01::glob::*;
+pub use libc::funcs::posix01::mman::*;
 pub use libc::funcs::posix08::unistd::*;
 
 pub use libc::funcs::bsd44::*;
@@ -285,7 +287,7 @@ pub mod types {
             #[cfg(target_arch = "x86")]
             #[cfg(target_arch = "mips")]
             pub mod posix01 {
-                use libc::types::os::arch::c95::{c_short, c_long, c_ulong, time_t};
+                use libc::types::os::arch::c95::{c_short, c_long, time_t};
                 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
                 use libc::types::os::arch::posix88::{mode_t, off_t};
                 use libc::types::os::arch::posix88::{uid_t};
@@ -903,52 +905,56 @@ pub mod consts {
     #[cfg(target_os = "win32")]
     pub mod os {
         pub mod c95 {
-            pub static EXIT_FAILURE : int = 1;
-            pub static EXIT_SUCCESS : int = 0;
-            pub static RAND_MAX : int = 32767;
-            pub static EOF : int = -1;
-            pub static SEEK_SET : int = 0;
-            pub static SEEK_CUR : int = 1;
-            pub static SEEK_END : int = 2;
-            pub static _IOFBF : int = 0;
-            pub static _IONBF : int = 4;
-            pub static _IOLBF : int = 64;
-            pub static BUFSIZ : uint = 512_u;
-            pub static FOPEN_MAX : uint = 20_u;
-            pub static FILENAME_MAX : uint = 260_u;
-            pub static L_tmpnam : uint = 16_u;
-            pub static TMP_MAX : uint = 32767_u;
+            use libc::types::os::arch::c95::{c_int, c_uint};
+
+            pub static EXIT_FAILURE : c_int = 1;
+            pub static EXIT_SUCCESS : c_int = 0;
+            pub static RAND_MAX : c_int = 32767;
+            pub static EOF : c_int = -1;
+            pub static SEEK_SET : c_int = 0;
+            pub static SEEK_CUR : c_int = 1;
+            pub static SEEK_END : c_int = 2;
+            pub static _IOFBF : c_int = 0;
+            pub static _IONBF : c_int = 4;
+            pub static _IOLBF : c_int = 64;
+            pub static BUFSIZ : c_uint = 512_u32;
+            pub static FOPEN_MAX : c_uint = 20_u32;
+            pub static FILENAME_MAX : c_uint = 260_u32;
+            pub static L_tmpnam : c_uint = 16_u32;
+            pub static TMP_MAX : c_uint = 32767_u32;
         }
         pub mod c99 {
         }
         pub mod posix88 {
-            pub static O_RDONLY : int = 0;
-            pub static O_WRONLY : int = 1;
-            pub static O_RDWR : int = 2;
-            pub static O_APPEND : int = 8;
-            pub static O_CREAT : int = 256;
-            pub static O_EXCL : int = 1024;
-            pub static O_TRUNC : int = 512;
-            pub static S_IFIFO : int = 4096;
-            pub static S_IFCHR : int = 8192;
-            pub static S_IFBLK : int = 12288;
-            pub static S_IFDIR : int = 16384;
-            pub static S_IFREG : int = 32768;
-            pub static S_IFMT : int = 61440;
-            pub static S_IEXEC : int = 64;
-            pub static S_IWRITE : int = 128;
-            pub static S_IREAD : int = 256;
-            pub static S_IRWXU : int = 448;
-            pub static S_IXUSR : int = 64;
-            pub static S_IWUSR : int = 128;
-            pub static S_IRUSR : int = 256;
-            pub static F_OK : int = 0;
-            pub static R_OK : int = 4;
-            pub static W_OK : int = 2;
-            pub static X_OK : int = 1;
-            pub static STDIN_FILENO : int = 0;
-            pub static STDOUT_FILENO : int = 1;
-            pub static STDERR_FILENO : int = 2;
+            use libc::types::os::arch::c95::c_int;
+
+            pub static O_RDONLY : c_int = 0;
+            pub static O_WRONLY : c_int = 1;
+            pub static O_RDWR : c_int = 2;
+            pub static O_APPEND : c_int = 8;
+            pub static O_CREAT : c_int = 256;
+            pub static O_EXCL : c_int = 1024;
+            pub static O_TRUNC : c_int = 512;
+            pub static S_IFIFO : c_int = 4096;
+            pub static S_IFCHR : c_int = 8192;
+            pub static S_IFBLK : c_int = 12288;
+            pub static S_IFDIR : c_int = 16384;
+            pub static S_IFREG : c_int = 32768;
+            pub static S_IFMT : c_int = 61440;
+            pub static S_IEXEC : c_int = 64;
+            pub static S_IWRITE : c_int = 128;
+            pub static S_IREAD : c_int = 256;
+            pub static S_IRWXU : c_int = 448;
+            pub static S_IXUSR : c_int = 64;
+            pub static S_IWUSR : c_int = 128;
+            pub static S_IRUSR : c_int = 256;
+            pub static F_OK : c_int = 0;
+            pub static R_OK : c_int = 4;
+            pub static W_OK : c_int = 2;
+            pub static X_OK : c_int = 1;
+            pub static STDIN_FILENO : c_int = 0;
+            pub static STDOUT_FILENO : c_int = 1;
+            pub static STDERR_FILENO : c_int = 2;
         }
         pub mod posix01 {
         }
@@ -957,18 +963,19 @@ pub mod consts {
         pub mod bsd44 {
         }
         pub mod extra {
+            use libc::types::os::arch::c95::c_int;
             use libc::types::os::arch::extra::{DWORD, BOOL};
 
             pub static TRUE : BOOL = 1;
             pub static FALSE : BOOL = 0;
 
-            pub static O_TEXT : int = 16384;
-            pub static O_BINARY : int = 32768;
-            pub static O_NOINHERIT: int = 128;
+            pub static O_TEXT : c_int = 16384;
+            pub static O_BINARY : c_int = 32768;
+            pub static O_NOINHERIT: c_int = 128;
 
-            pub static ERROR_SUCCESS : int = 0;
-            pub static ERROR_INSUFFICIENT_BUFFER : int = 122;
-            pub static INVALID_HANDLE_VALUE: int = -1;
+            pub static ERROR_SUCCESS : c_int = 0;
+            pub static ERROR_INSUFFICIENT_BUFFER : c_int = 122;
+            pub static INVALID_HANDLE_VALUE: c_int = -1;
 
             pub static DELETE : DWORD = 0x00010000;
             pub static READ_CONTROL : DWORD = 0x00020000;
@@ -1021,21 +1028,23 @@ pub mod consts {
     #[cfg(target_os = "android")]
     pub mod os {
         pub mod c95 {
-            pub static EXIT_FAILURE : int = 1;
-            pub static EXIT_SUCCESS : int = 0;
-            pub static RAND_MAX : int = 2147483647;
-            pub static EOF : int = -1;
-            pub static SEEK_SET : int = 0;
-            pub static SEEK_CUR : int = 1;
-            pub static SEEK_END : int = 2;
-            pub static _IOFBF : int = 0;
-            pub static _IONBF : int = 2;
-            pub static _IOLBF : int = 1;
-            pub static BUFSIZ : uint = 8192_u;
-            pub static FOPEN_MAX : uint = 16_u;
-            pub static FILENAME_MAX : uint = 4096_u;
-            pub static L_tmpnam : uint = 20_u;
-            pub static TMP_MAX : uint = 238328_u;
+            use libc::types::os::arch::c95::{c_int, c_uint};
+
+            pub static EXIT_FAILURE : c_int = 1;
+            pub static EXIT_SUCCESS : c_int = 0;
+            pub static RAND_MAX : c_int = 2147483647;
+            pub static EOF : c_int = -1;
+            pub static SEEK_SET : c_int = 0;
+            pub static SEEK_CUR : c_int = 1;
+            pub static SEEK_END : c_int = 2;
+            pub static _IOFBF : c_int = 0;
+            pub static _IONBF : c_int = 2;
+            pub static _IOLBF : c_int = 1;
+            pub static BUFSIZ : c_uint = 8192_u32;
+            pub static FOPEN_MAX : c_uint = 16_u32;
+            pub static FILENAME_MAX : c_uint = 4096_u32;
+            pub static L_tmpnam : c_uint = 20_u32;
+            pub static TMP_MAX : c_uint = 238328_u32;
         }
         pub mod c99 {
         }
@@ -1043,309 +1052,791 @@ pub mod consts {
         #[cfg(target_arch = "x86_64")]
         #[cfg(target_arch = "arm")]
         pub mod posix88 {
-            pub static O_RDONLY : int = 0;
-            pub static O_WRONLY : int = 1;
-            pub static O_RDWR : int = 2;
-            pub static O_APPEND : int = 1024;
-            pub static O_CREAT : int = 64;
-            pub static O_EXCL : int = 128;
-            pub static O_TRUNC : int = 512;
-            pub static S_IFIFO : int = 4096;
-            pub static S_IFCHR : int = 8192;
-            pub static S_IFBLK : int = 24576;
-            pub static S_IFDIR : int = 16384;
-            pub static S_IFREG : int = 32768;
-            pub static S_IFMT : int = 61440;
-            pub static S_IEXEC : int = 64;
-            pub static S_IWRITE : int = 128;
-            pub static S_IREAD : int = 256;
-            pub static S_IRWXU : int = 448;
-            pub static S_IXUSR : int = 64;
-            pub static S_IWUSR : int = 128;
-            pub static S_IRUSR : int = 256;
-            pub static F_OK : int = 0;
-            pub static R_OK : int = 4;
-            pub static W_OK : int = 2;
-            pub static X_OK : int = 1;
-            pub static STDIN_FILENO : int = 0;
-            pub static STDOUT_FILENO : int = 1;
-            pub static STDERR_FILENO : int = 2;
-            pub static F_LOCK : int = 1;
-            pub static F_TEST : int = 3;
-            pub static F_TLOCK : int = 2;
-            pub static F_ULOCK : int = 0;
-            pub static SIGHUP : int = 1;
-            pub static SIGINT : int = 2;
-            pub static SIGQUIT : int = 3;
-            pub static SIGILL : int = 4;
-            pub static SIGABRT : int = 6;
-            pub static SIGFPE : int = 8;
-            pub static SIGKILL : int = 9;
-            pub static SIGSEGV : int = 11;
-            pub static SIGPIPE : int = 13;
-            pub static SIGALRM : int = 14;
-            pub static SIGTERM : int = 15;
+            use libc::types::os::arch::c95::c_int;
+            use libc::types::common::c95::c_void;
+
+            pub static O_RDONLY : c_int = 0;
+            pub static O_WRONLY : c_int = 1;
+            pub static O_RDWR : c_int = 2;
+            pub static O_APPEND : c_int = 1024;
+            pub static O_CREAT : c_int = 64;
+            pub static O_EXCL : c_int = 128;
+            pub static O_TRUNC : c_int = 512;
+            pub static S_IFIFO : c_int = 4096;
+            pub static S_IFCHR : c_int = 8192;
+            pub static S_IFBLK : c_int = 24576;
+            pub static S_IFDIR : c_int = 16384;
+            pub static S_IFREG : c_int = 32768;
+            pub static S_IFMT : c_int = 61440;
+            pub static S_IEXEC : c_int = 64;
+            pub static S_IWRITE : c_int = 128;
+            pub static S_IREAD : c_int = 256;
+            pub static S_IRWXU : c_int = 448;
+            pub static S_IXUSR : c_int = 64;
+            pub static S_IWUSR : c_int = 128;
+            pub static S_IRUSR : c_int = 256;
+            pub static F_OK : c_int = 0;
+            pub static R_OK : c_int = 4;
+            pub static W_OK : c_int = 2;
+            pub static X_OK : c_int = 1;
+            pub static STDIN_FILENO : c_int = 0;
+            pub static STDOUT_FILENO : c_int = 1;
+            pub static STDERR_FILENO : c_int = 2;
+            pub static F_LOCK : c_int = 1;
+            pub static F_TEST : c_int = 3;
+            pub static F_TLOCK : c_int = 2;
+            pub static F_ULOCK : c_int = 0;
+            pub static SIGHUP : c_int = 1;
+            pub static SIGINT : c_int = 2;
+            pub static SIGQUIT : c_int = 3;
+            pub static SIGILL : c_int = 4;
+            pub static SIGABRT : c_int = 6;
+            pub static SIGFPE : c_int = 8;
+            pub static SIGKILL : c_int = 9;
+            pub static SIGSEGV : c_int = 11;
+            pub static SIGPIPE : c_int = 13;
+            pub static SIGALRM : c_int = 14;
+            pub static SIGTERM : c_int = 15;
+
+            pub static PROT_NONE : c_int = 0;
+            pub static PROT_READ : c_int = 1;
+            pub static PROT_WRITE : c_int = 2;
+            pub static PROT_EXEC : c_int = 4;
+
+            pub static MAP_FILE : c_int = 0x0000;
+            pub static MAP_SHARED : c_int = 0x0001;
+            pub static MAP_PRIVATE : c_int = 0x0002;
+            pub static MAP_FIXED : c_int = 0x0010;
+            pub static MAP_ANON : c_int = 0x1000;
+
+            pub static MAP_FAILED : *c_void = -1 as *c_void;
+
+            pub static MCL_CURRENT : c_int = 0x0001;
+            pub static MCL_FUTURE : c_int = 0x0002;
+
+            pub static MS_ASYNC : c_int = 0x0001;
+            pub static MS_INVALIDATE : c_int = 0x0002;
+            pub static MS_SYNC : c_int = 0x0004;
         }
         #[cfg(target_arch = "mips")]
         pub mod posix88 {
-            pub static O_RDONLY : int = 0;
-            pub static O_WRONLY : int = 1;
-            pub static O_RDWR : int = 2;
-            pub static O_APPEND : int = 8;
-            pub static O_CREAT : int = 256;
-            pub static O_EXCL : int = 1024;
-            pub static O_TRUNC : int = 512;
-            pub static S_IFIFO : int = 4096;
-            pub static S_IFCHR : int = 8192;
-            pub static S_IFBLK : int = 24576;
-            pub static S_IFDIR : int = 16384;
-            pub static S_IFREG : int = 32768;
-            pub static S_IFMT : int = 61440;
-            pub static S_IEXEC : int = 64;
-            pub static S_IWRITE : int = 128;
-            pub static S_IREAD : int = 256;
-            pub static S_IRWXU : int = 448;
-            pub static S_IXUSR : int = 64;
-            pub static S_IWUSR : int = 128;
-            pub static S_IRUSR : int = 256;
-            pub static F_OK : int = 0;
-            pub static R_OK : int = 4;
-            pub static W_OK : int = 2;
-            pub static X_OK : int = 1;
-            pub static STDIN_FILENO : int = 0;
-            pub static STDOUT_FILENO : int = 1;
-            pub static STDERR_FILENO : int = 2;
-            pub static F_LOCK : int = 1;
-            pub static F_TEST : int = 3;
-            pub static F_TLOCK : int = 2;
-            pub static F_ULOCK : int = 0;
-            pub static SIGHUP : int = 1;
-            pub static SIGINT : int = 2;
-            pub static SIGQUIT : int = 3;
-            pub static SIGILL : int = 4;
-            pub static SIGABRT : int = 6;
-            pub static SIGFPE : int = 8;
-            pub static SIGKILL : int = 9;
-            pub static SIGSEGV : int = 11;
-            pub static SIGPIPE : int = 13;
-            pub static SIGALRM : int = 14;
-            pub static SIGTERM : int = 15;
+            use libc::types::os::arch::c95::c_int;
+            use libc::types::common::c95::c_void;
+
+            pub static O_RDONLY : c_int = 0;
+            pub static O_WRONLY : c_int = 1;
+            pub static O_RDWR : c_int = 2;
+            pub static O_APPEND : c_int = 8;
+            pub static O_CREAT : c_int = 256;
+            pub static O_EXCL : c_int = 1024;
+            pub static O_TRUNC : c_int = 512;
+            pub static S_IFIFO : c_int = 4096;
+            pub static S_IFCHR : c_int = 8192;
+            pub static S_IFBLK : c_int = 24576;
+            pub static S_IFDIR : c_int = 16384;
+            pub static S_IFREG : c_int = 32768;
+            pub static S_IFMT : c_int = 61440;
+            pub static S_IEXEC : c_int = 64;
+            pub static S_IWRITE : c_int = 128;
+            pub static S_IREAD : c_int = 256;
+            pub static S_IRWXU : c_int = 448;
+            pub static S_IXUSR : c_int = 64;
+            pub static S_IWUSR : c_int = 128;
+            pub static S_IRUSR : c_int = 256;
+            pub static F_OK : c_int = 0;
+            pub static R_OK : c_int = 4;
+            pub static W_OK : c_int = 2;
+            pub static X_OK : c_int = 1;
+            pub static STDIN_FILENO : c_int = 0;
+            pub static STDOUT_FILENO : c_int = 1;
+            pub static STDERR_FILENO : c_int = 2;
+            pub static F_LOCK : c_int = 1;
+            pub static F_TEST : c_int = 3;
+            pub static F_TLOCK : c_int = 2;
+            pub static F_ULOCK : c_int = 0;
+            pub static SIGHUP : c_int = 1;
+            pub static SIGINT : c_int = 2;
+            pub static SIGQUIT : c_int = 3;
+            pub static SIGILL : c_int = 4;
+            pub static SIGABRT : c_int = 6;
+            pub static SIGFPE : c_int = 8;
+            pub static SIGKILL : c_int = 9;
+            pub static SIGSEGV : c_int = 11;
+            pub static SIGPIPE : c_int = 13;
+            pub static SIGALRM : c_int = 14;
+            pub static SIGTERM : c_int = 15;
+
+            pub static PROT_NONE : c_int = 0;
+            pub static PROT_READ : c_int = 1;
+            pub static PROT_WRITE : c_int = 2;
+            pub static PROT_EXEC : c_int = 4;
+
+            pub static MAP_FILE : c_int = 0x0000;
+            pub static MAP_SHARED : c_int = 0x0001;
+            pub static MAP_PRIVATE : c_int = 0x0002;
+            pub static MAP_FIXED : c_int = 0x0010;
+            pub static MAP_ANON : c_int = 0x1000;
+
+            pub static MAP_FAILED : *c_void = -1 as *c_void;
+
+            pub static MCL_CURRENT : c_int = 0x0001;
+            pub static MCL_FUTURE : c_int = 0x0002;
+
+            pub static MS_ASYNC : c_int = 0x0001;
+            pub static MS_INVALIDATE : c_int = 0x0002;
+            pub static MS_SYNC : c_int = 0x0004;
+
+            pub static _SC_ARG_MAX : c_int = 0;
+            pub static _SC_CHILD_MAX : c_int = 1;
+            pub static _SC_CLK_TCK : c_int = 2;
+            pub static _SC_NGROUPS_MAX : c_int = 3;
+            pub static _SC_OPEN_MAX : c_int = 4;
+            pub static _SC_STREAM_MAX : c_int = 5;
+            pub static _SC_TZNAME_MAX : c_int = 6;
+            pub static _SC_JOB_CONTROL : c_int = 7;
+            pub static _SC_SAVED_IDS : c_int = 8;
+            pub static _SC_REALTIME_SIGNALS : c_int = 9;
+            pub static _SC_PRIORITY_SCHEDULING : c_int = 10;
+            pub static _SC_TIMERS : c_int = 11;
+            pub static _SC_ASYNCHRONOUS_IO : c_int = 12;
+            pub static _SC_PRIORITIZED_IO : c_int = 13;
+            pub static _SC_SYNCHRONIZED_IO : c_int = 14;
+            pub static _SC_FSYNC : c_int = 15;
+            pub static _SC_MAPPED_FILES : c_int = 16;
+            pub static _SC_MEMLOCK : c_int = 17;
+            pub static _SC_MEMLOCK_RANGE : c_int = 18;
+            pub static _SC_MEMORY_PROTECTION : c_int = 19;
+            pub static _SC_MESSAGE_PASSING : c_int = 20;
+            pub static _SC_SEMAPHORES : c_int = 21;
+            pub static _SC_SHARED_MEMORY_OBJECTS : c_int = 22;
+            pub static _SC_AIO_LISTIO_MAX : c_int = 23;
+            pub static _SC_AIO_MAX : c_int = 24;
+            pub static _SC_AIO_PRIO_DELTA_MAX : c_int = 25;
+            pub static _SC_DELAYTIMER_MAX : c_int = 26;
+            pub static _SC_MQ_OPEN_MAX : c_int = 27;
+            pub static _SC_VERSION : c_int = 29;
+            pub static _SC_PAGESIZE : c_int = 30;
+            pub static _SC_RTSIG_MAX : c_int = 31;
+            pub static _SC_SEM_NSEMS_MAX : c_int = 32;
+            pub static _SC_SEM_VALUE_MAX : c_int = 33;
+            pub static _SC_SIGQUEUE_MAX : c_int = 34;
+            pub static _SC_TIMER_MAX : c_int = 35;
+            pub static _SC_BC_BASE_MAX : c_int = 36;
+            pub static _SC_BC_DIM_MAX : c_int = 37;
+            pub static _SC_BC_SCALE_MAX : c_int = 38;
+            pub static _SC_BC_STRING_MAX : c_int = 39;
+            pub static _SC_COLL_WEIGHTS_MAX : c_int = 40;
+            pub static _SC_EXPR_NEST_MAX : c_int = 42;
+            pub static _SC_LINE_MAX : c_int = 43;
+            pub static _SC_RE_DUP_MAX : c_int = 44;
+            pub static _SC_2_VERSION : c_int = 46;
+            pub static _SC_2_C_BIND : c_int = 47;
+            pub static _SC_2_C_DEV : c_int = 48;
+            pub static _SC_2_FORT_DEV : c_int = 49;
+            pub static _SC_2_FORT_RUN : c_int = 50;
+            pub static _SC_2_SW_DEV : c_int = 51;
+            pub static _SC_2_LOCALEDEF : c_int = 52;
+            pub static _SC_2_CHAR_TERM : c_int = 95;
+            pub static _SC_2_C_VERSION : c_int = 96;
+            pub static _SC_2_UPE : c_int = 97;
+            pub static _SC_XBS5_ILP32_OFF32 : c_int = 125;
+            pub static _SC_XBS5_ILP32_OFFBIG : c_int = 126;
+            pub static _SC_XBS5_LPBIG_OFFBIG : c_int = 128;
         }
         pub mod posix01 {
-            pub static SIGTRAP : int = 5;
-
-            pub static GLOB_ERR      : int = 1 << 0;
-            pub static GLOB_MARK     : int = 1 << 1;
-            pub static GLOB_NOSORT   : int = 1 << 2;
-            pub static GLOB_DOOFFS   : int = 1 << 3;
-            pub static GLOB_NOCHECK  : int = 1 << 4;
-            pub static GLOB_APPEND   : int = 1 << 5;
-            pub static GLOB_NOESCAPE : int = 1 << 6;
-
-            pub static GLOB_NOSPACE  : int = 1;
-            pub static GLOB_ABORTED  : int = 2;
-            pub static GLOB_NOMATCH  : int = 3;
+            use libc::types::os::arch::c95::c_int;
+
+            pub static SIGTRAP : c_int = 5;
+
+            pub static GLOB_ERR      : c_int = 1 << 0;
+            pub static GLOB_MARK     : c_int = 1 << 1;
+            pub static GLOB_NOSORT   : c_int = 1 << 2;
+            pub static GLOB_DOOFFS   : c_int = 1 << 3;
+            pub static GLOB_NOCHECK  : c_int = 1 << 4;
+            pub static GLOB_APPEND   : c_int = 1 << 5;
+            pub static GLOB_NOESCAPE : c_int = 1 << 6;
+
+            pub static GLOB_NOSPACE  : c_int = 1;
+            pub static GLOB_ABORTED  : c_int = 2;
+            pub static GLOB_NOMATCH  : c_int = 3;
+
+            pub static POSIX_MADV_NORMAL : c_int = 0;
+            pub static POSIX_MADV_RANDOM : c_int = 1;
+            pub static POSIX_MADV_SEQUENTIAL : c_int = 2;
+            pub static POSIX_MADV_WILLNEED : c_int = 3;
+            pub static POSIX_MADV_DONTNEED : c_int = 4;
+
+            pub static _SC_MQ_PRIO_MAX : c_int = 28;
+            pub static _SC_IOV_MAX : c_int = 60;
+            pub static _SC_GETGR_R_SIZE_MAX : c_int = 69;
+            pub static _SC_GETPW_R_SIZE_MAX : c_int = 70;
+            pub static _SC_LOGIN_NAME_MAX : c_int = 71;
+            pub static _SC_TTY_NAME_MAX : c_int = 72;
+            pub static _SC_THREADS : c_int = 67;
+            pub static _SC_THREAD_SAFE_FUNCTIONS : c_int = 68;
+            pub static _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73;
+            pub static _SC_THREAD_KEYS_MAX : c_int = 74;
+            pub static _SC_THREAD_STACK_MIN : c_int = 75;
+            pub static _SC_THREAD_THREADS_MAX : c_int = 76;
+            pub static _SC_THREAD_ATTR_STACKADDR : c_int = 77;
+            pub static _SC_THREAD_ATTR_STACKSIZE : c_int = 78;
+            pub static _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79;
+            pub static _SC_THREAD_PRIO_INHERIT : c_int = 80;
+            pub static _SC_THREAD_PRIO_PROTECT : c_int = 81;
+            pub static _SC_THREAD_PROCESS_SHARED : c_int = 82;
+            pub static _SC_ATEXIT_MAX : c_int = 87;
+            pub static _SC_XOPEN_VERSION : c_int = 89;
+            pub static _SC_XOPEN_XCU_VERSION : c_int = 90;
+            pub static _SC_XOPEN_UNIX : c_int = 91;
+            pub static _SC_XOPEN_CRYPT : c_int = 92;
+            pub static _SC_XOPEN_ENH_I18N : c_int = 93;
+            pub static _SC_XOPEN_SHM : c_int = 94;
+            pub static _SC_XOPEN_LEGACY : c_int = 129;
+            pub static _SC_XOPEN_REALTIME : c_int = 130;
+            pub static _SC_XOPEN_REALTIME_THREADS : c_int = 131;
         }
         pub mod posix08 {
         }
         pub mod bsd44 {
+            use libc::types::os::arch::c95::c_int;
+
+            pub static MADV_NORMAL : c_int = 0;
+            pub static MADV_RANDOM : c_int = 1;
+            pub static MADV_SEQUENTIAL : c_int = 2;
+            pub static MADV_WILLNEED : c_int = 3;
+            pub static MADV_DONTNEED : c_int = 4;
+            pub static MADV_REMOVE : c_int = 9;
+            pub static MADV_DONTFORK : c_int = 10;
+            pub static MADV_DOFORK : c_int = 11;
+            pub static MADV_MERGEABLE : c_int = 12;
+            pub static MADV_UNMERGEABLE : c_int = 13;
+            pub static MADV_HWPOISON : c_int = 100;
         }
         #[cfg(target_arch = "x86")]
         #[cfg(target_arch = "x86_64")]
         #[cfg(target_arch = "arm")]
         pub mod extra {
-            pub static O_RSYNC : int = 1052672;
-            pub static O_DSYNC : int = 4096;
-            pub static O_SYNC : int = 1052672;
+            use libc::types::os::arch::c95::c_int;
+
+            pub static O_RSYNC : c_int = 1052672;
+            pub static O_DSYNC : c_int = 4096;
+            pub static O_SYNC : c_int = 1052672;
+
+            pub static PROT_GROWSDOWN : c_int = 0x010000000;
+            pub static PROT_GROWSUP : c_int = 0x020000000;
+
+            pub static MAP_TYPE : c_int = 0x000f;
+            pub static MAP_ANONONYMOUS : c_int = 0x1000;
+            pub static MAP_32BIT : c_int = 0x0040;
+            pub static MAP_GROWSDOWN : c_int = 0x0100;
+            pub static MAP_DENYWRITE : c_int = 0x0800;
+            pub static MAP_EXECUTABLE : c_int = 0x01000;
+            pub static MAP_LOCKED : c_int = 0x02000;
+            pub static MAP_NONRESERVE : c_int = 0x04000;
+            pub static MAP_POPULATE : c_int = 0x08000;
+            pub static MAP_NONBLOCK : c_int = 0x010000;
+            pub static MAP_STACK : c_int = 0x020000;
         }
         #[cfg(target_arch = "mips")]
         pub mod extra {
-            pub static O_RSYNC : int = 16400;
-            pub static O_DSYNC : int = 16;
-            pub static O_SYNC : int = 16400;
+            use libc::types::os::arch::c95::c_int;
+
+            pub static O_RSYNC : c_int = 16400;
+            pub static O_DSYNC : c_int = 16;
+            pub static O_SYNC : c_int = 16400;
+
+            pub static PROT_GROWSDOWN : c_int = 0x010000000;
+            pub static PROT_GROWSUP : c_int = 0x020000000;
+
+            pub static MAP_TYPE : c_int = 0x000f;
+            pub static MAP_ANONONYMOUS : c_int = 0x1000;
+            pub static MAP_32BIT : c_int = 0x0040;
+            pub static MAP_GROWSDOWN : c_int = 0x0100;
+            pub static MAP_DENYWRITE : c_int = 0x0800;
+            pub static MAP_EXECUTABLE : c_int = 0x01000;
+            pub static MAP_LOCKED : c_int = 0x02000;
+            pub static MAP_NONRESERVE : c_int = 0x04000;
+            pub static MAP_POPULATE : c_int = 0x08000;
+            pub static MAP_NONBLOCK : c_int = 0x010000;
+            pub static MAP_STACK : c_int = 0x020000;
         }
     }
 
     #[cfg(target_os = "freebsd")]
     pub mod os {
         pub mod c95 {
-            pub static EXIT_FAILURE : int = 1;
-            pub static EXIT_SUCCESS : int = 0;
-            pub static RAND_MAX : int = 2147483647;
-            pub static EOF : int = -1;
-            pub static SEEK_SET : int = 0;
-            pub static SEEK_CUR : int = 1;
-            pub static SEEK_END : int = 2;
-            pub static _IOFBF : int = 0;
-            pub static _IONBF : int = 2;
-            pub static _IOLBF : int = 1;
-            pub static BUFSIZ : uint = 1024_u;
-            pub static FOPEN_MAX : uint = 20_u;
-            pub static FILENAME_MAX : uint = 1024_u;
-            pub static L_tmpnam : uint = 1024_u;
-            pub static TMP_MAX : uint = 308915776_u;
+            use libc::types::os::arch::c95::{c_int, c_uint};
+
+            pub static EXIT_FAILURE : c_int = 1;
+            pub static EXIT_SUCCESS : c_int = 0;
+            pub static RAND_MAX : c_int = 2147483647;
+            pub static EOF : c_int = -1;
+            pub static SEEK_SET : c_int = 0;
+            pub static SEEK_CUR : c_int = 1;
+            pub static SEEK_END : c_int = 2;
+            pub static _IOFBF : c_int = 0;
+            pub static _IONBF : c_int = 2;
+            pub static _IOLBF : c_int = 1;
+            pub static BUFSIZ : c_uint = 1024_u32;
+            pub static FOPEN_MAX : c_uint = 20_u32;
+            pub static FILENAME_MAX : c_uint = 1024_u32;
+            pub static L_tmpnam : c_uint = 1024_u32;
+            pub static TMP_MAX : c_uint = 308915776_u32;
         }
         pub mod c99 {
         }
         pub mod posix88 {
-            pub static O_RDONLY : int = 0;
-            pub static O_WRONLY : int = 1;
-            pub static O_RDWR : int = 2;
-            pub static O_APPEND : int = 8;
-            pub static O_CREAT : int = 512;
-            pub static O_EXCL : int = 2048;
-            pub static O_TRUNC : int = 1024;
-            pub static S_IFIFO : int = 4096;
-            pub static S_IFCHR : int = 8192;
-            pub static S_IFBLK : int = 24576;
-            pub static S_IFDIR : int = 16384;
-            pub static S_IFREG : int = 32768;
-            pub static S_IFMT : int = 61440;
-            pub static S_IEXEC : int = 64;
-            pub static S_IWRITE : int = 128;
-            pub static S_IREAD : int = 256;
-            pub static S_IRWXU : int = 448;
-            pub static S_IXUSR : int = 64;
-            pub static S_IWUSR : int = 128;
-            pub static S_IRUSR : int = 256;
-            pub static F_OK : int = 0;
-            pub static R_OK : int = 4;
-            pub static W_OK : int = 2;
-            pub static X_OK : int = 1;
-            pub static STDIN_FILENO : int = 0;
-            pub static STDOUT_FILENO : int = 1;
-            pub static STDERR_FILENO : int = 2;
-            pub static F_LOCK : int = 1;
-            pub static F_TEST : int = 3;
-            pub static F_TLOCK : int = 2;
-            pub static F_ULOCK : int = 0;
-            pub static SIGHUP : int = 1;
-            pub static SIGINT : int = 2;
-            pub static SIGQUIT : int = 3;
-            pub static SIGILL : int = 4;
-            pub static SIGABRT : int = 6;
-            pub static SIGFPE : int = 8;
-            pub static SIGKILL : int = 9;
-            pub static SIGSEGV : int = 11;
-            pub static SIGPIPE : int = 13;
-            pub static SIGALRM : int = 14;
-            pub static SIGTERM : int = 15;
+            use libc::types::common::c95::c_void;
+            use libc::types::os::arch::c95::c_int;
+
+            pub static O_RDONLY : c_int = 0;
+            pub static O_WRONLY : c_int = 1;
+            pub static O_RDWR : c_int = 2;
+            pub static O_APPEND : c_int = 8;
+            pub static O_CREAT : c_int = 512;
+            pub static O_EXCL : c_int = 2048;
+            pub static O_TRUNC : c_int = 1024;
+            pub static S_IFIFO : c_int = 4096;
+            pub static S_IFCHR : c_int = 8192;
+            pub static S_IFBLK : c_int = 24576;
+            pub static S_IFDIR : c_int = 16384;
+            pub static S_IFREG : c_int = 32768;
+            pub static S_IFMT : c_int = 61440;
+            pub static S_IEXEC : c_int = 64;
+            pub static S_IWRITE : c_int = 128;
+            pub static S_IREAD : c_int = 256;
+            pub static S_IRWXU : c_int = 448;
+            pub static S_IXUSR : c_int = 64;
+            pub static S_IWUSR : c_int = 128;
+            pub static S_IRUSR : c_int = 256;
+            pub static F_OK : c_int = 0;
+            pub static R_OK : c_int = 4;
+            pub static W_OK : c_int = 2;
+            pub static X_OK : c_int = 1;
+            pub static STDIN_FILENO : c_int = 0;
+            pub static STDOUT_FILENO : c_int = 1;
+            pub static STDERR_FILENO : c_int = 2;
+            pub static F_LOCK : c_int = 1;
+            pub static F_TEST : c_int = 3;
+            pub static F_TLOCK : c_int = 2;
+            pub static F_ULOCK : c_int = 0;
+            pub static SIGHUP : c_int = 1;
+            pub static SIGINT : c_int = 2;
+            pub static SIGQUIT : c_int = 3;
+            pub static SIGILL : c_int = 4;
+            pub static SIGABRT : c_int = 6;
+            pub static SIGFPE : c_int = 8;
+            pub static SIGKILL : c_int = 9;
+            pub static SIGSEGV : c_int = 11;
+            pub static SIGPIPE : c_int = 13;
+            pub static SIGALRM : c_int = 14;
+            pub static SIGTERM : c_int = 15;
+
+            pub static PROT_NONE : c_int = 0;
+            pub static PROT_READ : c_int = 1;
+            pub static PROT_WRITE : c_int = 2;
+            pub static PROT_EXEC : c_int = 4;
+
+            pub static MAP_FILE : c_int = 0x0000;
+            pub static MAP_SHARED : c_int = 0x0001;
+            pub static MAP_PRIVATE : c_int = 0x0002;
+            pub static MAP_FIXED : c_int = 0x0010;
+            pub static MAP_ANON : c_int = 0x1000;
+
+            pub static MAP_FAILED : *c_void = -1 as *c_void;
+
+            pub static MCL_CURRENT : c_int = 0x0001;
+            pub static MCL_FUTURE : c_int = 0x0002;
+
+            pub static MS_SYNC : c_int = 0x0000;
+            pub static MS_ASYNC : c_int = 0x0001;
+            pub static MS_INVALIDATE : c_int = 0x0002;
+
+            pub static _SC_ARG_MAX : c_int = 1;
+            pub static _SC_CHILD_MAX : c_int = 2;
+            pub static _SC_CLK_TCK : c_int = 3;
+            pub static _SC_NGROUPS_MAX : c_int = 4;
+            pub static _SC_OPEN_MAX : c_int = 5;
+            pub static _SC_JOB_CONTROL : c_int = 6;
+            pub static _SC_SAVED_IDS : c_int = 7;
+            pub static _SC_VERSION : c_int = 8;
+            pub static _SC_BC_BASE_MAX : c_int = 9;
+            pub static _SC_BC_DIM_MAX : c_int = 10;
+            pub static _SC_BC_SCALE_MAX : c_int = 11;
+            pub static _SC_BC_STRING_MAX : c_int = 12;
+            pub static _SC_COLL_WEIGHTS_MAX : c_int = 13;
+            pub static _SC_EXPR_NEST_MAX : c_int = 14;
+            pub static _SC_LINE_MAX : c_int = 15;
+            pub static _SC_RE_DUP_MAX : c_int = 16;
+            pub static _SC_2_VERSION : c_int = 17;
+            pub static _SC_2_C_BIND : c_int = 18;
+            pub static _SC_2_C_DEV : c_int = 19;
+            pub static _SC_2_CHAR_TERM : c_int = 20;
+            pub static _SC_2_FORT_DEV : c_int = 21;
+            pub static _SC_2_FORT_RUN : c_int = 22;
+            pub static _SC_2_LOCALEDEF : c_int = 23;
+            pub static _SC_2_SW_DEV : c_int = 24;
+            pub static _SC_2_UPE : c_int = 25;
+            pub static _SC_STREAM_MAX : c_int = 26;
+            pub static _SC_TZNAME_MAX : c_int = 27;
+            pub static _SC_ASYNCHRONOUS_IO : c_int = 28;
+            pub static _SC_MAPPED_FILES : c_int = 29;
+            pub static _SC_MEMLOCK : c_int = 30;
+            pub static _SC_MEMLOCK_RANGE : c_int = 31;
+            pub static _SC_MEMORY_PROTECTION : c_int = 32;
+            pub static _SC_MESSAGE_PASSING : c_int = 33;
+            pub static _SC_PRIORITIZED_IO : c_int = 34;
+            pub static _SC_PRIORITY_SCHEDULING : c_int = 35;
+            pub static _SC_REALTIME_SIGNALS : c_int = 36;
+            pub static _SC_SEMAPHORES : c_int = 37;
+            pub static _SC_FSYNC : c_int = 38;
+            pub static _SC_SHARED_MEMORY_OBJECTS : c_int = 39;
+            pub static _SC_SYNCHRONIZED_IO : c_int = 40;
+            pub static _SC_TIMERS : c_int = 41;
+            pub static _SC_AIO_LISTIO_MAX : c_int = 42;
+            pub static _SC_AIO_MAX : c_int = 43;
+            pub static _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
+            pub static _SC_DELAYTIMER_MAX : c_int = 45;
+            pub static _SC_MQ_OPEN_MAX : c_int = 46;
+            pub static _SC_PAGESIZE : c_int = 47;
+            pub static _SC_RTSIG_MAX : c_int = 48;
+            pub static _SC_SEM_NSEMS_MAX : c_int = 49;
+            pub static _SC_SEM_VALUE_MAX : c_int = 50;
+            pub static _SC_SIGQUEUE_MAX : c_int = 51;
+            pub static _SC_TIMER_MAX : c_int = 52;
         }
         pub mod posix01 {
-            pub static SIGTRAP : int = 5;
-
-            pub static GLOB_APPEND   : int = 0x0001;
-            pub static GLOB_DOOFFS   : int = 0x0002;
-            pub static GLOB_ERR      : int = 0x0004;
-            pub static GLOB_MARK     : int = 0x0008;
-            pub static GLOB_NOCHECK  : int = 0x0010;
-            pub static GLOB_NOSORT   : int = 0x0020;
-            pub static GLOB_NOESCAPE : int = 0x2000;
-
-            pub static GLOB_NOSPACE  : int = -1;
-            pub static GLOB_ABORTED  : int = -2;
-            pub static GLOB_NOMATCH  : int = -3;
+            use libc::types::os::arch::c95::c_int;
+
+            pub static SIGTRAP : c_int = 5;
+
+            pub static GLOB_APPEND   : c_int = 0x0001;
+            pub static GLOB_DOOFFS   : c_int = 0x0002;
+            pub static GLOB_ERR      : c_int = 0x0004;
+            pub static GLOB_MARK     : c_int = 0x0008;
+            pub static GLOB_NOCHECK  : c_int = 0x0010;
+            pub static GLOB_NOSORT   : c_int = 0x0020;
+            pub static GLOB_NOESCAPE : c_int = 0x2000;
+
+            pub static GLOB_NOSPACE  : c_int = -1;
+            pub static GLOB_ABORTED  : c_int = -2;
+            pub static GLOB_NOMATCH  : c_int = -3;
+
+            pub static POSIX_MADV_NORMAL : c_int = 0;
+            pub static POSIX_MADV_RANDOM : c_int = 1;
+            pub static POSIX_MADV_SEQUENTIAL : c_int = 2;
+            pub static POSIX_MADV_WILLNEED : c_int = 3;
+            pub static POSIX_MADV_DONTNEED : c_int = 4;
+
+            pub static _SC_IOV_MAX : c_int = 56;
+            pub static _SC_GETGR_R_SIZE_MAX : c_int = 70;
+            pub static _SC_GETPW_R_SIZE_MAX : c_int = 71;
+            pub static _SC_LOGIN_NAME_MAX : c_int = 73;
+            pub static _SC_MQ_PRIO_MAX : c_int = 75;
+            pub static _SC_THREAD_ATTR_STACKADDR : c_int = 82;
+            pub static _SC_THREAD_ATTR_STACKSIZE : c_int = 83;
+            pub static _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85;
+            pub static _SC_THREAD_KEYS_MAX : c_int = 86;
+            pub static _SC_THREAD_PRIO_INHERIT : c_int = 87;
+            pub static _SC_THREAD_PRIO_PROTECT : c_int = 88;
+            pub static _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89;
+            pub static _SC_THREAD_PROCESS_SHARED : c_int = 90;
+            pub static _SC_THREAD_SAFE_FUNCTIONS : c_int = 91;
+            pub static _SC_THREAD_STACK_MIN : c_int = 93;
+            pub static _SC_THREAD_THREADS_MAX : c_int = 94;
+            pub static _SC_THREADS : c_int = 96;
+            pub static _SC_TTY_NAME_MAX : c_int = 101;
+            pub static _SC_ATEXIT_MAX : c_int = 107;
+            pub static _SC_XOPEN_CRYPT : c_int = 108;
+            pub static _SC_XOPEN_ENH_I18N : c_int = 109;
+            pub static _SC_XOPEN_LEGACY : c_int = 110;
+            pub static _SC_XOPEN_REALTIME : c_int = 111;
+            pub static _SC_XOPEN_REALTIME_THREADS : c_int = 112;
+            pub static _SC_XOPEN_SHM : c_int = 113;
+            pub static _SC_XOPEN_UNIX : c_int = 115;
+            pub static _SC_XOPEN_VERSION : c_int = 116;
+            pub static _SC_XOPEN_XCU_VERSION : c_int = 117;
         }
         pub mod posix08 {
         }
         pub mod bsd44 {
+            use libc::types::os::arch::c95::c_int;
+
+            pub static MADV_NORMAL : c_int = 0;
+            pub static MADV_RANDOM : c_int = 1;
+            pub static MADV_SEQUENTIAL : c_int = 2;
+            pub static MADV_WILLNEED : c_int = 3;
+            pub static MADV_DONTNEED : c_int = 4;
+            pub static MADV_FREE : c_int = 5;
+            pub static MADV_NOSYNC : c_int = 6;
+            pub static MADV_AUTOSYNC : c_int = 7;
+            pub static MADV_NOCORE : c_int = 8;
+            pub static MADV_CORE : c_int = 9;
+            pub static MADV_PROTECT : c_int = 10;
+
+            pub static MINCORE_INCORE : c_int =  0x1;
+            pub static MINCORE_REFERENCED : c_int = 0x2;
+            pub static MINCORE_MODIFIED : c_int = 0x4;
+            pub static MINCORE_REFERENCED_OTHER : c_int = 0x8;
+            pub static MINCORE_MODIFIED_OTHER : c_int = 0x10;
+            pub static MINCORE_SUPER : c_int = 0x20;
         }
         pub mod extra {
-            pub static O_SYNC : int = 128;
-            pub static CTL_KERN: int = 1;
-            pub static KERN_PROC: int = 14;
-            pub static KERN_PROC_PATHNAME: int = 12;
+            use libc::types::os::arch::c95::c_int;
+
+            pub static O_SYNC : c_int = 128;
+            pub static CTL_KERN: c_int = 1;
+            pub static KERN_PROC: c_int = 14;
+            pub static KERN_PROC_PATHNAME: c_int = 12;
+
+            pub static MAP_COPY : c_int = 0x0002;
+            pub static MAP_RENAME : c_int = 0x0020;
+            pub static MAP_NORESERVE : c_int = 0x0040;
+            pub static MAP_HASSEMAPHORE : c_int = 0x0200;
+            pub static MAP_STACK : c_int = 0x0400;
+            pub static MAP_NOSYNC : c_int = 0x0800;
+            pub static MAP_NOCORE : c_int = 0x020000;
         }
     }
 
     #[cfg(target_os = "macos")]
     pub mod os {
         pub mod c95 {
-            pub static EXIT_FAILURE : int = 1;
-            pub static EXIT_SUCCESS : int = 0;
-            pub static RAND_MAX : int = 2147483647;
-            pub static EOF : int = -1;
-            pub static SEEK_SET : int = 0;
-            pub static SEEK_CUR : int = 1;
-            pub static SEEK_END : int = 2;
-            pub static _IOFBF : int = 0;
-            pub static _IONBF : int = 2;
-            pub static _IOLBF : int = 1;
-            pub static BUFSIZ : uint = 1024_u;
-            pub static FOPEN_MAX : uint = 20_u;
-            pub static FILENAME_MAX : uint = 1024_u;
-            pub static L_tmpnam : uint = 1024_u;
-            pub static TMP_MAX : uint = 308915776_u;
+            use libc::types::os::arch::c95::{c_int, c_uint};
+
+            pub static EXIT_FAILURE : c_int = 1;
+            pub static EXIT_SUCCESS : c_int = 0;
+            pub static RAND_MAX : c_int = 2147483647;
+            pub static EOF : c_int = -1;
+            pub static SEEK_SET : c_int = 0;
+            pub static SEEK_CUR : c_int = 1;
+            pub static SEEK_END : c_int = 2;
+            pub static _IOFBF : c_int = 0;
+            pub static _IONBF : c_int = 2;
+            pub static _IOLBF : c_int = 1;
+            pub static BUFSIZ : c_uint = 1024_u32;
+            pub static FOPEN_MAX : c_uint = 20_u32;
+            pub static FILENAME_MAX : c_uint = 1024_u32;
+            pub static L_tmpnam : c_uint = 1024_u32;
+            pub static TMP_MAX : c_uint = 308915776_u32;
         }
         pub mod c99 {
         }
         pub mod posix88 {
-            pub static O_RDONLY : int = 0;
-            pub static O_WRONLY : int = 1;
-            pub static O_RDWR : int = 2;
-            pub static O_APPEND : int = 8;
-            pub static O_CREAT : int = 512;
-            pub static O_EXCL : int = 2048;
-            pub static O_TRUNC : int = 1024;
-            pub static S_IFIFO : int = 4096;
-            pub static S_IFCHR : int = 8192;
-            pub static S_IFBLK : int = 24576;
-            pub static S_IFDIR : int = 16384;
-            pub static S_IFREG : int = 32768;
-            pub static S_IFMT : int = 61440;
-            pub static S_IEXEC : int = 64;
-            pub static S_IWRITE : int = 128;
-            pub static S_IREAD : int = 256;
-            pub static S_IRWXU : int = 448;
-            pub static S_IXUSR : int = 64;
-            pub static S_IWUSR : int = 128;
-            pub static S_IRUSR : int = 256;
-            pub static F_OK : int = 0;
-            pub static R_OK : int = 4;
-            pub static W_OK : int = 2;
-            pub static X_OK : int = 1;
-            pub static STDIN_FILENO : int = 0;
-            pub static STDOUT_FILENO : int = 1;
-            pub static STDERR_FILENO : int = 2;
-            pub static F_LOCK : int = 1;
-            pub static F_TEST : int = 3;
-            pub static F_TLOCK : int = 2;
-            pub static F_ULOCK : int = 0;
-            pub static SIGHUP : int = 1;
-            pub static SIGINT : int = 2;
-            pub static SIGQUIT : int = 3;
-            pub static SIGILL : int = 4;
-            pub static SIGABRT : int = 6;
-            pub static SIGFPE : int = 8;
-            pub static SIGKILL : int = 9;
-            pub static SIGSEGV : int = 11;
-            pub static SIGPIPE : int = 13;
-            pub static SIGALRM : int = 14;
-            pub static SIGTERM : int = 15;
+            use libc::types::common::c95::c_void;
+            use libc::types::os::arch::c95::c_int;
+
+            pub static O_RDONLY : c_int = 0;
+            pub static O_WRONLY : c_int = 1;
+            pub static O_RDWR : c_int = 2;
+            pub static O_APPEND : c_int = 8;
+            pub static O_CREAT : c_int = 512;
+            pub static O_EXCL : c_int = 2048;
+            pub static O_TRUNC : c_int = 1024;
+            pub static S_IFIFO : c_int = 4096;
+            pub static S_IFCHR : c_int = 8192;
+            pub static S_IFBLK : c_int = 24576;
+            pub static S_IFDIR : c_int = 16384;
+            pub static S_IFREG : c_int = 32768;
+            pub static S_IFMT : c_int = 61440;
+            pub static S_IEXEC : c_int = 64;
+            pub static S_IWRITE : c_int = 128;
+            pub static S_IREAD : c_int = 256;
+            pub static S_IRWXU : c_int = 448;
+            pub static S_IXUSR : c_int = 64;
+            pub static S_IWUSR : c_int = 128;
+            pub static S_IRUSR : c_int = 256;
+            pub static F_OK : c_int = 0;
+            pub static R_OK : c_int = 4;
+            pub static W_OK : c_int = 2;
+            pub static X_OK : c_int = 1;
+            pub static STDIN_FILENO : c_int = 0;
+            pub static STDOUT_FILENO : c_int = 1;
+            pub static STDERR_FILENO : c_int = 2;
+            pub static F_LOCK : c_int = 1;
+            pub static F_TEST : c_int = 3;
+            pub static F_TLOCK : c_int = 2;
+            pub static F_ULOCK : c_int = 0;
+            pub static SIGHUP : c_int = 1;
+            pub static SIGINT : c_int = 2;
+            pub static SIGQUIT : c_int = 3;
+            pub static SIGILL : c_int = 4;
+            pub static SIGABRT : c_int = 6;
+            pub static SIGFPE : c_int = 8;
+            pub static SIGKILL : c_int = 9;
+            pub static SIGSEGV : c_int = 11;
+            pub static SIGPIPE : c_int = 13;
+            pub static SIGALRM : c_int = 14;
+            pub static SIGTERM : c_int = 15;
+
+            pub static PROT_NONE : c_int = 0;
+            pub static PROT_READ : c_int = 1;
+            pub static PROT_WRITE : c_int = 2;
+            pub static PROT_EXEC : c_int = 4;
+
+            pub static MAP_FILE : c_int = 0x0000;
+            pub static MAP_SHARED : c_int = 0x0001;
+            pub static MAP_PRIVATE : c_int = 0x0002;
+            pub static MAP_FIXED : c_int = 0x0010;
+            pub static MAP_ANON : c_int = 0x1000;
+
+            pub static MAP_FAILED : *c_void = -1 as *c_void;
+
+            pub static MCL_CURRENT : c_int = 0x0001;
+            pub static MCL_FUTURE : c_int = 0x0002;
+
+            pub static MS_ASYNC : c_int = 0x0001;
+            pub static MS_INVALIDATE : c_int = 0x0002;
+            pub static MS_SYNC : c_int = 0x0010;
+
+            pub static MS_KILLPAGES : c_int = 0x0004;
+            pub static MS_DEACTIVATE : c_int = 0x0008;
+
+            pub static _SC_ARG_MAX : c_int = 1;
+            pub static _SC_CHILD_MAX : c_int = 2;
+            pub static _SC_CLK_TCK : c_int = 3;
+            pub static _SC_NGROUPS_MAX : c_int = 4;
+            pub static _SC_OPEN_MAX : c_int = 5;
+            pub static _SC_JOB_CONTROL : c_int = 6;
+            pub static _SC_SAVED_IDS : c_int = 7;
+            pub static _SC_VERSION : c_int = 8;
+            pub static _SC_BC_BASE_MAX : c_int = 9;
+            pub static _SC_BC_DIM_MAX : c_int = 10;
+            pub static _SC_BC_SCALE_MAX : c_int = 11;
+            pub static _SC_BC_STRING_MAX : c_int = 12;
+            pub static _SC_COLL_WEIGHTS_MAX : c_int = 13;
+            pub static _SC_EXPR_NEST_MAX : c_int = 14;
+            pub static _SC_LINE_MAX : c_int = 15;
+            pub static _SC_RE_DUP_MAX : c_int = 16;
+            pub static _SC_2_VERSION : c_int = 17;
+            pub static _SC_2_C_BIND : c_int = 18;
+            pub static _SC_2_C_DEV : c_int = 19;
+            pub static _SC_2_CHAR_TERM : c_int = 20;
+            pub static _SC_2_FORT_DEV : c_int = 21;
+            pub static _SC_2_FORT_RUN : c_int = 22;
+            pub static _SC_2_LOCALEDEF : c_int = 23;
+            pub static _SC_2_SW_DEV : c_int = 24;
+            pub static _SC_2_UPE : c_int = 25;
+            pub static _SC_STREAM_MAX : c_int = 26;
+            pub static _SC_TZNAME_MAX : c_int = 27;
+            pub static _SC_ASYNCHRONOUS_IO : c_int = 28;
+            pub static _SC_PAGESIZE : c_int = 29;
+            pub static _SC_MEMLOCK : c_int = 30;
+            pub static _SC_MEMLOCK_RANGE : c_int = 31;
+            pub static _SC_MEMORY_PROTECTION : c_int = 32;
+            pub static _SC_MESSAGE_PASSING : c_int = 33;
+            pub static _SC_PRIORITIZED_IO : c_int = 34;
+            pub static _SC_PRIORITY_SCHEDULING : c_int = 35;
+            pub static _SC_REALTIME_SIGNALS : c_int = 36;
+            pub static _SC_SEMAPHORES : c_int = 37;
+            pub static _SC_FSYNC : c_int = 38;
+            pub static _SC_SHARED_MEMORY_OBJECTS : c_int = 39;
+            pub static _SC_SYNCHRONIZED_IO : c_int = 40;
+            pub static _SC_TIMERS : c_int = 41;
+            pub static _SC_AIO_LISTIO_MAX : c_int = 42;
+            pub static _SC_AIO_MAX : c_int = 43;
+            pub static _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
+            pub static _SC_DELAYTIMER_MAX : c_int = 45;
+            pub static _SC_MQ_OPEN_MAX : c_int = 46;
+            pub static _SC_MAPPED_FILES : c_int = 47;
+            pub static _SC_RTSIG_MAX : c_int = 48;
+            pub static _SC_SEM_NSEMS_MAX : c_int = 49;
+            pub static _SC_SEM_VALUE_MAX : c_int = 50;
+            pub static _SC_SIGQUEUE_MAX : c_int = 51;
+            pub static _SC_TIMER_MAX : c_int = 52;
+            pub static _SC_XBS5_ILP32_OFF32 : c_int = 122;
+            pub static _SC_XBS5_ILP32_OFFBIG : c_int = 123;
+            pub static _SC_XBS5_LP64_OFF64 : c_int = 124;
+            pub static _SC_XBS5_LPBIG_OFFBIG : c_int = 125;
         }
         pub mod posix01 {
-            pub static SIGTRAP : int = 5;
-
-            pub static GLOB_APPEND   : int = 0x0001;
-            pub static GLOB_DOOFFS   : int = 0x0002;
-            pub static GLOB_ERR      : int = 0x0004;
-            pub static GLOB_MARK     : int = 0x0008;
-            pub static GLOB_NOCHECK  : int = 0x0010;
-            pub static GLOB_NOSORT   : int = 0x0020;
-            pub static GLOB_NOESCAPE : int = 0x2000;
-
-            pub static GLOB_NOSPACE  : int = -1;
-            pub static GLOB_ABORTED  : int = -2;
-            pub static GLOB_NOMATCH  : int = -3;
+            use libc::types::os::arch::c95::c_int;
+
+            pub static SIGTRAP : c_int = 5;
+
+            pub static GLOB_APPEND   : c_int = 0x0001;
+            pub static GLOB_DOOFFS   : c_int = 0x0002;
+            pub static GLOB_ERR      : c_int = 0x0004;
+            pub static GLOB_MARK     : c_int = 0x0008;
+            pub static GLOB_NOCHECK  : c_int = 0x0010;
+            pub static GLOB_NOSORT   : c_int = 0x0020;
+            pub static GLOB_NOESCAPE : c_int = 0x2000;
+
+            pub static GLOB_NOSPACE  : c_int = -1;
+            pub static GLOB_ABORTED  : c_int = -2;
+            pub static GLOB_NOMATCH  : c_int = -3;
+
+            pub static POSIX_MADV_NORMAL : c_int = 0;
+            pub static POSIX_MADV_RANDOM : c_int = 1;
+            pub static POSIX_MADV_SEQUENTIAL : c_int = 2;
+            pub static POSIX_MADV_WILLNEED : c_int = 3;
+            pub static POSIX_MADV_DONTNEED : c_int = 4;
+
+            pub static _SC_IOV_MAX : c_int = 56;
+            pub static _SC_GETGR_R_SIZE_MAX : c_int = 70;
+            pub static _SC_GETPW_R_SIZE_MAX : c_int = 71;
+            pub static _SC_LOGIN_NAME_MAX : c_int = 73;
+            pub static _SC_MQ_PRIO_MAX : c_int = 75;
+            pub static _SC_THREAD_ATTR_STACKADDR : c_int = 82;
+            pub static _SC_THREAD_ATTR_STACKSIZE : c_int = 83;
+            pub static _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85;
+            pub static _SC_THREAD_KEYS_MAX : c_int = 86;
+            pub static _SC_THREAD_PRIO_INHERIT : c_int = 87;
+            pub static _SC_THREAD_PRIO_PROTECT : c_int = 88;
+            pub static _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89;
+            pub static _SC_THREAD_PROCESS_SHARED : c_int = 90;
+            pub static _SC_THREAD_SAFE_FUNCTIONS : c_int = 91;
+            pub static _SC_THREAD_STACK_MIN : c_int = 93;
+            pub static _SC_THREAD_THREADS_MAX : c_int = 94;
+            pub static _SC_THREADS : c_int = 96;
+            pub static _SC_TTY_NAME_MAX : c_int = 101;
+            pub static _SC_ATEXIT_MAX : c_int = 107;
+            pub static _SC_XOPEN_CRYPT : c_int = 108;
+            pub static _SC_XOPEN_ENH_I18N : c_int = 109;
+            pub static _SC_XOPEN_LEGACY : c_int = 110;
+            pub static _SC_XOPEN_REALTIME : c_int = 111;
+            pub static _SC_XOPEN_REALTIME_THREADS : c_int = 112;
+            pub static _SC_XOPEN_SHM : c_int = 113;
+            pub static _SC_XOPEN_UNIX : c_int = 115;
+            pub static _SC_XOPEN_VERSION : c_int = 116;
+            pub static _SC_XOPEN_XCU_VERSION : c_int = 121;
         }
         pub mod posix08 {
         }
         pub mod bsd44 {
+            use libc::types::os::arch::c95::c_int;
+
+            pub static MADV_NORMAL : c_int = 0;
+            pub static MADV_RANDOM : c_int = 1;
+            pub static MADV_SEQUENTIAL : c_int = 2;
+            pub static MADV_WILLNEED : c_int = 3;
+            pub static MADV_DONTNEED : c_int = 4;
+            pub static MADV_FREE : c_int = 5;
+            pub static MADV_ZERO_WIRED_PAGES : c_int = 6;
+            pub static MADV_FREE_REUSABLE : c_int = 7;
+            pub static MADV_FREE_REUSE : c_int = 8;
+            pub static MADV_CAN_REUSE : c_int = 9;
+
+            pub static MINCORE_INCORE : c_int =  0x1;
+            pub static MINCORE_REFERENCED : c_int = 0x2;
+            pub static MINCORE_MODIFIED : c_int = 0x4;
+            pub static MINCORE_REFERENCED_OTHER : c_int = 0x8;
+            pub static MINCORE_MODIFIED_OTHER : c_int = 0x10;
         }
         pub mod extra {
-            pub static O_DSYNC : int = 4194304;
-            pub static O_SYNC : int = 128;
-            pub static F_FULLFSYNC : int = 51;
+            use libc::types::os::arch::c95::c_int;
+
+            pub static O_DSYNC : c_int = 4194304;
+            pub static O_SYNC : c_int = 128;
+            pub static F_FULLFSYNC : c_int = 51;
+
+            pub static MAP_COPY : c_int = 0x0002;
+            pub static MAP_RENAME : c_int = 0x0020;
+            pub static MAP_NORESERVE : c_int = 0x0040;
+            pub static MAP_NOEXTEND : c_int = 0x0100;
+            pub static MAP_HASSEMAPHORE : c_int = 0x0200;
+            pub static MAP_NOCACHE : c_int = 0x0400;
+            pub static MAP_JIT : c_int = 0x0800;
         }
     }
 }
@@ -1658,6 +2149,9 @@ pub mod funcs {
                              -> c_int;
             }
         }
+
+        pub mod mman {
+        }
     }
 
 
@@ -1835,6 +2329,38 @@ pub mod funcs {
                 unsafe fn kill(pid: pid_t, sig: c_int) -> c_int;
             }
         }
+
+        #[nolink]
+        #[abi = "cdecl"]
+        pub mod mman {
+            use libc::types::common::c95::{c_void};
+            use libc::types::os::arch::c95::{size_t, c_int, c_char};
+            use libc::types::os::arch::posix88::{mode_t, off_t};
+
+            pub extern {
+                unsafe fn mlock(addr: *c_void, len: size_t) -> c_int;
+                unsafe fn munlock(addr: *c_void, len: size_t) -> c_int;
+                unsafe fn mlockall(flags: c_int) -> c_int;
+                unsafe fn munlockall() -> c_int;
+
+                unsafe fn mmap(addr: *c_void,
+                               len: size_t,
+                               prot: c_int,
+                               flags: c_int,
+                               fd: c_int,
+                               offset: off_t) -> *mut c_void;
+                unsafe fn munmap(addr: *c_void, len: size_t) -> c_int;
+
+                unsafe fn mprotect(addr: *c_void, len: size_t, prot: c_int)
+                    -> c_int;
+
+                unsafe fn msync(addr: *c_void, len: size_t, flags: c_int)
+                    -> c_int;
+                unsafe fn shm_open(name: *c_char, oflag: c_int, mode: mode_t)
+                    -> c_int;
+                unsafe fn shm_unlink(name: *c_char) -> c_int;
+            }
+        }
     }
 
     #[cfg(target_os = "linux")]
@@ -1913,6 +2439,19 @@ pub mod funcs {
                 unsafe fn globfree(pglob: *mut glob_t);
             }
         }
+
+        #[nolink]
+        #[abi = "cdecl"]
+        pub mod mman {
+            use libc::types::common::c95::{c_void};
+            use libc::types::os::arch::c95::{c_int, size_t};
+
+            pub extern {
+                unsafe fn posix_madvise(addr: *c_void,
+                                        len: size_t,
+                                        advice: c_int) -> c_int;
+            }
+        }
     }
 
     #[cfg(target_os = "win32")]
@@ -1925,6 +2464,9 @@ pub mod funcs {
 
         pub mod glob {
         }
+
+        pub mod mman {
+        }
     }
 
 
@@ -1943,7 +2485,8 @@ pub mod funcs {
     #[cfg(target_os = "freebsd")]
     pub mod bsd44 {
         use libc::types::common::c95::{c_void};
-        use libc::types::os::arch::c95::{c_char, c_int, c_uint, size_t};
+        use libc::types::os::arch::c95::{c_char, c_uchar, c_int, c_uint,
+                                         size_t};
 
         #[abi = "cdecl"]
         pub extern {
@@ -1959,6 +2502,12 @@ pub mod funcs {
                                sizep: *mut size_t) -> c_int;
 
             unsafe fn getdtablesize() -> c_int;
+
+            unsafe fn madvise(addr: *c_void, len: size_t, advice: c_int)
+                -> c_int;
+
+            unsafe fn mincore(addr: *c_void, len: size_t, vec: *c_uchar)
+                -> c_int;
         }
     }
 
@@ -1966,11 +2515,18 @@ pub mod funcs {
     #[cfg(target_os = "linux")]
     #[cfg(target_os = "android")]
     pub mod bsd44 {
-        use libc::types::os::arch::c95::{c_int};
+        use libc::types::common::c95::{c_void};
+        use libc::types::os::arch::c95::{c_uchar, c_int, size_t};
 
         #[abi = "cdecl"]
         pub extern {
             unsafe fn getdtablesize() -> c_int;
+
+            unsafe fn madvise(addr: *c_void, len: size_t, advice: c_int)
+                -> c_int;
+
+            unsafe fn mincore(addr: *c_void, len: size_t, vec: *c_uchar)
+                -> c_int;
         }
     }
 
diff --git a/src/libstd/managed.rs b/src/libstd/managed.rs
index d514612b5af..b71b3b503c2 100644
--- a/src/libstd/managed.rs
+++ b/src/libstd/managed.rs
@@ -15,7 +15,7 @@ use ptr::to_unsafe_ptr;
 #[cfg(not(test))] use cmp::{Eq, Ord};
 
 pub mod raw {
-    use intrinsic::TyDesc;
+    use std::unstable::intrinsics::TyDesc;
 
     pub static RC_EXCHANGE_UNIQUE : uint = (-1) as uint;
     pub static RC_MANAGED_UNIQUE : uint = (-2) as uint;
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index de87f967d28..84fdc1c46d1 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -758,7 +758,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
                     FindFirstFileW(
                         path_ptr,
                         ::cast::transmute(wfd_ptr));
-                if find_handle as int != INVALID_HANDLE_VALUE {
+                if find_handle as libc::c_int != INVALID_HANDLE_VALUE {
                     let mut more_files = 1 as libc::c_int;
                     while more_files != 0 {
                         let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr);
diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs
index d276abf0c8b..16ab4771d0d 100644
--- a/src/libstd/reflect.rs
+++ b/src/libstd/reflect.rs
@@ -16,8 +16,10 @@ Runtime type reflection
 
 #[allow(missing_doc)];
 
-use intrinsic::{TyDesc, TyVisitor};
-use intrinsic::Opaque;
+#[cfg(stage0)]
+use intrinsic::{Opaque, TyDesc, TyVisitor};
+#[cfg(not(stage0))]
+use unstable::intrinsics::{Opaque, TyDesc, TyVisitor};
 use libc::c_void;
 use sys;
 use vec;
diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs
index ab3f83d34d5..f39b5a00ed0 100644
--- a/src/libstd/repr.rs
+++ b/src/libstd/repr.rs
@@ -19,9 +19,6 @@ More runtime type reflection
 use cast::transmute;
 use char;
 use container::Container;
-use intrinsic;
-use intrinsic::{TyDesc, TyVisitor, visit_tydesc};
-use intrinsic::Opaque;
 use io::{Writer, WriterUtil};
 use iterator::IteratorUtil;
 use libc::c_void;
@@ -34,6 +31,10 @@ use to_str::ToStr;
 use vec::raw::{VecRepr, SliceRepr};
 use vec;
 use vec::{OwnedVector, UnboxedVecRepr};
+#[cfg(stage0)]
+use intrinsic::{Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc};
+#[cfg(not(stage0))]
+use unstable::intrinsics::{Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc};
 
 #[cfg(test)] use io;
 
@@ -564,6 +565,7 @@ impl TyVisitor for ReprVisitor {
     fn visit_self(&self) -> bool { true }
     fn visit_type(&self) -> bool { true }
 
+    #[cfg(not(stage0))]
     fn visit_opaque_box(&self) -> bool {
         self.writer.write_char('@');
         do self.get::<&managed::raw::BoxRepr> |b| {
@@ -571,6 +573,16 @@ impl TyVisitor for ReprVisitor {
             self.visit_ptr_inner(p, b.header.type_desc);
         }
     }
+    #[cfg(stage0)]
+    fn visit_opaque_box(&self) -> bool {
+        self.writer.write_char('@');
+        do self.get::<&managed::raw::BoxRepr> |b| {
+            let p = ptr::to_unsafe_ptr(&b.data) as *c_void;
+            unsafe {
+                self.visit_ptr_inner(p, transmute(b.header.type_desc));
+            }
+        }
+    }
 
     // Type no longer exists, vestigial function.
     fn visit_constr(&self, _inner: *TyDesc) -> bool { fail!(); }
@@ -581,7 +593,7 @@ impl TyVisitor for ReprVisitor {
 pub fn write_repr<T>(writer: @Writer, object: &T) {
     unsafe {
         let ptr = ptr::to_unsafe_ptr(object) as *c_void;
-        let tydesc = intrinsic::get_tydesc::<T>();
+        let tydesc = get_tydesc::<T>();
         let u = ReprVisitor(ptr, writer);
         let v = reflect::MovePtrAdaptor(u);
         visit_tydesc(tydesc, @v as @TyVisitor)
diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs
index ce7ff87b445..1e9f9aab834 100644
--- a/src/libstd/rt/global_heap.rs
+++ b/src/libstd/rt/global_heap.rs
@@ -8,26 +8,22 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use sys::{TypeDesc, size_of};
+use sys::{size_of};
 use libc::{c_void, size_t, uintptr_t};
 use c_malloc = libc::malloc;
 use c_free = libc::free;
 use managed::raw::{BoxHeaderRepr, BoxRepr};
 use cast::transmute;
-use unstable::intrinsics::{atomic_xadd,atomic_xsub};
+use unstable::intrinsics::{atomic_xadd,atomic_xsub,TyDesc};
 use ptr::null;
-use intrinsic::TyDesc;
 
-pub unsafe fn malloc(td: *TypeDesc, size: uint) -> *c_void {
+pub unsafe fn malloc(td: *TyDesc, size: uint) -> *c_void {
     assert!(td.is_not_null());
 
     let total_size = get_box_size(size, (*td).align);
     let p = c_malloc(total_size as size_t);
     assert!(p.is_not_null());
 
-    // FIXME #3475: Converting between our two different tydesc types
-    let td: *TyDesc = transmute(td);
-
     let box: &mut BoxRepr = transmute(p);
     box.header.ref_count = -1; // Exchange values not ref counted
     box.header.type_desc = td;
diff --git a/src/libstd/core.rc b/src/libstd/std.rs
index 13c54799fac..13c54799fac 100644
--- a/src/libstd/core.rc
+++ b/src/libstd/std.rs
diff --git a/src/libstd/sys.rs b/src/libstd/sys.rs
index 79ea60cc224..a1d6342323c 100644
--- a/src/libstd/sys.rs
+++ b/src/libstd/sys.rs
@@ -17,23 +17,11 @@ use cast;
 use gc;
 use io;
 use libc;
-use libc::{c_void, c_char, size_t};
+use libc::{c_char, size_t};
 use repr;
 use str;
 use unstable::intrinsics;
 
-pub type FreeGlue<'self> = &'self fn(*TypeDesc, *c_void);
-
-// Corresponds to runtime type_desc type
-pub struct TypeDesc {
-    size: uint,
-    align: uint,
-    take_glue: uint,
-    drop_glue: uint,
-    free_glue: uint
-    // Remaining fields not listed
-}
-
 /// The representation of a Rust closure
 pub struct Closure {
     code: *(),
@@ -51,23 +39,6 @@ pub mod rustrt {
     }
 }
 
-/**
- * Returns a pointer to a type descriptor.
- *
- * Useful for calling certain function in the Rust runtime or otherwise
- * performing dark magick.
- */
-#[inline]
-pub fn get_type_desc<T>() -> *TypeDesc {
-    unsafe { intrinsics::get_tydesc::<T>() as *TypeDesc }
-}
-
-/// Returns a pointer to a type descriptor.
-#[inline]
-pub fn get_type_desc_val<T>(_val: &T) -> *TypeDesc {
-    get_type_desc::<T>()
-}
-
 /// Returns the size of a type
 #[inline]
 pub fn size_of<T>() -> uint {
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index 77053f39677..04c0dd79ded 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -111,7 +111,7 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) {
     assert!(was_present);
 }
 pub fn taskset_each(tasks: &TaskSet, blk: &fn(v: *rust_task) -> bool) -> bool {
-    tasks.each(|k| blk(*k))
+    tasks.iter().advance(|k| blk(*k))
 }
 
 // One of these per group of linked-failure tasks.
diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs
index 9f812288621..4d5bc0f8842 100644
--- a/src/libstd/to_str.rs
+++ b/src/libstd/to_str.rs
@@ -18,11 +18,9 @@ use str::OwnedStr;
 use hashmap::HashMap;
 use hashmap::HashSet;
 use iterator::IteratorUtil;
-use container::Map;
 use hash::Hash;
 use cmp::Eq;
 use vec::ImmutableVector;
-use iterator::IteratorUtil;
 
 /// A generic trait for converting a value to a string
 pub trait ToStr {
@@ -179,7 +177,7 @@ impl<A:ToStr> ToStr for @[A] {
 mod tests {
     use hashmap::HashMap;
     use hashmap::HashSet;
-    use container::Set;
+    use container::{Set,Map};
     #[test]
     fn test_simple_types() {
         assert_eq!(1i.to_str(), ~"1");
diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs
index e6449ef4922..8f70c75439a 100644
--- a/src/libstd/trie.rs
+++ b/src/libstd/trie.rs
@@ -58,30 +58,6 @@ impl<T> Map<uint, T> for TrieMap<T> {
         self.find(key).is_some()
     }
 
-    /// Visit all key-value pairs in order
-    #[inline]
-    fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
-        self.root.each(f)
-    }
-
-    /// Visit all keys in order
-    #[inline]
-    fn each_key(&self, f: &fn(&uint) -> bool) -> bool {
-        self.each(|k, _| f(k))
-    }
-
-    /// Visit all values in order
-    #[inline]
-    fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) -> bool {
-        self.each(|_, v| f(v))
-    }
-
-    /// Iterate over the map and mutate the contained values
-    #[inline]
-    fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) -> bool {
-        self.root.mutate_values(f)
-    }
-
     /// Return a reference to the value corresponding to the key
     #[inline]
     fn find<'a>(&'a self, key: &uint) -> Option<&'a T> {
@@ -158,6 +134,30 @@ impl<T> TrieMap<T> {
         self.root.each_reverse(f)
     }
 
+    /// Visit all key-value pairs in order
+    #[inline]
+    pub fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
+        self.root.each(f)
+    }
+
+    /// Visit all keys in order
+    #[inline]
+    pub fn each_key(&self, f: &fn(&uint) -> bool) -> bool {
+        self.each(|k, _| f(k))
+    }
+
+    /// Visit all values in order
+    #[inline]
+    pub fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) -> bool {
+        self.each(|_, v| f(v))
+    }
+
+    /// Iterate over the map and mutate the contained values
+    #[inline]
+    pub fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) -> bool {
+        self.root.mutate_values(f)
+    }
+
     /// Visit all keys in reverse order
     #[inline]
     pub fn each_key_reverse(&self, f: &fn(&uint) -> bool) -> bool {
diff --git a/src/libstd/unstable/atomics.rs b/src/libstd/unstable/atomics.rs
index 6e7a7e2b129..7a3a5f51d35 100644
--- a/src/libstd/unstable/atomics.rs
+++ b/src/libstd/unstable/atomics.rs
@@ -62,6 +62,7 @@ pub struct AtomicPtr<T> {
 /**
  * An owned atomic pointer. Ensures that only a single reference to the data is held at any time.
  */
+#[no_drop_flag]
 pub struct AtomicOption<T> {
     priv p: *mut c_void
 }
diff --git a/src/libstd/unstable/exchange_alloc.rs b/src/libstd/unstable/exchange_alloc.rs
index 3b35c2fb804..5c47901df48 100644
--- a/src/libstd/unstable/exchange_alloc.rs
+++ b/src/libstd/unstable/exchange_alloc.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use sys::{TypeDesc, size_of};
+use sys::size_of;
 use libc::{c_void, size_t};
 use c_malloc = libc::malloc;
 use c_free = libc::free;
@@ -16,18 +16,18 @@ use managed::raw::{BoxHeaderRepr, BoxRepr};
 use cast::transmute;
 use unstable::intrinsics::{atomic_xadd,atomic_xsub};
 use ptr::null;
+#[cfg(stage0)]
 use intrinsic::TyDesc;
+#[cfg(not(stage0))]
+use unstable::intrinsics::TyDesc;
 
-pub unsafe fn malloc(td: *TypeDesc, size: uint) -> *c_void {
+pub unsafe fn malloc(td: *TyDesc, size: uint) -> *c_void {
     assert!(td.is_not_null());
 
     let total_size = get_box_size(size, (*td).align);
     let p = c_malloc(total_size as size_t);
     assert!(p.is_not_null());
 
-    // FIXME #3475: Converting between our two different tydesc types
-    let td: *TyDesc = transmute(td);
-
     let box: &mut BoxRepr = transmute(p);
     box.header.ref_count = -1; // Exchange values not ref counted
     box.header.type_desc = td;
diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs
index c38b013a75a..1254a591293 100644
--- a/src/libstd/unstable/intrinsics.rs
+++ b/src/libstd/unstable/intrinsics.rs
@@ -32,6 +32,130 @@ A quick refresher on memory ordering:
 
 */
 
+// This is needed to prevent duplicate lang item definitions.
+#[cfg(test)]
+pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor};
+
+#[cfg(not(stage0))]
+pub type GlueFn = extern "Rust" fn(*i8);
+
+#[cfg(stage0)]
+pub type GlueFn = extern "Rust" fn(**TyDesc, *i8);
+
+// NB: this has to be kept in sync with the Rust ABI.
+#[lang="ty_desc"]
+#[cfg(not(test))]
+pub struct TyDesc {
+    size: uint,
+    align: uint,
+    take_glue: GlueFn,
+    drop_glue: GlueFn,
+    free_glue: GlueFn,
+    visit_glue: GlueFn,
+}
+
+#[lang="opaque"]
+#[cfg(not(test))]
+pub enum Opaque { }
+
+#[lang="ty_visitor"]
+#[cfg(not(test))]
+pub trait TyVisitor {
+    fn visit_bot(&self) -> bool;
+    fn visit_nil(&self) -> bool;
+    fn visit_bool(&self) -> bool;
+
+    fn visit_int(&self) -> bool;
+    fn visit_i8(&self) -> bool;
+    fn visit_i16(&self) -> bool;
+    fn visit_i32(&self) -> bool;
+    fn visit_i64(&self) -> bool;
+
+    fn visit_uint(&self) -> bool;
+    fn visit_u8(&self) -> bool;
+    fn visit_u16(&self) -> bool;
+    fn visit_u32(&self) -> bool;
+    fn visit_u64(&self) -> bool;
+
+    fn visit_float(&self) -> bool;
+    fn visit_f32(&self) -> bool;
+    fn visit_f64(&self) -> bool;
+
+    fn visit_char(&self) -> bool;
+    fn visit_str(&self) -> bool;
+
+    fn visit_estr_box(&self) -> bool;
+    fn visit_estr_uniq(&self) -> bool;
+    fn visit_estr_slice(&self) -> bool;
+    fn visit_estr_fixed(&self, n: uint, sz: uint, align: uint) -> bool;
+
+    fn visit_box(&self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_ptr(&self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_rptr(&self, mtbl: uint, inner: *TyDesc) -> bool;
+
+    fn visit_vec(&self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_unboxed_vec(&self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_evec_box(&self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_evec_uniq(&self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_evec_slice(&self, mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_evec_fixed(&self, n: uint, sz: uint, align: uint,
+                        mtbl: uint, inner: *TyDesc) -> bool;
+
+    fn visit_enter_rec(&self, n_fields: uint,
+                       sz: uint, align: uint) -> bool;
+    fn visit_rec_field(&self, i: uint, name: &str,
+                       mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_leave_rec(&self, n_fields: uint,
+                       sz: uint, align: uint) -> bool;
+
+    fn visit_enter_class(&self, n_fields: uint,
+                         sz: uint, align: uint) -> bool;
+    fn visit_class_field(&self, i: uint, name: &str,
+                         mtbl: uint, inner: *TyDesc) -> bool;
+    fn visit_leave_class(&self, n_fields: uint,
+                         sz: uint, align: uint) -> bool;
+
+    fn visit_enter_tup(&self, n_fields: uint,
+                       sz: uint, align: uint) -> bool;
+    fn visit_tup_field(&self, i: uint, inner: *TyDesc) -> bool;
+    fn visit_leave_tup(&self, n_fields: uint,
+                       sz: uint, align: uint) -> bool;
+
+    fn visit_enter_enum(&self, n_variants: uint,
+                        get_disr: extern unsafe fn(ptr: *Opaque) -> int,
+                        sz: uint, align: uint) -> bool;
+    fn visit_enter_enum_variant(&self, variant: uint,
+                                disr_val: int,
+                                n_fields: uint,
+                                name: &str) -> bool;
+    fn visit_enum_variant_field(&self, i: uint, offset: uint, inner: *TyDesc) -> bool;
+    fn visit_leave_enum_variant(&self, variant: uint,
+                                disr_val: int,
+                                n_fields: uint,
+                                name: &str) -> bool;
+    fn visit_leave_enum(&self, n_variants: uint,
+                        get_disr: extern unsafe fn(ptr: *Opaque) -> int,
+                        sz: uint, align: uint) -> bool;
+
+    fn visit_enter_fn(&self, purity: uint, proto: uint,
+                      n_inputs: uint, retstyle: uint) -> bool;
+    fn visit_fn_input(&self, i: uint, mode: uint, inner: *TyDesc) -> bool;
+    fn visit_fn_output(&self, retstyle: uint, inner: *TyDesc) -> bool;
+    fn visit_leave_fn(&self, purity: uint, proto: uint,
+                      n_inputs: uint, retstyle: uint) -> bool;
+
+    fn visit_trait(&self) -> bool;
+    fn visit_var(&self) -> bool;
+    fn visit_var_integral(&self) -> bool;
+    fn visit_param(&self, i: uint) -> bool;
+    fn visit_self(&self) -> bool;
+    fn visit_type(&self) -> bool;
+    fn visit_opaque_box(&self) -> bool;
+    fn visit_constr(&self, inner: *TyDesc) -> bool;
+    fn visit_closure_ptr(&self, ck: uint) -> bool;
+}
+
 #[abi = "rust-intrinsic"]
 pub extern "rust-intrinsic" {
 
@@ -42,9 +166,7 @@ pub extern "rust-intrinsic" {
     /// Atomic compare and exchange, release ordering.
     pub fn atomic_cxchg_rel(dst: &mut int, old: int, src: int) -> int;
 
-    #[cfg(not(stage0))]
     pub fn atomic_cxchg_acqrel(dst: &mut int, old: int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_cxchg_relaxed(dst: &mut int, old: int, src: int) -> int;
 
 
@@ -53,7 +175,6 @@ pub extern "rust-intrinsic" {
     /// Atomic load, acquire ordering.
     pub fn atomic_load_acq(src: &int) -> int;
 
-    #[cfg(not(stage0))]
     pub fn atomic_load_relaxed(src: &int) -> int;
 
     /// Atomic store, sequentially consistent.
@@ -61,7 +182,6 @@ pub extern "rust-intrinsic" {
     /// Atomic store, release ordering.
     pub fn atomic_store_rel(dst: &mut int, val: int);
 
-    #[cfg(not(stage0))]
     pub fn atomic_store_relaxed(dst: &mut int, val: int);
 
     /// Atomic exchange, sequentially consistent.
@@ -70,9 +190,7 @@ pub extern "rust-intrinsic" {
     pub fn atomic_xchg_acq(dst: &mut int, src: int) -> int;
     /// Atomic exchange, release ordering.
     pub fn atomic_xchg_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_xchg_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_xchg_relaxed(dst: &mut int, src: int) -> int;
 
     /// Atomic addition, sequentially consistent.
@@ -81,9 +199,7 @@ pub extern "rust-intrinsic" {
     pub fn atomic_xadd_acq(dst: &mut int, src: int) -> int;
     /// Atomic addition, release ordering.
     pub fn atomic_xadd_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_xadd_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_xadd_relaxed(dst: &mut int, src: int) -> int;
 
     /// Atomic subtraction, sequentially consistent.
@@ -92,97 +208,55 @@ pub extern "rust-intrinsic" {
     pub fn atomic_xsub_acq(dst: &mut int, src: int) -> int;
     /// Atomic subtraction, release ordering.
     pub fn atomic_xsub_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_xsub_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_xsub_relaxed(dst: &mut int, src: int) -> int;
 
-    #[cfg(not(stage0))]
     pub fn atomic_and(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_and_acq(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_and_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_and_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_and_relaxed(dst: &mut int, src: int) -> int;
 
-    #[cfg(not(stage0))]
     pub fn atomic_nand(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_nand_acq(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_nand_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_nand_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_nand_relaxed(dst: &mut int, src: int) -> int;
 
-    #[cfg(not(stage0))]
     pub fn atomic_or(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_or_acq(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_or_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_or_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_or_relaxed(dst: &mut int, src: int) -> int;
 
-    #[cfg(not(stage0))]
     pub fn atomic_xor(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_xor_acq(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_xor_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_xor_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_xor_relaxed(dst: &mut int, src: int) -> int;
 
-    #[cfg(not(stage0))]
     pub fn atomic_max(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_max_acq(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_max_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_max_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_max_relaxed(dst: &mut int, src: int) -> int;
 
-    #[cfg(not(stage0))]
     pub fn atomic_min(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_min_acq(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_min_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_min_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_min_relaxed(dst: &mut int, src: int) -> int;
 
-    #[cfg(not(stage0))]
     pub fn atomic_umin(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_umin_acq(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_umin_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_umin_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_umin_relaxed(dst: &mut int, src: int) -> int;
 
-    #[cfg(not(stage0))]
     pub fn atomic_umax(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_umax_acq(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_umax_rel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_umax_acqrel(dst: &mut int, src: int) -> int;
-    #[cfg(not(stage0))]
     pub fn atomic_umax_relaxed(dst: &mut int, src: int) -> int;
 
     /// The size of a type in bytes.
@@ -209,6 +283,9 @@ pub extern "rust-intrinsic" {
     pub fn pref_align_of<T>() -> uint;
 
     /// Get a static pointer to a type descriptor.
+    #[cfg(not(stage0))]
+    pub fn get_tydesc<T>() -> *TyDesc;
+    #[cfg(stage0)]
     pub fn get_tydesc<T>() -> *();
 
     /// Create a value initialized to zero.
@@ -231,9 +308,8 @@ pub extern "rust-intrinsic" {
     /// Returns `true` if a type requires drop glue.
     pub fn needs_drop<T>() -> bool;
 
-    // XXX: intrinsic uses legacy modes and has reference to TyDesc
-    // and TyVisitor which are in librustc
-    //fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor) -> ();
+    #[cfg(not(stage0))]
+    pub fn visit_tydesc(td: *TyDesc, tv: @TyVisitor);
 
     pub fn frame_address(f: &once fn(*u8));
 
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index 7b7a3020b93..2e18a588fae 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -30,6 +30,10 @@ use sys;
 use sys::size_of;
 use uint;
 use unstable::intrinsics;
+#[cfg(stage0)]
+use intrinsic::{get_tydesc};
+#[cfg(not(stage0))]
+use unstable::intrinsics::{get_tydesc};
 use vec;
 use util;
 
@@ -37,19 +41,22 @@ use util;
 
 pub mod rustrt {
     use libc;
-    use sys;
     use vec::raw;
+    #[cfg(stage0)]
+    use intrinsic::{TyDesc};
+    #[cfg(not(stage0))]
+    use unstable::intrinsics::{TyDesc};
 
     #[abi = "cdecl"]
     pub extern {
         // These names are terrible. reserve_shared applies
         // to ~[] and reserve_shared_actual applies to @[].
         #[fast_ffi]
-        unsafe fn vec_reserve_shared(t: *sys::TypeDesc,
+        unsafe fn vec_reserve_shared(t: *TyDesc,
                                      v: **raw::VecRepr,
                                      n: libc::size_t);
         #[fast_ffi]
-        unsafe fn vec_reserve_shared_actual(t: *sys::TypeDesc,
+        unsafe fn vec_reserve_shared_actual(t: *TyDesc,
                                             v: **raw::VecRepr,
                                             n: libc::size_t);
     }
@@ -78,7 +85,7 @@ pub fn reserve<T>(v: &mut ~[T], n: uint) {
     if capacity(v) < n {
         unsafe {
             let ptr: **raw::VecRepr = cast::transmute(v);
-            let td = sys::get_type_desc::<T>();
+            let td = get_tydesc::<T>();
             if ((**ptr).box_header.ref_count ==
                 managed::raw::RC_MANAGED_UNIQUE) {
                 rustrt::vec_reserve_shared_actual(td, ptr, n as libc::size_t);
@@ -437,7 +444,7 @@ pub fn partitioned<T:Copy>(v: &[T], f: &fn(&T) -> bool) -> (~[T], ~[T]) {
     let mut lefts  = ~[];
     let mut rights = ~[];
 
-    for each(v) |elt| {
+    for v.iter().advance |elt| {
         if f(elt) {
             lefts.push(copy *elt);
         } else {
@@ -843,7 +850,7 @@ pub fn grow_set<T:Copy>(v: &mut ~[T], index: uint, initval: &T, val: T) {
 /// Apply a function to each element of a vector and return the results
 pub fn map<T, U>(v: &[T], f: &fn(t: &T) -> U) -> ~[U] {
     let mut result = with_capacity(v.len());
-    for each(v) |elem| {
+    for v.iter().advance |elem| {
         result.push(f(elem));
     }
     result
@@ -879,7 +886,7 @@ pub fn mapi<T, U>(v: &[T], f: &fn(uint, t: &T) -> U) -> ~[U] {
  */
 pub fn flat_map<T, U>(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] {
     let mut result = ~[];
-    for each(v) |elem| { result.push_all_move(f(elem)); }
+    for v.iter().advance |elem| { result.push_all_move(f(elem)); }
     result
 }
 
@@ -932,7 +939,7 @@ pub fn filter_mapped<T, U: Copy>(
      */
 
     let mut result = ~[];
-    for each(v) |elem| {
+    for v.iter().advance |elem| {
         match f(elem) {
           None => {/* no-op */ }
           Some(result_elem) => { result.push(result_elem); }
@@ -967,7 +974,7 @@ pub fn filter<T>(v: ~[T], f: &fn(t: &T) -> bool) -> ~[T] {
  */
 pub fn filtered<T:Copy>(v: &[T], f: &fn(t: &T) -> bool) -> ~[T] {
     let mut result = ~[];
-    for each(v) |elem| {
+    for v.iter().advance |elem| {
         if f(elem) { result.push(copy *elem); }
     }
     result
@@ -1051,7 +1058,7 @@ impl<'self, T:Copy> VectorVector<T> for &'self [&'self [T]] {
 
 /// Return true if a vector contains an element with the given value
 pub fn contains<T:Eq>(v: &[T], x: &T) -> bool {
-    for each(v) |elt| { if *x == *elt { return true; } }
+    for v.iter().advance |elt| { if *x == *elt { return true; } }
     false
 }
 
@@ -1202,7 +1209,7 @@ pub fn bsearch_elem<T:TotalOrd>(v: &[T], x: &T) -> Option<uint> {
  */
 pub fn unzip_slice<T:Copy,U:Copy>(v: &[(T, U)]) -> (~[T], ~[U]) {
     let mut (ts, us) = (~[], ~[]);
-    for each(v) |p| {
+    for v.iter().advance |p| {
         let (t, u) = copy *p;
         ts.push(t);
         us.push(u);
@@ -1341,69 +1348,6 @@ pub fn reversed<T:Copy>(v: &const [T]) -> ~[T] {
 }
 
 /**
- * Iterates over a vector, yielding each element to a closure.
- *
- * # Arguments
- *
- * * `v` - A vector, to be iterated over
- * * `f` - A closure to do the iterating. Within this closure, return true to
- * * continue iterating, false to break.
- *
- * # Examples
- *
- * ~~~ {.rust}
- * [1,2,3].each(|&i| {
- *     io::println(int::str(i));
- *     true
- * });
- * ~~~
- *
- * ~~~ {.rust}
- * [1,2,3,4,5].each(|&i| {
- *     if i < 4 {
- *         io::println(int::str(i));
- *         true
- *     }
- *     else {
- *         false
- *     }
- * });
- * ~~~
- *
- * You probably will want to use each with a `for`/`do` expression, depending
- * on your iteration needs:
- *
- * ~~~ {.rust}
- * for [1,2,3].each |&i| {
- *     io::println(int::str(i));
- * }
- * ~~~
- */
-#[inline]
-pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool {
-    //            ^^^^
-    // NB---this CANNOT be &const [T]!  The reason
-    // is that you are passing it to `f()` using
-    // an immutable.
-
-    let mut broke = false;
-    do as_imm_buf(v) |p, n| {
-        let mut n = n;
-        let mut p = p;
-        while n > 0u {
-            unsafe {
-                let q = cast::copy_lifetime_vec(v, &*p);
-                if !f(q) { break; }
-                p = ptr::offset(p, 1u);
-            }
-            n -= 1u;
-        }
-        broke = n > 0;
-    }
-    return !broke;
-}
-
-/**
  * Iterate over all permutations of vector `v`.
  *
  * Permutations are produced in lexicographic order with respect to the order
@@ -2446,7 +2390,6 @@ macro_rules! iterator {
             }
 
             #[inline]
-            #[cfg(not(stage0))]
             fn size_hint(&self) -> (Option<uint>, Option<uint>) {
                 let exact = Some(((self.end as uint) - (self.ptr as uint)) / size_of::<$elem>());
                 (exact, exact)
@@ -3064,36 +3007,6 @@ mod tests {
     }
 
     #[test]
-    fn test_each_empty() {
-        for each::<int>([]) |_v| {
-            fail!(); // should never be executed
-        }
-    }
-
-    #[test]
-    fn test_each_nonempty() {
-        let mut i = 0;
-        for each([1, 2, 3]) |v| {
-            i += *v;
-        }
-        assert_eq!(i, 6);
-    }
-
-    #[test]
-    fn test_each_ret_len0() {
-        let a0 : [int, .. 0] = [];
-        assert_eq!(each(a0, |_p| fail!()), true);
-    }
-
-    #[test]
-    fn test_each_ret_len1() {
-        let a1 = [17];
-        assert_eq!(each(a1, |_p| true), true);
-        assert_eq!(each(a1, |_p| false), false);
-    }
-
-
-    #[test]
     fn test_each_permutation() {
         let mut results: ~[~[int]];
 
@@ -3851,21 +3764,6 @@ mod tests {
     #[test]
     #[ignore(windows)]
     #[should_fail]
-    fn test_each_fail() {
-        let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
-        let mut i = 0;
-        do each(v) |_elt| {
-            if i == 2 {
-                fail!()
-            }
-            i += 0;
-            false
-        };
-    }
-
-    #[test]
-    #[ignore(windows)]
-    #[should_fail]
     #[allow(non_implicitly_copyable_typarams)]
     fn test_permute_fail() {
         let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
@@ -3929,7 +3827,6 @@ mod tests {
     }
 
     #[test]
-    #[cfg(not(stage0))]
     fn test_iterator() {
         use iterator::*;
         let xs = [1, 2, 5, 10, 11];