[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/32] bsd-user: Implement target_to_host_rlim and host_to_target
From: |
Karim Taha |
Subject: |
[PATCH 08/32] bsd-user: Implement target_to_host_rlim and host_to_target_rlim conversion. |
Date: |
Sun, 27 Aug 2023 17:57:22 +0200 |
From: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
---
bsd-user/bsd-proc.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c
index ae2e636bb3..12e43cfeca 100644
--- a/bsd-user/bsd-proc.c
+++ b/bsd-user/bsd-proc.c
@@ -81,3 +81,36 @@ int target_to_host_resource(int code)
}
}
+rlim_t target_to_host_rlim(abi_llong target_rlim)
+{
+ abi_llong target_rlim_swap;
+ rlim_t result;
+
+ target_rlim_swap = tswap64(target_rlim);
+ if (target_rlim_swap == TARGET_RLIM_INFINITY) {
+ return RLIM_INFINITY;
+ }
+
+ result = target_rlim_swap;
+ if (target_rlim_swap != (rlim_t)result) {
+ return RLIM_INFINITY;
+ }
+
+ return result;
+}
+
+abi_llong host_to_target_rlim(rlim_t rlim)
+{
+ abi_llong target_rlim_swap;
+ abi_llong result;
+
+ if (rlim == RLIM_INFINITY || rlim != (abi_llong)rlim) {
+ target_rlim_swap = TARGET_RLIM_INFINITY;
+ } else {
+ target_rlim_swap = rlim;
+ }
+ result = tswap64(target_rlim_swap);
+
+ return result;
+}
+
--
2.40.0
- [PATCH 03/32] bsd-user: Implement host_to_target_siginfo., (continued)
- [PATCH 03/32] bsd-user: Implement host_to_target_siginfo., Karim Taha, 2023/08/28
- [PATCH 04/32] bsd-user: Add freebsd_exec_common and do_freebsd_procctl to qemu.h., Karim Taha, 2023/08/28
- [PATCH 05/32] bsd-user: add extern declarations for bsd-proc.c conversion functions, Karim Taha, 2023/08/28
- [PATCH 06/32] bsd-user: Add bsd-proc.c to meson.build, Karim Taha, 2023/08/28
- [PATCH 07/32] bsd-user: Implement target_to_host_resource conversion function, Karim Taha, 2023/08/28
- [PATCH 08/32] bsd-user: Implement target_to_host_rlim and host_to_target_rlim conversion.,
Karim Taha <=
- [PATCH 10/32] bsd-user: Implement host_to_target_waitstatus conversion., Karim Taha, 2023/08/28
- [PATCH 09/32] bsd-user: Implement host_to_target_rusage and host_to_target_wrusage., Karim Taha, 2023/08/28
- [PATCH 13/32] bsd-user: Implement umask(2), setlogin(2) and getlogin(2), Karim Taha, 2023/08/28
- [PATCH 12/32] bsd-user: Implement getgroups(2) and setgroups(2) system calls., Karim Taha, 2023/08/28
- [PATCH 11/32] bsd-user: Get number of cpus., Karim Taha, 2023/08/28