X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=include%2Flttng%2Fust-utils.h;h=d815cf0cc465ef5f3a8864e12d5125fed85057ff;hb=a9bd72496f60cd4cddb435cc6804381d6061feda;hp=2ebe917ca1ccd4e2a957cc4272ce43dbd0046fb3;hpb=3a98c813165062fa31d915e2de97f6d46a900d2d;p=lttng-ust.git diff --git a/include/lttng/ust-utils.h b/include/lttng/ust-utils.h index 2ebe917c..d815cf0c 100644 --- a/include/lttng/ust-utils.h +++ b/include/lttng/ust-utils.h @@ -59,15 +59,29 @@ #endif /** - * lttng_ust_ctf_array_element_type_is_supported - + * lttng_ust_is_pointer_type - check if type is a pointer * - * Adds a compilation assertion that CTF arrays and sequences declared by the - * user are of an integral type. + * Returns true if the type of @type is a pointer. */ -#define lttng_ust_ctf_array_element_type_is_supported(type, item) \ - lttng_ust_static_assert(lttng_ust_is_integer_type(type), \ - "Non-integer type `" #item "` not supported as element of CTF_ARRAY or CTF_SEQUENCE", \ - Non_integer_type__##item##__not_supported_as_element_of_CTF_ARRAY_or_CTF_SEQUENCE); +#if defined(__cplusplus) +#define lttng_ust_is_pointer_type(type) (std::is_pointer::value) +#else +/* The difference between two pointers is an integer. */ +#define lttng_ust_is_pointer_type(type) \ + (lttng_ust_is_integer_type(typeof(((type)1 - (type)1))) && !lttng_ust_is_integer_type(type)) +#endif + + +/** + * lttng_ust_field_array_element_type_is_supported - + * + * Adds a compilation assertion that array and sequence fields declared by the + * user are of an integral or pointer type. + */ +#define lttng_ust_field_array_element_type_is_supported(type, item) \ + lttng_ust_static_assert(lttng_ust_is_integer_type(type) || lttng_ust_is_pointer_type(type), \ + "Non-integer, non-pointer type `" #item "` not supported as element of LTTNG_UST_FIELD_ARRAY or LTTNG_UST_FIELD_SEQUENCE", \ + Non_integer_type__##item##__not_supported_as_element_of_LTTNG_UST_FIELD_ARRAY_or_LTTNG_UST_FIELD_SEQUENCE) /** @@ -138,7 +152,7 @@ * @align_drift: object offset from an "alignment"-aligned address. * @alignment: natural object alignment. Must be non-zero, power of 2. * - * Returns the offset that must be substracted to align towards lower addresses. + * Returns the offset that must be subtracted to align towards lower addresses. */ #define lttng_ust_offset_align_floor(align_drift, alignment) \ ({ \