Fix: wrapper random documentation
[lttng-modules.git] / lib / ringbuffer / iterator.h
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
9f36eaed 2 *
886d51a3 3 * lib/ringbuffer/iterator.h
f3bc08c5
MD
4 *
5 * Ring buffer and channel iterators.
6 *
886d51a3 7 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
f3bc08c5
MD
8 */
9
9f36eaed
MJ
10#ifndef _LIB_RING_BUFFER_ITERATOR_H
11#define _LIB_RING_BUFFER_ITERATOR_H
12
5671a661
MD
13#include <wrapper/ringbuffer/backend.h>
14#include <wrapper/ringbuffer/frontend.h>
15#include <wrapper/ringbuffer/vfs.h>
f3bc08c5
MD
16
17/*
18 * lib_ring_buffer_get_next_record advances the buffer read position to the next
19 * record. It returns either the size of the next record, -EAGAIN if there is
20 * currently no data available, or -ENODATA if no data is available and buffer
21 * is finalized.
22 */
23extern ssize_t lib_ring_buffer_get_next_record(struct channel *chan,
24 struct lib_ring_buffer *buf);
25
26/*
27 * channel_get_next_record advances the buffer read position to the next record.
28 * It returns either the size of the next record, -EAGAIN if there is currently
29 * no data available, or -ENODATA if no data is available and buffer is
30 * finalized.
31 * Returns the current buffer in ret_buf.
32 */
33extern ssize_t channel_get_next_record(struct channel *chan,
34 struct lib_ring_buffer **ret_buf);
35
36/**
37 * read_current_record - copy the buffer current record into dest.
38 * @buf: ring buffer
39 * @dest: destination where the record should be copied
40 *
41 * dest should be large enough to contain the record. Returns the number of
42 * bytes copied.
43 */
44static inline size_t read_current_record(struct lib_ring_buffer *buf, void *dest)
45{
46 return lib_ring_buffer_read(&buf->backend, buf->iter.read_offset,
47 dest, buf->iter.payload_len);
48}
49
50extern int lib_ring_buffer_iterator_open(struct lib_ring_buffer *buf);
51extern void lib_ring_buffer_iterator_release(struct lib_ring_buffer *buf);
52extern int channel_iterator_open(struct channel *chan);
53extern void channel_iterator_release(struct channel *chan);
54
55extern const struct file_operations channel_payload_file_operations;
56extern const struct file_operations lib_ring_buffer_payload_file_operations;
57
58/*
59 * Used internally.
60 */
61int channel_iterator_init(struct channel *chan);
62void channel_iterator_unregister_notifiers(struct channel *chan);
63void channel_iterator_free(struct channel *chan);
64void channel_iterator_reset(struct channel *chan);
65void lib_ring_buffer_iterator_reset(struct lib_ring_buffer *buf);
66
886d51a3 67#endif /* _LIB_RING_BUFFER_ITERATOR_H */
This page took 0.036593 seconds and 4 git commands to generate.