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