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