[igt-dev] [PATCH i-g-t 2/2] stubs: provide implementation for memfd_create
De Marchi, Lucas
lucas.demarchi at intel.com
Thu Jul 19 21:43:35 UTC 2018
On Thu, 2018-07-19 at 14:14 -0700, Antonio Argenziano wrote:
>
> On 19/07/18 13:54, Lucas De Marchi wrote:
> > When libc misses memfd_create(), provide a stub implementation to go
> > through the syscall() route. Syscall numbers are provided for platforms
> > currently supported by i-g-t only.
> >
> > Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
> > ---
> > lib/stubs/syscall/sys/mman.h | 37 ++++++++++++++++++++++++++++++++++++
> > meson.build | 3 +++
> > 2 files changed, 40 insertions(+)
> > create mode 100644 lib/stubs/syscall/sys/mman.h
> >
> > diff --git a/lib/stubs/syscall/sys/mman.h b/lib/stubs/syscall/sys/mman.h
> > new file mode 100644
> > index 00000000..36060bda
> > --- /dev/null
> > +++ b/lib/stubs/syscall/sys/mman.h
> > @@ -0,0 +1,37 @@
> > +/* SPDX-License-Identifier: MIT */
> > +
> > +#pragma once
> > +
> > +#include_next <sys/mman.h>
> > +
> > +#if !HAVE_MEMFD_CREATE
> > +#include <errno.h>
> > +#include <sys/syscall.h>
> > +#include <sys/types.h>
> > +#include <unistd.h>
> > +
> > +#ifndef __NR_memfd_create
> > +#if defined __x86_64__
> > +#define __NR_memfd_create 319
> > +#elif defined __i386__
> > +#define __NR_memfd_create 356
> > +#elif defined __arm__
> > +#define __NR_memfd_create 385
> > +#else
> > +#warning "__NR_memfd_create unknown for your architecture"
> > +#endif
> > +#endif
> > +
> > +static inline int missing_memfd_create(const char *name, unsigned int
> > flags)
> > +{
> > +#ifdef __NR_memfd_create
> > + return syscall(__NR_memfd_create, name, flags);
> > +#else
> > + errno = ENOSYS;
> > + return -1;
> > +#endif
> > +}
> > +
> > +#define memfd_create missing_memfd_create
> > +
> > +#endif
> > diff --git a/meson.build b/meson.build
> > index c24a3cf4..188301ca 100644
> > --- a/meson.build
> > +++ b/meson.build
>
> No love for make?
no, afaik it's dead, isn't it? Worse than supporting an old build system is
having to support it in addition to the new one.
Lucas De Marchi
>
> Antonio
>
> > @@ -196,6 +196,9 @@ if cc.has_member('struct sysinfo', 'totalram',
> > config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
> > endif
> >
> > +have = cc.has_function('memfd_create', prefix : '''#include
> > <sys/mman.h>''', args : '-D_GNU_SOURCE')
> > +config.set10('HAVE_MEMFD_CREATE', have)
> > +
> > add_project_arguments('-D_GNU_SOURCE', language : 'c')
> > add_project_arguments('-include', 'config.h', language : 'c')
> >
> >
More information about the igt-dev
mailing list