summary refs log tree commit diff stats
path: root/bsd-user/bsd-mem.h
diff options
context:
space:
mode:
authorStacey Son <sson@FreeBSD.org>2023-09-25 21:27:05 +0300
committerWarner Losh <imp@bsdimp.com>2023-10-03 17:14:07 -0600
commit4f0be683e399e7685608b83240da099ea45d84e6 (patch)
treebc968e7cb72dddd9a662b2bc022aefc53676643f /bsd-user/bsd-mem.h
parenta99d74034754b1d8735d814cf17db6bf0eb4bfd1 (diff)
downloadfocaccia-qemu-4f0be683e399e7685608b83240da099ea45d84e6.tar.gz
focaccia-qemu-4f0be683e399e7685608b83240da099ea45d84e6.zip
bsd-user: Implement shm_open(2)
Co-authored-by: Kyle Evans <kevans@FreeBSD.org>

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230925182709.4834-20-kariem.taha2.7@gmail.com>
Diffstat (limited to 'bsd-user/bsd-mem.h')
-rw-r--r--bsd-user/bsd-mem.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h
index b296c5c6f0..f8dc943c23 100644
--- a/bsd-user/bsd-mem.h
+++ b/bsd-user/bsd-mem.h
@@ -257,4 +257,29 @@ static inline abi_long do_obreak(abi_ulong brk_val)
     return target_brk;
 }
 
+/* shm_open(2) */
+static inline abi_long do_bsd_shm_open(abi_ulong arg1, abi_long arg2,
+        abi_long arg3)
+{
+    int ret;
+    void *p;
+
+    if (arg1 == (uintptr_t)SHM_ANON) {
+        p = SHM_ANON;
+    } else {
+        p = lock_user_string(arg1);
+        if (p == NULL) {
+            return -TARGET_EFAULT;
+        }
+    }
+    ret = get_errno(shm_open(p, target_to_host_bitmask(arg2, fcntl_flags_tbl),
+                             arg3));
+
+    if (p != SHM_ANON) {
+        unlock_user(p, arg1, 0);
+    }
+
+    return ret;
+}
+
 #endif /* BSD_USER_BSD_MEM_H */