move everything out of trunk
[lttv.git] / obsolete / ltt-usertrace / ltt / ltt-usertrace.h
1 /*****************************************************************************
2 * ltt-usertrace.h
3 *
4 * LTT userspace tracing header
5 *
6 * Mathieu Desnoyers, March 2006
7 */
8
9 #ifndef _LTT_USERTRACE_H
10 #define _LTT_USERTRACE_H
11
12 #include <errno.h>
13 #include <syscall.h>
14 #include <string.h>
15 #include <stdint.h>
16 #include <sys/types.h>
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22
23 #define inline inline __attribute__((always_inline))
24
25 #if defined(__powerpc__) || defined(__powerpc64__)
26 #ifdef __powerpc64__
27 #include <ltt/atomic-ppc64.h>
28 #include <ltt/system-ppc64.h>
29 #include <asm/timex.h>
30 #else
31 #include <ltt/ppc_asm-ppc.h>
32 #include <ltt/atomic-ppc.h>
33 #include <ltt/system-ppc.h>
34 #include <ltt/timex-ppc.h>
35 #endif
36 #elif defined(__x86_64__)
37 #include <ltt/kernelutils-x86_64.h>
38 #elif defined(__i386__)
39 #include <ltt/kernelutils-i386.h>
40 #elif defined(__arm__)
41 #include <ltt/kernelutils-arm.h>
42 #elif defined(__SH4__)
43 #include <ltt/kernelutils-sh.h>
44 #else
45 #error "Unsupported architecture"
46 #endif
47
48 #ifndef min
49 #define min(a,b) ((a)<(b)?(a):(b))
50 #endif
51
52 #ifdef i386
53 #define __NR_ltt_trace_generic 328
54 #define __NR_ltt_register_generic 329
55 #undef NR_syscalls
56 #define NR_syscalls 330
57 #endif
58
59 #ifdef __x86_64__
60 #define __NR_ltt_trace_generic 286
61 #define __NR_ltt_register_generic 287
62 #undef NR_syscalls
63 #define NR_syscalls 288
64 #endif
65
66 #ifdef __powerpc__
67 #define __NR_ltt_trace_generic 309
68 #define __NR_ltt_register_generic 310
69 #undef NR_syscalls
70 #define NR_syscalls 311
71 #endif
72
73 #ifdef __powerpc64__
74 #define __NR_ltt_trace_generic 309
75 #define __NR_ltt_register_generic 310
76 #undef NR_syscalls
77 #define NR_syscalls 311
78 #endif
79
80 #ifdef __arm__
81 #define __NR_ltt_trace_generic 352
82 #define __NR_ltt_register_generic 353
83 #undef NR_syscalls
84 #define NR_syscalls 354
85 #endif
86
87 //FIXME : setup for MIPS
88
89 #ifndef _LIBC
90 // Put in bits/syscall.h
91 #define SYS_ltt_trace_generic __NR_ltt_trace_generic
92 #define SYS_ltt_register_generic __NR_ltt_register_generic
93 #endif
94
95 #define FACNAME_LEN 32
96
97 /* LTT userspace tracing is non blocking by default when buffers are full */
98 #ifndef LTT_BLOCKING
99 #define LTT_BLOCKING 0
100 #endif //LTT_BLOCKING
101
102 typedef unsigned int ltt_facility_t;
103
104 struct user_facility_info {
105 char name[FACNAME_LEN];
106 uint32_t num_events;
107 uint32_t alignment;
108 uint32_t checksum;
109 uint32_t int_size;
110 uint32_t long_size;
111 uint32_t pointer_size;
112 uint32_t size_t_size;
113 };
114 #if 0
115 static inline __attribute__((no_instrument_function))
116 _syscall5(int, ltt_trace_generic, unsigned int, facility_id,
117 unsigned int, event_id, void *, data, size_t, data_size, int, blocking)
118 static inline __attribute__((no_instrument_function))
119 _syscall2(int, ltt_register_generic, unsigned int *, facility_id,
120 const struct user_facility_info *, info)
121 #endif //0
122
123 #define ltt_register_generic(...) syscall(__NR_ltt_register_generic, __VA_ARGS__)
124 #define ltt_trace_generic(...) syscall(__NR_ltt_trace_generic, __VA_ARGS__)
125
126 static inline unsigned int __attribute__((no_instrument_function))
127 ltt_align(size_t align_drift, size_t size_of_type);
128
129 #ifndef LTT_PACK
130 /* Calculate the offset needed to align the type */
131 static inline unsigned int
132 ltt_align(size_t align_drift, size_t size_of_type)
133 {
134 size_t alignment = min(sizeof(void*), size_of_type);
135
136 return ((alignment - align_drift) & (alignment-1));
137 }
138 #define LTT_ALIGN
139 #else
140 static inline unsigned int ltt_align(size_t align_drift, size_t size_of_type)
141 {
142 return 0;
143 }
144 #define LTT_ALIGN __attribute__((packed))
145 #endif //LTT_PACK
146
147 #ifdef __cplusplus
148 } /* end of extern "C" */
149 #endif
150
151 #ifdef LTT_TRACE_FAST
152 #include <ltt/ltt-usertrace-fast.h>
153 #endif //LTT_TRACE_FAST
154
155 #endif //_LTT_USERTRACE_H
This page took 0.032589 seconds and 4 git commands to generate.