chiark / gitweb /
core: move config_parse_set_status() into load-fragment.c
[elogind.git] / src / shared / missing.h
index 2661285a227c39fb3d8f181fbbee960aac90ee31..06c69dac8efff4562b16f2079cbd01646c19ded9 100644 (file)
@@ -28,6 +28,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <errno.h>
 #include <linux/oom.h>
 #include <linux/input.h>
 #include <linux/if_link.h>
@@ -272,25 +273,17 @@ static inline pid_t gettid(void) {
 #define MAX_HANDLE_SZ 128
 #endif
 
-#if defined __x86_64__
-#  ifndef __NR_name_to_handle_at
+#ifndef __NR_name_to_handle_at
+#  if defined(__x86_64__)
 #    define __NR_name_to_handle_at 303
-#  endif
-#elif defined __i386__
-#  ifndef __NR_name_to_handle_at
+#  elif defined(__i386__)
 #    define __NR_name_to_handle_at 341
-#  endif
-#elif defined __arm__
-#  ifndef __NR_name_to_handle_at
+#  elif defined(__arm__)
 #    define __NR_name_to_handle_at 370
-#  endif
-#elif defined __powerpc__
-#  ifndef __NR_name_to_handle_at
+#  elif defined(__powerpc__)
 #    define __NR_name_to_handle_at 345
-#  endif
-#else
-#  ifndef __NR_name_to_handle_at
-#    error __NR_name_to_handle_at is not defined
+#  else
+#    error "__NR_name_to_handle_at is not defined"
 #  endif
 #endif
 
@@ -310,7 +303,7 @@ static inline int name_to_handle_at(int fd, const char *name, struct file_handle
 #  ifdef HAVE___SECURE_GETENV
 #    define secure_getenv __secure_getenv
 #  else
-#    error neither secure_getenv nor __secure_getenv are available
+#    error "neither secure_getenv nor __secure_getenv are available"
 #  endif
 #endif
 
@@ -353,3 +346,19 @@ static inline int name_to_handle_at(int fd, const char *name, struct file_handle
 #endif
 
 #endif
+
+#ifndef __NR_setns
+#  if defined(__x86_64__)
+#    define __NR_setns 308
+#  elif defined(__i386__)
+#    define __NR_setns 346
+#  else
+#    error "__NR_setns is not defined"
+#  endif
+#endif
+
+#if !HAVE_DECL_SETNS
+static inline int setns(int fd, int nstype) {
+        return syscall(__NR_setns, fd, nstype);
+}
+#endif