WIP: Define common types

This commit is contained in:
Jeremy Soller
2018-03-03 10:08:16 -07:00
parent d337caafe6
commit a9aae80ae0
14 changed files with 117 additions and 6 deletions
+4
View File
@@ -0,0 +1,4 @@
[package]
name = "common"
version = "0.1.0"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
+60
View File
@@ -0,0 +1,60 @@
//! 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;
+1 -1
View File
@@ -8,4 +8,4 @@ build = "build.rs"
cbindgen = "0.5"
[dependencies]
libc = { version = "0.2", default-features = false }
common = { path = "../common" }
+2 -2
View File
@@ -2,9 +2,9 @@
#![no_std]
extern crate libc;
extern crate common;
use libc::*;
pub use common::*;
pub const F_DUPFD: c_int = 0;
pub const F_GETFD: c_int = 1;
View File
+7
View File
@@ -0,0 +1,7 @@
#ifndef _STDINT_H
#define _STDINT_H
typedef int int32_t;
typedef int intptr_t;
#endif /* _STDINT_H */
+6
View File
@@ -0,0 +1,6 @@
#ifndef _STDLIB_H
#define _STDLIB_H
#include <sys/types.h>
#endif /* _STDLIB_H */
+16
View File
@@ -0,0 +1,16 @@
#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 */
+7
View File
@@ -1,7 +1,14 @@
#![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 {}
}
+1
View File
@@ -0,0 +1 @@
/write
+5
View File
@@ -0,0 +1,5 @@
write: write.c
gcc -nostdinc -nostdlib -I ../include -I ../target/include $< ../target/debug/libc.a -o $@
clean:
rm -f write
+5
View File
@@ -0,0 +1,5 @@
#include <unistd.h>
void _start(void) {
write(STDOUT_FILENO, "Hello World!\n", 14);
}
+1 -1
View File
@@ -8,4 +8,4 @@ build = "build.rs"
cbindgen = "0.5"
[dependencies]
libc = { version = "0.2", default-features = false }
common = { path = "../common" }
+2 -2
View File
@@ -2,9 +2,9 @@
#![no_std]
extern crate libc;
extern crate common;
use libc::*;
pub use common::*;
pub const NULL: c_int = 0;