aboutsummaryrefslogtreecommitdiff
path: root/ctr-libc/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ctr-libc/src/lib.rs')
-rw-r--r--ctr-libc/src/lib.rs177
1 files changed, 177 insertions, 0 deletions
diff --git a/ctr-libc/src/lib.rs b/ctr-libc/src/lib.rs
new file mode 100644
index 0000000..50ead9d
--- /dev/null
+++ b/ctr-libc/src/lib.rs
@@ -0,0 +1,177 @@
+// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![allow(bad_style, overflowing_literals, improper_ctypes, non_camel_case_types)]
+
+#![no_std]
+
+mod constants;
+mod functions;
+pub use constants::*;
+pub use functions::*;
+
+#[link(name = "c")]
+#[link(name = "m")]
+extern {}
+
+#[repr(u8)]
+pub enum c_void {
+ __variant1,
+ __variant2,
+}
+
+// char is u8 on ARM
+pub type c_char = u8;
+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;
+
+// 4 bytes on ARM
+pub type c_long = i32;
+pub type c_ulong = u32;
+
+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;
+
+// devkitARM says wchar_t is 4 bytes. Nintendo's API says it's 2 bytes.
+// hope you never have to interact between the two...
+pub type wchar_t = c_int;
+
+pub type int8_t = i8;
+pub type uint8_t = u8;
+pub type int16_t = i16;
+pub type uint16_t = u16;
+pub type int32_t = i32;
+pub type uint32_t = u32;
+pub type int64_t = i64;
+pub type uint64_t = u64;
+
+pub type time_t = i32;
+pub type clockid_t = c_int;
+pub type mode_t = u32;
+pub type sighandler_t = size_t;
+pub type dev_t = u32;
+pub type nlink_t = u32;
+pub type uid_t = u32;
+pub type gid_t = u32;
+pub type off_t = i64;
+pub type blksize_t = i32;
+pub type blkcnt_t = c_ulong;
+pub type fsblkcnt_t = uint64_t;
+pub type fsfilcnt_t = uint32_t;
+pub type ino_t = u32;
+pub type suseconds_t = i32;
+pub type error_t = c_int;
+
+pub enum timezone {}
+
+pub enum _reent {}
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+#[derive(Debug)]
+pub struct timeval {
+ pub tv_sec: time_t,
+ pub tv_usec: suseconds_t,
+}
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+#[derive(Debug)]
+pub struct timespec {
+ pub tv_sec: time_t,
+ pub tv_nsec: c_long,
+}
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+#[derive(Debug)]
+pub struct itimerspec {
+ pub it_interval: timespec,
+ pub it_value: timespec,
+}
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+#[derive(Debug)]
+pub struct tm {
+ pub tm_sec: c_int,
+ pub tm_min: c_int,
+ pub tm_hour: c_int,
+ pub tm_mday: c_int,
+ pub tm_mon: c_int,
+ pub tm_year: c_int,
+ pub tm_wday: c_int,
+ pub tm_yday: c_int,
+ pub tm_isdst: c_int,
+}
+
+pub enum DIR {}
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+#[derive(Debug)]
+pub struct stat {
+ pub st_dev: dev_t,
+ pub st_ino: ino_t,
+ pub st_mode: mode_t,
+ pub st_nlink: nlink_t,
+ pub st_uid: uid_t,
+ pub st_gid: gid_t,
+ pub st_rdev: dev_t,
+ pub st_size: off_t,
+ pub st_atime: time_t,
+ pub st_spare1: c_long,
+ pub st_mtime: time_t,
+ pub st_spare2: c_long,
+ pub st_ctime: time_t,
+ pub st_spare3: c_long,
+ pub st_blksize: blksize_t,
+ pub st_blocks: blkcnt_t,
+ pub st_spare4: [c_long; 2usize],
+}
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+#[derive(Debug)]
+pub struct statvfs {
+ pub f_bsize: c_ulong,
+ pub f_frsize: c_ulong,
+ pub f_blocks: fsblkcnt_t,
+ pub f_bfree: fsblkcnt_t,
+ pub f_bavail: fsblkcnt_t,
+ pub f_files: fsfilcnt_t,
+ pub f_ffree: fsfilcnt_t,
+ pub f_favail: fsfilcnt_t,
+ pub f_fsid: c_ulong,
+ pub f_flag: c_ulong,
+ pub f_namemax: c_ulong,
+}
+
+#[repr(C)]
+#[derive(Copy)]
+pub struct dirent {
+ pub d_ino: ino_t,
+ pub d_type: c_uchar,
+ pub d_name: [c_char; 256usize],
+}
+impl Clone for dirent {
+ fn clone(&self) -> Self { *self }
+}