add usertrace-generic
[lttv.git] / usertrace-generic / ltt / ltt-generic.h
1 /*****************************************************************************
2 * ltt-generic.h
3 *
4 * LTT generic userspace tracing header
5 *
6 * Mathieu Desnoyers, March 2006
7 */
8
9 #ifndef _LTT_GENERIC_H
10 #define _LTT_GENERIC_H
11
12 #include <errno.h>
13 #include <syscall.h>
14 #include <linux/unistd.h>
15 #include <asm/atomic.h>
16 #include <string.h>
17 #include <sys/types.h>
18 #include <stdint.h>
19
20 #ifndef min
21 #define min(a,b) ((a)<(b)?(a):(b))
22 #endif
23
24 //Put in asm-i486/unistd.h
25 #define __NR_ltt_trace_generic 294
26 #define __NR_ltt_register_generic 295
27
28 #undef NR_syscalls
29 #define NR_syscalls 296
30
31 //FIXME : setup for ARM
32 //FIXME : setup for MIPS
33
34 #ifndef _LIBC
35 // Put in bits/syscall.h
36 #define SYS_ltt_trace_generic __NR_ltt_trace_generic
37 #define SYS_ltt_register_generic __NR_ltt_register_generic
38 #endif
39
40 #define FACNAME_LEN 32
41
42 typedef unsigned int ltt_facility_t;
43
44 struct user_facility_info {
45 char name[FACNAME_LEN];
46 unsigned int num_events;
47 size_t alignment;
48 uint32_t checksum;
49 size_t int_size;
50 size_t long_size;
51 size_t pointer_size;
52 size_t size_t_size;
53 };
54
55 static inline _syscall4(int, ltt_trace_generic, unsigned int, facility_id,
56 unsigned int, event_id, void *, data, size_t, data_size)
57 static inline _syscall2(int, ltt_register_generic, unsigned int *, facility_id, const struct user_facility_info *, info)
58
59 #ifndef LTT_PACK
60 /* Calculate the offset needed to align the type */
61 static inline unsigned int ltt_align(size_t align_drift,
62 size_t size_of_type)
63 {
64 size_t alignment = min(sizeof(void*), size_of_type);
65
66 return ((alignment - align_drift) & (alignment-1));
67 }
68 #else
69 static inline unsigned int ltt_align(size_t align_drift,
70 size_t size_of_type)
71 {
72 return 0;
73 }
74 #endif //LTT_PACK
75
76 #endif //_LTT_GENERIC_H
77
78
This page took 0.031332 seconds and 4 git commands to generate.