From 83974be06fa2b572304faa064ef79fe7b6b05277 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Fri, 22 Aug 2014 12:21:30 +0200 Subject: [PATCH] Add repr(C) to c structs --- src/common/c_types.rs | 6 ++++++ src/common/utmpx.rs | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/common/c_types.rs b/src/common/c_types.rs index b75b94303..a2de63100 100644 --- a/src/common/c_types.rs +++ b/src/common/c_types.rs @@ -18,6 +18,7 @@ use std::ptr::{mut_null, read}; use std::string::raw::from_buf; #[cfg(target_os = "macos")] +#[repr(C)] pub struct c_passwd { pub pw_name: *const c_char, /* user name */ pub pw_passwd: *const c_char, /* user name */ @@ -32,6 +33,7 @@ pub struct c_passwd { } #[cfg(target_os = "linux")] +#[repr(C)] pub struct c_passwd { pub pw_name: *const c_char, /* user name */ pub pw_passwd: *const c_char, /* user name */ @@ -43,6 +45,7 @@ pub struct c_passwd { } #[cfg(target_os = "macos")] +#[repr(C)] pub struct utsname { pub sysname: [c_char, ..256], pub nodename: [c_char, ..256], @@ -52,6 +55,7 @@ pub struct utsname { } #[cfg(target_os = "linux")] +#[repr(C)] pub struct utsname { pub sysname: [c_char, ..65], pub nodename: [c_char, ..65], @@ -61,6 +65,7 @@ pub struct utsname { pub domainame: [c_char, ..65] } +#[repr(C)] pub struct c_group { pub gr_name: *const c_char, // group name pub gr_passwd: *const c_char, // password @@ -68,6 +73,7 @@ pub struct c_group { pub gr_mem: *const *const c_char, // member list } +#[repr(C)] pub struct c_tm { pub tm_sec: c_int, /* seconds */ pub tm_min: c_int, /* minutes */ diff --git a/src/common/utmpx.rs b/src/common/utmpx.rs index 536bc8c36..08e96ee90 100644 --- a/src/common/utmpx.rs +++ b/src/common/utmpx.rs @@ -26,11 +26,13 @@ mod utmpx { pub static DEAD_PROCESS: libc::c_short = 8; pub static ACCOUNTING: libc::c_short = 9; + #[repr(C)] pub struct c_exit_status { pub e_termination: libc::c_short, pub e_exit: libc::c_short, } + #[repr(C)] pub struct c_utmp { pub ut_type: libc::c_short, pub ut_pid: libc::pid_t, @@ -70,11 +72,13 @@ mod utmpx { pub static DEAD_PROCESS: libc::c_short = 8; pub static ACCOUNTING: libc::c_short = 9; + #[repr(C)] pub struct c_exit_status { pub e_termination: libc::c_short, pub e_exit: libc::c_short, } + #[repr(C)] pub struct c_utmp { pub ut_user: [libc::c_char, ..UT_NAMESIZE], pub ut_id: [libc::c_char, ..UT_IDSIZE],