Xenomai  3.0-rc3
traceobj.h
1 /*
2  * Copyright (C) 2008 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13 
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 
19 #ifndef _COPPERPLATE_TRACEOBJ_H
20 #define _COPPERPLATE_TRACEOBJ_H
21 
22 #include <pthread.h>
23 
24 struct threadobj;
25 
26 struct traceobj {
27  pthread_mutex_t lock;
28  pthread_cond_t join;
29  const char *label;
30  int nr_marks;
31  int cur_mark;
32  struct tracemark *marks;
33  int nr_threads;
34 };
35 
36 #define traceobj_assert(trobj, cond) \
37 do { \
38  int __ret = (cond); \
39  if (!__ret) \
40  __traceobj_assert_failed(trobj, __FILE__, __LINE__, __STRING(cond)); \
41 } while(0)
42 
43 #define traceobj_mark(trobj, mark) \
44  __traceobj_mark(trobj, __FILE__, __LINE__, mark)
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 int traceobj_init(struct traceobj *trobj,
51  const char *label, int nr_marks);
52 
53 void traceobj_verify(struct traceobj *trobj, int tseq[], int nr_seq);
54 
55 void traceobj_destroy(struct traceobj *trobj);
56 
57 void traceobj_enter(struct traceobj *trobj);
58 
59 void traceobj_exit(struct traceobj *trobj);
60 
61 void traceobj_unwind(struct traceobj *trobj);
62 
63 void traceobj_join(struct traceobj *trobj);
64 
65 void __traceobj_assert_failed(struct traceobj *trobj,
66  const char *file, int line, const char *cond);
67 
68 void __traceobj_mark(struct traceobj *trobj,
69  const char *file, int line, int mark);
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif /* _COPPERPLATE_TRACEOBJ_H */