chiark / gitweb /
memfd: always create our memfds with CLOEXEC set
[elogind.git] / src / shared / missing.h
index 5b87e23eec311d6d34b3693de361a25a09c3055d..0d7c55952ee3f885ecf8c0cd3121c1dfd40ce374 100644 (file)
 #endif
 
 #ifndef MFD_ALLOW_SEALING
-#define MFD_ALLOW_SEALING 0x0002ULL
+#define MFD_ALLOW_SEALING 0x0002U
+#endif
+
+#ifndef MFD_CLOEXEC
+#define MFD_CLOEXEC 0x0001U
 #endif
 
 #ifndef IP_FREEBIND
@@ -115,21 +119,15 @@ static inline int pivot_root(const char *new_root, const char *put_old) {
 }
 #endif
 
-#ifdef __x86_64__
-#  ifndef __NR_memfd_create
+#ifndef __NR_memfd_create
+#  if defined __x86_64__
 #    define __NR_memfd_create 319
-#  endif
-#elif defined __arm__
-#  ifndef __NR_memfd_create
+#  elif defined __arm__
 #    define __NR_memfd_create 385
-#  endif
-#elif defined _MIPS_SIM
-#  ifndef __NR_memfd_create
+#  elif defined _MIPS_SIM
 #    warning "__NR_memfd_create not yet defined for MIPS"
 #    define __NR_memfd_create 0xffffffff
-#  endif
-#else
-#  ifndef __NR_memfd_create
+#  else
 #    define __NR_memfd_create 356
 #  endif
 #endif
@@ -142,7 +140,7 @@ static inline int memfd_create(const char *name, unsigned int flags) {
 
 #ifndef __NR_getrandom
 #  if defined __x86_64__
-#    define __NR_getrandom 278
+#    define __NR_getrandom 318
 #  else
 #    warning "__NR_getrandom unknown for your architecture"
 #    define __NR_getrandom 0xffffffff
@@ -155,6 +153,14 @@ static inline int getrandom(void *buffer, size_t count, unsigned flags) {
 }
 #endif
 
+#ifndef GRND_NONBLOCK
+#define GRND_NONBLOCK 0x0001
+#endif
+
+#ifndef GRND_RANDOM
+#define GRND_RANDOM 0x0002
+#endif
+
 #ifndef BTRFS_IOCTL_MAGIC
 #define BTRFS_IOCTL_MAGIC 0x94
 #endif
@@ -426,7 +432,7 @@ static inline int setns(int fd, int nstype) {
 #define IFLA_BOND_AD_INFO 23
 #define __IFLA_BOND_MAX 24
 
-#define IFLA_BOND_MAX  (__IFLA_BOND_MAX - 1)
+#define IFLA_BOND_MAX   (__IFLA_BOND_MAX - 1)
 #endif
 
 #if !HAVE_DECL_IFLA_VLAN_PROTOCOL