ust-fd: Add close_range declaration
[lttng-ust.git] / include / lttng / ust-utils.h
index d2747d4a6a388b6ac312f4e7b2528048e4de9209..575034faa5bae82fa3a5f890bb16b1702e70e86e 100644 (file)
@@ -1,8 +1,6 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
+// SPDX-FileCopyrightText: 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: MIT
 
 #ifndef _LTTNG_UST_UTILS_H
 #define _LTTNG_UST_UTILS_H
                __builtin_types_compatible_p(type, unsigned long long))
 #endif
 
+/**
+ * lttng_ust_is_pointer_type - check if type is a pointer
+ *
+ * Returns true if the type of @type is a pointer.
+ *
+ * Note: The C implementation of lttng_ust_is_pointer_type uses pointer
+ * arithmetic, which does not work on opaque pointer types.
+ */
+#if defined(__cplusplus)
+#define lttng_ust_is_pointer_type(type) (std::is_pointer<type>::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 type.
+ * 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), \
-                       "Non-integer type `" #item "` not supported as element of LTTNG_UST_FIELD_ARRAY or LTTNG_UST_FIELD_SEQUENCE", \
+               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)
 
 
  * @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)                  \
        ({                                                                     \
This page took 0.027327 seconds and 4 git commands to generate.