#endif
#if (defined(__linux__) || defined(__CYGWIN__))
-#include <endian.h>
-#include <byteswap.h>
-
-#define side_bswap_16(x) bswap_16(x)
-#define side_bswap_32(x) bswap_32(x)
-#define side_bswap_64(x) bswap_64(x)
+#define side_bswap_16(x) __builtin_bswap16(x)
+#define side_bswap_32(x) __builtin_bswap32(x)
+#define side_bswap_64(x) __builtin_bswap64(x)
#define SIDE_BYTE_ORDER __BYTE_ORDER
#define SIDE_LITTLE_ENDIAN __LITTLE_ENDIAN
/*
* The forward declaration linkage is always the same in C. In C++ however, it
* is necessary to not use the same linkage as the declaration.
+ *
+ * Rationale for disabled diagnostics:
+ *
+ * -Wsection:
+ * Clang complains about redeclared sections.
*/
#define _side_define_event(_forward_decl_linkage, _linkage, _identifier, _provider, _event, _loglevel, _fields, _flags, _attr...) \
+ SIDE_PUSH_DIAGNOSTIC() \
+ SIDE_DIAGNOSTIC(ignored "-Wsection") \
_forward_decl_linkage struct side_event_description __attribute__((section("side_event_description"))) \
_identifier; \
_forward_decl_linkage struct side_event_state_0 __attribute__((section("side_event_state"))) \
.end = {} \
}; \
static const struct side_event_description __attribute__((section("side_event_description_ptr"), used)) \
- *side_event_ptr__##_identifier = &(_identifier)
+ *side_event_ptr__##_identifier = &(_identifier); \
+ SIDE_POP_DIAGNOSTIC() SIDE_ACCEPT_COMMA()
/*
* In C++, it is not possible to forward declare a static variable. Use
/* Same as SIDE_CAT, but can expand SIDE_CAT within the expansion itself. */
#define SIDE_CAT2_PRIMITIVE(x, y...) x ## y
#define SIDE_CAT2(x, y...) SIDE_CAT2_PRIMITIVE(x, y)
+
+/* Accept a trailing comma. */
+#define SIDE_ACCEPT_COMMA(...) side_static_assert(1, "", _)
+
+/*
+ * The diagnostic macros can be used to turn-off warnings using inline _Pragma.
+ */
+#if defined(__clang__)
+
+# define SIDE_DIAGNOSTIC(x) \
+ _Pragma(SIDE_STR(clang diagnostic x))
+
+#elif defined(__GNUC__)
+
+# define SIDE_DIAGNOSTIC(x) \
+ _Pragma(SIDE_STR(GCC diagnostic x))
+
+#endif
+
+#ifdef __cplusplus
+# define SIDE_DIAGNOSTIC_C(...)
+# define SIDE_DIAGNOSTIC_CXX SIDE_DIAGNOSTIC
+#else
+# define SIDE_DIAGNOSTIC_C SIDE_DIAGNOSTIC
+# define SIDE_DIAGNOSTIC_CXX(...)
+#endif
+
+#define SIDE_PUSH_DIAGNOSTIC() \
+ SIDE_DIAGNOSTIC(push) \
+ SIDE_DIAGNOSTIC(ignored "-Wpragmas")
+
+#define SIDE_POP_DIAGNOSTIC() \
+ SIDE_DIAGNOSTIC(pop)
+
/*
* Define a unique identifier in the compilation unit.
*/
# define SIDE_PTR_INIT(...) \
{ \
.v = { \
- [0] = (__VA_ARGS__), \
- [1] = 0, \
- [2] = 0, \
- [3] = 0, \
+ (__VA_ARGS__), \
+ 0, \
+ 0, \
+ 0, \
}, \
}
# else
# define SIDE_PTR_INIT(...) \
{ \
.v = { \
- [0] = 0, \
- [1] = 0, \
- [2] = 0, \
- [3] = (__VA_ARGS__), \
+ 0, \
+ 0, \
+ 0, \
+ (__VA_ARGS__), \
}, \
}
# endif
# define SIDE_PTR_INIT(...) \
{ \
.v = { \
- [0] = (__VA_ARGS__), \
- [1] = 0, \
+ (__VA_ARGS__), \
+ 0, \
}, \
}
# else
# define SIDE_PTR_INIT(...) \
{ \
.v = { \
- [0] = 0, \
- [1] = (__VA_ARGS__), \
+ 0, \
+ (__VA_ARGS__), \
}, \
}
# endif
# define SIDE_PTR_INIT(...) \
{ \
.v = { \
- [0] = (__VA_ARGS__), \
+ (__VA_ARGS__), \
}, \
}
#else
* unreachable.
*/
es0->nr_callbacks = 0;
- side_rcu_assign_pointer(es0->callbacks, &side_empty_callback);
+ side_rcu_assign_pointer(es0->callbacks, (struct side_callback *)&side_empty_callback);
/*
* No need to wait for grace period because instrumentation is
* unreachable.
X(float, FLT_MIN, float);
X(double, DBL_MIN, double);
-#ifdef __SIZEOF_LONG_DOUBLE__
+#if defined(__SIZEOF_LONG_DOUBLE) && \
+ ((__SIZEOF_LONG_DOUBLE__ <= 4 && __HAVE_FLOAT32) || \
+ (__SIZEOF_LONG_DOUBLE__ <= 8 && __HAVE_FLOAT64) || \
+ (__SIZEOF_LONG_DOUBLE__ <= 16 && __HAVE_FLOAT128))
X(long double, LDBL_MIN, long_double);
#endif
.c = { 0, 1, 2, 3 },
},
.nestarray = {
- [0] = {
+ {
.b = 77,
.c = { 11, 12, 13, 14 },
},
- [1] = {
+ {
.b = 88,
.c = { 15, 16, 17, 18 },
},