[lttng-dev] [PATCH lttng-tools 24/24] Android : Add splice compatibility to fcntl layer

Charles Briere c.briere at samsung.com
Mon Oct 27 16:49:30 EDT 2014


From: Charles Briere <c.briere at samsung.com>

Define splice() as __NR_splice() when not available directly (happens with BIONIC)
Define SPLICE_*_* values

Signed-off-by: Charles Briere <c.briere at samsung.com>
---
 configure.ac              |  2 +-
 src/common/compat/fcntl.h | 26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index ea37ad0..7230e92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,7 +67,7 @@ AC_CHECK_TYPES([in_port_t], [], [], [[#include <netinet/in.h>]])
 
 AC_CHECK_DECLS([sigwaitinfo],[],[], [[#include <signal.h>]])
 AC_CHECK_DECLS([pthread_cancel], [], [], [[#include <pthread.h>]])
-AC_CHECK_DECLS([posix_fadvise],[],[], [[#include <fcntl.h>]])
+AC_CHECK_DECLS([posix_fadvise, splice],[],[], [[#include <fcntl.h>]])
 
 AC_CHECK_FUNCS([getpwuid_r],[],[])
 
diff --git a/src/common/compat/fcntl.h b/src/common/compat/fcntl.h
index 779c942..b3453a2 100644
--- a/src/common/compat/fcntl.h
+++ b/src/common/compat/fcntl.h
@@ -46,9 +46,33 @@ extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
 #  include <linux/fadvise.h>
 # endif
 
+# if !HAVE_DECL_SPLICE
+#  if defined(__NR_splice)
+#   define splice(fdin, off_in, fdout, off_out, len, flags) syscall(__NR_splice, fdin, off_in, fdout, off_out, len, flags)
+#  endif
+# endif
+
 # ifndef SYNC_FILE_RANGE_WRITE
 #  include <linux/fs.h>
-#endif
+# endif
+
+# ifndef SPLICE_F_MOVE
+#  define SPLICE_F_MOVE 	1	/* Move pages instead of copying.  */
+# endif
+
+# ifndef SPLICE_F_NONBLOCK
+#  define SPLICE_F_NONBLOCK	2	/* Don't block on the pipe splicing
+					  (but we may still block on the fd
+					  we splice from/to).  */
+# endif
+
+# ifndef SPLICE_F_MORE
+#  define SPLICE_F_MORE 	4	/* Expect more data.  */
+# endif
+
+# ifndef SPLICE_F_GIFT
+#  define SPLICE_F_GIFT		8	/* Pages passed in are a gift.  */
+# endif
 
 #endif /* __linux__ */
 
-- 
2.1.2



More information about the lttng-dev mailing list