[igt-dev] [PATCH i-g-t 2/2] stubs: provide implementation for memfd_create

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Fri Jul 20 09:48:47 UTC 2018


On 19/07/2018 22: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.

It's definitely bad having to support two, but until someone gets brave 
enough to do a git rm on the old one I think we need to keep it functional.

Regards,

Tvrtko


More information about the igt-dev mailing list