Conversation
|
Rustix doesn't use |
|
@sunfishcode Hi, I found that getrlimit and setrlimit functions have been implemented using prlimit64 in the file src/backend/linux_raw/process/syscalls.rs. Maybe loongarch64 does not need additional processing. But I am not sure which file the following code calls in the file src/process/rlimit.rs: Because both src/backend/linux_raw/process/syscalls.rs and src/backend/libc/process/syscalls.rs define the two functions setrlimit and getrlimit. |
Rustix has two "backends", one that uses libc calls and one that uses raw linux syscalls. The code in src/process/rlimit.rs will call either the code in src/backend/linux_raw/process/syscalls.rs or src/backend/libc/process/syscalls.rs depending on which backend the user has configured. However, I'd expect both backends to work with loongarch64, because rustix doesn't use the |
sunfishcode
left a comment
There was a problem hiding this comment.
Since loongarch64 has Tier-2 targets in Rust, adding support for raw syscalls to rustix should also add testing using qemu in the CI scripts, following the other architectures.
| /// [`FileType::from_raw_mode`]: crate::fs::FileType::from_raw_mode | ||
| #[cfg(not(target_arch = "loongarch64"))] | ||
| #[inline] | ||
| pub fn fstat<Fd: AsFd>(fd: Fd) -> io::Result<Stat> { |
There was a problem hiding this comment.
I assume loongarch64 should support the public fstat API. There may be no __NR_fstat but if so then src/backend/linux_raw/fs/syscalls.rs' fstat can probably use statx instead.
| /// [Linux]: https://man7.org/linux/man-pages/man2/setrlimit.2.html | ||
| #[cfg(not(target_arch = "loongarch64"))] | ||
| #[inline] | ||
| pub fn setrlimit(resource: Resource, new: Rlimit) -> io::Result<()> { |
There was a problem hiding this comment.
Similarly, I assume loongarch64 should support the public setrlimit API even if there is no __NR_setrlimit, as it can use prlimit64 instead.
| asm!( | ||
| "syscall 0", | ||
| in("$a7") nr.to_asm(), | ||
| inlateout("$a0") a0.to_asm() => r0, | ||
| in("$a1") a1.to_asm(), | ||
| in("$a2") a2.to_asm(), | ||
| in("$a3") a3.to_asm(), | ||
| in("$a4") a4.to_asm(), | ||
| in("$a5") a5.to_asm(), | ||
| options(nostack, preserves_flags) | ||
| ); |
There was a problem hiding this comment.
According to musl and glibc, loongarch syscall clobbers $t[0-8] regardless of the number of arguments.
No description provided.