Namespace kernel version macros
[lttng-modules.git] / wrapper / splice.c
index 44a4d6b87b2b8062b571ed6270b4556006e8572a..7160ea1aa009c148836ce636a27a79c356b3273f 100644 (file)
@@ -4,12 +4,15 @@
  *
  * wrapper around splice_to_pipe. Using KALLSYMS to get its address when
  * available, else we need to have a kernel that exports this function to GPL
- * modules.
+ * modules. The export was introduced in kernel 4.2.
  *
  * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  */
 
-#ifdef CONFIG_KALLSYMS
+#include <lttng-kernel-version.h>
+
+#if (defined(CONFIG_KALLSYMS) \
+       && (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(4,2,0)))
 
 #include <linux/kallsyms.h>
 #include <linux/fs.h>
@@ -33,6 +36,21 @@ ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
        }
 }
 
+/*
+ * Canary function to check for 'splice_to_pipe()' at compile time.
+ *
+ * From 'include/linux/splice.h':
+ *
+ *   extern ssize_t splice_to_pipe(struct pipe_inode_info *,
+ *                                 struct splice_pipe_desc *spd);
+ */
+__attribute__((unused)) static
+ssize_t __canary__splice_to_pipe(struct pipe_inode_info *pipe,
+                               struct splice_pipe_desc *spd)
+{
+       return splice_to_pipe(pipe, spd);
+}
+
 #else
 
 #include <linux/fs.h>
This page took 0.023438 seconds and 4 git commands to generate.