common: compile libconfig as C++
[lttng-tools.git] / src / common / fd-handle.h
CommitLineData
dd1bac00
JG
1/*
2 * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8#ifndef FD_HANDLE_H
9#define FD_HANDLE_H
10
11#include <common/macros.h>
12
7966af57
SM
13#ifdef __cplusplus
14extern "C" {
15#endif
16
dd1bac00
JG
17/*
18 * Wrapper around a file descriptor providing reference counting semantics.
19 *
20 * An fd_handle will close() the underlying file descriptor when its reference
21 * count reaches zero.
22 */
23struct fd_handle;
24
25/* Create a file descriptor handle. */
dd1bac00
JG
26struct fd_handle *fd_handle_create(int fd);
27
28/* Acquire reference to a file descriptor handle. */
dd1bac00
JG
29void fd_handle_get(struct fd_handle *handle);
30
31/* Release reference to a file descriptor handle. */
dd1bac00
JG
32void fd_handle_put(struct fd_handle *handle);
33
34/*
35 * Return the underlying file descriptor of a file descriptor handle.
36 *
37 * This function can't fail.
38 */
dd1bac00
JG
39int fd_handle_get_fd(struct fd_handle *handle);
40
41/*
42 * Obtain a copy of a file descriptor handle.
43 *
44 * On success, the caller becomes the sole owner of the returned file descriptor
45 * handle. The underlying file descriptor is duplicated using dup(). Refer to
46 * the system documentation for the semantics of dup() for this particular file
47 * descriptor type.
48 */
dd1bac00
JG
49struct fd_handle *fd_handle_copy(const struct fd_handle *handle);
50
7966af57
SM
51#ifdef __cplusplus
52}
53#endif
54
dd1bac00 55#endif /* FS_HANDLE_H */
This page took 0.027838 seconds and 4 git commands to generate.