diff --git a/libc-test/build.rs b/libc-test/build.rs index 5c5bba2d360e3..f8f38d736a87c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4476,14 +4476,14 @@ fn test_linux(target: &str) { (struct_ == "iw_encode_ext" && field == "key") || // the `tcpi_snd_rcv_wscale` map two bitfield fields stored in a u8 (struct_ == "tcp_info" && field == "tcpi_snd_rcv_wscale") || - // the `tcpi_delivery_rate_app_limited` field is a bitfield on musl - (musl && struct_ == "tcp_info" && field == "tcpi_delivery_rate_app_limited") || - // the `tcpi_fast_open_client_fail` field is a bitfield on musl - (musl && struct_ == "tcp_info" && field == "tcpi_fast_open_client_fail") || + // the `tcpi_delivery_fastopen_bitfields` map two bitfield fields stored in a u8 + (musl && struct_ == "tcp_info" && field == "tcpi_delivery_fastopen_bitfields") || // either fsid_t or int[2] type (struct_ == "fanotify_event_info_fid" && field == "fsid") || // `handle` is a VLA - (struct_ == "fanotify_event_info_fid" && field == "handle") + (struct_ == "fanotify_event_info_fid" && field == "handle") || + // invalid application of 'sizeof' to incomplete type 'long unsigned int[]' + (musl && struct_ == "mcontext_t" && field == "__extcontext" && loongarch64) }); cfg.skip_roundtrip(move |s| match s { diff --git a/libc-test/semver/linux-gnu-loongarch64.txt b/libc-test/semver/linux-gnu-loongarch64.txt index dd1781a03504e..ec6595b79b76f 100644 --- a/libc-test/semver/linux-gnu-loongarch64.txt +++ b/libc-test/semver/linux-gnu-loongarch64.txt @@ -1,6 +1,21 @@ +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 PTRACE_GETFPREGS PTRACE_GETFPXREGS PTRACE_GETREGS PTRACE_SETFPREGS PTRACE_SETFPXREGS PTRACE_SETREGS +PTRACE_SYSEMU +PTRACE_SYSEMU_SINGLESTEP diff --git a/libc-test/semver/linux-loongarch64.txt b/libc-test/semver/linux-loongarch64.txt index 2e2b66b83bf42..ebcd4bf93356f 100644 --- a/libc-test/semver/linux-loongarch64.txt +++ b/libc-test/semver/linux-loongarch64.txt @@ -40,26 +40,11 @@ BPF_XOR CIBAUD FICLONE FICLONERANGE -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 diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index ba56be7a92479..ec41f20c85e5f 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -346,7 +346,10 @@ cfg_if! { pub const RLIMIT_RTPRIO: ::c_int = 14; pub const RLIMIT_RTTIME: ::c_int = 15; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + #[cfg(not(target_arch = "loongarch64"))] pub const RLIM_NLIMITS: ::c_int = 15; + #[cfg(target_arch = "loongarch64")] + pub const RLIM_NLIMITS: ::c_int = 16; #[allow(deprecated)] #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS; diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index ac02803640e30..4866ac039d324 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -11,10 +11,6 @@ pub type __u64 = ::c_ulonglong; pub type __s64 = ::c_longlong; s! { - pub struct pthread_attr_t { - __size: [::c_ulong; 7], - } - pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, @@ -59,21 +55,6 @@ s! { __unused: [::c_int; 2], } - pub struct statfs { - pub f_type: ::c_long, - pub f_bsize: ::c_long, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_long, - pub f_frsize: ::c_long, - pub f_flags: ::c_long, - pub f_spare: [::c_long; 4], - } - pub struct statfs64 { pub f_type: ::c_long, pub f_bsize: ::c_long, @@ -96,7 +77,7 @@ s! { pub cuid: ::uid_t, pub cgid: ::gid_t, pub mode: ::c_uint, - pub __seq: ::c_ushort, + pub __seq: ::c_int, __pad2: ::c_ushort, __unused1: ::c_ulong, __unused2: ::c_ulong, @@ -127,10 +108,10 @@ s! { #[repr(align(16))] pub struct mcontext_t { - pub __pc: ::c_ulonglong, - pub __gregs: [::c_ulonglong; 32], + pub __pc: ::c_ulong, + pub __gregs: [::c_ulong; 32], pub __flags: ::c_uint, - pub __extcontext: [::c_ulonglong; 0], + pub __extcontext: [::c_ulong; 0], } #[repr(align(8))] @@ -468,7 +449,7 @@ pub const SYS_futex_requeue: ::c_long = 456; pub const O_APPEND: ::c_int = 1024; pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_LARGEFILE: ::c_int = 0; +pub const O_LARGEFILE: ::c_int = 0o0100000; pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; @@ -477,7 +458,7 @@ pub const O_NONBLOCK: ::c_int = 2048; pub const O_SYNC: ::c_int = 1052672; pub const O_RSYNC: ::c_int = 1052672; pub const O_DSYNC: ::c_int = 4096; -pub const O_ASYNC: ::c_int = 4096; +pub const O_ASYNC: ::c_int = 0o20000; pub const SIGSTKSZ: ::size_t = 16384; pub const MINSIGSTKSZ: ::size_t = 4096; @@ -661,6 +642,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; pub const CIBAUD: ::tcflag_t = 0o02003600000; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index bfdbb0f0bad59..411139d6bbfcb 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -356,13 +356,15 @@ s! { pub tcpi_options: u8, /* * FIXME(musl): when musl headers are more up to date + */ /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. /// Each is 4 bits. + #[cfg(target_arch = "loongarch64")] pub tcpi_snd_rcv_wscale: u8, /// This contains the bitfields `tcpi_delivery_rate_app_limited` (1 bit) and /// `tcpi_fastopen_client_fail` (2 bits). + #[cfg(target_arch = "loongarch64")] pub tcpi_delivery_fastopen_bitfields: u8, - */ pub tcpi_rto: u32, pub tcpi_ato: u32, pub tcpi_snd_mss: u32, @@ -408,8 +410,10 @@ s! { pub tcpi_dsack_dups: u32, pub tcpi_reord_seen: u32, // FIXME(musl): to uncomment once CI musl is updated - //pub tcpi_rcv_ooopack: u32, - //pub tcpi_snd_wnd: u32, + #[cfg(target_arch = "loongarch64")] + pub tcpi_rcv_ooopack: u32, + #[cfg(target_arch = "loongarch64")] + pub tcpi_snd_wnd: u32, } } @@ -449,8 +453,17 @@ s_no_extra_traits! { pub ut_exit: __exit_status, #[cfg(target_env = "musl")] + #[cfg(not(target_arch = "loongarch64"))] pub ut_session: ::c_long, + #[cfg(target_env = "musl")] + #[cfg(target_arch = "loongarch64")] + pub ut_session: ::c_int, + + #[cfg(target_env = "musl")] + #[cfg(target_arch = "loongarch64")] + __ut_pad2: ::c_int, + #[cfg(target_env = "ohos")] #[cfg(target_endian = "little")] pub ut_session: ::c_int, @@ -712,7 +725,10 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +#[cfg(not(target_arch = "loongarch64"))] pub const CPU_SETSIZE: ::c_int = 128; +#[cfg(target_arch = "loongarch64")] +pub const CPU_SETSIZE: ::c_int = 1024; pub const PTRACE_TRACEME: ::c_int = 0; pub const PTRACE_PEEKTEXT: ::c_int = 1;