Skip to content

Commit

Permalink
Auto merge of #3246 - loongarch-rs:fix-loongarch, r=JohnTitor
Browse files Browse the repository at this point in the history
Fix loongarch64 bindings

This PR aims to fix the LoongArch64 bindings and incorporate tests for LoongArch.

- libc-test: PASSED
  • Loading branch information
bors committed May 13, 2023
2 parents e1c4a38 + d6967dd commit fe563a8
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 5 deletions.
6 changes: 6 additions & 0 deletions libc-test/semver/linux-gnu-loongarch64.txt
@@ -0,0 +1,6 @@
PTRACE_GETFPREGS
PTRACE_SETFPREGS
PTRACE_GETFPXREGS
PTRACE_SETFPXREGS
PTRACE_GETREGS
PTRACE_SETREGS
136 changes: 136 additions & 0 deletions libc-test/semver/linux-loongarch64.txt
@@ -0,0 +1,136 @@
B2500000
B3000000
B3500000
B4000000
BPF_ABS
BPF_ADD
BPF_ALU
BPF_B
BPF_DIV
BPF_H
BPF_IMM
BPF_IND
BPF_JA
BPF_JEQ
BPF_JGE
BPF_JGT
BPF_JMP
BPF_JUMP
BPF_K
BPF_LD
BPF_LDX
BPF_LEN
BPF_LL_OFF
BPF_MEM
BPF_MISC
BPF_MISCOP
BPF_MOD
BPF_MSH
BPF_NEG
BPF_NET_OFF
BPF_RET
BPF_RVAL
BPF_ST
BPF_STMT
BPF_STX
BPF_SUB
BPF_W
BPF_X
BPF_XOR
CIBAUD
FICLONE
FICLONERANGE
flock64
KEYCTL_CAPABILITIES
KEYCTL_CAPS0_BIG_KEY
KEYCTL_CAPS0_CAPABILITIES
KEYCTL_CAPS0_DIFFIE_HELLMAN
KEYCTL_CAPS0_INVALIDATE
KEYCTL_CAPS0_MOVE
KEYCTL_CAPS0_PERSISTENT_KEYRINGS
KEYCTL_CAPS0_PUBLIC_KEY
KEYCTL_CAPS0_RESTRICT_KEYRING
KEYCTL_CAPS1_NS_KEYRING_NAME
KEYCTL_CAPS1_NS_KEY_TAG
KEYCTL_MOVE
MADV_SOFT_OFFLINE
MAP_SYNC
NFT_MSG_DELOBJ
NFT_MSG_GETOBJ
NFT_MSG_GETOBJ_RESET
NFT_MSG_NEWOBJ
PTRACE_SYSEMU
PTRACE_SYSEMU_SINGLESTEP
SCM_TIMESTAMPNS
SCM_WIFI_STATUS
SIGSTKFLT
SIGUNUSED
SKF_AD_ALU_XOR_X
SKF_AD_CPU
SKF_AD_HATYPE
SKF_AD_MARK
SKF_AD_MAX
SKF_AD_NLATTR
SKF_AD_NLATTR_NEST
SKF_AD_OFF
SKF_AD_PAY_OFFSET
SKF_AD_PKTTYPE
SKF_AD_PROTOCOL
SKF_AD_QUEUE
SKF_AD_RANDOM
SKF_AD_RXHASH
SKF_AD_VLAN_TAG
SKF_AD_VLAN_TAG_PRESENT
SKF_AD_VLAN_TPID
SKF_LL_OFF
SKF_NET_OFF
SO_ATTACH_BPF
SO_ATTACH_FILTER
SO_BPF_EXTENSIONS
SO_BSDCOMPAT
SO_DETACH_BPF
SO_DETACH_FILTER
SO_GET_FILTER
SO_INCOMING_CPU
SO_LOCK_FILTER
SO_MAX_PACING_RATE
SO_NO_CHECK
SO_NOFCS
SO_PEERNAME
SO_PRIORITY
SO_PROTOCOL
SO_SECURITY_AUTHENTICATION
SO_SECURITY_ENCRYPTION_NETWORK
SO_SECURITY_ENCRYPTION_TRANSPORT
SO_SELECT_ERR_QUEUE
SO_TIMESTAMPNS
SO_WIFI_STATUS
SYS_accept
SYS_msgctl
SYS_msgget
SYS_msgrcv
SYS_msgsnd
SYS_pkey_alloc
SYS_pkey_free
SYS_pkey_mprotect
SYS_semctl
SYS_semget
SYS_semop
SYS_semtimedop
SYS_sendfile
SYS_shmat
SYS_shmctl
SYS_shmdt
SYS_shmget
SYS_sync_file_range
termios2
TIOCCBRK
TIOCGRS485
TIOCSBRK
TIOCSRS485
XCASE
max_align_t
mcontext_t
ucontext_t
user_regs_struct
user_fp_struct
8 changes: 4 additions & 4 deletions src/unix/linux_like/linux/gnu/b64/loongarch64/align.rs
Expand Up @@ -17,10 +17,10 @@ s! {

#[repr(align(16))]
pub struct mcontext_t {
pub sc_pc: ::c_ulonglong,
pub sc_regs: [::c_ulonglong; 32],
pub sc_flags: ::c_ulong,
pub sc_extcontext: [u64; 0],
pub __pc: ::c_ulonglong,
pub __gregs: [::c_ulonglong; 32],
pub __flags: ::c_uint,
pub __extcontext: [::c_ulonglong; 0],
}

#[repr(align(8))]
Expand Down
23 changes: 22 additions & 1 deletion src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs
Expand Up @@ -189,6 +189,21 @@ s! {
__unused4: ::c_ulong,
__unused5: ::c_ulong
}

pub struct user_regs_struct {
pub regs: [u64; 32],
pub orig_a0: u64,
pub csr_era: u64,
pub csr_badv: u64,
pub reserved: [u64; 10],

}

pub struct user_fp_struct {
pub fpr: [u64; 32],
pub fcc: u64,
pub fcsr: u32,
}
}

pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
Expand Down Expand Up @@ -549,7 +564,7 @@ pub const SYS_landlock_add_rule: ::c_long = 445;
pub const SYS_landlock_restrict_self: ::c_long = 446;
pub const SYS_process_mrelease: ::c_long = 448;
pub const SYS_futex_waitv: ::c_long = 449;
//pub const SYS_set_mempolicy_home_node: ::c_long = 450;
pub const SYS_set_mempolicy_home_node: ::c_long = 450;

pub const POSIX_FADV_DONTNEED: ::c_int = 4;
pub const POSIX_FADV_NOREUSE: ::c_int = 5;
Expand Down Expand Up @@ -684,6 +699,8 @@ pub const ENOTRECOVERABLE: ::c_int = 131;
pub const ERFKILL: ::c_int = 132;
pub const EHWPOISON: ::c_int = 133;

pub const MADV_SOFT_OFFLINE: ::c_int = 101;

pub const MAP_NORESERVE: ::c_int = 0x4000;
pub const MAP_ANONYMOUS: ::c_int = 0x0020;
pub const MAP_ANON: ::c_int = 0x0020;
Expand All @@ -695,6 +712,7 @@ pub const MAP_POPULATE: ::c_int = 0x8000;
pub const MAP_NONBLOCK: ::c_int = 0x10000;
pub const MAP_STACK: ::c_int = 0x20000;
pub const MAP_HUGETLB: ::c_int = 0x40000;
pub const MAP_SYNC: ::c_int = 0x080000;
pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const MCL_ONFAULT: ::c_int = 0x0004;
Expand Down Expand Up @@ -746,6 +764,8 @@ pub const PTRACE_GETFPXREGS: ::c_uint = 18;
pub const PTRACE_SETFPXREGS: ::c_uint = 19;
pub const PTRACE_GETREGS: ::c_uint = 12;
pub const PTRACE_SETREGS: ::c_uint = 13;
pub const PTRACE_SYSEMU: ::c_uint = 31;
pub const PTRACE_SYSEMU_SINGLESTEP: ::c_uint = 32;

pub const RTLD_DEEPBIND: ::c_int = 0x8;
pub const RTLD_GLOBAL: ::c_int = 0x100;
Expand Down Expand Up @@ -846,6 +866,7 @@ pub const ECHOPRT: ::tcflag_t = 0x00000400;
pub const ECHOCTL: ::tcflag_t = 0x00000200;
pub const ISIG: ::tcflag_t = 0x00000001;
pub const ICANON: ::tcflag_t = 0x00000002;
pub const XCASE: ::tcflag_t = 0x00000004;
pub const PENDIN: ::tcflag_t = 0x00004000;
pub const NOFLSH: ::tcflag_t = 0x00000080;

Expand Down

0 comments on commit fe563a8

Please sign in to comment.