Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Andrii Zymohliad
2018-03-14 09:55:59 +08:00
9 changed files with 139 additions and 247 deletions
+4
View File
@@ -3,5 +3,9 @@ include_guard = "_FCNTL_H"
trailer = "#include <bits/fcntl.h>"
language = "C"
[defines]
"target_os = linux" = "__linux__"
"target_os = redox" = "__redox__"
[enum]
prefix_with_name = true
+46 -6
View File
@@ -6,15 +6,55 @@ extern crate platform;
use platform::types::*;
pub use sys::*;
#[cfg(target_os = "linux")]
#[path = "linux.rs"]
pub mod sys;
pub const O_RDONLY: c_int = 0x0000;
#[cfg(target_os = "linux")]
pub const O_WRONLY: c_int = 0x0001;
#[cfg(target_os = "linux")]
pub const O_RDWR: c_int = 0x0002;
#[cfg(target_os = "linux")]
pub const O_CREAT: c_int = 0x0040;
#[cfg(target_os = "linux")]
pub const O_TRUNC: c_int = 0x0200;
#[cfg(target_os = "linux")]
pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR;
#[cfg(target_os = "redox")]
#[path = "redox.rs"]
pub mod sys;
pub const O_RDONLY: c_int = 0x0001_0000;
#[cfg(target_os = "redox")]
pub const O_WRONLY: c_int = 0x0002_0000;
#[cfg(target_os = "redox")]
pub const O_RDWR: c_int = 0x0003_0000;
#[cfg(target_os = "redox")]
pub const O_NONBLOCK: c_int = 0x0004_0000;
#[cfg(target_os = "redox")]
pub const O_APPEND: c_int = 0x0008_0000;
#[cfg(target_os = "redox")]
pub const O_SHLOCK: c_int = 0x0010_0000;
#[cfg(target_os = "redox")]
pub const O_EXLOCK: c_int = 0x0020_0000;
#[cfg(target_os = "redox")]
pub const O_ASYNC: c_int = 0x0040_0000;
#[cfg(target_os = "redox")]
pub const O_FSYNC: c_int = 0x0080_0000;
#[cfg(target_os = "redox")]
pub const O_CLOEXEC: c_int = 0x0100_0000;
#[cfg(target_os = "redox")]
pub const O_CREAT: c_int = 0x0200_0000;
#[cfg(target_os = "redox")]
pub const O_TRUNC: c_int = 0x0400_0000;
#[cfg(target_os = "redox")]
pub const O_EXCL: c_int = 0x0800_0000;
#[cfg(target_os = "redox")]
pub const O_DIRECTORY: c_int = 0x1000_0000;
#[cfg(target_os = "redox")]
pub const O_STAT: c_int = 0x2000_0000;
#[cfg(target_os = "redox")]
pub const O_SYMLINK: c_int = 0x4000_0000;
#[cfg(target_os = "redox")]
pub const O_NOFOLLOW: c_int = 0x8000_0000;
#[cfg(target_os = "redox")]
pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR;
pub const F_DUPFD: c_int = 0;
pub const F_GETFD: c_int = 1;
-8
View File
@@ -1,8 +0,0 @@
use platform::types::*;
pub const O_RDONLY: c_int = 0x0000;
pub const O_WRONLY: c_int = 0x0001;
pub const O_RDWR: c_int = 0x0002;
pub const O_CREAT: c_int = 0x0040;
pub const O_TRUNC: c_int = 0x0200;
pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR;
-20
View File
@@ -1,20 +0,0 @@
use platform::types::*;
pub const O_RDONLY: c_int = 0x0001_0000;
pub const O_WRONLY: c_int = 0x0002_0000;
pub const O_RDWR: c_int = 0x0003_0000;
pub const O_NONBLOCK: c_int = 0x0004_0000;
pub const O_APPEND: c_int = 0x0008_0000;
pub const O_SHLOCK: c_int = 0x0010_0000;
pub const O_EXLOCK: c_int = 0x0020_0000;
pub const O_ASYNC: c_int = 0x0040_0000;
pub const O_FSYNC: c_int = 0x0080_0000;
pub const O_CLOEXEC: c_int = 0x0100_0000;
pub const O_CREAT: c_int = 0x0200_0000;
pub const O_TRUNC: c_int = 0x0400_0000;
pub const O_EXCL: c_int = 0x0800_0000;
pub const O_DIRECTORY: c_int = 0x1000_0000;
pub const O_STAT: c_int = 0x2000_0000;
pub const O_SYMLINK: c_int = 0x4000_0000;
pub const O_NOFOLLOW: c_int = 0x8000_0000;
pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR;
+11
View File
@@ -17,46 +17,57 @@ pub struct fenv_t {
pub cw: u64,
}
#[no_mangle]
pub unsafe extern "C" fn feclearexcept(excepts: c_int) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn fegenenv(envp: *mut fenv_t) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn fegetexceptflag(flagp: *mut fexcept_t, excepts: c_int) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn fegetround() -> c_int {
FE_TONEAREST
}
#[no_mangle]
pub unsafe extern "C" fn feholdexcept(envp: *mut fenv_t) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn feraiseexcept(except: c_int) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn fesetenv(envp: *const fenv_t) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn fesetexceptflag(flagp: *const fexcept_t, excepts: c_int) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn fesetround(round: c_int) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn fetestexcept(excepts: c_int) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn feupdateenv(envp: *const fenv_t) -> c_int {
unimplemented!();
}
+1
View File
@@ -11,6 +11,7 @@ use fenv::{fegetround, FE_TONEAREST};
pub const FLT_RADIX: c_int = 2;
#[no_mangle]
pub unsafe extern "C" fn flt_rounds() -> c_int {
match fegetround() {
FE_TONEAREST => 1,
+8 -8
View File
@@ -125,7 +125,7 @@ pub unsafe extern "C" fn strcspn(s1: *const c_char, s2: *const c_char) -> c_ulon
// The below logic is effectively ripped from the musl implementation
let mut byteset = [0u8; 32 / mem::size_of::<usize>()];
let mut byteset = [0usize; 32 / mem::size_of::<usize>()];
let mut i = 0;
while *s2.offset(i) != 0 {
@@ -135,9 +135,9 @@ pub unsafe extern "C" fn strcspn(s1: *const c_char, s2: *const c_char) -> c_ulon
}
i = 0; // reset
while *s2.offset(i) != 0 {
if byteset[(*s2.offset(i) as usize) / (8 * byteset.len())]
& 1 << (*s2.offset(i) as usize % (8 * byteset.len())) > 0
while *s1.offset(i) != 0 {
if byteset[(*s1.offset(i) as usize) / (8 * byteset.len())]
& 1 << (*s1.offset(i) as usize % (8 * byteset.len())) > 0
{
break;
}
@@ -282,7 +282,7 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> c_ulong
// The below logic is effectively ripped from the musl implementation
let mut byteset = [0u8; 32 / mem::size_of::<usize>()];
let mut byteset = [0usize; 32 / mem::size_of::<usize>()];
let mut i = 0;
while *s2.offset(i) != 0 {
@@ -292,9 +292,9 @@ pub unsafe extern "C" fn strspn(s1: *const c_char, s2: *const c_char) -> c_ulong
}
i = 0; // reset
while *s2.offset(i) != 0 {
if byteset[(*s2.offset(i) as usize) / (8 * byteset.len())]
& 1 << (*s2.offset(i) as usize % (8 * byteset.len())) < 1
while *s1.offset(i) != 0 {
if byteset[(*s1.offset(i) as usize) / (8 * byteset.len())]
& 1 << (*s1.offset(i) as usize % (8 * byteset.len())) < 1
{
break;
}