Skip to content

Commit 0dec549

Browse files
committed
Add types for newlib on Xtensa.
1 parent e742043 commit 0dec549

File tree

4 files changed

+129
-9
lines changed

4 files changed

+129
-9
lines changed

src/unix/newlib/aarch64/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub type clock_t = ::c_long;
12
pub type c_char = u8;
23
pub type wchar_t = u32;
34

@@ -29,5 +30,13 @@ s! {
2930
}
3031
}
3132

33+
pub const FIONBIO: ::c_ulong = 1;
34+
35+
pub const POLLIN: ::c_short = 0x1;
36+
pub const POLLPRI: ::c_short = 0x2;
3237
pub const POLLOUT: ::c_short = 0x4;
38+
pub const POLLERR: ::c_short = 0x8;
3339
pub const POLLHUP: ::c_short = 0x10;
40+
pub const POLLNVAL: ::c_short = 0x20;
41+
42+
pub const SOL_SOCKET: ::c_int = 65535;

src/unix/newlib/arm/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub type clock_t = ::c_long;
12
pub type c_char = u8;
23
pub type wchar_t = u32;
34

@@ -31,5 +32,13 @@ s! {
3132
}
3233
}
3334

34-
pub const POLLOUT: ::c_short = 0x10;
35+
pub const FIONBIO: ::c_ulong = 1;
36+
37+
pub const POLLIN: ::c_short = 0x1;
38+
pub const POLLPRI: ::c_short = 0x2;
3539
pub const POLLHUP: ::c_short = 0x4;
40+
pub const POLLERR: ::c_short = 0x8;
41+
pub const POLLOUT: ::c_short = 0x10;
42+
pub const POLLNVAL: ::c_short = 0x20;
43+
44+
pub const SOL_SOCKET: ::c_int = 65535;

src/unix/newlib/mod.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pub type blkcnt_t = i32;
22
pub type blksize_t = i32;
3-
pub type clock_t = i32;
43
pub type clockid_t = ::c_ulong;
54
pub type dev_t = u32;
65
pub type fsblkcnt_t = u64;
@@ -31,8 +30,15 @@ s! {
3130
pub ai_socktype: ::c_int,
3231
pub ai_protocol: ::c_int,
3332
pub ai_addrlen: socklen_t,
33+
34+
#[cfg(target_arch = "xtensa")]
35+
pub ai_addr: *mut sockaddr,
36+
3437
pub ai_canonname: *mut ::c_char,
38+
39+
#[cfg(not(target_arch = "xtensa"))]
3540
pub ai_addr: *mut sockaddr,
41+
3642
pub ai_next: *mut addrinfo,
3743
}
3844

@@ -364,11 +370,6 @@ pub const O_NONBLOCK: ::c_int = 16384;
364370
pub const O_ACCMODE: ::c_int = 3;
365371
pub const O_CLOEXEC: ::c_int = 0x80000;
366372

367-
pub const POLLIN: ::c_short = 0x1;
368-
pub const POLLPRI: ::c_short = 0x2;
369-
pub const POLLERR: ::c_short = 0x8;
370-
pub const POLLNVAL: ::c_short = 0x20;
371-
372373
pub const RTLD_LAZY: ::c_int = 0x1;
373374

374375
pub const STDIN_FILENO: ::c_int = 0;
@@ -379,7 +380,6 @@ pub const SEEK_SET: ::c_int = 0;
379380
pub const SEEK_CUR: ::c_int = 1;
380381
pub const SEEK_END: ::c_int = 2;
381382

382-
pub const FIONBIO: ::c_ulong = 1;
383383
pub const FIOCLEX: ::c_ulong = 0x20006601;
384384
pub const FIONCLEX: ::c_ulong = 0x20006602;
385385

@@ -406,7 +406,6 @@ pub const S_IROTH: ::mode_t = 4;
406406
pub const S_IWOTH: ::mode_t = 2;
407407
pub const S_IXOTH: ::mode_t = 1;
408408

409-
pub const SOL_SOCKET: ::c_int = 65535;
410409
pub const SOL_TCP: ::c_int = 6;
411410

412411
pub const PF_UNSPEC: ::c_int = 0;
@@ -547,6 +546,9 @@ pub const EAI_MEMORY: ::c_int = -304;
547546
pub const EAI_NONAME: ::c_int = -305;
548547
pub const EAI_SOCKTYPE: ::c_int = -307;
549548

549+
pub const EXIT_SUCCESS: ::c_int = 0;
550+
pub const EXIT_FAILURE: ::c_int = 1;
551+
550552
pub const PRIO_PROCESS: ::c_int = 0;
551553
pub const PRIO_PGRP: ::c_int = 1;
552554
pub const PRIO_USER: ::c_int = 2;
@@ -702,6 +704,9 @@ cfg_if! {
702704
} else if #[cfg(target_arch = "aarch64")] {
703705
mod aarch64;
704706
pub use self::aarch64::*;
707+
} else if #[cfg(target_arch = "xtensa")] {
708+
mod xtensa;
709+
pub use self::xtensa::*;
705710
} else {
706711
// Only tested on ARM so far. Other platforms might have different
707712
// definitions for types and constants.

src/unix/newlib/xtensa/mod.rs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
pub type clock_t = ::c_ulong;
2+
pub type c_char = i8;
3+
pub type wchar_t = u32;
4+
5+
pub type c_long = i32;
6+
pub type c_ulong = u32;
7+
8+
s! {
9+
pub struct cmsghdr {
10+
pub cmsg_len: ::socklen_t,
11+
pub cmsg_level: ::c_int,
12+
pub cmsg_type: ::c_int,
13+
}
14+
15+
pub struct msghdr {
16+
pub msg_name: *mut ::c_void,
17+
pub msg_namelen: ::socklen_t,
18+
pub msg_iov: *mut ::iovec,
19+
pub msg_iovlen: ::c_int,
20+
pub msg_control: *mut ::c_void,
21+
pub msg_controllen: ::socklen_t,
22+
pub msg_flags: ::c_int,
23+
}
24+
25+
pub struct sockaddr_un {
26+
pub sun_family: ::sa_family_t,
27+
pub sun_path: [::c_char; 108],
28+
}
29+
30+
pub struct sockaddr {
31+
pub sa_len: u8,
32+
pub sa_family: ::sa_family_t,
33+
pub sa_data: [::c_char; 14],
34+
}
35+
36+
pub struct sockaddr_in6 {
37+
pub sin6_len: u8,
38+
pub sin6_family: ::sa_family_t,
39+
pub sin6_port: ::in_port_t,
40+
pub sin6_flowinfo: u32,
41+
pub sin6_addr: ::in6_addr,
42+
pub sin6_scope_id: u32,
43+
}
44+
45+
pub struct sockaddr_in {
46+
pub sin_len: u8,
47+
pub sin_family: ::sa_family_t,
48+
pub sin_port: ::in_port_t,
49+
pub sin_addr: ::in_addr,
50+
pub sin_zero: [::c_char; 8],
51+
}
52+
53+
pub struct sockaddr_storage {
54+
pub s2_len: u8,
55+
pub ss_family: ::sa_family_t,
56+
pub s2_data1: [::c_char; 2],
57+
pub s2_data2: [u32; 3],
58+
pub s2_data3: [u32; 3],
59+
}
60+
}
61+
62+
pub const AF_UNIX: ::c_int = 1;
63+
64+
pub const FIONBIO: ::c_ulong = 2147772030;
65+
66+
pub const POLLIN: ::c_short = 1 << 0;
67+
pub const POLLRDNORM: ::c_short = 1 << 1;
68+
pub const POLLRDBAND: ::c_short = 1 << 2;
69+
pub const POLLPRI: ::c_short = POLLRDBAND;
70+
pub const POLLOUT: ::c_short = 1 << 3;
71+
pub const POLLWRNORM: ::c_short = POLLOUT;
72+
pub const POLLWRBAND: ::c_short = 1 << 4;
73+
pub const POLLERR: ::c_short = 1 << 5;
74+
pub const POLLHUP: ::c_short = 1 << 6;
75+
76+
pub const SOL_SOCKET: ::c_int = 0xfff;
77+
78+
extern "C" {
79+
pub fn sendmsg(
80+
s: ::c_int,
81+
msg: *const ::msghdr,
82+
flags: ::c_int,
83+
) -> ::ssize_t;
84+
pub fn recvmsg(
85+
s: ::c_int,
86+
msg: *mut ::msghdr,
87+
flags: ::c_int,
88+
) -> ::ssize_t;
89+
90+
pub fn writev(s: ::c_int, iov: *const ::iovec, iovcnt: ::c_int)
91+
-> ::c_int;
92+
pub fn readv(
93+
fd: ::c_int,
94+
iov: *const ::iovec,
95+
iovcnt: ::c_int,
96+
) -> ::ssize_t;
97+
}

0 commit comments

Comments
 (0)