<sys/membarrier.h>
enh
enh@google.com
Thu Jul 9 18:36:56 GMT 2026
yeah, "all the choices suck". varargs has caused android (and android
developers) pain in the past too, so i'm tempted to go for three
arguments, but then callers are going to need an #if to support musl,
at which point everyone may as well have stuck with syscall() :-(
On Thu, Jul 9, 2026 at 2:24 PM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 09/07/26 14:09, enh wrote:
> > fyi, it looks like musl added a <sys/membarrier.h>. membarrier() has
> > seen quite a lot of use in android (via syscall() so far) so i'm
> > thinking we'll add <sys/membarrier.h> to bionic. i'm assuming glibc
> > has no immediate plans to add it somewhere else like <sys/mman.h> or
> > whatever?
>
> We don't have any RFE for this addition, but it should not be a blocker
> either. It seems that musl has used the old Linux 5.10 prototype,
> membarrier (int, int), where newer kernel now defined it with 3
> argument.
>
> I think it should avoid use varargs, this has bitten us in the past; so
> I would suggest to either mimic the kernel interface with 3 arguments,
> or at least return EINVAL when MEMBARRIER_CMD_FLAG_CPU is used (if the
> idea is t keep some compatibility with musl).
>
> Which kind of interface do you plan to use on Android? I don't have a
> strong preference either to which header to use, sys/membarrier.h works
> as well.
More information about the Libc-alpha
mailing list