Merge branch 'master' into 'master'
Add the few last things to get gcc_complete working See merge request redox-os/relibc!146
This commit is contained in:
Generated
+22
-4
@@ -148,6 +148,17 @@ dependencies = [
|
||||
"sys_socket 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inttypes"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cbindgen 0.5.2",
|
||||
"ctype 0.1.0",
|
||||
"errno 0.1.0",
|
||||
"platform 0.1.0",
|
||||
"stdlib 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.1"
|
||||
@@ -274,6 +285,7 @@ dependencies = [
|
||||
"fenv 0.1.0",
|
||||
"float 0.1.0",
|
||||
"grp 0.1.0",
|
||||
"inttypes 0.1.0",
|
||||
"locale 0.1.0",
|
||||
"netinet 0.1.0",
|
||||
"platform 0.1.0",
|
||||
@@ -288,6 +300,7 @@ dependencies = [
|
||||
"sys_socket 0.1.0",
|
||||
"sys_stat 0.1.0",
|
||||
"sys_time 0.1.0",
|
||||
"sys_utsname 0.1.0",
|
||||
"sys_wait 0.1.0",
|
||||
"time 0.1.0",
|
||||
"unistd 0.1.0",
|
||||
@@ -355,10 +368,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "setjmp"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cbindgen 0.5.2",
|
||||
"platform 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal"
|
||||
@@ -486,6 +495,14 @@ dependencies = [
|
||||
"platform 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sys_utsname"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cbindgen 0.5.2",
|
||||
"platform 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sys_wait"
|
||||
version = "0.1.0"
|
||||
@@ -567,6 +584,7 @@ dependencies = [
|
||||
"platform 0.1.0",
|
||||
"stdio 0.1.0",
|
||||
"string 0.1.0",
|
||||
"sys_utsname 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
+3
-1
@@ -20,6 +20,7 @@ fcntl = { path = "src/fcntl" }
|
||||
fenv = { path = "src/fenv" }
|
||||
float = { path = "src/float" }
|
||||
grp = { path = "src/grp" }
|
||||
inttypes = { path = "src/inttypes" }
|
||||
locale = { path = "src/locale" }
|
||||
netinet = { path = "src/netinet" }
|
||||
platform = { path = "src/platform" }
|
||||
@@ -34,6 +35,7 @@ sys_resource = { path = "src/sys_resource" }
|
||||
sys_socket = { path = "src/sys_socket" }
|
||||
sys_stat = { path = "src/sys_stat" }
|
||||
sys_time = { path = "src/sys_time" }
|
||||
sys_utsname = { path = "src/sys_utsname" }
|
||||
sys_wait = { path = "src/sys_wait" }
|
||||
time = { path = "src/time" }
|
||||
unistd = { path = "src/unistd" }
|
||||
@@ -42,7 +44,7 @@ wctype = { path = "src/wctype" }
|
||||
[dependencies.compiler_builtins]
|
||||
git = "https://github.com/rust-lang-nursery/compiler-builtins.git"
|
||||
default-features = false
|
||||
features = ["no-lang-items"]
|
||||
features = ["no-lang-items", "mangled-names"]
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
@@ -40,6 +40,7 @@ install: all
|
||||
cp -v "$(BUILD)/debug/crt0.o" "$(DESTDIR)/lib"
|
||||
cp -rv "openlibm/include"/* "$(DESTDIR)/include"
|
||||
cp -rv "openlibm/src"/*.h "$(DESTDIR)/include"
|
||||
cp -v "$(BUILD)/openlibm/libopenlibm.a" "$(DESTDIR)/lib/libm.a"
|
||||
|
||||
libc: $(BUILD)/debug/libc.a $(BUILD)/debug/crt0.o
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _ASSERT_H
|
||||
#define _ASSERT_H
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define assert(cond)
|
||||
#else
|
||||
# include <stdio.h>
|
||||
# define assert(cond) if (!(cond)) { \
|
||||
fprintf(stderr, "%s: %s:%d: Assertion `%s` failed.\n", __func__, __FILE__, __LINE__, #cond); \
|
||||
abort(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
#ifndef _BITS_INTTYPE_H
|
||||
#define _BITS_INTTYPE_H
|
||||
|
||||
#define PRId8 "hhd"
|
||||
#define PRId16 "hd"
|
||||
#define PRId32 "ld"
|
||||
#define PRId64 "Ld"
|
||||
|
||||
#define PRIdLEAST8 "hhd"
|
||||
#define PRIdLEAST16 "hd"
|
||||
#define PRIdLEAST32 "ld"
|
||||
#define PRIdLEAST64 "Ld"
|
||||
|
||||
#define PRIdFAST8 "hhd"
|
||||
#define PRIdFAST16 "hd"
|
||||
#define PRIdFAST32 "ld"
|
||||
#define PRIdFAST64 "Ld"
|
||||
|
||||
#define PRIi8 "hhi"
|
||||
#define PRIi16 "hi"
|
||||
#define PRIi32 "li"
|
||||
#define PRIi64 "Li"
|
||||
|
||||
#define PRIiLEAST8 "hhi"
|
||||
#define PRIiLEAST16 "hi"
|
||||
#define PRIiLEAST32 "li"
|
||||
#define PRIiLEAST64 "Li"
|
||||
|
||||
#define PRIiFAST8 "hhi"
|
||||
#define PRIiFAST16 "hi"
|
||||
#define PRIiFAST32 "li"
|
||||
#define PRIiFAST64 "Li"
|
||||
|
||||
#define PRIo8 "hho"
|
||||
#define PRIo16 "ho"
|
||||
#define PRIo32 "lo"
|
||||
#define PRIo64 "Lo"
|
||||
|
||||
#define PRIoLEAST8 "hho"
|
||||
#define PRIoLEAST16 "ho"
|
||||
#define PRIoLEAST32 "lo"
|
||||
#define PRIoLEAST64 "Lo"
|
||||
|
||||
#define PRIoFAST8 "hho"
|
||||
#define PRIoFAST16 "ho"
|
||||
#define PRIoFAST32 "lo"
|
||||
#define PRIoFAST64 "Lo"
|
||||
|
||||
#define PRIu8 "hhu"
|
||||
#define PRIu16 "hu"
|
||||
#define PRIu32 "lu"
|
||||
#define PRIu64 "Lu"
|
||||
|
||||
#define PRIuLEAST8 "hhu"
|
||||
#define PRIuLEAST16 "hu"
|
||||
#define PRIuLEAST32 "lu"
|
||||
#define PRIuLEAST64 "Lu"
|
||||
|
||||
#define PRIuFAST8 "hhu"
|
||||
#define PRIuFAST16 "hu"
|
||||
#define PRIuFAST32 "lu"
|
||||
#define PRIuFAST64 "Lu"
|
||||
|
||||
#define PRIx8 "hhx"
|
||||
#define PRIx16 "hx"
|
||||
#define PRIx32 "lx"
|
||||
#define PRIx64 "Lx"
|
||||
|
||||
#define PRIxLEAST8 "hhx"
|
||||
#define PRIxLEAST16 "hx"
|
||||
#define PRIxLEAST32 "lx"
|
||||
#define PRIxLEAST64 "Lx"
|
||||
|
||||
#define PRIxFAST8 "hhx"
|
||||
#define PRIxFAST16 "hx"
|
||||
#define PRIxFAST32 "lx"
|
||||
#define PRIxFAST64 "Lx"
|
||||
|
||||
#define PRIX8 "hhX"
|
||||
#define PRIX16 "hX"
|
||||
#define PRIX32 "lX"
|
||||
#define PRIX64 "LX"
|
||||
|
||||
#define PRIXLEAST8 "hhX"
|
||||
#define PRIXLEAST16 "hX"
|
||||
#define PRIXLEAST32 "lX"
|
||||
#define PRIXLEAST64 "LX"
|
||||
|
||||
#define PRIXFAST8 "hhX"
|
||||
#define PRIXFAST16 "hX"
|
||||
#define PRIXFAST32 "lX"
|
||||
#define PRIXFAST64 "LX"
|
||||
|
||||
#define PRIdMAX "jd"
|
||||
#define PRIiMAX "ji"
|
||||
#define PRIoMAX "jo"
|
||||
#define PRIuMAX "ju"
|
||||
#define PRIxMAX "jx"
|
||||
#define PRIXMAX "jX"
|
||||
|
||||
#define PRIdPTR "td"
|
||||
#define PRIiPTR "ti"
|
||||
#define PRIoPTR "to"
|
||||
#define PRIuPTR "tu"
|
||||
#define PRIxPTR "tx"
|
||||
#define PRIXPTR "tX"
|
||||
|
||||
#define SCNd8 "hhd"
|
||||
#define SCNd16 "hd"
|
||||
#define SCNd32 "ld"
|
||||
#define SCNd64 "Ld"
|
||||
|
||||
#define SCNdLEAST8 "hhd"
|
||||
#define SCNdLEAST16 "hd"
|
||||
#define SCNdLEAST32 "ld"
|
||||
#define SCNdLEAST64 "Ld"
|
||||
|
||||
#define SCNdFAST8 "hhd"
|
||||
#define SCNdFAST16 "hd"
|
||||
#define SCNdFAST32 "ld"
|
||||
#define SCNdFAST64 "Ld"
|
||||
|
||||
#define SCNi8 "hhi"
|
||||
#define SCNi16 "hi"
|
||||
#define SCNi32 "li"
|
||||
#define SCNi64 "Li"
|
||||
|
||||
#define SCNiLEAST8 "hhi"
|
||||
#define SCNiLEAST16 "hi"
|
||||
#define SCNiLEAST32 "li"
|
||||
#define SCNiLEAST64 "Li"
|
||||
|
||||
#define SCNiFAST8 "hhi"
|
||||
#define SCNiFAST16 "hi"
|
||||
#define SCNiFAST32 "li"
|
||||
#define SCNiFAST64 "Li"
|
||||
|
||||
#define SCNo8 "hho"
|
||||
#define SCNo16 "ho"
|
||||
#define SCNo32 "lo"
|
||||
#define SCNo64 "Lo"
|
||||
|
||||
#define SCNoLEAST8 "hho"
|
||||
#define SCNoLEAST16 "ho"
|
||||
#define SCNoLEAST32 "lo"
|
||||
#define SCNoLEAST64 "Lo"
|
||||
|
||||
#define SCNoFAST8 "hho"
|
||||
#define SCNoFAST16 "ho"
|
||||
#define SCNoFAST32 "lo"
|
||||
#define SCNoFAST64 "Lo"
|
||||
|
||||
#define SCNu8 "hhu"
|
||||
#define SCNu16 "hu"
|
||||
#define SCNu32 "lu"
|
||||
#define SCNu64 "Lu"
|
||||
|
||||
#define SCNuLEAST8 "hhu"
|
||||
#define SCNuLEAST16 "hu"
|
||||
#define SCNuLEAST32 "lu"
|
||||
#define SCNuLEAST64 "Lu"
|
||||
|
||||
#define SCNuFAST8 "hhu"
|
||||
#define SCNuFAST16 "hu"
|
||||
#define SCNuFAST32 "lu"
|
||||
#define SCNuFAST64 "Lu"
|
||||
|
||||
#define SCNx8 "hhx"
|
||||
#define SCNx16 "hx"
|
||||
#define SCNx32 "lx"
|
||||
#define SCNx64 "Lx"
|
||||
|
||||
#define SCNxLEAST8 "hhx"
|
||||
#define SCNxLEAST16 "hx"
|
||||
#define SCNxLEAST32 "lx"
|
||||
#define SCNxLEAST64 "Lx"
|
||||
|
||||
#define SCNxFAST8 "hhx"
|
||||
#define SCNxFAST16 "hx"
|
||||
#define SCNxFAST32 "lx"
|
||||
#define SCNxFAST64 "Lx"
|
||||
|
||||
#define SCNdMAX "jd"
|
||||
#define SCNiMAX "ji"
|
||||
#define SCNoMAX "jo"
|
||||
#define SCNuMAX "ju"
|
||||
#define SCNxMAX "jx"
|
||||
|
||||
#define SCNdPTR "td"
|
||||
#define SCNiPTR "ti"
|
||||
#define SCNoPTR "to"
|
||||
#define SCNuPTR "tu"
|
||||
#define SCNxPTR "tx"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef _BITS_STAT_H
|
||||
#define _BITS_STAT_H
|
||||
|
||||
#define S_ISDIR(mode) mode & S_IFMT == S_IFDIR
|
||||
#define S_ISCHR(mode) mode & S_IFMT == S_IFCHR
|
||||
#define S_ISBLK(mode) mode & S_IFMT == S_IFBLK
|
||||
#define S_ISREG(mode) mode & S_IFMT == S_IFREG
|
||||
#define S_ISIFO(mode) mode & S_IFMT == S_IFIFO
|
||||
#define S_ISLNK(mode) mode & S_IFMT == S_IFLNK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
#define OPENLIBM_USE_HOST_FENV_H 1
|
||||
#include <openlibm.h>
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef _BITS_SETJMP_H
|
||||
#define _BITS_SETJMP_H
|
||||
#ifndef _SETJMP_H
|
||||
#define _SETJMP_H
|
||||
|
||||
#ifdef __arch64__
|
||||
typedef unsigned long jmp_buf[22];
|
||||
+1
-1
@@ -125,6 +125,6 @@ typedef uint64_t uintptr_t;
|
||||
|
||||
#define SIZE_MAX UINT64_MAX
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
typedef long sig_atomic_t;
|
||||
|
||||
#endif /* _STDINT_H */
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "inttypes"
|
||||
version = "0.1.0"
|
||||
authors = ["jD91mZM2 <me@krake.one>"]
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = { path = "../../cbindgen" }
|
||||
|
||||
[dependencies]
|
||||
ctype = { path = "../ctype" }
|
||||
errno = { path = "../errno" }
|
||||
platform = { path = "../platform" }
|
||||
stdlib = { path = "../stdlib" }
|
||||
@@ -0,0 +1,11 @@
|
||||
extern crate cbindgen;
|
||||
|
||||
use std::{env, fs};
|
||||
|
||||
fn main() {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
|
||||
fs::create_dir_all("../../target/include").expect("failed to create include directory");
|
||||
cbindgen::generate(crate_dir)
|
||||
.expect("failed to generate bindings")
|
||||
.write_to_file("../../target/include/inttypes.h");
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
sys_includes = ["stdint.h"]
|
||||
include_guard = "_INTTYPES_H"
|
||||
trailer = "#include <bits/inttypes.h>"
|
||||
language = "C"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -0,0 +1,74 @@
|
||||
#[macro_use] extern crate stdlib;
|
||||
extern crate ctype;
|
||||
extern crate errno;
|
||||
extern crate platform;
|
||||
|
||||
use errno::*;
|
||||
use platform::types::*;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn imaxabs(i: intmax_t) -> intmax_t {
|
||||
i.abs()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[repr(C)]
|
||||
pub struct intmaxdiv_t {
|
||||
quot: intmax_t,
|
||||
rem: intmax_t
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn imaxdiv(i: intmax_t, j: intmax_t) -> intmaxdiv_t {
|
||||
intmaxdiv_t {
|
||||
quot: i / j,
|
||||
rem: i % j
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn strtoimax(s: *const c_char,
|
||||
endptr: *mut *mut c_char,
|
||||
base: c_int)
|
||||
-> intmax_t {
|
||||
use stdlib::*;
|
||||
strto_impl!(
|
||||
intmax_t,
|
||||
false,
|
||||
intmax_t::max_value(),
|
||||
intmax_t::min_value(),
|
||||
s,
|
||||
endptr,
|
||||
base
|
||||
)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn strtoumax(s: *const c_char,
|
||||
endptr: *mut *mut c_char,
|
||||
base: c_int)
|
||||
-> uintmax_t {
|
||||
use stdlib::*;
|
||||
strto_impl!(
|
||||
uintmax_t,
|
||||
false,
|
||||
uintmax_t::max_value(),
|
||||
uintmax_t::min_value(),
|
||||
s,
|
||||
endptr,
|
||||
base
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstoimax(nptr: *const wchar_t, endptr: *mut *mut wchar_t,
|
||||
base: c_int) -> intmax_t {
|
||||
unimplemented!();
|
||||
}
|
||||
#[allow(unused)]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstoumax(nptr: *const wchar_t, endptr: *mut *mut wchar_t,
|
||||
base: c_int) -> uintmax_t {
|
||||
unimplemented!();
|
||||
}
|
||||
@@ -16,6 +16,7 @@ pub extern crate locale;
|
||||
pub extern crate netinet;
|
||||
pub extern crate semaphore;
|
||||
pub extern crate setjmp;
|
||||
pub extern crate signal;
|
||||
pub extern crate stdio;
|
||||
pub extern crate stdlib;
|
||||
pub extern crate string;
|
||||
@@ -24,6 +25,7 @@ pub extern crate sys_resource;
|
||||
pub extern crate sys_socket;
|
||||
pub extern crate sys_stat;
|
||||
pub extern crate sys_time;
|
||||
pub extern crate sys_utsname;
|
||||
pub extern crate sys_wait;
|
||||
pub extern crate time;
|
||||
pub extern crate unistd;
|
||||
|
||||
@@ -10,7 +10,7 @@ extern crate sc;
|
||||
|
||||
#[cfg(all(not(feature = "no_std"), target_os = "redox"))]
|
||||
#[macro_use]
|
||||
extern crate syscall;
|
||||
pub extern crate syscall;
|
||||
|
||||
pub use sys::*;
|
||||
|
||||
|
||||
@@ -198,6 +198,10 @@ pub fn stat(file: *const c_char, buf: *mut stat) -> c_int {
|
||||
e(unsafe { syscall!(NEWFSTATAT, AT_FDCWD, file, buf, 0) }) as c_int
|
||||
}
|
||||
|
||||
pub fn uname(utsname: usize) -> c_int {
|
||||
e(unsafe { syscall!(UNAME, utsname, 0) }) as c_int
|
||||
}
|
||||
|
||||
pub fn unlink(path: *const c_char) -> c_int {
|
||||
e(unsafe { syscall!(UNLINKAT, AT_FDCWD, path, 0) }) as c_int
|
||||
}
|
||||
|
||||
@@ -2,10 +2,3 @@
|
||||
name = "setjmp"
|
||||
version = "0.1.0"
|
||||
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = { path = "../../cbindgen" }
|
||||
|
||||
[dependencies]
|
||||
platform = { path = "../platform" }
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
extern crate cbindgen;
|
||||
|
||||
use std::{env, fs, process::Command};
|
||||
|
||||
fn compile(file: &str, object: &str, output: &str) {
|
||||
let status = Command::new("gcc")
|
||||
.args(&["-c", file, "-o", object])
|
||||
.status()
|
||||
.expect("failed to run gcc to compile assembly");
|
||||
|
||||
if !status.success() {
|
||||
panic!("compilation error");
|
||||
}
|
||||
|
||||
let status = Command::new("ar")
|
||||
.args(&["rcs", output, object])
|
||||
.status()
|
||||
.expect("failed to run ar to convert object to a static library");
|
||||
|
||||
if !status.success() {
|
||||
panic!("error converting object to static library");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rustc-link-lib=static=setjmp");
|
||||
println!("cargo:rustc-link-lib=static=longjmp");
|
||||
|
||||
macro_rules! detect_arch {
|
||||
($($($token:tt);+),+) => {
|
||||
$(
|
||||
detect_arch!(inner $($token);+);
|
||||
)+
|
||||
};
|
||||
(inner $arch:expr) => {
|
||||
detect_arch!(inner $arch; ".s");
|
||||
};
|
||||
(inner $arch:expr; $ext:expr) => {
|
||||
#[cfg(target_arch = $arch)] {
|
||||
compile(concat!("impl/", $arch, "/setjmp", $ext), "impl/bin/setjmp.o", "impl/bin/libsetjmp.a");
|
||||
compile(concat!("impl/", $arch, "/longjmp", $ext), "impl/bin/longjmp.o", "impl/bin/liblongjmp.a");
|
||||
|
||||
let dir = env::current_dir().expect("failed to find current directory");
|
||||
println!("cargo:rustc-link-search=native={}/impl/bin", dir.display());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
detect_arch! {
|
||||
"aarch64",
|
||||
"arm",
|
||||
"i386",
|
||||
"m68k",
|
||||
"microblaze",
|
||||
"mips"; ".S",
|
||||
"mips64"; ".S",
|
||||
"mipsn32"; ".S",
|
||||
"or1k",
|
||||
"powerpc"; ".S",
|
||||
"powerpc64",
|
||||
"s390x",
|
||||
"sh"; ".S",
|
||||
"x32",
|
||||
"x86_64"
|
||||
}
|
||||
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
|
||||
fs::create_dir_all("../../target/include").expect("failed to create include directory");
|
||||
cbindgen::generate(crate_dir)
|
||||
.expect("failed to generate bindings")
|
||||
.write_to_file("../../target/include/setjmp.h");
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
include_guard = "_SETJMP_H"
|
||||
trailer = "#include <bits/setjmp.h>"
|
||||
language = "C"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
+29
-2
@@ -1,6 +1,33 @@
|
||||
//! setjmp implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/setjmp.h.html
|
||||
|
||||
#![no_std]
|
||||
#![feature(global_asm)]
|
||||
|
||||
// EMPTY FILE.
|
||||
// This project is here because of the build.rs file which will compile musl's existing code for setjmp.
|
||||
macro_rules! platform_specific {
|
||||
($($arch:expr,$ext:expr;)+) => {
|
||||
$(
|
||||
#[cfg(target_arch = $arch)]
|
||||
global_asm!(include_str!(concat!("impl/", $arch, "/setjmp.", $ext)));
|
||||
#[cfg(target_arch = $arch)]
|
||||
global_asm!(include_str!(concat!("impl/", $arch, "/longjmp.", $ext)));
|
||||
)+
|
||||
}
|
||||
}
|
||||
|
||||
platform_specific! {
|
||||
"aarch64","s";
|
||||
"arm","s";
|
||||
"i386","s";
|
||||
"m68k","s";
|
||||
"microblaze","s";
|
||||
"mips","S";
|
||||
"mips64","S";
|
||||
"mipsn32","S";
|
||||
"or1k","s";
|
||||
"powerpc","S";
|
||||
"powerpc64","s";
|
||||
"s390x","s";
|
||||
"sh","S";
|
||||
"x32","s";
|
||||
"x86_64","s";
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ pub mod sys;
|
||||
#[path = "redox.rs"]
|
||||
pub mod sys;
|
||||
|
||||
pub const SIG_BLOCK: c_int = 0;
|
||||
pub const SIG_UNBLOCK: c_int = 1;
|
||||
pub const SIG_SETMASK: c_int = 2;
|
||||
|
||||
pub use sys::*;
|
||||
|
||||
use platform::types::*;
|
||||
|
||||
+13
-8
@@ -553,7 +553,7 @@ pub unsafe extern "C" fn strtod(s: *const c_char, endptr: *mut *mut c_char) -> c
|
||||
}
|
||||
}
|
||||
|
||||
fn is_positive(ch: c_char) -> Option<(bool, isize)> {
|
||||
pub fn is_positive(ch: c_char) -> Option<(bool, isize)> {
|
||||
match ch {
|
||||
0 => None,
|
||||
ch if ch == b'+' as c_char => Some((true, 1)),
|
||||
@@ -562,7 +562,7 @@ fn is_positive(ch: c_char) -> Option<(bool, isize)> {
|
||||
}
|
||||
}
|
||||
|
||||
fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
|
||||
pub fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
|
||||
let first = unsafe { *s } as u8;
|
||||
match first {
|
||||
0 => None,
|
||||
@@ -581,7 +581,7 @@ fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
pub unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
if *s != 0 && *s == b'0' as c_char {
|
||||
if let Some((val, idx, overflow)) = convert_integer(s.offset(1), 8) {
|
||||
Some((val, idx + 1, overflow))
|
||||
@@ -594,7 +594,7 @@ unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
pub unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
if (*s != 0 && *s == b'0' as c_char)
|
||||
&& (*s.offset(1) != 0 && (*s.offset(1) == b'x' as c_char || *s.offset(1) == b'X' as c_char))
|
||||
{
|
||||
@@ -604,7 +604,7 @@ unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, bool)> {
|
||||
pub fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, bool)> {
|
||||
// -1 means the character is invalid
|
||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
const LOOKUP_TABLE: [c_long; 256] = [
|
||||
@@ -658,6 +658,7 @@ fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, boo
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! strto_impl {
|
||||
(
|
||||
$rettype:ty,
|
||||
@@ -675,7 +676,11 @@ macro_rules! strto_impl {
|
||||
|
||||
let set_endptr = |idx: isize| {
|
||||
if !$endptr.is_null() {
|
||||
*$endptr = $s.offset(idx);
|
||||
// This is stupid, but apparently strto* functions want
|
||||
// const input but mut output, yet the man page says
|
||||
// "stores the address of the first invalid character in *endptr"
|
||||
// so obviously it doesn't want us to clone it.
|
||||
*$endptr = $s.offset(idx) as *mut _;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -767,7 +772,7 @@ macro_rules! strto_impl {
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn strtoul(s: *const c_char,
|
||||
endptr: *mut *const c_char,
|
||||
endptr: *mut *mut c_char,
|
||||
base: c_int)
|
||||
-> c_ulong {
|
||||
strto_impl!(
|
||||
@@ -783,7 +788,7 @@ pub unsafe extern "C" fn strtoul(s: *const c_char,
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn strtol(s: *const c_char,
|
||||
endptr: *mut *const c_char,
|
||||
endptr: *mut *mut c_char,
|
||||
base: c_int)
|
||||
-> c_long {
|
||||
strto_impl!(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
sys_includes = ["sys/types.h"]
|
||||
include_guard = "_SYS_STAT_H"
|
||||
trailer = "#include <bits/sys/stat.h>"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
|
||||
|
||||
+25
-25
@@ -6,31 +6,31 @@ extern crate platform;
|
||||
|
||||
use platform::types::*;
|
||||
|
||||
pub const S_IFMT: c_int = 00170000;
|
||||
pub const S_IFBLK: c_int = 0060000;
|
||||
pub const S_IFCHR: c_int = 0020000;
|
||||
pub const S_IFIFO: c_int = 0010000;
|
||||
pub const S_IFREG: c_int = 0100000;
|
||||
pub const S_IFDIR: c_int = 0040000;
|
||||
pub const S_IFLNK: c_int = 0120000;
|
||||
pub const S_IFMT: c_int = 0o0170000;
|
||||
pub const S_IFBLK: c_int = 0o060000;
|
||||
pub const S_IFCHR: c_int = 0o020000;
|
||||
pub const S_IFIFO: c_int = 0o010000;
|
||||
pub const S_IFREG: c_int = 0o100000;
|
||||
pub const S_IFDIR: c_int = 0o040000;
|
||||
pub const S_IFLNK: c_int = 0o120000;
|
||||
|
||||
pub const S_IRWXU: c_int = 00700;
|
||||
pub const S_IRUSR: c_int = 00400;
|
||||
pub const S_IWUSR: c_int = 00200;
|
||||
pub const S_IXUSR: c_int = 00100;
|
||||
pub const S_IRWXU: c_int = 0o0700;
|
||||
pub const S_IRUSR: c_int = 0o0400;
|
||||
pub const S_IWUSR: c_int = 0o0200;
|
||||
pub const S_IXUSR: c_int = 0o0100;
|
||||
|
||||
pub const S_IRWXG: c_int = 00070;
|
||||
pub const S_IRGRP: c_int = 00040;
|
||||
pub const S_IWGRP: c_int = 00020;
|
||||
pub const S_IXGRP: c_int = 00010;
|
||||
pub const S_IRWXG: c_int = 0o0070;
|
||||
pub const S_IRGRP: c_int = 0o0040;
|
||||
pub const S_IWGRP: c_int = 0o0020;
|
||||
pub const S_IXGRP: c_int = 0o0010;
|
||||
|
||||
pub const S_IRWXO: c_int = 00007;
|
||||
pub const S_IROTH: c_int = 00004;
|
||||
pub const S_IWOTH: c_int = 00002;
|
||||
pub const S_IXOTH: c_int = 00001;
|
||||
pub const S_ISUID: c_int = 04000;
|
||||
pub const S_ISGID: c_int = 02000;
|
||||
pub const S_ISVTX: c_int = 01000;
|
||||
pub const S_IRWXO: c_int = 0o0007;
|
||||
pub const S_IROTH: c_int = 0o0004;
|
||||
pub const S_IWOTH: c_int = 0o0002;
|
||||
pub const S_IXOTH: c_int = 0o0001;
|
||||
pub const S_ISUID: c_int = 0o4000;
|
||||
pub const S_ISGID: c_int = 0o2000;
|
||||
pub const S_ISVTX: c_int = 0o1000;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
@@ -43,9 +43,9 @@ pub struct stat {
|
||||
pub st_rdev: dev_t,
|
||||
pub st_size: off_t,
|
||||
pub st_blksize: blksize_t,
|
||||
pub st_atim: time_t,
|
||||
pub st_mtim: time_t,
|
||||
pub st_ctim: time_t,
|
||||
pub st_atime: time_t,
|
||||
pub st_mtime: time_t,
|
||||
pub st_ctime: time_t,
|
||||
pub st_blocks: blkcnt_t,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
sys_includes = ["sys/types.h"]
|
||||
include_guard = "_SYS_TIME_H"
|
||||
language = "C"
|
||||
style = "Both"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "sys_utsname"
|
||||
version = "0.1.0"
|
||||
authors = ["jD91mZM2 <me@krake.one>"]
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = { path = "../../cbindgen" }
|
||||
|
||||
[dependencies]
|
||||
platform = { path = "../platform" }
|
||||
@@ -0,0 +1,11 @@
|
||||
extern crate cbindgen;
|
||||
|
||||
use std::{env, fs};
|
||||
|
||||
fn main() {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
|
||||
fs::create_dir_all("../../target/include").expect("failed to create include directory");
|
||||
cbindgen::generate(crate_dir)
|
||||
.expect("failed to generate bindings")
|
||||
.write_to_file("../../target/include/sys/utsname.h");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
include_guard = "_SYS_UTSNAME_H"
|
||||
language = "C"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -0,0 +1,28 @@
|
||||
//! sys/utsname implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html
|
||||
|
||||
#![no_std]
|
||||
#![cfg(target_os = "linux")]
|
||||
|
||||
extern crate platform;
|
||||
|
||||
use core::ptr;
|
||||
use platform::types::*;
|
||||
|
||||
const LENGTH: usize = 65;
|
||||
|
||||
#[allow(non_camel_case)]
|
||||
#[no_mangle]
|
||||
#[repr(C)]
|
||||
pub struct utsname {
|
||||
pub sysname: [c_char; LENGTH],
|
||||
pub nodename: [c_char; LENGTH],
|
||||
pub release: [c_char; LENGTH],
|
||||
pub version: [c_char; LENGTH],
|
||||
pub machine: [c_char; LENGTH],
|
||||
pub domainname: [c_char; LENGTH]
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn uname(uts: *mut utsname) -> c_int {
|
||||
platform::uname(uts as usize)
|
||||
}
|
||||
@@ -11,3 +11,4 @@ cbindgen = { path = "../../cbindgen" }
|
||||
platform = { path = "../platform" }
|
||||
stdio = { path = "../stdio" }
|
||||
string = { path = "../string" }
|
||||
sys_utsname = { path = "../sys_utsname" }
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
extern crate platform;
|
||||
extern crate stdio;
|
||||
extern crate string;
|
||||
extern crate sys_utsname;
|
||||
|
||||
pub use platform::types::*;
|
||||
pub use getopt::*;
|
||||
@@ -199,6 +200,54 @@ pub extern "C" fn gethostid() -> c_long {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn gethostname(mut name: *mut c_char, len: size_t) -> c_int {
|
||||
#[cfg(target_os = "linux")] {
|
||||
use core::mem;
|
||||
|
||||
// len only needs to be mutable on linux
|
||||
let mut len = len;
|
||||
|
||||
let mut uts: sys_utsname::utsname = mem::uninitialized();
|
||||
let err = sys_utsname::uname(&mut uts);
|
||||
if err < 0 {
|
||||
mem::forget(uts);
|
||||
return err;
|
||||
}
|
||||
for c in uts.nodename.iter() {
|
||||
if len == 0 { break; }
|
||||
len -= 1;
|
||||
|
||||
*name = *c;
|
||||
|
||||
if *name == 0 {
|
||||
// We do want to copy the zero also, so we check this after the copying.
|
||||
break;
|
||||
}
|
||||
|
||||
name = name.offset(1);
|
||||
}
|
||||
0
|
||||
}
|
||||
#[cfg(target_os = "redox")] {
|
||||
use platform::{FileReader, Read};
|
||||
use platform::syscall::flag::*;
|
||||
|
||||
let fd = platform::open("/etc/hostname\0",as_ptr(), 0, O_RDONLY);
|
||||
if fd < 0 {
|
||||
return fd;
|
||||
}
|
||||
let reader = FileReader(fd);
|
||||
for _ in 0..len {
|
||||
if !reader.read_u8(&mut *name) {
|
||||
*name = 0;
|
||||
break;
|
||||
}
|
||||
name = name.offset(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn getlogin() -> *mut c_char {
|
||||
unimplemented!();
|
||||
|
||||
@@ -0,0 +1,394 @@
|
||||
//! wchar implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/string.h.html
|
||||
|
||||
#![no_std]
|
||||
|
||||
extern crate errno;
|
||||
extern crate platform;
|
||||
extern crate stdlib;
|
||||
extern crate string;
|
||||
extern crate time;
|
||||
|
||||
use platform::types::*;
|
||||
use errno::*;
|
||||
use time::*;
|
||||
use core::cmp;
|
||||
use core::usize;
|
||||
use core::ptr;
|
||||
use core::mem;
|
||||
use string::*;
|
||||
|
||||
pub type wint_t = i32;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct mbstate_t {
|
||||
pub mbs_count: c_int,
|
||||
pub mbs_length: c_int,
|
||||
pub mbs_wch: wint_t,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn btowc(c: c_int) -> wint_t {
|
||||
//Check for EOF
|
||||
if c == -1 {
|
||||
return -1;
|
||||
}
|
||||
|
||||
let uc = c as u8;
|
||||
let c = uc as c_char;
|
||||
let mut ps: mbstate_t = mbstate_t {
|
||||
mbs_count: 0,
|
||||
mbs_length: 0,
|
||||
mbs_wch: 0,
|
||||
};
|
||||
let mut wc: wchar_t = 0;
|
||||
let saved_errno = platform::errno;
|
||||
let status = mbrtowc(&mut wc, &c as (*const c_char), 1, &mut ps);
|
||||
if status == usize::max_value() || status == usize::max_value() - 1 {
|
||||
platform::errno = saved_errno;
|
||||
return platform::errno;
|
||||
}
|
||||
return wc as wint_t;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn getwchar() -> wint_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn mbsinit(ps: *const mbstate_t) -> c_int {
|
||||
if ps.is_null() || (*ps).mbs_count == 0 {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn mbrlen(s: *const c_char, n: usize, ps: *mut mbstate_t) -> usize {
|
||||
static mut internal: mbstate_t = mbstate_t {
|
||||
mbs_count: 0,
|
||||
mbs_length: 0,
|
||||
mbs_wch: 0,
|
||||
};
|
||||
return mbrtowc(ptr::null_mut(), s, n, &mut internal);
|
||||
}
|
||||
|
||||
//Only works for utf8!
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn mbrtowc(
|
||||
pwc: *mut wchar_t,
|
||||
s: *const c_char,
|
||||
n: usize,
|
||||
ps: *mut mbstate_t,
|
||||
) -> usize {
|
||||
static mut internal: mbstate_t = mbstate_t {
|
||||
mbs_count: 0,
|
||||
mbs_length: 0,
|
||||
mbs_wch: 0,
|
||||
};
|
||||
|
||||
if ps.is_null() {
|
||||
let ps = &mut internal;
|
||||
}
|
||||
if s.is_null() {
|
||||
let xs: [c_char; 1] = [0];
|
||||
utf8_mbrtowc(pwc, &xs[0] as *const c_char, 1, ps);
|
||||
}
|
||||
|
||||
return utf8_mbrtowc(pwc, s, n, ps);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn utf8_mbrtowc(
|
||||
pwc: *mut wchar_t,
|
||||
s: *const c_char,
|
||||
n: usize,
|
||||
ps: *mut mbstate_t,
|
||||
) -> usize {
|
||||
let mut i: usize = 0;
|
||||
|
||||
while !(i > 0 && (*ps).mbs_count == 0) {
|
||||
if (n <= i) {
|
||||
return -2isize as usize;
|
||||
}
|
||||
let c = s.offset(i as isize);
|
||||
let uc = c as u8;
|
||||
|
||||
if (*ps).mbs_count == 0 {
|
||||
//1 byte sequence - 00–7F
|
||||
if (uc & 0b10000000) == 0b00000000 {
|
||||
(*ps).mbs_count = 0;
|
||||
(*ps).mbs_length = 1;
|
||||
(*ps).mbs_wch = (uc as wchar_t & 0b1111111) as wint_t;
|
||||
}
|
||||
//2 byte sequence - C2–DF
|
||||
else if (uc & 0b11100000) == 0b11000000 {
|
||||
(*ps).mbs_count = 1;
|
||||
(*ps).mbs_length = 2;
|
||||
(*ps).mbs_wch = (uc as wchar_t & 0b11111) as wint_t;
|
||||
}
|
||||
//3 byte sequence - E0–EF
|
||||
else if (uc & 0b11110000) == 0b11100000 {
|
||||
(*ps).mbs_count = 2;
|
||||
(*ps).mbs_length = 3;
|
||||
(*ps).mbs_wch = (uc as wchar_t & 0b1111) as wint_t;
|
||||
}
|
||||
//4 byte sequence - F0–F4
|
||||
else if (uc & 0b11111000) == 0b11110000 {
|
||||
(*ps).mbs_count = 3;
|
||||
(*ps).mbs_length = 4;
|
||||
(*ps).mbs_wch = (uc as wchar_t & 0b111) as wint_t;
|
||||
} else {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
} else {
|
||||
if (uc & 0b11000000) != 0b10000000 {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
|
||||
(*ps).mbs_wch = (*ps).mbs_wch << 6 | (uc & 0b00111111) as wint_t;
|
||||
(*ps).mbs_count -= 1;
|
||||
}
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// Reject the character if it was produced with an overly long sequence.
|
||||
if (*ps).mbs_length == 1 && 1 << 7 <= (*ps).mbs_wch {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
if (*ps).mbs_length == 2 && 1 << (5 + 1 * 6) <= (*ps).mbs_wch {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
if (*ps).mbs_length == 3 && 1 << (5 + 2 * 6) <= (*ps).mbs_wch {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
if (*ps).mbs_length == 4 && 1 << (5 + 3 * 6) <= (*ps).mbs_wch {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
|
||||
// The definition of UTF-8 prohibits encoding character numbers between
|
||||
// U+D800 and U+DFFF, which are reserved for use with the UTF-16 encoding
|
||||
// form (as surrogate pairs) and do not directly represent characters.
|
||||
if 0xD800 <= (*ps).mbs_wch && (*ps).mbs_wch <= 0xDFFF {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
// RFC 3629 limits UTF-8 to 0x0 through 0x10FFFF.
|
||||
if 0x10FFFF <= (*ps).mbs_wch {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
|
||||
let result: wchar_t = (*ps).mbs_wch as wchar_t;
|
||||
|
||||
if !pwc.is_null() {
|
||||
*pwc = result;
|
||||
}
|
||||
|
||||
(*ps).mbs_length = 0;
|
||||
(*ps).mbs_wch = 0;
|
||||
|
||||
return if result != 0 { i } else { 0 };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mbsrtowcs(
|
||||
dst: *mut wchar_t,
|
||||
src: *mut *const c_char,
|
||||
len: usize,
|
||||
ps: *mut mbstate_t,
|
||||
) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn putwchar(wc: wchar_t) -> wint_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn towlower(wc: wint_t) -> wint_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn towupper(wc: wint_t) -> wint_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcrtomb(s: *mut c_char, wc: wchar_t, ps: *mut mbstate_t) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcscat(ws1: *mut wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcschr(ws1: *const wchar_t, ws2: wchar_t) -> *mut c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcscmp(ws1: *const wchar_t, ws2: *const wchar_t) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcscoll(ws1: *const wchar_t, ws2: *const wchar_t) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcscpy(ws1: *mut wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcscspn(ws1: *const wchar_t, ws2: *const wchar_t) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsftime(
|
||||
wcs: *mut wchar_t,
|
||||
maxsize: usize,
|
||||
format: *const wchar_t,
|
||||
timptr: *mut tm,
|
||||
) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcslen(ws: *const wchar_t) -> c_ulong {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsncat(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsncmp(ws1: *const wchar_t, ws2: *const wchar_t, n: usize) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsncpy(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcspbrk(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsrchr(ws1: *const wchar_t, ws2: wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsrtombs(
|
||||
dst: *mut c_char,
|
||||
src: *mut *const wchar_t,
|
||||
len: usize,
|
||||
ps: *mut mbstate_t,
|
||||
) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsspn(ws1: *const wchar_t, ws2: *const wchar_t) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsstr(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstod(nptr: *const wchar_t, endptr: *mut *mut wchar_t) -> f64 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstok(
|
||||
ws1: *mut wchar_t,
|
||||
ws2: *const wchar_t,
|
||||
ptr: *mut *mut wchar_t,
|
||||
) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstol(nptr: *const wchar_t, endptr: *mut *mut wchar_t, base: c_int) -> c_long {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstoul(nptr: *const wchar_t, endptr: *mut *mut wchar_t, base: c_int) -> c_ulong {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcswcs(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcswidth(pwcs: *const wchar_t, n: usize) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsxfrm(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wctob(c: wint_t) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcwidth(wc: wchar_t) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wmemchr(ws: *const wchar_t, wc: wchar_t, n: usize) -> *mut c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wmemcmp(ws1: *const wchar_t, ws2: *const wchar_t, n: usize) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wmemcpy(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wmemmove(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wmemset(ws1: *mut wchar_t, ws2: wchar_t, n: usize) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
/*.out
|
||||
/gen/
|
||||
/alloc
|
||||
/assert
|
||||
/args
|
||||
/atof
|
||||
/atoi
|
||||
@@ -14,8 +15,9 @@
|
||||
/fcntl
|
||||
/fsync
|
||||
/ftruncate
|
||||
/getid
|
||||
/getc_unget
|
||||
/gethostname
|
||||
/getid
|
||||
/link
|
||||
/locale
|
||||
/math
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Binaries that should generate the same output every time
|
||||
EXPECT_BINS=\
|
||||
assert \
|
||||
atof \
|
||||
atoi \
|
||||
brk \
|
||||
@@ -57,6 +58,7 @@ BINS=\
|
||||
$(EXPECT_BINS) \
|
||||
alloc \
|
||||
chdir \
|
||||
gethostname \
|
||||
getid \
|
||||
setid
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
assert(1 == 1);
|
||||
assert(1 + 1 == 2);
|
||||
|
||||
puts("yay!");
|
||||
|
||||
//This fails, but I can't test it because that'd
|
||||
//make the test fail lol
|
||||
//assert(42 == 1337);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
yay!
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
char* hostname = malloc(256);
|
||||
if (gethostname(hostname, 256) == 0) {
|
||||
printf("Hostname: %s\n", hostname);
|
||||
} else {
|
||||
puts("error getting hostname");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user