[igt-dev] [PATCH i-g-t 2/2] stubs: provide implementation for memfd_create
Chris Wilson
chris at chris-wilson.co.uk
Fri Jul 20 07:05:46 UTC 2018
Quoting Antonio Argenziano (2018-07-19 23:17:19)
>
>
> On 19/07/18 14:43, De Marchi, Lucas wrote:
> > 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.
Ffs, I have platforms where meson is no go. meson itself is not yet
stable, why force a broken build system on us until it has at least had
the decency to declare itself stable and not require trashing its build
directory every other week.
-Chris
More information about the igt-dev
mailing list