lib: make message iterator creation functions return a status
[babeltrace.git] / include / babeltrace2 / current-thread.h
1 #ifndef BABELTRACE2_CURRENT_THREAD_H
2 #define BABELTRACE2_CURRENT_THREAD_H
3
4 /*
5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
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 #ifndef __BT_IN_BABELTRACE_H
27 # error "Please include <babeltrace2/babeltrace.h> instead."
28 #endif
29
30 #include <stdarg.h>
31
32 #include <babeltrace2/types.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 extern
39 const bt_error *bt_current_thread_take_error(void);
40
41 extern
42 void bt_current_thread_clear_error(void);
43
44 extern
45 void bt_current_thread_move_error(const bt_error *error);
46
47 typedef enum bt_current_thread_error_append_cause_status {
48 BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
49 BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_STATUS_OK = __BT_FUNC_STATUS_OK,
50 } bt_current_thread_error_append_cause_status;
51
52 extern
53 bt_current_thread_error_append_cause_status
54 bt_current_thread_error_append_cause_from_unknown(
55 const char *module_name, const char *file_name,
56 uint64_t line_no, const char *msg_fmt, ...);
57
58 extern
59 bt_current_thread_error_append_cause_status
60 bt_current_thread_error_append_cause_from_component(
61 bt_self_component *self_comp, const char *file_name,
62 uint64_t line_no, const char *msg_fmt, ...);
63
64 extern
65 bt_current_thread_error_append_cause_status
66 bt_current_thread_error_append_cause_from_component_class(
67 bt_self_component_class *self_comp_class, const char *file_name,
68 uint64_t line_no, const char *msg_fmt, ...);
69
70 extern
71 bt_current_thread_error_append_cause_status
72 bt_current_thread_error_append_cause_from_message_iterator(
73 bt_self_message_iterator *self_iter, const char *file_name,
74 uint64_t line_no, const char *msg_fmt, ...);
75
76 #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(_module_name, _msg_fmt, ...) \
77 bt_current_thread_error_append_cause_from_unknown( \
78 (_module_name), __FILE__, __LINE__, (_msg_fmt), ##__VA_ARGS__)
79
80 #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT(_self_comp, _msg_fmt, ...) \
81 bt_current_thread_error_append_cause_from_component( \
82 (_self_comp), __FILE__, __LINE__, (_msg_fmt), ##__VA_ARGS__)
83
84 #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT_CLASS(_self_cc, _msg_fmt, ...) \
85 bt_current_thread_error_append_cause_from_component_class( \
86 (_self_cc), __FILE__, __LINE__, (_msg_fmt), ##__VA_ARGS__)
87
88 #define BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_MESSAGE_ITERATOR(_self_iter, _msg_fmt, ...) \
89 bt_current_thread_error_append_cause_from_message_iterator( \
90 (_self_iter), __FILE__, __LINE__, (_msg_fmt), ##__VA_ARGS__)
91
92 #define BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET(_var) \
93 do { \
94 bt_current_thread_move_error(_var); \
95 (_var) = NULL; \
96 } while (0)
97
98 #ifdef __cplusplus
99 }
100 #endif
101
102 #endif /* BABELTRACE2_CURRENT_THREAD_H */
This page took 0.031876 seconds and 4 git commands to generate.