Skip to content

Commit

Permalink
Auto merge of #29289 - DiamondLovesYou:pnacl-std-crates, r=alexcrichton
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Oct 29, 2015
2 parents b4af35f + a7d93c9 commit e8e6892
Show file tree
Hide file tree
Showing 16 changed files with 273 additions and 299 deletions.
29 changes: 28 additions & 1 deletion src/libstd/dynamic_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl DynamicLibrary {
}
}

#[cfg(all(test, not(target_os = "ios")))]
#[cfg(all(test, not(target_os = "ios"), not(target_os = "nacl")))]
mod tests {
use super::*;
use prelude::v1::*;
Expand Down Expand Up @@ -374,3 +374,30 @@ mod dl {
fn SetErrorMode(uMode: libc::c_uint) -> libc::c_uint;
}
}

#[cfg(target_os = "nacl")]
pub mod dl {
use ffi::OsStr;
use ptr;
use result::Result;
use result::Result::Err;
use libc;
use string::String;
use ops::FnOnce;
use option::Option;

pub fn open(_filename: Option<&OsStr>) -> Result<*mut u8, String> {
Err(format!("NaCl + Newlib doesn't impl loading shared objects"))
}

pub fn check_for_errors_in<T, F>(_f: F) -> Result<T, String>
where F: FnOnce() -> T,
{
Err(format!("NaCl doesn't support shared objects"))
}

pub unsafe fn symbol(_handle: *mut u8, _symbol: *const libc::c_char) -> *mut u8 {
ptr::null_mut()
}
pub unsafe fn close(_handle: *mut u8) { }
}
26 changes: 26 additions & 0 deletions src/libstd/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,27 @@ mod os {
pub const EXE_EXTENSION: &'static str = "exe";
}

#[cfg(all(target_os = "nacl", not(target_arch = "le32")))]
mod os {
pub const FAMILY: &'static str = "unix";
pub const OS: &'static str = "nacl";
pub const DLL_PREFIX: &'static str = "lib";
pub const DLL_SUFFIX: &'static str = ".so";
pub const DLL_EXTENSION: &'static str = "so";
pub const EXE_SUFFIX: &'static str = ".nexe";
pub const EXE_EXTENSION: &'static str = "nexe";
}
#[cfg(all(target_os = "nacl", target_arch = "le32"))]
mod os {
pub const FAMILY: &'static str = "unix";
pub const OS: &'static str = "pnacl";
pub const DLL_PREFIX: &'static str = "lib";
pub const DLL_SUFFIX: &'static str = ".pso";
pub const DLL_EXTENSION: &'static str = "pso";
pub const EXE_SUFFIX: &'static str = ".pexe";
pub const EXE_EXTENSION: &'static str = "pexe";
}

#[cfg(target_arch = "x86")]
mod arch {
pub const ARCH: &'static str = "x86";
Expand Down Expand Up @@ -842,6 +863,11 @@ mod arch {
pub const ARCH: &'static str = "powerpc";
}

#[cfg(target_arch = "le32")]
mod arch {
pub const ARCH: &'static str = "le32";
}

#[cfg(test)]
mod tests {
use prelude::v1::*;
Expand Down
269 changes: 30 additions & 239 deletions src/libstd/os/nacl/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,245 +12,36 @@
#![stable(feature = "raw_ext", since = "1.1.0")]

#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type pid_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;

pub use self::arch::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t};

#[cfg(any(target_arch = "x86",
target_arch = "le32",
target_arch = "powerpc",
target_arch = "arm"))]
mod arch {
use super::{dev_t, mode_t};
use os::raw::{c_long, c_short};
use os::unix::raw::{gid_t, uid_t};

#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;

#[repr(C)]
#[derive(Clone)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_dev: dev_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __pad1: c_short,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ino: ino_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mode: mode_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_nlink: nlink_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_uid: uid_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_gid: gid_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_rdev: dev_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __pad2: c_short,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_size: off_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_blksize: blksize_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_blocks: blkcnt_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __unused4: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __unused5: c_long,
}
}

#[cfg(any(target_arch = "mips",
target_arch = "mipsel"))]
mod arch {
use super::{dev_t, mode_t};
use os::raw::c_long;
use os::unix::raw::{gid_t, uid_t};

#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i32;

#[repr(C)]
#[derive(Clone)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_dev: c_ulong,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_pad1: [c_long; 3],
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ino: ino_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mode: mode_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_nlink: nlink_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_uid: uid_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_gid: gid_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_rdev: c_ulong,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_pad2: [c_long; 2],
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_size: off_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_pad3: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_blksize: blksize_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_blocks: blkcnt_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_pad5: [c_long; 14],
}
}

#[cfg(target_arch = "aarch64")]
mod arch {
use super::{dev_t, mode_t};
use os::raw::{c_long, c_int};
use os::unix::raw::{gid_t, uid_t};

#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;

#[repr(C)]
#[derive(Clone)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_dev: dev_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ino: ino_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mode: mode_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_nlink: nlink_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_uid: uid_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_gid: gid_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_rdev: dev_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __pad1: dev_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_size: off_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_blksize: blksize_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __pad2: c_int,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_blocks: blkcnt_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __unused: [c_int; 2],
}
}

#[cfg(target_arch = "x86_64")]
mod arch {
use super::{dev_t, mode_t};
use os::raw::{c_long, c_int};
use os::unix::raw::{gid_t, uid_t};

#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = i64;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64;

#[repr(C)]
#[derive(Clone)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_dev: dev_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ino: ino_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_nlink: nlink_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mode: mode_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_uid: uid_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_gid: gid_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __pad0: c_int,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_rdev: dev_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_size: off_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_blksize: blksize_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_blocks: blkcnt_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_atime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_mtime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub st_ctime_nsec: c_long,
#[stable(feature = "raw_ext", since = "1.1.0")]
pub __unused: [c_long; 3],
}
#[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = i32;
#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i32;

#[repr(C)]
#[derive(Copy, Clone)]
#[stable(feature = "raw_ext", since = "1.1.0")]
pub struct stat {
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_dev: dev_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_ino: ino_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_mode: mode_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_nlink: nlink_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_uid: uid_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_gid: gid_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_rdev: dev_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_size: off_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_blksize: blksize_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_blocks: blkcnt_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_atime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_atime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_mtime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_mtime_nsec: i64,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_ctime: time_t,
#[stable(feature = "raw_ext", since = "1.1.0")] pub st_ctime_nsec: i64,
}
8 changes: 8 additions & 0 deletions src/libstd/rtdeps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ extern {}
#[link(name = "pthread")]
extern {}

// For PNaCl targets, nacl_io is a Pepper wrapper for some IO functions
// missing (ie always error) in Newlib.
#[cfg(all(target_os = "nacl", not(test)))]
#[link(name = "nacl_io", kind = "static")]
#[link(name = "c++", kind = "static")] // for `nacl_io` and EH.
#[link(name = "pthread", kind = "static")]
extern {}

#[cfg(target_os = "macos")]
#[link(name = "System")]
extern {}
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/sys/common/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![cfg_attr(target_os = "nacl", allow(dead_code))]

use env;
use io::prelude::*;
use io;
Expand Down
Loading

0 comments on commit e8e6892

Please sign in to comment.