+#elif defined(HAVE_2ARGS_NEW_SHRINKER_CALLBACK)
+#define SPL_SHRINKER_DECLARE(s, x, y) \
+static struct shrinker s = { \
+ .shrink = x, \
+ .seeks = y \
+}
+
+#define SPL_SHRINKER_CALLBACK_FWD_DECLARE(fn) \
+static int fn(struct shrinker *, struct shrink_control *)
+
+#define SPL_SHRINKER_CALLBACK_WRAPPER(fn) \
+static int \
+fn(struct shrinker *shrink, struct shrink_control *sc) \
+{ \
+ return (__ ## fn(shrink, sc)); \
+}
+
+/*
+ * Linux 3.12 and later Shrinker API Compatibility.
+ */
+#elif defined(HAVE_SPLIT_SHRINKER_CALLBACK)
+#define SPL_SHRINKER_DECLARE(s, x, y) \
+static struct shrinker s = { \
+ .count_objects = x ## _count_objects, \
+ .scan_objects = x ## _scan_objects, \
+ .seeks = y \
+}
+
+#define SPL_SHRINKER_CALLBACK_FWD_DECLARE(fn) \
+static unsigned long fn ## _count_objects(struct shrinker *, \
+ struct shrink_control *); \
+static unsigned long fn ## _scan_objects(struct shrinker *, \
+ struct shrink_control *)
+
+#define SPL_SHRINKER_CALLBACK_WRAPPER(fn) \
+static unsigned long \
+fn ## _count_objects(struct shrinker *shrink, struct shrink_control *sc)\
+{ \
+ int __ret__; \
+ \
+ sc->nr_to_scan = 0; \
+ __ret__ = __ ## fn(NULL, sc); \
+ \
+ /* Errors may not be returned and must be converted to zeros */ \
+ return ((__ret__ < 0) ? 0 : __ret__); \
+} \
+ \
+static unsigned long \
+fn ## _scan_objects(struct shrinker *shrink, struct shrink_control *sc) \
+{ \
+ int __ret__; \
+ \
+ __ret__ = __ ## fn(NULL, sc); \
+ return ((__ret__ < 0) ? SHRINK_STOP : __ret__); \
+}
+#else
+/*
+ * Linux 2.x to 2.6.22, or a newer shrinker API has been introduced.
+ */
+#error "Unknown shrinker callback"
+#endif
+
+#if defined(HAVE_SPLIT_SHRINKER_CALLBACK)
+typedef unsigned long spl_shrinker_t;
+#else
+typedef int spl_shrinker_t;
+#define SHRINK_STOP (-1)
+#endif