]> rtime.felk.cvut.cz Git - ulut.git/commitdiff
Qualifiers removal macro which allows NULL - UL_CAST_UNQX_NULL_ALLOWED.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 11 Sep 2014 16:45:36 +0000 (18:45 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 11 Sep 2014 16:45:36 +0000 (18:45 +0200)
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
ulut/ul_utdefs.h

index 4c89ca0e0424badc9a4db4af48b3dc248a4f43d5..7cd38a79dc5c99324e4f8cad42f24634cf8421d4 100644 (file)
@@ -170,6 +170,12 @@ extern void UL_CAST_UNQX_types_not_compatible(void);
     UL_CAST_UNQX_types_not_compatible() \
   ) \
 )
+#define UL_CAST_UNQX_NULL_ALLOWED(ref_asterisks, new_type, expr) ( \
+  __builtin_choose_expr(!__builtin_types_compatible_p(void *, typeof(expr)), \
+    UL_CAST_UNQX(ref_asterisks, new_type, expr), \
+    expr \
+  ) \
+)
 #else /*__GNUC__*/
 #define UL_CAST_UNQX(ref_asterisks, new_type, expr) ((new_type)(expr))
 #endif /*__GNUC__*/
@@ -184,6 +190,14 @@ extern void UL_CAST_UNQX_types_not_compatible(void);
 #define UL_CAST_UNQ3(new_type, expr) \
   UL_CAST_UNQX(**, new_type, expr)
 
+#ifndef UL_CAST_UNQX_NULL_ALLOWED
+#define UL_CAST_UNQX_NULL_ALLOWED(ref_asterisks, new_type, expr) \
+  UL_CAST_UNQX(ref_asterisks, new_type, expr)
+#endif /*UL_CAST_UNQX_NULL_ALLOWED*/
+
+#define UL_CAST_UNQ1_NULL_ALLOWED(new_type, expr) \
+  UL_CAST_UNQX_NULL_ALLOWED(*, new_type, expr)
+
 #ifdef __cplusplus
 } /* extern "C"*/
 #endif