Skip to content

Commit def9f06

Browse files
authored
Merge pull request managarm#1345 from 48cf/hi
Missing defines and some rust-libc fixes
2 parents dda34e9 + f3ea962 commit def9f06

File tree

6 files changed

+112
-3
lines changed

6 files changed

+112
-3
lines changed

abis/linux/statvfs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66

77
#define ST_RDONLY 1
88
#define ST_NOSUID 2
9+
#define ST_NODEV 4
10+
#define ST_NOEXEC 8
11+
#define ST_SYNCHRONOUS 16
912
#define ST_MANDLOCK 64
13+
#define ST_WRITE 128
14+
#define ST_APPEND 256
15+
#define ST_IMMUTABLE 512
16+
#define ST_NOATIME 1024
17+
#define ST_NODIRATIME 2048
1018

1119
/* On Linux, this struct is not directly used by the kernel. */
1220

options/glibc/include/sys/ioctl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ int ioctl(int __fd, unsigned long __request, ...);
2121

2222
#endif /* !__MLIBC_ABI_ONLY */
2323

24+
#define TIOCMGET 0x5415
25+
#define TIOCMBIS 0x5416
26+
#define TIOCMBIC 0x5417
27+
2428
#define FIONREAD 0x541B
2529
#define FIONBIO 0x5421
2630
#define FIONCLEX 0x5450

options/posix/include/termios.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ extern "C" {
6666

6767
#define TIOCM_DTR 0x002
6868
#define TIOCM_RTS 0x004
69+
#define TIOCM_CTS 0x020
70+
#define TIOCM_CAR 0x040
71+
#define TIOCM_RNG 0x080
72+
#define TIOCM_DSR 0x100
73+
#define TIOCM_RI TIOCM_RNG
74+
#define TIOCM_CD TIOCM_CAR
6975

7076
#ifndef __MLIBC_ABI_ONLY
7177

scripts/rust-libc-config.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,17 @@ force_macro_type:
20092009
- "SA_RESETHAND"
20102010
- "SA_RESTART"
20112011
- "SA_SIGINFO"
2012+
- "ST_RDONLY"
2013+
- "ST_NOSUID"
2014+
- "ST_NODEV"
2015+
- "ST_NOEXEC"
2016+
- "ST_SYNCHRONOUS"
2017+
- "ST_MANDLOCK"
2018+
- "ST_WRITE"
2019+
- "ST_APPEND"
2020+
- "ST_IMMUTABLE"
2021+
- "ST_NOATIME"
2022+
- "ST_NODIRATIME"
20122023
"c_uint":
20132024
- "IGNBRK"
20142025
- "BRKINT"
@@ -2028,8 +2039,10 @@ force_macro_type:
20282039
- "POLLWRBAND"
20292040
"usize":
20302041
- "NCCS"
2031-
- "VEOF"
20322042
- "PTHREAD_STACK_MIN"
2043+
- "VEOF"
2044+
- "VMIN"
2045+
- "VTIME"
20332046
"crate::speed_t":
20342047
- "B0"
20352048
- "B50"
@@ -2065,6 +2078,9 @@ force_macro_type:
20652078
"crate::tcflag_t":
20662079
- "BS1"
20672080
- "BSDLY"
2081+
- "CBAUD"
2082+
- "CBAUDEX"
2083+
- "CIBAUD"
20682084
- "CLOCAL"
20692085
- "CMSPAR"
20702086
- "CR1"

scripts/rust-libc-header.rs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,78 @@ impl siginfo_t {
174174
self.sifields().fields[0]
175175
}
176176
}
177+
178+
s! {
179+
pub struct sockaddr_nl {
180+
pub nl_family: crate::sa_family_t,
181+
nl_pad: c_ushort,
182+
pub nl_pid: u32,
183+
pub nl_groups: u32,
184+
}
185+
}
186+
187+
// linux/netlink.h
188+
pub const NLA_ALIGNTO: c_int = 4;
189+
190+
pub const NETLINK_ROUTE: c_int = 0;
191+
pub const NETLINK_UNUSED: c_int = 1;
192+
pub const NETLINK_USERSOCK: c_int = 2;
193+
pub const NETLINK_FIREWALL: c_int = 3;
194+
pub const NETLINK_SOCK_DIAG: c_int = 4;
195+
pub const NETLINK_NFLOG: c_int = 5;
196+
pub const NETLINK_XFRM: c_int = 6;
197+
pub const NETLINK_SELINUX: c_int = 7;
198+
pub const NETLINK_ISCSI: c_int = 8;
199+
pub const NETLINK_AUDIT: c_int = 9;
200+
pub const NETLINK_FIB_LOOKUP: c_int = 10;
201+
pub const NETLINK_CONNECTOR: c_int = 11;
202+
pub const NETLINK_NETFILTER: c_int = 12;
203+
pub const NETLINK_IP6_FW: c_int = 13;
204+
pub const NETLINK_DNRTMSG: c_int = 14;
205+
pub const NETLINK_KOBJECT_UEVENT: c_int = 15;
206+
pub const NETLINK_GENERIC: c_int = 16;
207+
pub const NETLINK_SCSITRANSPORT: c_int = 18;
208+
pub const NETLINK_ECRYPTFS: c_int = 19;
209+
pub const NETLINK_RDMA: c_int = 20;
210+
pub const NETLINK_CRYPTO: c_int = 21;
211+
pub const NETLINK_INET_DIAG: c_int = NETLINK_SOCK_DIAG;
212+
213+
pub const NLM_F_REQUEST: c_int = 1;
214+
pub const NLM_F_MULTI: c_int = 2;
215+
pub const NLM_F_ACK: c_int = 4;
216+
pub const NLM_F_ECHO: c_int = 8;
217+
pub const NLM_F_DUMP_INTR: c_int = 16;
218+
pub const NLM_F_DUMP_FILTERED: c_int = 32;
219+
220+
pub const NLM_F_ROOT: c_int = 0x100;
221+
pub const NLM_F_MATCH: c_int = 0x200;
222+
pub const NLM_F_ATOMIC: c_int = 0x400;
223+
pub const NLM_F_DUMP: c_int = NLM_F_ROOT | NLM_F_MATCH;
224+
225+
pub const NLM_F_REPLACE: c_int = 0x100;
226+
pub const NLM_F_EXCL: c_int = 0x200;
227+
pub const NLM_F_CREATE: c_int = 0x400;
228+
pub const NLM_F_APPEND: c_int = 0x800;
229+
230+
pub const NLM_F_NONREC: c_int = 0x100;
231+
pub const NLM_F_BULK: c_int = 0x200;
232+
233+
pub const NLM_F_CAPPED: c_int = 0x100;
234+
pub const NLM_F_ACK_TLVS: c_int = 0x200;
235+
236+
pub const NETLINK_ADD_MEMBERSHIP: c_int = 1;
237+
pub const NETLINK_DROP_MEMBERSHIP: c_int = 2;
238+
pub const NETLINK_PKTINFO: c_int = 3;
239+
pub const NETLINK_BROADCAST_ERROR: c_int = 4;
240+
pub const NETLINK_NO_ENOBUFS: c_int = 5;
241+
pub const NETLINK_RX_RING: c_int = 6;
242+
pub const NETLINK_TX_RING: c_int = 7;
243+
pub const NETLINK_LISTEN_ALL_NSID: c_int = 8;
244+
pub const NETLINK_LIST_MEMBERSHIPS: c_int = 9;
245+
pub const NETLINK_CAP_ACK: c_int = 10;
246+
pub const NETLINK_EXT_ACK: c_int = 11;
247+
pub const NETLINK_GET_STRICT_CHK: c_int = 12;
248+
249+
pub const NLA_F_NESTED: c_int = 1 << 15;
250+
pub const NLA_F_NET_BYTEORDER: c_int = 1 << 14;
251+
pub const NLA_TYPE_MASK: c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);

scripts/rust-libc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ def convert_ptr_type(self, c, ty, is_pointee=False):
8080
ret_type = Type(c, pointee.get_result())
8181
if c.semantic_parent.spelling in config["force_raw_function_pointer"]:
8282
return f'extern "C" fn({args})' + (
83-
f" -> {ret_type}" if ret_type != "c_void" else ""
83+
f" -> {ret_type}" if str(ret_type) != "c_void" else ""
8484
)
8585
else:
8686
return f'Option<unsafe extern "C" fn({args})' + (
87-
f" -> {ret_type}>" if ret_type != "c_void" else ">"
87+
f" -> {ret_type}>" if str(ret_type) != "c_void" else ">"
8888
)
8989

9090
is_mut = not pointee.spelling.startswith("const")

0 commit comments

Comments
 (0)