new ltt-usertrace
[lttv.git] / 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 <linux/unistd.h>
15 #include <asm/atomic.h>
16 #include <string.h>
17 #include <sys/types.h>
18 #include <stdint.h>
19
20 #ifdef LTT_TRACE_FAST
21 #include <ltt/ltt-usertrace-fast.h>
22 #endif //LTT_TRACE_FAST
23
24 #ifndef min
25 #define min(a,b) ((a)<(b)?(a):(b))
26 #endif
27
28 //Put in asm-i486/unistd.h
29 #define __NR_ltt_trace_generic 294
30 #define __NR_ltt_register_generic 295
31
32 #undef NR_syscalls
33 #define NR_syscalls 296
34
35 //FIXME : setup for ARM
36 //FIXME : setup for MIPS
37
38 #ifndef _LIBC
39 // Put in bits/syscall.h
40 #define SYS_ltt_trace_generic __NR_ltt_trace_generic
41 #define SYS_ltt_register_generic __NR_ltt_register_generic
42 #endif
43
44 #define FACNAME_LEN 32
45
46 /* LTT userspace tracing is non blocking by default when buffers are full */
47 #ifndef LTT_BLOCKING
48 #define LTT_BLOCKING 0
49 #endif //LTT_BLOCKING
50
51 typedef unsigned int ltt_facility_t;
52
53 struct user_facility_info {
54 char name[FACNAME_LEN];
55 unsigned int num_events;
56 size_t alignment;
57 uint32_t checksum;
58 size_t int_size;
59 size_t long_size;
60 size_t pointer_size;
61 size_t size_t_size;
62 };
63
64 static inline __attribute__((no_instrument_function))
65 _syscall5(int, ltt_trace_generic, unsigned int, facility_id,
66 unsigned int, event_id, void *, data, size_t, data_size, int, blocking)
67 static inline __attribute__((no_instrument_function))
68 _syscall2(int, ltt_register_generic, unsigned int *, facility_id,
69 const struct user_facility_info *, info)
70
71 #ifndef LTT_PACK
72 /* Calculate the offset needed to align the type */
73 static inline unsigned int __attribute__((no_instrument_function))
74 ltt_align(size_t align_drift,
75 size_t size_of_type)
76 {
77 size_t alignment = min(sizeof(void*), size_of_type);
78
79 return ((alignment - align_drift) & (alignment-1));
80 }
81 #define LTT_ALIGN
82 #else
83 static inline unsigned int __attribute__((no_instrument_function))
84 ltt_align(size_t align_drift,
85 size_t size_of_type)
86 {
87 return 0;
88 }
89 #define LTT_ALIGN __attribute__((packed))
90 #endif //LTT_PACK
91
92 #endif //_LTT_USERTRACE_H
93
94
This page took 0.031964 seconds and 5 git commands to generate.