[glib/wip/kdbus-junk: 1/37] grow our __NR_memfd_create collection
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/kdbus-junk: 1/37] grow our __NR_memfd_create collection
- Date: Wed, 10 Dec 2014 15:57:16 +0000 (UTC)
commit f64cc2f745b5bf7a571cfdcb4e15926c78bdbc56
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Dec 4 10:51:30 2014 -0500
grow our __NR_memfd_create collection
Also add a fallback case in case we don't know the arch.
glib/glib-linux.h | 38 +++++++++++++++++++++++++++++++-------
1 files changed, 31 insertions(+), 7 deletions(-)
---
diff --git a/glib/glib-linux.h b/glib/glib-linux.h
index b9009e5..e417584 100644
--- a/glib/glib-linux.h
+++ b/glib/glib-linux.h
@@ -20,6 +20,8 @@
#ifndef __GLIB_LINUX_H__
#define __GLIB_LINUX_H__
+#include <errno.h>
+
/* If we know that we are on Linux, add some features, even if they are
* not (yet) advertised in the glibc or kernel headers.
*
@@ -44,6 +46,13 @@
#include <sys/syscall.h>
+static inline int
+glib_linux_enosys (void)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
/* futex */
#include <linux/futex.h>
@@ -68,20 +77,35 @@ glib_linux_futex (int *uaddr,
#endif
#ifndef __NR_memfd_create
- #ifdef __x86_64__
- #define __NR_memfd_create 319
- #elif defined __arm__
- #define __NR_memfd_create 385
- #else
- #define __NR_memfd_create 356
- #endif
+# if defined __x86_64__
+# define __NR_memfd_create 319
+# elif defined i386
+# define __NR_memfd_create 356
+# elif defined __arm__
+ /* arm and arm64 have the same value */
+# define __NR_memfd_create 385
+# elif defined _MIPS_SIM
+# if _MIPS_SIM == _MIPS_SIM_ABI32
+# define __NR_memfd_create 4354
+# endif
+# if _MIPS_SIM == _MIPS_SIM_NABI32
+# define __NR_memfd_create 6318
+# endif
+# if _MIPS_SIM == _MIPS_SIM_ABI64
+# define __NR_memfd_create 5314
+# endif
+# endif
#endif
static inline int
glib_linux_memfd_create (const char *name,
unsigned int flags)
{
+#ifdef __NR_memfd_create
return syscall (__NR_memfd_create, name, flags);
+#else
+ return glib_linux_enosys ();
+#endif
}
/* Linux-specific fcntl() operations */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]