Fix: liblttng-ctl: compat_sync_file_range inadvertantly exported
[lttng-tools.git] / src / common / buffer-view.h
CommitLineData
01dc0eed
JG
1/*
2 * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, version 2.1 only,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18#ifndef LTTNG_BUFFER_VIEW_H
19#define LTTNG_BUFFER_VIEW_H
20
21#include <stddef.h>
22#include <stdint.h>
ff28f865 23#include <common/macros.h>
01dc0eed
JG
24
25struct lttng_dynamic_buffer;
26
27struct lttng_buffer_view {
28 const char *data;
29 size_t size;
30};
31
b35aac84
JG
32/**
33 * Return a buffer view referencing a subset of the memory referenced by a raw
34 * pointer.
35 *
36 * @src Source buffer to reference
37 * @offset Offset to apply to the source memory buffer
38 * @len Length of the memory contents to reference.
39 *
40 * Note that a buffer view never assumes the ownership of the memory it
41 * references.
42 */
43LTTNG_HIDDEN
44struct lttng_buffer_view lttng_buffer_view_init(
45 const char *src, size_t offset, ptrdiff_t len);
46
01dc0eed
JG
47/**
48 * Return a buffer view referencing a subset of the memory referenced by another
49 * view.
50 *
51 * @src Source view to reference
52 * @offset Offset to apply to the source memory content
53 * @len Length of the memory contents to reference. Passing -1 will
54 * cause the view to reference the whole view from the offset
55 * provided.
56 *
57 * Note that a buffer view never assumes the ownership of the memory it
58 * references.
59 */
ff28f865 60LTTNG_HIDDEN
01dc0eed
JG
61struct lttng_buffer_view lttng_buffer_view_from_view(
62 const struct lttng_buffer_view *src, size_t offset,
63 ptrdiff_t len);
64
65/**
66 * Return a buffer view referencing a subset of the memory referenced by a
67 * dynamic buffer.
68 *
69 * @src Source dynamic buffer to reference
70 * @offset Offset to apply to the source memory content
71 * @len Length of the memory contents to reference. Passing -1 will
72 * cause the view to reference the whole dynamic buffer from the
73 * offset provided.
74 *
75 * Note that a buffer view never assumes the ownership of the memory it
76 * references.
77 */
ff28f865 78LTTNG_HIDDEN
01dc0eed
JG
79struct lttng_buffer_view lttng_buffer_view_from_dynamic_buffer(
80 const struct lttng_dynamic_buffer *src, size_t offset,
81 ptrdiff_t len);
82
83#endif /* LTTNG_BUFFER_VIEW_H */
This page took 0.031517 seconds and 4 git commands to generate.