#endif
#endif /*UL_ATTR_REENTRANT*/
+/* The cast idea based on libHX by Jan Engelhardt */
+#define UL_TYPEOF_REFX(ref_asterisks, ptr_type) \
+ typeof(ref_asterisks(union { int z; typeof(ptr_type) x; }){0}.x)
+
+#ifdef __GNUC__
+#define UL_CAST_UNQX(ref_asterisks, new_type, expr) ({ \
+ UL_BUILD_BUG_ON_MSG(!__builtin_types_compatible_p\
+ (UL_TYPEOF_REFX(ref_asterisks, expr), \
+ UL_TYPEOF_REFX(ref_asterisks,new_type)), \
+ "Qualifiers stripping cast to incompatible type"); \
+ (new_type)(expr); \
+})
+#else /*__GNUC__*/
+#define UL_CAST_UNQX(ref_asterisks, new_type, expr) ((new_type)(expr))
+#endif /*__GNUC__*/
+
+#define UL_CAST_UNQ1(new_type, expr) \
+ UL_CAST_UNQX(*, new_type, expr)
+
+#define UL_CAST_UNQ2(new_type, expr) \
+ UL_CAST_UNQX(**, new_type, expr)
+
+#define UL_CAST_UNQ3(new_type, expr) \
+ UL_CAST_UNQX(**, new_type, expr)
+
#ifdef __cplusplus
} /* extern "C"*/
#endif