Skip to content

Commit f3a43cf

Browse files
Re-organized the QNX support.
As most of the differences are related to the change in network stack half-way through the life of QNX Neutrino 7.1, the definitions are now split into io-pkt (the older stack) and io-sock (the newer stack). I didn't add any architecture definitions for x86 (as would be required for i686-pc-nto-qnx700) because I don't have access to QNX Neutrino 7.0 to verify what should go here. But there's a clear place to add it later. I do have QNX Neutrino 7.1 and QNX OS 8.0 and I have verified each of the types in the io-pkt and io-sock modules against the relevant C header files. I have not verified the remaining types or functions - I assume they are correct.
1 parent a41bc08 commit f3a43cf

8 files changed

Lines changed: 347 additions & 268 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//! Definitions specific to QNX on AArch64
2+
//!
3+
//! This module applies to:
4+
//!
5+
//! * `aarch64-unknown-nto-qnx700`
6+
//! * `aarch64-unknown-nto-qnx710`
7+
//! * `aarch64-unknown-nto-qnx710_iosock`
8+
//! * `aarch64-unknown-nto-qnx800`
9+
110
use crate::prelude::*;
211

312
pub type wchar_t = u32;

src/unix/nto/arch/i686.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! Definitions specific to QNX on x86
2+
//!
3+
//! This module applies to:
4+
//!
5+
//! * `i686-pc-nto-qnx700`
6+
7+
use crate::prelude::*;
8+
9+
pub type wchar_t = u32;
10+
pub type time_t = i64;

src/unix/nto/arch/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//! Architecture-specific definitions for QNX
2+
3+
cfg_if! {
4+
if #[cfg(target_arch = "x86_64")] {
5+
mod x86_64;
6+
pub use self::x86_64::*;
7+
} else if #[cfg(target_arch = "aarch64")] {
8+
mod aarch64;
9+
pub use self::aarch64::*;
10+
} else {
11+
panic!("Unsupported arch");
12+
}
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
//! Definitions specific to QNX on x86-64
2+
//!
3+
//! This module applies to:
4+
//!
5+
//! * `x86_64-pc-nto-qnx710`
6+
//! * `x86_64-pc-nto-qnx710_iosock`
7+
//! * `x86_64-pc-nto-qnx800`
8+
19
use crate::prelude::*;
210

311
pub type wchar_t = u32;

src/unix/nto/io_pkt/mod.rs

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
//! Definitions specific to QNX versions using io-pkt networking
2+
//!
3+
//! This module applies to:
4+
//!
5+
//! * `aarch64-unknown-nto-qnx700`
6+
//! * `i686-pc-nto-qnx700`
7+
//! * `aarch64-unknown-nto-qnx710`
8+
//! * `x86_64-pc-nto-qnx710`
9+
10+
use crate::prelude::*;
11+
12+
s! {
13+
#[repr(packed)]
14+
pub struct in_addr {
15+
pub s_addr: crate::in_addr_t,
16+
}
17+
18+
pub struct sockaddr_in {
19+
pub sin_len: u8,
20+
pub sin_family: crate::sa_family_t,
21+
pub sin_port: crate::in_port_t,
22+
pub sin_addr: crate::in_addr,
23+
pub sin_zero: [i8; 8],
24+
}
25+
26+
pub struct in_pktinfo {
27+
pub ipi_addr: crate::in_addr,
28+
pub ipi_ifindex: c_uint,
29+
}
30+
31+
#[repr(packed)]
32+
pub struct arphdr {
33+
pub ar_hrd: u16,
34+
pub ar_pro: u16,
35+
pub ar_hln: u8,
36+
pub ar_pln: u8,
37+
pub ar_op: u16,
38+
}
39+
40+
pub struct unpcbid {
41+
pub unp_pid: crate::pid_t,
42+
pub unp_euid: crate::uid_t,
43+
pub unp_egid: crate::gid_t,
44+
}
45+
46+
pub struct mmsghdr {
47+
pub msg_hdr: crate::msghdr,
48+
pub msg_len: c_uint,
49+
}
50+
51+
pub struct bpf_stat {
52+
pub bs_recv: u64,
53+
pub bs_drop: u64,
54+
pub bs_capt: u64,
55+
bs_padding: Padding<[u64; 13]>,
56+
}
57+
58+
pub struct sockaddr_dl {
59+
pub sdl_len: c_uchar,
60+
pub sdl_family: crate::sa_family_t,
61+
pub sdl_index: u16,
62+
pub sdl_type: c_uchar,
63+
pub sdl_nlen: c_uchar,
64+
pub sdl_alen: c_uchar,
65+
pub sdl_slen: c_uchar,
66+
pub sdl_data: [c_char; 12],
67+
}
68+
}
69+
70+
pub const SCM_CREDS: c_int = 0x04;
71+
pub const IFF_NOTRAILERS: c_int = 0x00000020;
72+
pub const AF_INET6: c_int = 24;
73+
pub const AF_BLUETOOTH: c_int = 31;
74+
pub const pseudo_AF_KEY: c_int = 29;
75+
pub const MSG_NOSIGNAL: c_int = 0x0800;
76+
pub const MSG_WAITFORONE: c_int = 0x2000;
77+
pub const IP_IPSEC_POLICY_COMPAT: c_int = 22;
78+
pub const IP_PKTINFO: c_int = 25;
79+
pub const IPPROTO_DIVERT: c_int = 259;
80+
pub const IPV6_IPSEC_POLICY_COMPAT: c_int = 28;
81+
pub const TCP_KEEPALIVE: c_int = 0x04;
82+
pub const ARPHRD_ARCNET: u16 = 7;
83+
pub const SO_BINDTODEVICE: c_int = 0x0800;
84+
pub const EAI_NODATA: c_int = 7;
85+
pub const IPTOS_ECN_NOT_ECT: u8 = 0x00;
86+
pub const RTF_BROADCAST: u32 = 0x80000;
87+
pub const UDP_ENCAP: c_int = 100;
88+
pub const HW_IOSTATS: c_int = 9;
89+
pub const HW_MACHINE_ARCH: c_int = 10;
90+
pub const HW_ALIGNBYTES: c_int = 11;
91+
pub const HW_CNMAGIC: c_int = 12;
92+
pub const HW_PHYSMEM64: c_int = 13;
93+
pub const HW_USERMEM64: c_int = 14;
94+
pub const HW_IOSTATNAMES: c_int = 15;
95+
pub const HW_MAXID: c_int = 15;
96+
pub const CTL_UNSPEC: c_int = 0;
97+
pub const CTL_QNX: c_int = 9;
98+
pub const CTL_PROC: c_int = 10;
99+
pub const CTL_VENDOR: c_int = 11;
100+
pub const CTL_EMUL: c_int = 12;
101+
pub const CTL_SECURITY: c_int = 13;
102+
pub const CTL_MAXID: c_int = 14;
103+
pub const AF_ARP: c_int = 28;
104+
pub const AF_IEEE80211: c_int = 32;
105+
pub const AF_NATM: c_int = 27;
106+
pub const AF_NS: c_int = 6;
107+
pub const BIOCGDLTLIST: c_int = -1072676233;
108+
pub const BIOCGETIF: c_int = 1083196011;
109+
pub const BIOCGSEESENT: c_int = 1074020984;
110+
pub const BIOCGSTATS: c_int = 1082147439;
111+
pub const BIOCSDLT: c_int = -2147204490;
112+
pub const BIOCSETIF: c_int = -2138029460;
113+
pub const BIOCSSEESENT: c_int = -2147204487;
114+
pub const FIONSPACE: c_int = 1074030200;
115+
pub const FIONWRITE: c_int = 1074030201;
116+
pub const IFF_ACCEPTRTADV: c_int = 0x40000000;
117+
pub const IFF_IP6FORWARDING: c_int = 0x20000000;
118+
pub const IFF_SHIM: c_int = 0x80000000;
119+
pub const KERN_ARND: c_int = 81;
120+
pub const KERN_IOV_MAX: c_int = 38;
121+
pub const KERN_LOGSIGEXIT: c_int = 46;
122+
pub const KERN_MAXID: c_int = 83;
123+
pub const KERN_PROC_ARGS: c_int = 48;
124+
pub const KERN_PROC_ENV: c_int = 3;
125+
pub const KERN_PROC_GID: c_int = 7;
126+
pub const KERN_PROC_RGID: c_int = 8;
127+
pub const LOCAL_CONNWAIT: c_int = 0x0002;
128+
pub const LOCAL_CREDS: c_int = 0x0001;
129+
pub const LOCAL_PEEREID: c_int = 0x0003;
130+
pub const MSG_NOTIFICATION: c_int = 0x0400;
131+
pub const NET_RT_IFLIST: c_int = 4;
132+
pub const NI_NUMERICSCOPE: c_int = 0x00000040;
133+
pub const PF_ARP: c_int = 28;
134+
pub const PF_NATM: c_int = 27;
135+
pub const pseudo_AF_HDRCMPLT: c_int = 30;
136+
pub const SIOCGIFADDR: c_int = -1064277727;
137+
pub const SO_FIB: c_int = 0x100a;
138+
pub const SO_TXPRIO: c_int = 0x100b;
139+
pub const SO_SETFIB: c_int = 0x100a;
140+
pub const SO_VLANPRIO: c_int = 0x100c;
141+
pub const USER_ATEXIT_MAX: c_int = 21;
142+
pub const USER_MAXID: c_int = 22;
143+
pub const SO_OVERFLOWED: c_int = 0x1009;
144+
145+
extern "C" {
146+
pub fn sendmmsg(
147+
sockfd: c_int,
148+
msgvec: *mut crate::mmsghdr,
149+
vlen: c_uint,
150+
flags: c_uint,
151+
) -> c_int;
152+
153+
pub fn recvmmsg(
154+
sockfd: c_int,
155+
msgvec: *mut crate::mmsghdr,
156+
vlen: c_uint,
157+
flags: c_uint,
158+
timeout: *mut crate::timespec,
159+
) -> c_int;
160+
}

src/unix/nto/io_sock/mod.rs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
//! Definitions specific to QNX versions using io-sock networking
2+
//!
3+
//! This module applies to:
4+
//!
5+
//! * `aarch64-unknown-nto-qnx710`
6+
//! * `x86_64-pc-nto-qnx710`
7+
//! * `aarch64-unknown-nto-qnx800`
8+
//! * `x86_64-pc-nto-qnx800`
9+
10+
use crate::prelude::*;
11+
12+
s! {
13+
pub struct in_addr {
14+
pub s_addr: crate::in_addr_t,
15+
}
16+
17+
pub struct sockaddr_in {
18+
pub sin_len: u8,
19+
pub sin_family: crate::sa_family_t,
20+
pub sin_port: crate::in_port_t,
21+
pub sin_addr: crate::in_addr,
22+
pub sin_zero: [c_char; 8],
23+
}
24+
25+
pub struct arphdr {
26+
pub ar_hrd: u16,
27+
pub ar_pro: u16,
28+
pub ar_hln: u8,
29+
pub ar_pln: u8,
30+
pub ar_op: u16,
31+
}
32+
33+
pub struct mmsghdr {
34+
pub msg_hdr: crate::msghdr,
35+
pub msg_len: ssize_t,
36+
}
37+
38+
pub struct bpf_stat {
39+
pub bs_recv: c_uint,
40+
pub bs_drop: c_uint,
41+
}
42+
43+
pub struct sockaddr_dl {
44+
pub sdl_len: c_uchar,
45+
pub sdl_family: c_uchar,
46+
pub sdl_index: c_ushort,
47+
pub sdl_type: c_uchar,
48+
pub sdl_nlen: c_uchar,
49+
pub sdl_alen: c_uchar,
50+
pub sdl_slen: c_uchar,
51+
pub sdl_data: [c_char; 46],
52+
}
53+
}
54+
55+
pub const SCM_CREDS: c_int = 0x03;
56+
pub const AF_INET6: c_int = 28;
57+
pub const AF_BLUETOOTH: c_int = 36;
58+
pub const pseudo_AF_KEY: c_int = 27;
59+
pub const MSG_NOSIGNAL: c_int = 0x20000;
60+
pub const MSG_WAITFORONE: c_int = 0x00080000;
61+
pub const IPPROTO_DIVERT: c_int = 258;
62+
pub const RTF_BROADCAST: u32 = 0x400000;
63+
pub const UDP_ENCAP: c_int = 1;
64+
pub const HW_MACHINE_ARCH: c_int = 11;
65+
pub const AF_ARP: c_int = 35;
66+
pub const AF_IEEE80211: c_int = 37;
67+
pub const AF_NATM: c_int = 29;
68+
pub const BIOCGDLTLIST: c_ulong = 0xffffffffc0104279;
69+
pub const BIOCGETIF: c_int = 0x4020426b;
70+
pub const BIOCGSEESENT: c_int = 0x40044276;
71+
pub const BIOCGSTATS: c_int = 0x4008426f;
72+
pub const BIOCSDLT: c_int = 0x80044278;
73+
pub const BIOCSETIF: c_int = 0x8020426c;
74+
pub const BIOCSSEESENT: c_int = 0x80044277;
75+
pub const KERN_ARND: c_int = 37;
76+
pub const KERN_IOV_MAX: c_int = 35;
77+
pub const KERN_LOGSIGEXIT: c_int = 34;
78+
pub const KERN_PROC_ARGS: c_int = 7;
79+
pub const KERN_PROC_ENV: c_int = 35;
80+
pub const KERN_PROC_GID: c_int = 11;
81+
pub const KERN_PROC_RGID: c_int = 10;
82+
pub const LOCAL_CONNWAIT: c_int = 4;
83+
pub const LOCAL_CREDS: c_int = 2;
84+
pub const MSG_NOTIFICATION: c_int = 0x00002000;
85+
pub const NET_RT_IFLIST: c_int = 3;
86+
pub const NI_NUMERICSCOPE: c_int = 0x00000020;
87+
pub const PF_ARP: c_int = AF_ARP;
88+
pub const PF_NATM: c_int = AF_NATM;
89+
pub const pseudo_AF_HDRCMPLT: c_int = 31;
90+
pub const SIOCGIFADDR: c_int = 0xc0206921;
91+
pub const SO_SETFIB: c_int = 0x1014;
92+
93+
extern "C" {
94+
pub fn sendmmsg(
95+
sockfd: c_int,
96+
msgvec: *mut crate::mmsghdr,
97+
vlen: size_t,
98+
flags: c_int,
99+
) -> ssize_t;
100+
101+
pub fn recvmmsg(
102+
sockfd: c_int,
103+
msgvec: *mut crate::mmsghdr,
104+
vlen: size_t,
105+
flags: c_int,
106+
timeout: *const crate::timespec,
107+
) -> ssize_t;
108+
}

0 commit comments

Comments
 (0)