summaryrefslogtreecommitdiff
path: root/lib/stubs/syscalls/sys/mman.h
blob: 2ac2da6a42db7d4b6b6c2403d708a20f9c43bc0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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