summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Soller <jackpot51@gmail.com>2016-11-03 16:53:22 -0600
committerJeremy Soller <jackpot51@gmail.com>2016-11-03 16:53:22 -0600
commit4ddaf1f4c1675785cc8cc66c9ce7e5f7e7745789 (patch)
treed07ad65915ce1e212d5580224e512ef8d9e3e14b
parent15950baa0afd0a632e71b08f16094ae040bc2a51 (diff)
downloadrust-libc-4ddaf1f4c1675785cc8cc66c9ce7e5f7e7745789.tar.gz
Minimal liblibc for Redox
-rw-r--r--src/lib.rs3
-rw-r--r--src/redox.rs57
2 files changed, 60 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index dcc4791f9a..2a16fad0e3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -265,6 +265,9 @@ cfg_if! {
if #[cfg(windows)] {
mod windows;
pub use windows::*;
+ } else if #[cfg(redox)] {
+ mod redox;
+ pub use redox::*;
} else if #[cfg(unix)] {
mod unix;
pub use unix::*;
diff --git a/src/redox.rs b/src/redox.rs
new file mode 100644
index 0000000000..09b07da562
--- /dev/null
+++ b/src/redox.rs
@@ -0,0 +1,57 @@
+pub type c_char = i8;
+pub type c_long = i64;
+pub type c_ulong = u64;
+
+pub type wchar_t = i16;
+
+pub type off_t = usize;
+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 in_addr_t = u32;
+pub type in_port_t = u16;
+
+pub type socklen_t = u32;
+pub type sa_family_t = u16;
+
+#[derive(Copy, Clone)]
+#[repr(C)]
+pub struct in_addr {
+ pub s_addr: in_addr_t,
+}
+
+#[derive(Copy, Clone)]
+#[repr(C)]
+pub struct in6_addr {
+ pub s6_addr: [u8; 16],
+ __align: [u32; 0],
+}
+
+#[derive(Copy, Clone)]
+#[repr(C)]
+pub struct sockaddr {
+ pub sa_family: sa_family_t,
+ pub sa_data: [::c_char; 14],
+}
+
+#[derive(Copy, Clone)]
+#[repr(C)]
+pub struct sockaddr_in {
+ pub sin_family: sa_family_t,
+ pub sin_port: ::in_port_t,
+ pub sin_addr: ::in_addr,
+ pub sin_zero: [u8; 8],
+}
+
+#[derive(Copy, Clone)]
+#[repr(C)]
+pub struct sockaddr_in6 {
+ pub sin6_family: sa_family_t,
+ pub sin6_port: in_port_t,
+ pub sin6_flowinfo: u32,
+ pub sin6_addr: ::in6_addr,
+ pub sin6_scope_id: u32,
+}