chiark / gitweb /
basic/missing: add copy_file_range
[elogind.git] / src / basic / missing.h
index 0039fb0dfcf167ac37ef4fa460dc81981dc665ca..bf685ffe699923767b124e4d56666b882fca2874 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/neighbour.h>
 #include <linux/oom.h>
 #include <linux/rtnetlink.h>
+#include <net/ethernet.h>
 #include <stdlib.h>
 #include <sys/resource.h>
 #include <sys/syscall.h>
@@ -892,13 +893,16 @@ static inline int setns(int fd, int nstype) {
 #define IFLA_BRPORT_FAST_LEAVE 7
 #define IFLA_BRPORT_LEARNING 8
 #define IFLA_BRPORT_UNICAST_FLOOD 9
-#define IFLA_BRPORT_PROXYARP 10
 #define IFLA_BRPORT_LEARNING_SYNC 11
 #define __IFLA_BRPORT_MAX 12
 
 #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
 #endif
 
+#if !HAVE_DECL_IFLA_BRPORT_PROXYARP
+#define IFLA_BRPORT_PROXYARP 10
+#endif
+
 #if !HAVE_DECL_NDA_IFINDEX
 #define NDA_UNSPEC 0
 #define NDA_DST 1
@@ -1181,4 +1185,38 @@ static inline key_serial_t request_key(const char *type, const char *description
 #define char16_t uint16_t
 #endif
 
+#ifndef ETHERTYPE_LLDP
+#define ETHERTYPE_LLDP 0x88cc
+#endif
+
+#endif
+
+#ifndef __NR_copy_file_range
+#  if defined(__x86_64__)
+#    define __NR_copy_file_range 326
+#  elif defined(__i386__)
+#    define __NR_copy_file_range 377
+#  elif defined __s390__
+#    define __NR_copy_file_range 375
+#  elif defined __arm__
+#    define __NR_copy_file_range 391
+#  elif defined __aarch64__
+#    define __NR_copy_file_range 285
+#  else
+#    warning "__NR_copy_file_range not defined for your architecture"
+#  endif
+#endif
+
+#if !HAVE_DECL_COPY_FILE_RANGE
+static inline ssize_t copy_file_range(int fd_in, loff_t *off_in,
+                                      int fd_out, loff_t *off_out,
+                                      size_t len,
+                                      unsigned int flags) {
+#ifdef __NR_copy_file_range
+        return syscall(__NR_copy_file_range, fd_in, off_in, fd_out, off_out, len, flags);
+#else
+        errno = ENOSYS;
+        return -1;
+#endif
+}
 #endif