X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fpayload-view.h;h=af8519ab32641aaab739fa66985179ee025b47ba;hp=47c2c8c917d29e33e6956818ff0b2f31de9db1aa;hb=7966af5763c4aaca39df9bbfa9277ff15715c720;hpb=18eec1c924daf8d63a5f2cc06b1c1fdd9a838c6e diff --git a/src/common/payload-view.h b/src/common/payload-view.h index 47c2c8c91..af8519ab3 100644 --- a/src/common/payload-view.h +++ b/src/common/payload-view.h @@ -11,6 +11,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + struct lttng_payload; struct fd_handle; @@ -46,13 +50,43 @@ struct fd_handle; struct lttng_payload_view { struct lttng_buffer_view buffer; /* private */ - const struct lttng_dynamic_pointer_array _fd_handles; + + /* + * Avoid a -Wreturn-type-c-linkage warning with clang. + * gcc is more permissive with regards to this warning, but + * clang is right that a structure containing a _const_ structure is not + * a trivial type in the eyes of the C++ standard, theoritically affecting its + * compatibility with C from an ABI standpoint: + * A trivial class is a class that is trivially copyable and has one or + * more default constructors, all of which are either trivial or deleted and + * at least one of which is not deleted. + * + * A const member implicitly deletes lttng_payload_view's constructor, + * making it non-trivial. This is not a problem for the moment as we are + * transitioning all code to C++11. + */ +#if !defined(__cplusplus) + const +#endif + struct lttng_dynamic_pointer_array _fd_handles; + struct { size_t *p_fd_handles_position; size_t fd_handles_position; } _iterator; }; +/** + * Checks if a payload view's buffer is safe to access. + * + * After calling the payload view creation functions, callers should verify + * if the resquested length (if any is explicitly provided) could be mapped + * to a new view. + * + * @view Payload to validate + */ +bool lttng_payload_view_is_valid(const struct lttng_payload_view *view); + /** * Return a payload view referencing a subset of a payload. * @@ -62,7 +96,6 @@ struct lttng_payload_view { * cause the view to reference the whole payload from the * offset provided. */ -LTTNG_HIDDEN struct lttng_payload_view lttng_payload_view_from_payload( const struct lttng_payload *payload, size_t offset, ptrdiff_t len); @@ -77,7 +110,6 @@ struct lttng_payload_view lttng_payload_view_from_payload( * cause the payload view to reference the whole payload view's * buffer view from the offset provided. */ -LTTNG_HIDDEN struct lttng_payload_view lttng_payload_view_from_view( struct lttng_payload_view *view, size_t offset, ptrdiff_t len); @@ -94,7 +126,6 @@ struct lttng_payload_view lttng_payload_view_from_view( * cause the payload view to reference the whole payload from the * offset provided. */ -LTTNG_HIDDEN struct lttng_payload_view lttng_payload_view_from_dynamic_buffer( const struct lttng_dynamic_buffer *buffer, size_t offset, ptrdiff_t len); @@ -111,7 +142,6 @@ struct lttng_payload_view lttng_payload_view_from_dynamic_buffer( * cause the payload view to reference the whole payload from the * offset provided. */ -LTTNG_HIDDEN struct lttng_payload_view lttng_payload_view_from_buffer_view( const struct lttng_buffer_view *view, size_t offset, ptrdiff_t len); @@ -127,7 +157,6 @@ struct lttng_payload_view lttng_payload_view_from_buffer_view( * Note that a payload view never assumes the ownership of the memory it * references. */ -LTTNG_HIDDEN struct lttng_payload_view lttng_payload_view_init_from_buffer( const char *src, size_t offset, ptrdiff_t len); @@ -138,7 +167,6 @@ struct lttng_payload_view lttng_payload_view_init_from_buffer( * * Returns the number of file descriptor handles left on success, -1 on error. */ -LTTNG_HIDDEN int lttng_payload_view_get_fd_handle_count( const struct lttng_payload_view *payload_view); @@ -151,8 +179,11 @@ int lttng_payload_view_get_fd_handle_count( * * Returns an fd_handle on success, -1 on error. */ -LTTNG_HIDDEN struct fd_handle *lttng_payload_view_pop_fd_handle( struct lttng_payload_view *payload_view); +#ifdef __cplusplus +} +#endif + #endif /* LTTNG_PAYLOAD_VIEW_H */