Skip to content

Commit 057bb14

Browse files
authored
Merge pull request #4382 from sunfishcode/sunfishcode/riscv32-ioctls
Define more ioctl codes on riscv32gc-unknown-linux-gnu
2 parents 67442f4 + 4b439b0 commit 057bb14

File tree

1 file changed

+15
-60
lines changed
  • src/unix/linux_like/linux/arch/generic

1 file changed

+15
-60
lines changed

src/unix/linux_like/linux/arch/generic/mod.rs

+15-60
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::prelude::*;
2-
use crate::Ioctl;
2+
use crate::{Ioctl, _IOR, _IOW};
33

44
s! {
55
pub struct termios2 {
@@ -158,21 +158,8 @@ pub const SO_DEVMEM_LINEAR: c_int = 78;
158158
pub const SO_DEVMEM_DMABUF: c_int = 79;
159159
pub const SO_DEVMEM_DONTNEED: c_int = 80;
160160

161-
cfg_if! {
162-
if #[cfg(any(
163-
target_arch = "x86",
164-
target_arch = "x86_64",
165-
target_arch = "arm",
166-
target_arch = "aarch64",
167-
target_arch = "riscv64",
168-
target_arch = "s390x",
169-
target_arch = "csky",
170-
target_arch = "loongarch64"
171-
))] {
172-
pub const FICLONE: c_ulong = 0x40049409;
173-
pub const FICLONERANGE: c_ulong = 0x4020940D;
174-
}
175-
}
161+
pub const FICLONE: Ioctl = _IOW::<c_int>(0x94, 9) as Ioctl;
162+
pub const FICLONERANGE: Ioctl = _IOW::<crate::file_clone_range>(0x94, 13) as Ioctl;
176163

177164
// Defined in unix/linux_like/mod.rs
178165
// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP;
@@ -293,50 +280,18 @@ pub const TUNGETVNETBE: Ioctl = 0x800454df;
293280
pub const TUNSETSTEERINGEBPF: Ioctl = 0x800454e0;
294281
pub const TUNSETFILTEREBPF: Ioctl = 0x800454e1;
295282

296-
cfg_if! {
297-
// Those type are constructed using the _IOC macro
298-
// DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN
299-
// where D stands for direction (either None (00), Read (01) or Write (11))
300-
// where S stands for size (int, long, struct...)
301-
// where T stands for type ('f','v','X'...)
302-
// where N stands for NR (NumbeR)
303-
if #[cfg(any(
304-
target_arch = "x86",
305-
target_arch = "arm",
306-
target_arch = "csky"
307-
))] {
308-
pub const FS_IOC_GETFLAGS: Ioctl = 0x80046601;
309-
pub const FS_IOC_SETFLAGS: Ioctl = 0x40046602;
310-
pub const FS_IOC_GETVERSION: Ioctl = 0x80047601;
311-
pub const FS_IOC_SETVERSION: Ioctl = 0x40047602;
312-
pub const FS_IOC32_GETFLAGS: Ioctl = 0x80046601;
313-
pub const FS_IOC32_SETFLAGS: Ioctl = 0x40046602;
314-
pub const FS_IOC32_GETVERSION: Ioctl = 0x80047601;
315-
pub const FS_IOC32_SETVERSION: Ioctl = 0x40047602;
316-
pub const TUNATTACHFILTER: Ioctl = 0x400854d5;
317-
pub const TUNDETACHFILTER: Ioctl = 0x400854d6;
318-
pub const TUNGETFILTER: Ioctl = 0x800854db;
319-
} else if #[cfg(any(
320-
target_arch = "x86_64",
321-
target_arch = "riscv64",
322-
target_arch = "aarch64",
323-
target_arch = "s390x",
324-
target_arch = "loongarch64",
325-
target_arch = "wasm32"
326-
))] {
327-
pub const FS_IOC_GETFLAGS: Ioctl = 0x80086601;
328-
pub const FS_IOC_SETFLAGS: Ioctl = 0x40086602;
329-
pub const FS_IOC_GETVERSION: Ioctl = 0x80087601;
330-
pub const FS_IOC_SETVERSION: Ioctl = 0x40087602;
331-
pub const FS_IOC32_GETFLAGS: Ioctl = 0x80046601;
332-
pub const FS_IOC32_SETFLAGS: Ioctl = 0x40046602;
333-
pub const FS_IOC32_GETVERSION: Ioctl = 0x80047601;
334-
pub const FS_IOC32_SETVERSION: Ioctl = 0x40047602;
335-
pub const TUNATTACHFILTER: Ioctl = 0x401054d5;
336-
pub const TUNDETACHFILTER: Ioctl = 0x401054d6;
337-
pub const TUNGETFILTER: Ioctl = 0x801054db;
338-
}
339-
}
283+
pub const FS_IOC_GETFLAGS: Ioctl = _IOR::<c_long>('f' as u32, 1) as Ioctl;
284+
pub const FS_IOC_SETFLAGS: Ioctl = _IOW::<c_long>('f' as u32, 2) as Ioctl;
285+
pub const FS_IOC_GETVERSION: Ioctl = _IOR::<c_long>('v' as u32, 1) as Ioctl;
286+
pub const FS_IOC_SETVERSION: Ioctl = _IOW::<c_long>('v' as u32, 2) as Ioctl;
287+
pub const FS_IOC32_GETFLAGS: Ioctl = _IOR::<c_int>('f' as u32, 1) as Ioctl;
288+
pub const FS_IOC32_SETFLAGS: Ioctl = _IOW::<c_int>('f' as u32, 2) as Ioctl;
289+
pub const FS_IOC32_GETVERSION: Ioctl = _IOR::<c_int>('v' as u32, 1) as Ioctl;
290+
pub const FS_IOC32_SETVERSION: Ioctl = _IOW::<c_int>('v' as u32, 2) as Ioctl;
291+
292+
pub const TUNATTACHFILTER: Ioctl = _IOW::<crate::sock_fprog>('T' as u32, 213) as Ioctl;
293+
pub const TUNDETACHFILTER: Ioctl = _IOW::<crate::sock_fprog>('T' as u32, 214) as Ioctl;
294+
pub const TUNGETFILTER: Ioctl = _IOR::<crate::sock_fprog>('T' as u32, 219) as Ioctl;
340295

341296
cfg_if! {
342297
if #[cfg(any(target_arch = "arm", target_arch = "s390x"))] {

0 commit comments

Comments
 (0)