xref: /freebsd/sys/contrib/openzfs/config/kernel-declare-event-class.m4 (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1dnl #
2dnl # Ensure the DECLARE_EVENT_CLASS macro is available to non-GPL modules.
3dnl #
4AC_DEFUN([ZFS_AC_KERNEL_DECLARE_EVENT_CLASS], [
5	AC_MSG_CHECKING([whether DECLARE_EVENT_CLASS() is available])
6	ZFS_LINUX_TRY_COMPILE_HEADER([
7		#include <linux/module.h>
8		MODULE_LICENSE("$ZFS_META_LICENSE");
9
10		#define CREATE_TRACE_POINTS
11		#include "conftest.h"
12	],[
13		trace_zfs_autoconf_event_one(1UL);
14		trace_zfs_autoconf_event_two(2UL);
15	],[
16		AC_MSG_RESULT(yes)
17		AC_DEFINE(HAVE_DECLARE_EVENT_CLASS, 1,
18		    [DECLARE_EVENT_CLASS() is available])
19	],[
20		AC_MSG_RESULT(no)
21	],[
22		#if !defined(_CONFTEST_H) || defined(TRACE_HEADER_MULTI_READ)
23		#define _CONFTEST_H
24
25		#undef  TRACE_SYSTEM
26		#define TRACE_SYSTEM zfs
27		#include <linux/tracepoint.h>
28
29		DECLARE_EVENT_CLASS(zfs_autoconf_event_class,
30			TP_PROTO(unsigned long i),
31			TP_ARGS(i),
32			TP_STRUCT__entry(
33				__field(unsigned long, i)
34			),
35			TP_fast_assign(
36				__entry->i = i;
37			),
38			TP_printk("i = %lu", __entry->i)
39		);
40
41		#define DEFINE_AUTOCONF_EVENT(name) \
42		DEFINE_EVENT(zfs_autoconf_event_class, name, \
43			TP_PROTO(unsigned long i), \
44			TP_ARGS(i))
45		DEFINE_AUTOCONF_EVENT(zfs_autoconf_event_one);
46		DEFINE_AUTOCONF_EVENT(zfs_autoconf_event_two);
47
48		#endif /* _CONFTEST_H */
49
50		#undef  TRACE_INCLUDE_PATH
51		#define TRACE_INCLUDE_PATH .
52		#define TRACE_INCLUDE_FILE conftest
53		#include <trace/define_trace.h>
54	])
55])
56