]> rtime.felk.cvut.cz Git - ulut.git/blobdiff - ulut/ul_utdefs.h
Add missing #include
[ulut.git] / ulut / ul_utdefs.h
index 4c89ca0e0424badc9a4db4af48b3dc248a4f43d5..aa96537695b45bd8545657e1bdb0e6a54d5acd96 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef _UL_UTDEFS_H
 #define _UL_UTDEFS_H
 
+#include <stddef.h> /* For size_t */
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -66,6 +68,24 @@ extern "C" {
 #endif /*__GNUC__*/
 #endif /*UL_CONTAINEROF*/
 
+#ifndef UL_ALIGNOF_FIELD
+#define        UL_ALIGNOF_FIELD(_type) UL_OFFSETOF(struct {char _fld0; _type _fld1;}, _fld1)
+#endif /*UL_ALIGNOF*/
+
+#ifndef UL_ALIGNOF_TYPE
+#ifdef  __GNUC__
+/* The compiler provided alignment for performance can differ from ABI struct one */
+#define        UL_ALIGNOF_TYPE(_type) __alignof__(_type)
+#else /*__GNUC__*/
+#define UL_ALIGNOF_TYPE UL_ALIGNOF_FIELD
+#endif /*__GNUC__*/
+#endif /*UL_ALIGNOF*/
+
+#ifndef UL_ALIGNOF
+#define        UL_ALIGNOF UL_ALIGNOF_FIELD
+#endif /*UL_ALIGNOF*/
+
+
 #ifndef UL_NOPSTATEMENT
 #define UL_NOPSTATEMENT do { } while(0)
 #endif
@@ -170,6 +190,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 +210,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