Skip to content

Commit 55705b8

Browse files
authored
On powerpc, make termios2 an alias for termios. (#69)
PowerPC Linux doesn't define a `termios2` struct; instead, the regular `termios` struct has the extra `termios2` fields, so to simplify users, define `termios2` as an alias for `termios, and similar for the `TCSETS2` and related ioctls.
1 parent 32d5f19 commit 55705b8

File tree

8 files changed

+30
-0
lines changed

8 files changed

+30
-0
lines changed

gen/include/ioctl-addendum.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Additional definitions to add to the ioctl.h module.
2+
3+
// On PowerPC, the kernel does not define a `struct termios2` or its associated
4+
// ioctls, and the regular `termios` has the extra `termios2` fields.
5+
#if defined(__powerpc__) || defined(__powerpc64__)
6+
#define TCGETS2 TCGETS
7+
#define TCSETS2 TCSETS
8+
#define TCSETSF2 TCSETSF
9+
#define TCSETSW2 TCSETSW
10+
#endif

gen/ioctl/generate.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,7 @@ qemu-s390x -L /usr/s390x-linux-gnu ./main.exe >> "$out"
4848
# pre-generated output is used for the time being
4949
cat loongarch-ioctls.txt >> "$out"
5050

51+
# Add any extra custom definitions at the end.
52+
echo "#include \"ioctl-addendum.h\"" >> "$out"
53+
5154
rm list.o main.exe

gen/modules/general.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,9 @@ struct kernel_sigaction {
246246
#endif
247247
kernel_sigset_t sa_mask;
248248
};
249+
250+
// On PowerPC, the kernel does not define a `termios2` or associated ioctls,
251+
// and the regular `termios` has the extra `termios2` fields.
252+
#if defined(__powerpc__) || defined(__powerpc64__)
253+
typedef struct termios termios2;
254+
#endif

gen/modules/ioctl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15496,3 +15496,4 @@
1549615496
#define ACRN_IOCTL_DESTROY_IOREQ_CLIENT 0xa234ul
1549715497
#define ACRN_IOCTL_VM_INTR_MONITOR 0x4008a224ul
1549815498
#endif
15499+
#include "ioctl-addendum.h"

src/powerpc/general.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub type cc_t = crate::ctypes::c_uchar;
6565
pub type speed_t = crate::ctypes::c_uint;
6666
pub type tcflag_t = crate::ctypes::c_uint;
6767
pub type __fsword_t = __u32;
68+
pub type termios2 = termios;
6869
#[repr(C)]
6970
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
7071
pub struct __BindgenBitfieldUnit<Storage> {

src/powerpc/ioctl.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,3 +1482,7 @@ pub const ACRN_IOCTL_DEASSIGN_PCIDEV: u32 = 2149884502;
14821482
pub const ACRN_IOCTL_RESET_VM: u32 = 536912405;
14831483
pub const ACRN_IOCTL_DESTROY_IOREQ_CLIENT: u32 = 536912436;
14841484
pub const ACRN_IOCTL_VM_INTR_MONITOR: u32 = 2148049444;
1485+
pub const TCGETS2: u32 = 1076655123;
1486+
pub const TCSETS2: u32 = 2150396948;
1487+
pub const TCSETSF2: u32 = 2150396950;
1488+
pub const TCSETSW2: u32 = 2150396949;

src/powerpc64/general.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub type cc_t = crate::ctypes::c_uchar;
6565
pub type speed_t = crate::ctypes::c_uint;
6666
pub type tcflag_t = crate::ctypes::c_uint;
6767
pub type __fsword_t = __kernel_long_t;
68+
pub type termios2 = termios;
6869
#[repr(C)]
6970
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
7071
pub struct __BindgenBitfieldUnit<Storage> {

src/powerpc64/ioctl.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,3 +1482,7 @@ pub const ACRN_IOCTL_DEASSIGN_PCIDEV: u32 = 2149884502;
14821482
pub const ACRN_IOCTL_RESET_VM: u32 = 536912405;
14831483
pub const ACRN_IOCTL_DESTROY_IOREQ_CLIENT: u32 = 536912436;
14841484
pub const ACRN_IOCTL_VM_INTR_MONITOR: u32 = 2148049444;
1485+
pub const TCGETS2: u32 = 1076655123;
1486+
pub const TCSETS2: u32 = 2150396948;
1487+
pub const TCSETSF2: u32 = 2150396950;
1488+
pub const TCSETSW2: u32 = 2150396949;

0 commit comments

Comments
 (0)