Xenomai  3.1
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_check(__trobj, __status, __expected) \
44 do { \
45  if (__status != __expected) \
46  __traceobj_check_abort(__trobj, __FILE__, __LINE__, \
47  __status, __expected); \
48 } while(0)
49 
50 #define traceobj_check_warn(__trobj, __status, __expected) \
51 do { \
52  if (__status != __expected) \
53  __traceobj_check_warn(__trobj, __FILE__, __LINE__, \
54  __status, __expected); \
55 } while(0)
56 
57 #define traceobj_mark(trobj, mark) \
58  __traceobj_mark(trobj, __FILE__, __LINE__, mark)
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 int traceobj_init(struct traceobj *trobj,
65  const char *label, int nr_marks);
66 
67 void traceobj_verify(struct traceobj *trobj, int tseq[], int nr_seq);
68 
69 void traceobj_destroy(struct traceobj *trobj);
70 
71 void traceobj_enter(struct traceobj *trobj);
72 
73 void traceobj_exit(struct traceobj *trobj);
74 
75 void traceobj_unwind(struct traceobj *trobj);
76 
77 void traceobj_join(struct traceobj *trobj);
78 
79 void __traceobj_assert_failed(struct traceobj *trobj,
80  const char *file, int line, const char *cond);
81 
82 void __traceobj_check_abort(struct traceobj *trobj,
83  const char *file, int line,
84  int received, int expected);
85 
86 void __traceobj_check_warn(struct traceobj *trobj,
87  const char *file, int line,
88  int received, int expected);
89 
90 void __traceobj_mark(struct traceobj *trobj,
91  const char *file, int line, int mark);
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* _COPPERPLATE_TRACEOBJ_H */