Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.2: Backport c_char fixes #4203

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,6 @@ fn test_dragonflybsd(target: &str) {
match ty {
// sighandler_t is crazy across platforms
"sighandler_t" => true,

_ => false,
}
});
Expand Down Expand Up @@ -4002,7 +4001,7 @@ fn test_linux(target: &str) {
}
// FIXME: Requires >= 5.4 kernel headers
if name == "PTP_CLOCK_GETCAPS2"
|| name == "PTP_ENABLE_PPS2"
|| name == "PTP_ENABLE_PPS2"
|| name == "PTP_EXTTS_REQUEST2"
|| name == "PTP_PEROUT_REQUEST2"
|| name == "PTP_PIN_GETFUNC2"
Expand Down
1 change: 0 additions & 1 deletion src/fuchsia/aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::off_t;
use crate::prelude::*;

pub type c_char = u8;
pub type __u64 = c_ulonglong;
pub type wchar_t = u32;
pub type nlink_t = c_ulong;
Expand Down
1 change: 0 additions & 1 deletion src/fuchsia/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::off_t;
use crate::prelude::*;

// From psABI Calling Convention for RV64
pub type c_char = u8;
pub type __u64 = c_ulonglong;
pub type wchar_t = i32;

Expand Down
1 change: 0 additions & 1 deletion src/fuchsia/x86_64.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::off_t;
use crate::prelude::*;

pub type c_char = i8;
pub type wchar_t = i32;
pub type nlink_t = u64;
pub type blksize_t = c_long;
Expand Down
8 changes: 0 additions & 8 deletions src/hermit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

use crate::prelude::*;

cfg_if! {
if #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] {
pub type c_char = u8;
} else {
pub type c_char = i8;
}
}

pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
Expand Down
32 changes: 32 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,38 @@ cfg_if! {

pub use core::ffi::c_void;

cfg_if! {
// This configuration comes from `rust-lang/rust` in `library/core/src/ffi/mod.rs`.
if #[cfg(all(
not(windows),
// FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it
not(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos",
)),
any(
target_arch = "aarch64",
target_arch = "arm",
target_arch = "csky",
target_arch = "hexagon",
target_arch = "msp430",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "riscv64",
target_arch = "riscv32",
target_arch = "s390x",
target_arch = "xtensa",
)
))] {
pub type c_char = u8;
} else {
pub type c_char = i8;
}
}

cfg_if! {
if #[cfg(windows)] {
mod fixed_width_ints;
Expand Down
1 change: 0 additions & 1 deletion src/psp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub type intptr_t = isize;
pub type uintptr_t = usize;
pub type ssize_t = isize;

pub type c_char = u8;
pub type c_long = i64;
pub type c_ulong = u64;

Expand Down
1 change: 0 additions & 1 deletion src/sgx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ 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;

Expand Down
1 change: 0 additions & 1 deletion src/solid/aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub type c_char = i8;
pub type wchar_t = u32;
pub type c_long = i64;
pub type c_ulong = u64;
1 change: 0 additions & 1 deletion src/solid/arm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub type c_char = i8;
pub type wchar_t = u32;
pub type c_long = i32;
pub type c_ulong = u32;
1 change: 0 additions & 1 deletion src/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub type uintptr_t = usize;
pub type ssize_t = isize;

pub type off_t = i64;
pub type c_char = u8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type wchar_t = u32;
Expand Down
6 changes: 0 additions & 6 deletions src/teeos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

// only supported on Rust > 1.59, so we can directly reexport c_void from core.
pub use core::ffi::c_void;

use crate::prelude::*;

pub type c_schar = i8;
Expand Down Expand Up @@ -48,9 +45,6 @@ pub type ssize_t = isize;

pub type pid_t = c_int;

// aarch64 specific
pub type c_char = u8;

pub type wchar_t = u32;

pub type c_long = i64;
Expand Down
10 changes: 1 addition & 9 deletions src/trusty.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
pub use core::ffi::c_void;
use crate::prelude::*;

pub type size_t = usize;
pub type ssize_t = isize;

pub type off_t = i64;

cfg_if! {
if #[cfg(any(target_arch = "aarch64", target_arch = "arm"))] {
pub type c_char = u8;
} else if #[cfg(target_arch = "x86_64")] {
pub type c_char = i8;
}
}

pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
Expand Down
1 change: 0 additions & 1 deletion src/unix/aix/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;

pub type c_char = u8;
pub type caddr_t = *mut c_char;
pub type clockid_t = c_longlong;
pub type blkcnt_t = c_long;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use crate::prelude::*;
use crate::{cmsghdr, off_t};

pub type c_char = i8;
pub type wchar_t = i32;
pub type clock_t = c_ulong;
pub type time_t = c_long;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;
use crate::{cmsghdr, off_t};

pub type dev_t = u32;
pub type c_char = i8;
pub type wchar_t = i32;
pub type clock_t = u64;
pub type ino_t = u64;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;

pub type c_char = u8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type clock_t = i32;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/arm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;

pub type c_char = u8;
pub type c_long = i32;
pub type c_ulong = u32;
pub type clock_t = u32;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/powerpc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;

pub type c_char = u8;
pub type c_long = i32;
pub type c_ulong = u32;
pub type clock_t = u32;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/powerpc64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;

pub type c_char = u8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type clock_t = u32;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/riscv64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;

pub type c_char = u8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type clock_t = i32;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/x86.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;

pub type c_char = i8;
pub type c_long = i32;
pub type c_ulong = u32;
pub type clock_t = c_ulong;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;

pub type c_char = i8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type clock_t = i32;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::PT_FIRSTMACH;

pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = u8;
pub type greg_t = u64;
pub type __cpu_simple_lock_nv_t = c_uchar;

Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::PT_FIRSTMACH;

pub type c_long = i32;
pub type c_ulong = u32;
pub type c_char = u8;
pub type __cpu_simple_lock_nv_t = c_int;

pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_longlong>() - 1;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/mips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::PT_FIRSTMACH;

pub type c_long = i32;
pub type c_ulong = u32;
pub type c_char = i8;
pub type __cpu_simple_lock_nv_t = c_int;

pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_longlong>() - 1;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/powerpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::PT_FIRSTMACH;

pub type c_long = i32;
pub type c_ulong = u32;
pub type c_char = u8;
pub type __cpu_simple_lock_nv_t = c_int;

pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_double>() - 1;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::prelude::*;

pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = u8;
pub type __greg_t = u64;
pub type __cpu_simple_lock_nv_t = c_int;
pub type __gregset = [__greg_t; _NGREG];
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/sparc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;

pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = i8;
pub type __cpu_simple_lock_nv_t = c_uchar;

// should be pub(crate), but that requires Rust 1.18.0
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;

pub type c_long = i32;
pub type c_ulong = u32;
pub type c_char = i8;
pub type __cpu_simple_lock_nv_t = c_uchar;

pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_int>() - 1;
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::PT_FIRSTMACH;

pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = i8;
pub type c___greg_t = u64;
pub type __cpu_simple_lock_nv_t = c_uchar;

Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;

pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = u8;
pub type ucontext_t = sigcontext;

s! {
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;

pub type c_long = i32;
pub type c_ulong = u32;
pub type c_char = u8;

pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_double>() - 1;

Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/mips64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = i8;

#[doc(hidden)]
pub const _ALIGNBYTES: usize = 7;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/powerpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;

pub type c_long = i32;
pub type c_ulong = u32;
pub type c_char = u8;

pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_double>() - 1;

Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;

pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = u8;

pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_long>() - 1;

Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;

pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = u8;
pub type ucontext_t = sigcontext;

s! {
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/sparc64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = i8;

#[doc(hidden)]
pub const _ALIGNBYTES: usize = 0xf;
Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::prelude::*;

pub type c_long = i32;
pub type c_ulong = u32;
pub type c_char = i8;

pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_int>() - 1;

Expand Down
1 change: 0 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::PT_FIRSTMACH;

pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = i8;
pub type ucontext_t = sigcontext;

s! {
Expand Down
1 change: 0 additions & 1 deletion src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub type pthread_key_t = c_int;
pub type nfds_t = c_ulong;
pub type tcflag_t = c_uint;
pub type speed_t = c_uchar;
pub type c_char = i8;
pub type clock_t = i32;
pub type clockid_t = i32;
pub type suseconds_t = i32;
Expand Down
2 changes: 0 additions & 2 deletions src/unix/hurd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use crate::c_schar;
use crate::prelude::*;

// types
pub type c_char = i8;

pub type __s16_type = c_short;
pub type __u16_type = c_ushort;
pub type __s32_type = c_int;
Expand Down
1 change: 0 additions & 1 deletion src/unix/linux_like/android/b32/arm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;

pub type c_char = u8;
pub type wchar_t = u32;
pub type greg_t = i32;
pub type mcontext_t = sigcontext;
Expand Down
Loading
Loading