xref: /aosp_15_r20/external/igt-gpu-tools/lib/stubs/syscalls/sys/mman.h (revision d83cc019efdc2edc6c4b16e9034a3ceb8d35d77c)
1 /* SPDX-License-Identifier: MIT */
2 
3 #pragma once
4 
5 #include_next <sys/mman.h>
6 
7 #if !defined(HAVE_MEMFD_CREATE) || !HAVE_MEMFD_CREATE
8 #include <errno.h>
9 #include <sys/syscall.h>
10 #include <sys/types.h>
11 #include <unistd.h>
12 
13 #ifndef __NR_memfd_create
14 #if defined __x86_64__
15 #define __NR_memfd_create 319
16 #elif defined __i386__
17 #define __NR_memfd_create 356
18 #elif defined __arm__
19 #define __NR_memfd_create 385
20 #else
21 #warning "__NR_memfd_create unknown for your architecture"
22 #endif
23 #endif
24 
missing_memfd_create(const char * name,unsigned int flags)25 static inline int missing_memfd_create(const char *name, unsigned int flags)
26 {
27 #ifdef __NR_memfd_create
28 	return syscall(__NR_memfd_create, name, flags);
29 #else
30 	errno = ENOSYS;
31 	return -1;
32 #endif
33 }
34 
35 #define memfd_create missing_memfd_create
36 
37 #endif
38