License cleanup, ifdef namespace cleanup
[lttng-modules.git] / lib / ringbuffer / iterator.h
CommitLineData
886d51a3
MD
1#ifndef _LIB_RING_BUFFER_ITERATOR_H
2#define _LIB_RING_BUFFER_ITERATOR_H
f3bc08c5
MD
3
4/*
886d51a3 5 * lib/ringbuffer/iterator.h
f3bc08c5
MD
6 *
7 * Ring buffer and channel iterators.
8 *
886d51a3
MD
9 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; only
14 * version 2.1 of the License.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 *
f3bc08c5
MD
25 * Author:
26 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
f3bc08c5
MD
27 */
28
29#include "../../wrapper/ringbuffer/backend.h"
30#include "../../wrapper/ringbuffer/frontend.h"
31
32/*
33 * lib_ring_buffer_get_next_record advances the buffer read position to the next
34 * record. It returns either the size of the next record, -EAGAIN if there is
35 * currently no data available, or -ENODATA if no data is available and buffer
36 * is finalized.
37 */
38extern ssize_t lib_ring_buffer_get_next_record(struct channel *chan,
39 struct lib_ring_buffer *buf);
40
41/*
42 * channel_get_next_record advances the buffer read position to the next record.
43 * It returns either the size of the next record, -EAGAIN if there is currently
44 * no data available, or -ENODATA if no data is available and buffer is
45 * finalized.
46 * Returns the current buffer in ret_buf.
47 */
48extern ssize_t channel_get_next_record(struct channel *chan,
49 struct lib_ring_buffer **ret_buf);
50
51/**
52 * read_current_record - copy the buffer current record into dest.
53 * @buf: ring buffer
54 * @dest: destination where the record should be copied
55 *
56 * dest should be large enough to contain the record. Returns the number of
57 * bytes copied.
58 */
59static inline size_t read_current_record(struct lib_ring_buffer *buf, void *dest)
60{
61 return lib_ring_buffer_read(&buf->backend, buf->iter.read_offset,
62 dest, buf->iter.payload_len);
63}
64
65extern int lib_ring_buffer_iterator_open(struct lib_ring_buffer *buf);
66extern void lib_ring_buffer_iterator_release(struct lib_ring_buffer *buf);
67extern int channel_iterator_open(struct channel *chan);
68extern void channel_iterator_release(struct channel *chan);
69
70extern const struct file_operations channel_payload_file_operations;
71extern const struct file_operations lib_ring_buffer_payload_file_operations;
72
73/*
74 * Used internally.
75 */
76int channel_iterator_init(struct channel *chan);
77void channel_iterator_unregister_notifiers(struct channel *chan);
78void channel_iterator_free(struct channel *chan);
79void channel_iterator_reset(struct channel *chan);
80void lib_ring_buffer_iterator_reset(struct lib_ring_buffer *buf);
81
886d51a3 82#endif /* _LIB_RING_BUFFER_ITERATOR_H */
This page took 0.026136 seconds and 4 git commands to generate.