Commit | Line | Data |
---|---|---|
b7cdc182 | 1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
9f36eaed | 2 | * |
db758d11 MD |
3 | * lttng-clock-plugin-test.c |
4 | * | |
5 | * Copyright (C) 2014, 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
db758d11 MD |
6 | */ |
7 | ||
8 | #include <linux/module.h> | |
9 | #include <linux/ktime.h> | |
10 | #include <linux/hrtimer.h> | |
11 | #include <linux/time.h> | |
12 | ||
1c124020 | 13 | #include <lttng-tracer.h> |
db758d11 MD |
14 | #include <lttng-clock.h> /* From lttng-modules */ |
15 | ||
16 | static u64 trace_clock_read64_example(void) | |
17 | { | |
18 | /* Freeze time. */ | |
19 | return 0; | |
20 | } | |
21 | ||
22 | static u64 trace_clock_freq_example(void) | |
23 | { | |
24 | return 1000; /* 1KHz */ | |
25 | } | |
26 | ||
27 | static int trace_clock_uuid_example(char *uuid) | |
28 | { | |
29 | const char myuuid[] = "83c63deb-7aa4-48fb-abda-946f400d76e6"; | |
30 | memcpy(uuid, myuuid, LTTNG_MODULES_UUID_STR_LEN); | |
31 | return 0; | |
32 | } | |
33 | ||
34 | static const char *trace_clock_name_example(void) | |
35 | { | |
36 | return "lttng_test_clock_override"; | |
37 | } | |
38 | ||
39 | static const char *trace_clock_description_example(void) | |
40 | { | |
41 | return "Freeze time with 1KHz for regression test"; | |
42 | } | |
43 | ||
44 | static | |
45 | struct lttng_trace_clock ltc = { | |
46 | .read64 = trace_clock_read64_example, | |
47 | .freq = trace_clock_freq_example, | |
48 | .uuid = trace_clock_uuid_example, | |
49 | .name = trace_clock_name_example, | |
50 | .description = trace_clock_description_example, | |
51 | }; | |
52 | ||
53 | static __init | |
54 | int lttng_clock_plugin_init(void) | |
55 | { | |
56 | return lttng_clock_register_plugin(<c, THIS_MODULE); | |
57 | } | |
de0203be | 58 | fs_initcall(lttng_clock_plugin_init); |
db758d11 MD |
59 | |
60 | static __exit | |
61 | void lttng_clock_plugin_exit(void) | |
62 | { | |
63 | lttng_clock_unregister_plugin(<c, THIS_MODULE); | |
64 | } | |
65 | module_exit(lttng_clock_plugin_exit); | |
66 | ||
67 | MODULE_LICENSE("GPL and additional rights"); | |
68 | MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>"); | |
69 | MODULE_DESCRIPTION("LTTng Clock Plugin Example"); | |
1c124020 MJ |
70 | MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." |
71 | __stringify(LTTNG_MODULES_MINOR_VERSION) "." | |
72 | __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION) | |
73 | LTTNG_MODULES_EXTRAVERSION); |