Commit | Line | Data |
---|---|---|
c0e90f23 PP |
1 | #ifndef BABELTRACE_CURRENT_THREAD_H |
2 | #define BABELTRACE_CURRENT_THREAD_H | |
3 | ||
4 | /* | |
5 | * Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com> | |
6 | * | |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
8 | * of this software and associated documentation files (the "Software"), to deal | |
9 | * in the Software without restriction, including without limitation the rights | |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
11 | * copies of the Software, and to permit persons to whom the Software is | |
12 | * furnished to do so, subject to the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | |
15 | * all copies or substantial portions of the Software. | |
16 | * | |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
23 | * SOFTWARE. | |
24 | */ | |
25 | ||
26 | #include <stdarg.h> | |
27 | ||
28 | /* | |
29 | * For bt_error, bt_self_component, bt_self_component_class, and | |
30 | * bt_self_message_iterator | |
31 | */ | |
32 | #include <babeltrace2/types.h> | |
33 | ||
34 | /* For __BT_FUNC_STATUS_* */ | |
35 | #define __BT_FUNC_STATUS_ENABLE | |
36 | #include <babeltrace2/func-status.h> | |
37 | #undef __BT_FUNC_STATUS_ENABLE | |
38 | ||
39 | #ifdef __cplusplus | |
40 | extern "C" { | |
41 | #endif | |
42 | ||
43 | extern | |
44 | const bt_error *bt_current_thread_take_error(void); | |
45 | ||
46 | extern | |
47 | void bt_current_thread_clear_error(void); | |
48 | ||
49 | extern | |
50 | void bt_current_thread_move_error(const bt_error *error); | |
51 | ||
52 | typedef enum bt_current_thread_error_append_cause_status { | |
53 | BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
54 | BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_OK = __BT_FUNC_STATUS_OK, | |
55 | } bt_current_thread_error_append_cause_status; | |
56 | ||
57 | extern | |
58 | bt_current_thread_error_append_cause_status | |
59 | bt_current_thread_error_append_cause_from_unknown( | |
60 | const char *module_name, const char *file_name, | |
61 | uint64_t line_no, const char *msg_fmt, ...); | |
62 | ||
63 | extern | |
64 | bt_current_thread_error_append_cause_status | |
65 | bt_current_thread_error_append_cause_from_component( | |
66 | bt_self_component *self_comp, const char *file_name, | |
67 | uint64_t line_no, const char *msg_fmt, ...); | |
68 | ||
69 | extern | |
70 | bt_current_thread_error_append_cause_status | |
71 | bt_current_thread_error_append_cause_from_component_class( | |
72 | bt_self_component_class *self_comp_class, const char *file_name, | |
73 | uint64_t line_no, const char *msg_fmt, ...); | |
74 | ||
75 | extern | |
76 | bt_current_thread_error_append_cause_status | |
77 | bt_current_thread_error_append_cause_from_message_iterator( | |
78 | bt_self_message_iterator *self_iter, const char *file_name, | |
79 | uint64_t line_no, const char *msg_fmt, ...); | |
80 | ||
81 | #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(_module_name, _msg_fmt, ...) \ | |
82 | bt_current_thread_error_append_cause_from_unknown( \ | |
83 | (_module_name), __FILE__, __LINE__, (_msg_fmt), ##__VA_ARGS__) | |
84 | ||
85 | #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT(_self_comp, _msg_fmt, ...) \ | |
86 | bt_current_thread_error_append_cause_from_component( \ | |
87 | (_self_comp), __FILE__, __LINE__, (_msg_fmt), ##__VA_ARGS__) | |
88 | ||
89 | #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT_CLASS(_self_cc, _msg_fmt, ...) \ | |
90 | bt_current_thread_error_append_cause_from_component_class( \ | |
91 | (_self_cc), __FILE__, __LINE__, (_msg_fmt), ##__VA_ARGS__) | |
92 | ||
93 | #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_MESSAGE_ITERATOR(_self_iter, _msg_fmt, ...) \ | |
94 | bt_current_thread_error_append_cause_from_component( \ | |
95 | (_self_iter), __FILE__, __LINE__, (_msg_fmt), ##__VA_ARGS__) | |
96 | ||
97 | #ifdef __cplusplus | |
98 | } | |
99 | #endif | |
100 | ||
101 | #include <babeltrace2/undef-func-status.h> | |
102 | ||
103 | #endif /* BABELTRACE_CURRENT_THREAD_H */ |