update spec
[lttv.git] / ltt-usertrace / ltt / ltt-usertrace.h
CommitLineData
3d57eb5b 1/*****************************************************************************
38f24d5c 2 * ltt-usertrace.h
3d57eb5b 3 *
38f24d5c 4 * LTT userspace tracing header
3d57eb5b 5 *
6 * Mathieu Desnoyers, March 2006
7 */
8
38f24d5c 9#ifndef _LTT_USERTRACE_H
10#define _LTT_USERTRACE_H
3d57eb5b 11
12#include <errno.h>
13#include <syscall.h>
3d57eb5b 14#include <string.h>
3d57eb5b 15#include <stdint.h>
4359c2bb 16#include <sys/types.h>
17#include <linux/unistd.h>
3a4541a5 18
19#define inline inline __attribute__((always_inline))
20
60009e26 21#if defined(__powerpc__) || defined(__powerpc64__)
3a4541a5 22#ifdef __powerpc64__
23#include <ltt/atomic-ppc64.h>
24#include <ltt/system-ppc64.h>
25#include <asm/timex.h>
26#else
27#include <ltt/ppc_asm-ppc.h>
28#include <ltt/atomic-ppc.h>
29#include <ltt/system-ppc.h>
30#include <ltt/timex-ppc.h>
31#endif
60009e26 32#else
3a4541a5 33#include <asm/timex.h>
60009e26 34#include <asm/atomic.h>
35#endif
3d57eb5b 36
37#ifndef min
38#define min(a,b) ((a)<(b)?(a):(b))
39#endif
40
d86395c3 41#ifdef i386
ac493dbc 42#define __NR_ltt_trace_generic 317
43#define __NR_ltt_register_generic 318
3d57eb5b 44#undef NR_syscalls
ac493dbc 45#define NR_syscalls 319
d86395c3 46#endif
47
3a4541a5 48#ifdef __powerpc__
ac493dbc 49#define __NR_ltt_trace_generic 301
50#define __NR_ltt_register_generic 302
3a4541a5 51#undef NR_syscalls
ac493dbc 52#define NR_syscalls 303
3a4541a5 53#endif
54
55#ifdef __powerpc64__
ac493dbc 56#define __NR_ltt_trace_generic 301
57#define __NR_ltt_register_generic 302
d86395c3 58#undef NR_syscalls
ac493dbc 59#define NR_syscalls 303
d86395c3 60#endif
3d57eb5b 61
3a4541a5 62
63
3d57eb5b 64//FIXME : setup for ARM
65//FIXME : setup for MIPS
66
67#ifndef _LIBC
68// Put in bits/syscall.h
69#define SYS_ltt_trace_generic __NR_ltt_trace_generic
70#define SYS_ltt_register_generic __NR_ltt_register_generic
71#endif
72
73#define FACNAME_LEN 32
74
972a52cf 75/* LTT userspace tracing is non blocking by default when buffers are full */
76#ifndef LTT_BLOCKING
77#define LTT_BLOCKING 0
78#endif //LTT_BLOCKING
79
3d57eb5b 80typedef unsigned int ltt_facility_t;
81
82struct user_facility_info {
83 char name[FACNAME_LEN];
84 unsigned int num_events;
85 size_t alignment;
86 uint32_t checksum;
87 size_t int_size;
88 size_t long_size;
89 size_t pointer_size;
90 size_t size_t_size;
91};
92
e90c7b86 93static inline __attribute__((no_instrument_function))
94_syscall5(int, ltt_trace_generic, unsigned int, facility_id,
95 unsigned int, event_id, void *, data, size_t, data_size, int, blocking)
96static inline __attribute__((no_instrument_function))
97_syscall2(int, ltt_register_generic, unsigned int *, facility_id,
98 const struct user_facility_info *, info)
3d57eb5b 99
100#ifndef LTT_PACK
101/* Calculate the offset needed to align the type */
e90c7b86 102static inline unsigned int __attribute__((no_instrument_function))
103 ltt_align(size_t align_drift,
104 size_t size_of_type)
3d57eb5b 105{
106 size_t alignment = min(sizeof(void*), size_of_type);
107
108 return ((alignment - align_drift) & (alignment-1));
109}
8a9103df 110#define LTT_ALIGN
3d57eb5b 111#else
e90c7b86 112static inline unsigned int __attribute__((no_instrument_function))
113 ltt_align(size_t align_drift,
114 size_t size_of_type)
3d57eb5b 115{
116 return 0;
117}
8a9103df 118#define LTT_ALIGN __attribute__((packed))
3d57eb5b 119#endif //LTT_PACK
120
976db1b3 121#ifdef LTT_TRACE_FAST
122#include <ltt/ltt-usertrace-fast.h>
123#endif //LTT_TRACE_FAST
124
38f24d5c 125#endif //_LTT_USERTRACE_H
3d57eb5b 126
127
This page took 0.029344 seconds and 4 git commands to generate.