diff options
author | Lucas De Marchi <lucas.demarchi@intel.com> | 2018-07-24 15:20:24 -0700 |
---|---|---|
committer | Rodrigo Vivi <rodrigo.vivi@intel.com> | 2018-07-25 15:48:47 -0700 |
commit | bcb37a9b20eeec97f15fac2222408cc2e0b77631 (patch) | |
tree | a83ffec8f590e2c4bf6ef559ebab9c900140ce47 /lib/stubs | |
parent | 31ea7dd5e66d8ff3acf093de79a2890a2cbec045 (diff) |
build: provide stub implementation for memfd_create
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.
v2: add support to autotools
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Antonio Argenziano <antonio.argenziano@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'lib/stubs')
-rw-r--r-- | lib/stubs/syscalls/sys/mman.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/stubs/syscalls/sys/mman.h b/lib/stubs/syscalls/sys/mman.h new file mode 100644 index 00000000..2ac2da6a --- /dev/null +++ b/lib/stubs/syscalls/sys/mman.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: MIT */ + +#pragma once + +#include_next <sys/mman.h> + +#if !defined(HAVE_MEMFD_CREATE) || !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 |