lib: graph.c: add missing `enum` and `const` keywords
[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
43 if (!intr) {
44 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one interrupter.");
45 goto error;
46 }
47
48 bt_object_init_shared(&intr->base, destroy_interrupter);
49 goto end;
50
51error:
52 BT_OBJECT_PUT_REF_AND_RESET(intr);
53
54end:
55 return intr;
56}
57
58void bt_interrupter_set(struct bt_interrupter *intr)
59{
60 BT_ASSERT_PRE_NON_NULL(intr, "Interrupter");
61 intr->is_set = true;
62}
63
64void bt_interrupter_reset(struct bt_interrupter *intr)
65{
66 BT_ASSERT_PRE_NON_NULL(intr, "Interrupter");
67 intr->is_set = false;
68}
69
70bt_bool bt_interrupter_is_set(const struct bt_interrupter *intr)
71{
72 BT_ASSERT_PRE_NON_NULL(intr, "Interrupter");
73 return (bt_bool) intr->is_set;
74}
75
76void bt_interrupter_get_ref(const struct bt_interrupter *intr)
77{
78 bt_object_get_ref(intr);
79}
80
81void bt_interrupter_put_ref(const struct bt_interrupter *intr)
82{
83 bt_object_put_ref(intr);
84}
This page took 0.02846 seconds and 4 git commands to generate.