55facb77755ba5b581f95f403ba2ee154b60e1f4
[lttng-modules.git] / tests / clock-plugin / lttng-clock-plugin-test.c
1 /*
2 * lttng-clock-plugin-test.c
3 *
4 * Copyright (C) 2014, 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; only
9 * version 2.1 of the License.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <linux/module.h>
22 #include <linux/ktime.h>
23 #include <linux/hrtimer.h>
24 #include <linux/time.h>
25
26 #include <lttng-clock.h> /* From lttng-modules */
27
28 static u64 trace_clock_read64_example(void)
29 {
30 /* Freeze time. */
31 return 0;
32 }
33
34 static u64 trace_clock_freq_example(void)
35 {
36 return 1000; /* 1KHz */
37 }
38
39 static int trace_clock_uuid_example(char *uuid)
40 {
41 const char myuuid[] = "83c63deb-7aa4-48fb-abda-946f400d76e6";
42 memcpy(uuid, myuuid, LTTNG_MODULES_UUID_STR_LEN);
43 return 0;
44 }
45
46 static const char *trace_clock_name_example(void)
47 {
48 return "lttng_test_clock_override";
49 }
50
51 static const char *trace_clock_description_example(void)
52 {
53 return "Freeze time with 1KHz for regression test";
54 }
55
56 static
57 struct lttng_trace_clock ltc = {
58 .read64 = trace_clock_read64_example,
59 .freq = trace_clock_freq_example,
60 .uuid = trace_clock_uuid_example,
61 .name = trace_clock_name_example,
62 .description = trace_clock_description_example,
63 };
64
65 static __init
66 int lttng_clock_plugin_init(void)
67 {
68 return lttng_clock_register_plugin(&ltc, THIS_MODULE);
69 }
70 fs_initcall(lttng_clock_plugin_init);
71
72 static __exit
73 void lttng_clock_plugin_exit(void)
74 {
75 lttng_clock_unregister_plugin(&ltc, THIS_MODULE);
76 }
77 module_exit(lttng_clock_plugin_exit);
78
79 MODULE_LICENSE("GPL and additional rights");
80 MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
81 MODULE_DESCRIPTION("LTTng Clock Plugin Example");
This page took 0.031105 seconds and 3 git commands to generate.