Skip to content
Snippets Groups Projects
Commit 457d3972 authored by Paul Sajna's avatar Paul Sajna
Browse files

merge with origin, put unistd back the way it was

parents 1a298045 9fb0b77d
No related branches found
No related tags found
No related merge requests found
File moved
[submodule "openlibm"] [submodule "openlibm"]
path = openlibm path = openlibm
url = https://github.com/redox-os/openlibm.git url = https://github.com/redox-os/openlibm.git
[submodule "cbindgen"]
path = cbindgen
url = https://github.com/redox-os/cbindgen.git
[package]
name = "relibc"
version = "0.1.0"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
[lib]
name = "c"
crate-type = ["staticlib"]
[workspace]
[dependencies]
fcntl = { path = "fcntl" }
unistd = { path = "unistd" }
[profile.dev]
incremental = false
lto = true
panic = "abort"
[profile.release]
incremental = false
lto = true
panic = "abort"
Subproject commit 97ceb5862f397b14c5b63cd60af7f5f345ad065c
[package]
name = "common"
version = "0.1.0"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
//! fcntl implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.h.html
#![no_std]
#![allow(non_camel_case_types)]
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
// more optimization opportunities around it recognizing things like
// malloc/free.
#[repr(u8)]
pub enum c_void {
// Two dummy variants so the #[repr] attribute can be used.
#[doc(hidden)]
__variant1,
#[doc(hidden)]
__variant2,
}
pub type int8_t = i8;
pub type int16_t = i16;
pub type int32_t = i32;
pub type int64_t = i64;
pub type uint8_t = u8;
pub type uint16_t = u16;
pub type uint32_t = u32;
pub type uint64_t = u64;
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
pub type c_ushort = u16;
pub type c_int = i32;
pub type c_uint = u32;
pub type c_float = f32;
pub type c_double = f64;
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type intmax_t = i64;
pub type uintmax_t = u64;
pub type size_t = usize;
pub type ptrdiff_t = isize;
pub type intptr_t = isize;
pub type uintptr_t = usize;
pub type ssize_t = isize;
pub type c_char = i8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type wchar_t = i16;
pub type off_t = c_long;
pub type mode_t = u16;
pub type time_t = i64;
pub type pid_t = usize;
pub type gid_t = usize;
pub type uid_t = usize;
pub type useconds_t = i32;
pub type suseconds_t = i64;
[package]
name = "fcntl"
version = "0.1.0"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
build = "build.rs"
[build-dependencies]
cbindgen = { path = "../cbindgen" }
[dependencies]
common = { path = "../common" }
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/fcntl.h");
}
sys_includes = ["sys/types.h"]
include_guard = "_FCNTL_H"
language = "C"
[enum]
prefix_with_name = true
//! fcntl implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.h.html
#![no_std]
extern crate common;
pub use common::*;
pub const F_DUPFD: c_int = 0;
pub const F_GETFD: c_int = 1;
pub const F_SETFD: c_int = 2;
pub const F_GETFL: c_int = 3;
pub const F_SETFL: c_int = 4;
pub const F_GETLK: c_int = 5;
pub const F_SETLK: c_int = 6;
pub const F_SETLKW: c_int = 7;
pub const FD_CLOEXEC: c_int = 0x0100_0000;
pub const F_RDLCK: c_int = 0;
pub const F_WRLCK: c_int = 1;
pub const F_UNLCK: c_int = 2;
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;
#[no_mangle]
pub extern "C" fn creat(path: *const c_char, mode: mode_t) -> c_int {
open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)
}
#[no_mangle]
pub extern "C" fn fcntl(fildes: c_int, cmd: c_int, arg: c_int) -> c_int {
unimplemented!();
}
#[no_mangle]
pub extern "C" fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
unimplemented!();
}
/*
#[no_mangle]
pub extern "C" fn func(args) -> c_int {
unimplemented!();
}
*/
#ifndef _STDBOOL_H
#define _STDBOOL_H
typedef _Bool bool;
#define true 1
#define false 0
#define __bool_true_false_are_defined 1
#endif /* _STDBOOL_H */
#ifndef _STDINT_H
#define _STDINT_H
#define INT8_MIN -0x80
#define INT8_MAX 0x7F
typedef signed char int8_t;
#define UINT8_MIN 0x00
#define UINT8_MAX 0xFF
typedef unsigned char uint8_t;
#define INT16_MIN -0x8000
#define INT16_MAX 0x7FFF
typedef signed short int16_t;
#define UINT16_MIN 0x0000
#define UINT16_MAX 0xFFFF
typedef unsigned short uint16_t;
#define INT32_MIN -0x80000000
#define INT32_MAX 0x7FFFFFFF
typedef signed long int32_t;
#define UINT32_MIN 0x00000000
#define UINT32_MAX 0xFFFFFFFF
typedef unsigned long uint32_t;
#define INT64_MIN -0x8000000000000000
#define INT64_MAX 0x7FFFFFFFFFFFFFFF
typedef signed long long int64_t;
#define UINT64_MIN 0x0000000000000000
#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
typedef unsigned long long uint64_t;
#define INTPTR_MIN INT64_MIN
#define INTPTR_MAX INT64_MAX
typedef int64_t intptr_t;
#define UINTPTR_MIN UINT64_MIN
#define UINTPTR_MAX UINT64_MAX
typedef uint64_t uintptr_t;
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
typedef int64_t intmax_t;
#define UINTMAX_MIN UINT64_MIN
#define UINTMAX_MAX UINT64_MAX
typedef uint64_t uintmax_t;
#endif /* _STDINT_H */
#ifndef _SYS_TYPES_H
#define _SYS_TYPES_H
typedef int gid_t;
typedef int uid_t;
typedef long off_t;
typedef int pid_t;
typedef unsigned long size_t;
typedef long ssize_t;
typedef int useconds_t;
#endif /* _SYS_TYPES_H */
#![no_std]
#![feature(lang_items)]
extern crate fcntl;
extern crate unistd;
pub use fcntl::*;
pub use unistd::*;
#[lang = "panic_fmt"]
#[no_mangle]
pub extern "C" fn rust_begin_unwind(fmt: ::core::fmt::Arguments, file: &str, line: u32) -> ! {
loop {}
}
/write
write: write.c
gcc -nostdinc -nostdlib -I ../include -I ../target/include $< ../target/debug/libc.a -o $@
clean:
rm -f write
#include <unistd.h>
void _start(void) {
write(STDOUT_FILENO, "Hello World!\n", 14);
}
...@@ -2,13 +2,10 @@ ...@@ -2,13 +2,10 @@
name = "unistd" name = "unistd"
version = "0.1.0" version = "0.1.0"
authors = ["Jeremy Soller <jackpot51@gmail.com>"] authors = ["Jeremy Soller <jackpot51@gmail.com>"]
build = "build.rs"
[lib]
name = "unistd"
crate-type = ["cdylib"]
[build-dependencies] [build-dependencies]
cbindgen = "0.5" cbindgen = { path = "../cbindgen" }
[dependencies] [dependencies]
libc = "0.2" common = { path = "../common" }
extern crate cbindgen; extern crate cbindgen;
use std::env; use std::{env, fs};
fn main() { fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); 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) cbindgen::generate(crate_dir)
.expect("Unable to generate bindings") .expect("failed to generate bindings")
.write_to_file("target/unistd.h"); .write_to_file("../target/include/unistd.h");
} }
sys_includes = ["stdint.h", "sys/types.h"]
include_guard = "_UNISTD_H" include_guard = "_UNISTD_H"
language = "C" language = "C"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment