update syscalls
[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 <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 #else
43 #error "Unsupported architecture"
44 #endif
45
46 #ifndef min
47 #define min(a,b) ((a)<(b)?(a):(b))
48 #endif
49
50 #ifdef i386
51 #define __NR_ltt_trace_generic 326
52 #define __NR_ltt_register_generic 327
53 #undef NR_syscalls
54 #define NR_syscalls 328
55 #endif
56
57 #ifdef __x86_64__
58 #define __NR_ltt_trace_generic 284
59 #define __NR_ltt_register_generic 285
60 #undef NR_syscalls
61 #define NR_syscalls 286
62 #endif
63
64 #ifdef __powerpc__
65 #define __NR_ltt_trace_generic 304
66 #define __NR_ltt_register_generic 305
67 #undef NR_syscalls
68 #define NR_syscalls 306
69 #endif
70
71 #ifdef __powerpc64__
72 #define __NR_ltt_trace_generic 304
73 #define __NR_ltt_register_generic 305
74 #undef NR_syscalls
75 #define NR_syscalls 306
76 #endif
77
78 #ifdef __arm__
79 #define __NR_ltt_trace_generic 348
80 #define __NR_ltt_register_generic 349
81 #undef NR_syscalls
82 #define NR_syscalls 350
83 #endif
84
85 //FIXME : setup for MIPS
86
87 #ifndef _LIBC
88 // Put in bits/syscall.h
89 #define SYS_ltt_trace_generic __NR_ltt_trace_generic
90 #define SYS_ltt_register_generic __NR_ltt_register_generic
91 #endif
92
93 #define FACNAME_LEN 32
94
95 /* LTT userspace tracing is non blocking by default when buffers are full */
96 #ifndef LTT_BLOCKING
97 #define LTT_BLOCKING 0
98 #endif //LTT_BLOCKING
99
100 typedef unsigned int ltt_facility_t;
101
102 struct user_facility_info {
103 char name[FACNAME_LEN];
104 unsigned int num_events;
105 size_t alignment;
106 uint32_t checksum;
107 size_t int_size;
108 size_t long_size;
109 size_t pointer_size;
110 size_t size_t_size;
111 };
112 #if 0
113 static inline __attribute__((no_instrument_function))
114 _syscall5(int, ltt_trace_generic, unsigned int, facility_id,
115 unsigned int, event_id, void *, data, size_t, data_size, int, blocking)
116 static inline __attribute__((no_instrument_function))
117 _syscall2(int, ltt_register_generic, unsigned int *, facility_id,
118 const struct user_facility_info *, info)
119 #endif //0
120
121 #define ltt_register_generic(...) syscall(__NR_ltt_register_generic, __VA_ARGS__)
122 #define ltt_trace_generic(...) syscall(__NR_ltt_trace_generic, __VA_ARGS__)
123
124 static inline unsigned int __attribute__((no_instrument_function))
125 ltt_align(size_t align_drift, size_t size_of_type);
126
127 #ifndef LTT_PACK
128 /* Calculate the offset needed to align the type */
129 static inline unsigned int
130 ltt_align(size_t align_drift, size_t size_of_type)
131 {
132 size_t alignment = min(sizeof(void*), size_of_type);
133
134 return ((alignment - align_drift) & (alignment-1));
135 }
136 #define LTT_ALIGN
137 #else
138 static inline unsigned int ltt_align(size_t align_drift, size_t size_of_type)
139 {
140 return 0;
141 }
142 #define LTT_ALIGN __attribute__((packed))
143 #endif //LTT_PACK
144
145 #ifdef __cplusplus
146 } /* end of extern "C" */
147 #endif
148
149 #ifdef LTT_TRACE_FAST
150 #include <ltt/ltt-usertrace-fast.h>
151 #endif //LTT_TRACE_FAST
152
153 #endif //_LTT_USERTRACE_H
This page took 0.066077 seconds and 5 git commands to generate.