Fix: kconsumer: missing wait for metadata thread in do_sync_metadata
[lttng-tools.git] / src / common / buffer-view.h
CommitLineData
01dc0eed 1/*
ab5be9fa 2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
01dc0eed 3 *
ab5be9fa 4 * SPDX-License-Identifier: LGPL-2.1-only
01dc0eed 5 *
01dc0eed
JG
6 */
7
8#ifndef LTTNG_BUFFER_VIEW_H
9#define LTTNG_BUFFER_VIEW_H
10
67d8e2ef
SM
11#include <common/macros.h>
12#include <stdbool.h>
01dc0eed
JG
13#include <stddef.h>
14#include <stdint.h>
15
16struct lttng_dynamic_buffer;
17
18struct lttng_buffer_view {
19 const char *data;
20 size_t size;
21};
22
b35aac84
JG
23/**
24 * Return a buffer view referencing a subset of the memory referenced by a raw
25 * pointer.
26 *
27 * @src Source buffer to reference
28 * @offset Offset to apply to the source memory buffer
29 * @len Length of the memory contents to reference.
30 *
31 * Note that a buffer view never assumes the ownership of the memory it
32 * references.
33 */
34LTTNG_HIDDEN
35struct lttng_buffer_view lttng_buffer_view_init(
36 const char *src, size_t offset, ptrdiff_t len);
37
01dc0eed
JG
38/**
39 * Return a buffer view referencing a subset of the memory referenced by another
40 * view.
41 *
42 * @src Source view to reference
43 * @offset Offset to apply to the source memory content
44 * @len Length of the memory contents to reference. Passing -1 will
45 * cause the view to reference the whole view from the offset
46 * provided.
47 *
48 * Note that a buffer view never assumes the ownership of the memory it
49 * references.
50 */
ff28f865 51LTTNG_HIDDEN
01dc0eed
JG
52struct lttng_buffer_view lttng_buffer_view_from_view(
53 const struct lttng_buffer_view *src, size_t offset,
54 ptrdiff_t len);
55
56/**
57 * Return a buffer view referencing a subset of the memory referenced by a
58 * dynamic buffer.
59 *
60 * @src Source dynamic buffer to reference
61 * @offset Offset to apply to the source memory content
62 * @len Length of the memory contents to reference. Passing -1 will
63 * cause the view to reference the whole dynamic buffer from the
64 * offset provided.
65 *
66 * Note that a buffer view never assumes the ownership of the memory it
67 * references.
68 */
ff28f865 69LTTNG_HIDDEN
01dc0eed
JG
70struct lttng_buffer_view lttng_buffer_view_from_dynamic_buffer(
71 const struct lttng_dynamic_buffer *src, size_t offset,
72 ptrdiff_t len);
73
67d8e2ef
SM
74/**
75 * Verify that `buf` contains a string starting at `str` of length
76 * `len_with_null_terminator`.
77 *
78 * @buf The buffer view
79 * @str The start of the string
80 * @len_with_null_terminator Expected length of the string, including the
81 * NULL terminator.
82 */
83LTTNG_HIDDEN
84bool lttng_buffer_view_contains_string(const struct lttng_buffer_view *buf,
85 const char *str,
86 size_t len_with_null_terminator);
87
01dc0eed 88#endif /* LTTNG_BUFFER_VIEW_H */
This page took 0.035406 seconds and 4 git commands to generate.