Only define memfd_create when not already defined

This commit is contained in:
Wim Taymans 2017-11-24 17:23:40 +01:00
parent bde1012c5c
commit 2a86814bb8
3 changed files with 7 additions and 0 deletions

View file

@ -445,3 +445,4 @@
#mesondefine HAVE_ALARM #mesondefine HAVE_ALARM
#mesondefine HAVE_DECL_LOCALTIME_R #mesondefine HAVE_DECL_LOCALTIME_R
#mesondefine HAVE_DECL_STRSIGNAL #mesondefine HAVE_DECL_STRSIGNAL
#mesondefine HAVE_MEMFD_CREATE

View file

@ -117,6 +117,10 @@ if cc.has_function('mkstemp', prefix : '#include <stdlib.h>')
cdata.set('HAVE_MKSTEMP', 1) cdata.set('HAVE_MKSTEMP', 1)
endif endif
if cc.has_function('memfd_create', prefix : '#include <sys/mman.h>')
cdata.set('HAVE_MEMFD_CREATE', 1)
endif
configure_file(input : 'config.h.meson', configure_file(input : 'config.h.meson',
output : 'config.h', output : 'config.h',
configuration : cdata) configuration : cdata)

View file

@ -20,6 +20,7 @@
#include <sys/syscall.h> #include <sys/syscall.h>
#include <fcntl.h> #include <fcntl.h>
#ifndef HAVE_MEMFD_CREATE
/* /*
* No glibc wrappers exist for memfd_create(2), so provide our own. * No glibc wrappers exist for memfd_create(2), so provide our own.
* *
@ -32,6 +33,7 @@ static inline int
memfd_create(const char *name, unsigned int flags) { memfd_create(const char *name, unsigned int flags) {
return syscall(SYS_memfd_create, name, flags); return syscall(SYS_memfd_create, name, flags);
} }
#endif
/* memfd_create(2) flags */ /* memfd_create(2) flags */