License cleanup, ifdef namespace cleanup
[lttng-modules.git] / lib / ringbuffer / iterator.h
1 #ifndef _LIB_RING_BUFFER_ITERATOR_H
2 #define _LIB_RING_BUFFER_ITERATOR_H
3
4 /*
5 * lib/ringbuffer/iterator.h
6 *
7 * Ring buffer and channel iterators.
8 *
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 *
25 * Author:
26 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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 */
38 extern 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 */
48 extern 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 */
59 static 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
65 extern int lib_ring_buffer_iterator_open(struct lib_ring_buffer *buf);
66 extern void lib_ring_buffer_iterator_release(struct lib_ring_buffer *buf);
67 extern int channel_iterator_open(struct channel *chan);
68 extern void channel_iterator_release(struct channel *chan);
69
70 extern const struct file_operations channel_payload_file_operations;
71 extern const struct file_operations lib_ring_buffer_payload_file_operations;
72
73 /*
74 * Used internally.
75 */
76 int channel_iterator_init(struct channel *chan);
77 void channel_iterator_unregister_notifiers(struct channel *chan);
78 void channel_iterator_free(struct channel *chan);
79 void channel_iterator_reset(struct channel *chan);
80 void lib_ring_buffer_iterator_reset(struct lib_ring_buffer *buf);
81
82 #endif /* _LIB_RING_BUFFER_ITERATOR_H */
This page took 0.055597 seconds and 5 git commands to generate.