[PATCH 16/24] bsd-user: Add do_bsd_semget implementation

Warner Losh posted 24 patches 3 days, 16 hours ago
Maintainers: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, Riku Voipio <riku.voipio@iki.fi>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
There is a newer version of this series
[PATCH 16/24] bsd-user: Add do_bsd_semget implementation
Posted by Warner Losh 3 days, 16 hours ago
From: Stacey Son <sson@FreeBSD.org>

Add implementation of semget(2) syscall to get System V semaphore set
identifier. Converts target IPC flags to host format.

Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/bsd-misc.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/bsd-user/bsd-misc.h b/bsd-user/bsd-misc.h
index b722c63437..18520548fb 100644
--- a/bsd-user/bsd-misc.h
+++ b/bsd-user/bsd-misc.h
@@ -77,6 +77,18 @@ out:
     return ret;
 }
 
+/*
+ * System V Semaphores
+ */
+
+/* semget(2) */
+static inline abi_long do_bsd_semget(abi_long key, int nsems,
+        int target_flags)
+{
+    return get_errno(semget(key, nsems,
+                target_to_host_bitmask(target_flags, ipc_flags_tbl)));
+}
+
 /* getdtablesize(2) */
 static inline abi_long do_bsd_getdtablesize(void)
 {

-- 
2.52.0
Re: [PATCH 16/24] bsd-user: Add do_bsd_semget implementation
Posted by Richard Henderson 3 days, 6 hours ago
On 2/6/26 03:26, Warner Losh wrote:
> From: Stacey Son <sson@FreeBSD.org>
> 
> Add implementation of semget(2) syscall to get System V semaphore set
> identifier. Converts target IPC flags to host format.
> 
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/bsd-misc.h | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/bsd-user/bsd-misc.h b/bsd-user/bsd-misc.h
> index b722c63437..18520548fb 100644
> --- a/bsd-user/bsd-misc.h
> +++ b/bsd-user/bsd-misc.h
> @@ -77,6 +77,18 @@ out:
>       return ret;
>   }
>   
> +/*
> + * System V Semaphores
> + */
> +
> +/* semget(2) */
> +static inline abi_long do_bsd_semget(abi_long key, int nsems,
> +        int target_flags)
> +{
> +    return get_errno(semget(key, nsems,
> +                target_to_host_bitmask(target_flags, ipc_flags_tbl)));
> +}
> +
>   /* getdtablesize(2) */
>   static inline abi_long do_bsd_getdtablesize(void)
>   {
> 

Doesn't FreeBSD have consistent ipc flags across targets?
I'm surprised the conversion is necessary.

Anyway,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Re: [PATCH 16/24] bsd-user: Add do_bsd_semget implementation
Posted by Warner Losh 2 days, 15 hours ago
On Thu, Feb 5, 2026 at 8:11 PM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 2/6/26 03:26, Warner Losh wrote:
> > From: Stacey Son <sson@FreeBSD.org>
> >
> > Add implementation of semget(2) syscall to get System V semaphore set
> > identifier. Converts target IPC flags to host format.
> >
> > Signed-off-by: Stacey Son <sson@FreeBSD.org>
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >   bsd-user/bsd-misc.h | 12 ++++++++++++
> >   1 file changed, 12 insertions(+)
> >
> > diff --git a/bsd-user/bsd-misc.h b/bsd-user/bsd-misc.h
> > index b722c63437..18520548fb 100644
> > --- a/bsd-user/bsd-misc.h
> > +++ b/bsd-user/bsd-misc.h
> > @@ -77,6 +77,18 @@ out:
> >       return ret;
> >   }
> >
> > +/*
> > + * System V Semaphores
> > + */
> > +
> > +/* semget(2) */
> > +static inline abi_long do_bsd_semget(abi_long key, int nsems,
> > +        int target_flags)
> > +{
> > +    return get_errno(semget(key, nsems,
> > +                target_to_host_bitmask(target_flags, ipc_flags_tbl)));
> > +}
> > +
> >   /* getdtablesize(2) */
> >   static inline abi_long do_bsd_getdtablesize(void)
> >   {
> >
>
> Doesn't FreeBSD have consistent ipc flags across targets?
> I'm surprised the conversion is necessary.
>

It does, and this could be a simplification, but for now I'm going to leave
in place since there is some other related work someone else is doing I
don't want to get in the way of...

Warner


> Anyway,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
> r~
>
>