X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;ds=sidebyside;f=include%2Fbabeltrace%2Fgraph%2Fport-input-const.h;h=5301769f08f5476d6b76a61b5ac4e1671905b4b5;hb=7e69c04f557e46fb50e5a888a3bc3451afbd3b8e;hp=85a201d905ecbd25db53d605ee255e30ef56d37c;hpb=0d72b8c329ad51d14ab4e83330b38c2c8da69dd4;p=babeltrace.git diff --git a/include/babeltrace/graph/port-input-const.h b/include/babeltrace/graph/port-input-const.h index 85a201d9..5301769f 100644 --- a/include/babeltrace/graph/port-input-const.h +++ b/include/babeltrace/graph/port-input-const.h @@ -2,10 +2,9 @@ #define BABELTRACE_GRAPH_PORT_INPUT_CONST_H /* + * Copyright 2017-2018 Philippe Proulx * Copyright 2017 Jérémie Galarneau * - * Author: Jérémie Galarneau - * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights @@ -25,22 +24,38 @@ * SOFTWARE. */ +/* For bt_port, bt_port_input, __BT_UPCAST_CONST */ +#include + #include #ifdef __cplusplus extern "C" { #endif -struct bt_port; -struct bt_port_input; - static inline -const struct bt_port *bt_port_input_as_port_const( - const struct bt_port_input *port_input) +const bt_port *bt_port_input_as_port_const(const bt_port_input *port_input) { - return (const void *) port_input; + return __BT_UPCAST_CONST(bt_port, port_input); } +extern void bt_port_input_get_ref(const bt_port_input *port_input); + +extern void bt_port_input_put_ref(const bt_port_input *port_input); + +#define BT_PORT_INPUT_PUT_REF_AND_RESET(_var) \ + do { \ + bt_port_input_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_PORT_INPUT_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_port_input_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + #ifdef __cplusplus } #endif