Skip to content

Commit 07e57b2

Browse files
committed
hurd: Fix C API interface completion
c72c68c ("hurd: Complete C API interface") was actually missing a few fixes.
1 parent 90cb774 commit 07e57b2

File tree

1 file changed

+211
-15
lines changed

1 file changed

+211
-15
lines changed

src/unix/hurd/mod.rs

+211-15
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ pub type pthread_key_t = __pthread_key;
164164
pub type pthread_once_t = __pthread_once;
165165

166166
pub type __rlimit_resource = ::c_uint;
167+
pub type __rlimit_resource_t = __rlimit_resource;
167168
pub type rlim_t = __rlim_t;
168169
pub type rlim64_t = __rlim64_t;
169170

@@ -215,10 +216,34 @@ pub type tcp_ca_state = ::c_uint;
215216

216217
pub type idtype_t = ::c_uint;
217218

219+
pub type mqd_t = ::c_int;
220+
221+
pub type Lmid_t = ::c_long;
222+
218223
pub type regoff_t = ::c_int;
219224

225+
pub type nl_item = ::c_int;
226+
220227
pub type iconv_t = *mut ::c_void;
221228

229+
#[cfg_attr(feature = "extra_traits", derive(Debug))]
230+
pub enum fpos64_t {} // FIXME: fill this out with a struct
231+
impl ::Copy for fpos64_t {}
232+
impl ::Clone for fpos64_t {
233+
fn clone(&self) -> fpos64_t {
234+
*self
235+
}
236+
}
237+
238+
#[cfg_attr(feature = "extra_traits", derive(Debug))]
239+
pub enum timezone {}
240+
impl ::Copy for timezone {}
241+
impl ::Clone for timezone {
242+
fn clone(&self) -> timezone {
243+
*self
244+
}
245+
}
246+
222247
// structs
223248
s! {
224249
pub struct ip_mreq {
@@ -431,7 +456,7 @@ s! {
431456

432457
pub struct stat {
433458
pub st_fstype: ::c_int,
434-
pub st_fsid: __fsid_t,
459+
pub st_dev: __fsid_t, /* Actually st_fsid */
435460
pub st_ino: __ino_t,
436461
pub st_gen: ::c_uint,
437462
pub st_rdev: __dev_t,
@@ -583,6 +608,18 @@ s! {
583608
__glibc_reserved: [::c_char; 32]
584609
}
585610

611+
pub struct mq_attr {
612+
pub mq_flags: ::c_long,
613+
pub mq_maxmsg: ::c_long,
614+
pub mq_msgsize: ::c_long,
615+
pub mq_curmsgs: ::c_long,
616+
}
617+
618+
pub struct __exit_status {
619+
pub e_termination: ::c_short,
620+
pub e_exit: ::c_short,
621+
}
622+
586623
#[cfg_attr(target_pointer_width = "32",
587624
repr(align(4)))]
588625
#[cfg_attr(target_pointer_width = "64",
@@ -998,6 +1035,96 @@ s! {
9981035

9991036
}
10001037

1038+
s_no_extra_traits! {
1039+
pub struct utmpx {
1040+
pub ut_type: ::c_short,
1041+
pub ut_pid: ::pid_t,
1042+
pub ut_line: [::c_char; __UT_LINESIZE],
1043+
pub ut_id: [::c_char; 4],
1044+
1045+
pub ut_user: [::c_char; __UT_NAMESIZE],
1046+
pub ut_host: [::c_char; __UT_HOSTSIZE],
1047+
pub ut_exit: __exit_status,
1048+
1049+
#[cfg(any( all(target_pointer_width = "32",
1050+
not(target_arch = "x86_64"))))]
1051+
pub ut_session: ::c_long,
1052+
#[cfg(any(all(target_pointer_width = "32",
1053+
not(target_arch = "x86_64"))))]
1054+
pub ut_tv: ::timeval,
1055+
1056+
#[cfg(not(any(all(target_pointer_width = "32",
1057+
not(target_arch = "x86_64")))))]
1058+
pub ut_session: i32,
1059+
#[cfg(not(any(all(target_pointer_width = "32",
1060+
not(target_arch = "x86_64")))))]
1061+
pub ut_tv: __timeval,
1062+
1063+
pub ut_addr_v6: [i32; 4],
1064+
__glibc_reserved: [::c_char; 20],
1065+
}
1066+
}
1067+
1068+
cfg_if! {
1069+
if #[cfg(feature = "extra_traits")] {
1070+
impl PartialEq for utmpx {
1071+
fn eq(&self, other: &utmpx) -> bool {
1072+
self.ut_type == other.ut_type
1073+
&& self.ut_pid == other.ut_pid
1074+
&& self.ut_line == other.ut_line
1075+
&& self.ut_id == other.ut_id
1076+
&& self.ut_user == other.ut_user
1077+
&& self
1078+
.ut_host
1079+
.iter()
1080+
.zip(other.ut_host.iter())
1081+
.all(|(a,b)| a == b)
1082+
&& self.ut_exit == other.ut_exit
1083+
&& self.ut_session == other.ut_session
1084+
&& self.ut_tv == other.ut_tv
1085+
&& self.ut_addr_v6 == other.ut_addr_v6
1086+
&& self.__glibc_reserved == other.__glibc_reserved
1087+
}
1088+
}
1089+
1090+
impl Eq for utmpx {}
1091+
1092+
impl ::fmt::Debug for utmpx {
1093+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1094+
f.debug_struct("utmpx")
1095+
.field("ut_type", &self.ut_type)
1096+
.field("ut_pid", &self.ut_pid)
1097+
.field("ut_line", &self.ut_line)
1098+
.field("ut_id", &self.ut_id)
1099+
.field("ut_user", &self.ut_user)
1100+
// FIXME: .field("ut_host", &self.ut_host)
1101+
.field("ut_exit", &self.ut_exit)
1102+
.field("ut_session", &self.ut_session)
1103+
.field("ut_tv", &self.ut_tv)
1104+
.field("ut_addr_v6", &self.ut_addr_v6)
1105+
.field("__glibc_reserved", &self.__glibc_reserved)
1106+
.finish()
1107+
}
1108+
}
1109+
1110+
impl ::hash::Hash for utmpx {
1111+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
1112+
self.ut_type.hash(state);
1113+
self.ut_pid.hash(state);
1114+
self.ut_line.hash(state);
1115+
self.ut_id.hash(state);
1116+
self.ut_user.hash(state);
1117+
self.ut_host.hash(state);
1118+
self.ut_exit.hash(state);
1119+
self.ut_session.hash(state);
1120+
self.ut_tv.hash(state);
1121+
self.ut_addr_v6.hash(state);
1122+
self.__glibc_reserved.hash(state);
1123+
}
1124+
}
1125+
}
1126+
}
1127+
10011128
impl siginfo_t {
10021129
pub unsafe fn si_addr(&self) -> *mut ::c_void {
10031130
self.si_addr
@@ -1310,7 +1437,10 @@ pub const INET_ADDRSTRLEN: usize = 16;
13101437
pub const INET6_ADDRSTRLEN: usize = 46;
13111438

13121439
// netinet/ip.h
1313-
pub const IPTOS_ECN_MASK: u8 = 0x03;
1440+
pub const IPTOS_TOS_MASK: u8 = 0x1E;
1441+
pub const IPTOS_PREC_MASK: u8 = 0xE0;
1442+
1443+
pub const IPTOS_ECN_NOT_ECT: u8 = 0x00;
13141444

13151445
pub const IPTOS_LOWDELAY: u8 = 0x10;
13161446
pub const IPTOS_THROUGHPUT: u8 = 0x08;
@@ -1372,6 +1502,12 @@ pub const ARPOP_InREQUEST: u16 = 8;
13721502
pub const ARPOP_InREPLY: u16 = 9;
13731503
pub const ARPOP_NAK: u16 = 10;
13741504

1505+
pub const MAX_ADDR_LEN: usize = 7;
1506+
pub const ARPD_UPDATE: ::c_ushort = 0x01;
1507+
pub const ARPD_LOOKUP: ::c_ushort = 0x02;
1508+
pub const ARPD_FLUSH: ::c_ushort = 0x03;
1509+
pub const ATF_MAGIC: ::c_int = 0x80;
1510+
13751511
pub const ATF_NETMASK: ::c_int = 0x20;
13761512
pub const ATF_DONTPUB: ::c_int = 0x40;
13771513

@@ -1598,6 +1734,71 @@ pub const LC_MEASUREMENT_MASK: ::c_int = 2048;
15981734
pub const LC_IDENTIFICATION_MASK: ::c_int = 4096;
15991735
pub const LC_ALL_MASK: ::c_int = 8127;
16001736

1737+
pub const ABDAY_1: ::nl_item = 0x20000;
1738+
pub const ABDAY_2: ::nl_item = 0x20001;
1739+
pub const ABDAY_3: ::nl_item = 0x20002;
1740+
pub const ABDAY_4: ::nl_item = 0x20003;
1741+
pub const ABDAY_5: ::nl_item = 0x20004;
1742+
pub const ABDAY_6: ::nl_item = 0x20005;
1743+
pub const ABDAY_7: ::nl_item = 0x20006;
1744+
1745+
pub const DAY_1: ::nl_item = 0x20007;
1746+
pub const DAY_2: ::nl_item = 0x20008;
1747+
pub const DAY_3: ::nl_item = 0x20009;
1748+
pub const DAY_4: ::nl_item = 0x2000A;
1749+
pub const DAY_5: ::nl_item = 0x2000B;
1750+
pub const DAY_6: ::nl_item = 0x2000C;
1751+
pub const DAY_7: ::nl_item = 0x2000D;
1752+
1753+
pub const ABMON_1: ::nl_item = 0x2000E;
1754+
pub const ABMON_2: ::nl_item = 0x2000F;
1755+
pub const ABMON_3: ::nl_item = 0x20010;
1756+
pub const ABMON_4: ::nl_item = 0x20011;
1757+
pub const ABMON_5: ::nl_item = 0x20012;
1758+
pub const ABMON_6: ::nl_item = 0x20013;
1759+
pub const ABMON_7: ::nl_item = 0x20014;
1760+
pub const ABMON_8: ::nl_item = 0x20015;
1761+
pub const ABMON_9: ::nl_item = 0x20016;
1762+
pub const ABMON_10: ::nl_item = 0x20017;
1763+
pub const ABMON_11: ::nl_item = 0x20018;
1764+
pub const ABMON_12: ::nl_item = 0x20019;
1765+
1766+
pub const MON_1: ::nl_item = 0x2001A;
1767+
pub const MON_2: ::nl_item = 0x2001B;
1768+
pub const MON_3: ::nl_item = 0x2001C;
1769+
pub const MON_4: ::nl_item = 0x2001D;
1770+
pub const MON_5: ::nl_item = 0x2001E;
1771+
pub const MON_6: ::nl_item = 0x2001F;
1772+
pub const MON_7: ::nl_item = 0x20020;
1773+
pub const MON_8: ::nl_item = 0x20021;
1774+
pub const MON_9: ::nl_item = 0x20022;
1775+
pub const MON_10: ::nl_item = 0x20023;
1776+
pub const MON_11: ::nl_item = 0x20024;
1777+
pub const MON_12: ::nl_item = 0x20025;
1778+
1779+
pub const AM_STR: ::nl_item = 0x20026;
1780+
pub const PM_STR: ::nl_item = 0x20027;
1781+
1782+
pub const D_T_FMT: ::nl_item = 0x20028;
1783+
pub const D_FMT: ::nl_item = 0x20029;
1784+
pub const T_FMT: ::nl_item = 0x2002A;
1785+
pub const T_FMT_AMPM: ::nl_item = 0x2002B;
1786+
1787+
pub const ERA: ::nl_item = 0x2002C;
1788+
pub const ERA_D_FMT: ::nl_item = 0x2002E;
1789+
pub const ALT_DIGITS: ::nl_item = 0x2002F;
1790+
pub const ERA_D_T_FMT: ::nl_item = 0x20030;
1791+
pub const ERA_T_FMT: ::nl_item = 0x20031;
1792+
1793+
pub const CODESET: ::nl_item = 14;
1794+
pub const CRNCYSTR: ::nl_item = 0x4000F;
1795+
pub const RADIXCHAR: ::nl_item = 0x10000;
1796+
pub const THOUSEP: ::nl_item = 0x10001;
1797+
pub const YESEXPR: ::nl_item = 0x50000;
1798+
pub const NOEXPR: ::nl_item = 0x50001;
1799+
pub const YESSTR: ::nl_item = 0x50002;
1800+
pub const NOSTR: ::nl_item = 0x50003;
1801+
16011802
// reboot.h
16021803
pub const RB_AUTOBOOT: ::c_int = 0x0;
16031804
pub const RB_ASKNAME: ::c_int = 0x1;
@@ -1785,6 +1986,7 @@ pub const CBRK: u8 = 0u8;
17851986

17861987
// dlfcn.h
17871988
pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
1989+
pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
17881990
pub const RTLD_LAZY: ::c_int = 1;
17891991
pub const RTLD_NOW: ::c_int = 2;
17901992
pub const RTLD_BINDING_MASK: ::c_int = 3;
@@ -2942,6 +3144,10 @@ pub const PRIO_PROCESS: __priority_which = 0;
29423144
pub const PRIO_PGRP: __priority_which = 1;
29433145
pub const PRIO_USER: __priority_which = 2;
29443146

3147+
pub const __UT_LINESIZE: usize = 32;
3148+
pub const __UT_NAMESIZE: usize = 32;
3149+
pub const __UT_HOSTSIZE: usize = 256;
3150+
29453151
pub const SOCK_STREAM: ::c_int = 1;
29463152
pub const SOCK_DGRAM: ::c_int = 2;
29473153
pub const SOCK_RAW: ::c_int = 3;
@@ -3079,11 +3285,6 @@ pub const RTLD_DI_TLS_DATA: ::c_int = 10;
30793285
pub const RTLD_DI_PHDR: ::c_int = 11;
30803286
pub const RTLD_DI_MAX: ::c_int = 11;
30813287

3082-
pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
3083-
pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
3084-
pub const RTLD_NODELETE: ::c_int = 0x1000;
3085-
pub const RTLD_NOW: ::c_int = 0x2;
3086-
30873288
pub const SI_ASYNCIO: ::c_int = -4;
30883289
pub const SI_MESGQ: ::c_int = -3;
30893290
pub const SI_TIMER: ::c_int = -2;
@@ -3262,12 +3463,12 @@ f! {
32623463
return 0 as *mut cmsghdr;
32633464
};
32643465
let next = (cmsg as usize +
3265-
super::CMSG_ALIGN((*cmsg).cmsg_len as usize))
3466+
CMSG_ALIGN((*cmsg).cmsg_len as usize))
32663467
as *mut cmsghdr;
32673468
let max = (*mhdr).msg_control as usize
32683469
+ (*mhdr).msg_controllen as usize;
32693470
if (next.offset(1)) as usize > max ||
3270-
next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max
3471+
next as usize + CMSG_ALIGN((*next).cmsg_len as usize) > max
32713472
{
32723473
0 as *mut cmsghdr
32733474
} else {
@@ -3756,19 +3957,14 @@ extern "C" {
37563957
__attr: *const pthread_attr_t,
37573958
__guardsize: *mut ::size_t,
37583959
) -> ::c_int;
3960+
pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int;
37593961

37603962
pub fn pthread_attr_getstack(
37613963
__attr: *const pthread_attr_t,
37623964
__stackaddr: *mut *mut ::c_void,
37633965
__stacksize: *mut ::size_t,
37643966
) -> ::c_int;
37653967

3766-
pub fn pthread_attr_getguardsize(
3767-
attr: *const ::pthread_attr_t,
3768-
guardsize: *mut ::size_t,
3769-
) -> ::c_int;
3770-
pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int;
3771-
37723968
pub fn pthread_mutexattr_getpshared(
37733969
attr: *const pthread_mutexattr_t,
37743970
pshared: *mut ::c_int,

0 commit comments

Comments
 (0)