| 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> |
| 23 | #include <common/macros.h> |
| 24 | |
| 25 | struct lttng_dynamic_buffer; |
| 26 | |
| 27 | struct lttng_buffer_view { |
| 28 | const char *data; |
| 29 | size_t size; |
| 30 | }; |
| 31 | |
| 32 | /** |
| 33 | * Return a buffer view referencing a subset of the memory referenced by another |
| 34 | * view. |
| 35 | * |
| 36 | * @src Source view to reference |
| 37 | * @offset Offset to apply to the source memory content |
| 38 | * @len Length of the memory contents to reference. Passing -1 will |
| 39 | * cause the view to reference the whole view from the offset |
| 40 | * provided. |
| 41 | * |
| 42 | * Note that a buffer view never assumes the ownership of the memory it |
| 43 | * references. |
| 44 | */ |
| 45 | LTTNG_HIDDEN |
| 46 | struct lttng_buffer_view lttng_buffer_view_from_view( |
| 47 | const struct lttng_buffer_view *src, size_t offset, |
| 48 | ptrdiff_t len); |
| 49 | |
| 50 | /** |
| 51 | * Return a buffer view referencing a subset of the memory referenced by a |
| 52 | * dynamic buffer. |
| 53 | * |
| 54 | * @src Source dynamic buffer to reference |
| 55 | * @offset Offset to apply to the source memory content |
| 56 | * @len Length of the memory contents to reference. Passing -1 will |
| 57 | * cause the view to reference the whole dynamic buffer from the |
| 58 | * offset provided. |
| 59 | * |
| 60 | * Note that a buffer view never assumes the ownership of the memory it |
| 61 | * references. |
| 62 | */ |
| 63 | LTTNG_HIDDEN |
| 64 | struct lttng_buffer_view lttng_buffer_view_from_dynamic_buffer( |
| 65 | const struct lttng_dynamic_buffer *src, size_t offset, |
| 66 | ptrdiff_t len); |
| 67 | |
| 68 | #endif /* LTTNG_BUFFER_VIEW_H */ |