Fix: src.ctf.fs: initialize the other_entry variable
[babeltrace.git] / src / lib / graph / interrupter.c
CommitLineData
b70d57a1
PP
1/*
2 * Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23#define BT_LOG_TAG "LIB/INTERRUPTER"
24#include "lib/logging.h"
25
26#include <stdlib.h>
27#include <stdint.h>
28#include <babeltrace2/babeltrace.h>
29
30#include "interrupter.h"
31#include "lib/assert-pre.h"
32
33static
34void destroy_interrupter(struct bt_object *obj)
35{
36 g_free(obj);
37}
38
39extern struct bt_interrupter *bt_interrupter_create(void)
40{
41 struct bt_interrupter *intr = g_new0(struct bt_interrupter, 1);
42
17f3083a
SM
43 BT_ASSERT_PRE_NO_ERROR();
44
b70d57a1
PP
45 if (!intr) {
46 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one interrupter.");
47 goto error;
48 }
49
50 bt_object_init_shared(&intr->base, destroy_interrupter);
51 goto end;
52
53error:
54 BT_OBJECT_PUT_REF_AND_RESET(intr);
55
56end:
57 return intr;
58}
59
60void bt_interrupter_set(struct bt_interrupter *intr)
61{
62 BT_ASSERT_PRE_NON_NULL(intr, "Interrupter");
63 intr->is_set = true;
64}
65
66void bt_interrupter_reset(struct bt_interrupter *intr)
67{
68 BT_ASSERT_PRE_NON_NULL(intr, "Interrupter");
69 intr->is_set = false;
70}
71
72bt_bool bt_interrupter_is_set(const struct bt_interrupter *intr)
73{
74 BT_ASSERT_PRE_NON_NULL(intr, "Interrupter");
75 return (bt_bool) intr->is_set;
76}
77
78void bt_interrupter_get_ref(const struct bt_interrupter *intr)
79{
80 bt_object_get_ref(intr);
81}
82
83void bt_interrupter_put_ref(const struct bt_interrupter *intr)
84{
85 bt_object_put_ref(intr);
86}
This page took 0.045318 seconds and 4 git commands to generate.