|
| 1 | +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +// libc port for HermitCore (https://hermitcore.org) |
| 12 | +// |
| 13 | +// Ported by Colin Fink <colin.finck@rwth-aachen.de> |
| 14 | +// and Stefan Lankes <slankes@eonerc.rwth-aachen.de> |
| 15 | + |
| 16 | +pub type int8_t = i8; |
| 17 | +pub type int16_t = i16; |
| 18 | +pub type int32_t = i32; |
| 19 | +pub type int64_t = i64; |
| 20 | +pub type uint8_t = u8; |
| 21 | +pub type uint16_t = u16; |
| 22 | +pub type uint32_t = u32; |
| 23 | +pub type uint64_t = u64; |
| 24 | + |
| 25 | +pub type c_schar = i8; |
| 26 | +pub type c_uchar = u8; |
| 27 | +pub type c_short = i16; |
| 28 | +pub type c_ushort = u16; |
| 29 | +pub type c_int = i32; |
| 30 | +pub type c_uint = u32; |
| 31 | +pub type c_float = f32; |
| 32 | +pub type c_double = f64; |
| 33 | +pub type c_longlong = i64; |
| 34 | +pub type c_ulonglong = u64; |
| 35 | +pub type intmax_t = i64; |
| 36 | +pub type uintmax_t = u64; |
| 37 | + |
| 38 | +pub type size_t = usize; |
| 39 | +pub type ptrdiff_t = isize; |
| 40 | +pub type intptr_t = isize; |
| 41 | +pub type uintptr_t = usize; |
| 42 | +pub type ssize_t = isize; |
| 43 | + |
| 44 | +pub type c_long = i64; |
| 45 | +pub type c_ulong = u64; |
| 46 | + |
| 47 | +pub type wint_t = u32; |
| 48 | +pub type wctype_t = i64; |
| 49 | + |
| 50 | +pub type regoff_t = size_t; |
| 51 | +pub type off_t = c_long; |
| 52 | + |
| 53 | +cfg_if! { |
| 54 | + if #[cfg(target_arch = "aarch64")] { |
| 55 | + mod aarch64; |
| 56 | + pub use self::aarch64::*; |
| 57 | + } else if #[cfg(target_arch = "x86_64")] { |
| 58 | + mod x86_64; |
| 59 | + pub use self::x86_64::*; |
| 60 | + } else { |
| 61 | + // Unknown target_arch |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +cfg_if! { |
| 66 | + if #[cfg(libc_core_cvoid)] { |
| 67 | + pub use ::ffi::c_void; |
| 68 | + } else { |
| 69 | + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help |
| 70 | + // enable more optimization opportunities around it recognizing things |
| 71 | + // like malloc/free. |
| 72 | + #[repr(u8)] |
| 73 | + #[allow(missing_copy_implementations)] |
| 74 | + #[allow(missing_debug_implementations)] |
| 75 | + pub enum c_void { |
| 76 | + // Two dummy variants so the #[repr] attribute can be used. |
| 77 | + #[doc(hidden)] |
| 78 | + __variant1, |
| 79 | + #[doc(hidden)] |
| 80 | + __variant2, |
| 81 | + } |
| 82 | + } |
| 83 | +} |
0 commit comments