4 #if !defined(_SIZE_T_DEFINED) && !defined(__SIZE_T_DEFINED)
5 #define _SIZE_T_DEFINED
6 #define __SIZE_T_DEFINED
7 typedef unsigned int size_t;
11 /* offset of structure field */
12 #define UL_OFFSETOF(_type,_member) \
13 ((size_t)&(((_type*)0)->_member))
16 #ifndef UL_CONTAINEROF
18 #define UL_CONTAINEROF(_ptr, _type, _member) ({ \
19 const typeof( ((_type *)0)->_member ) *__mptr = (_ptr); \
20 (_type *)( (char *)__mptr - UL_OFFSETOF(_type,_member) );})
22 #define UL_CONTAINEROF(_ptr, _type, _member) \
23 ((_type *)( (char *)_ptr - UL_OFFSETOF(_type,_member)))
25 #endif /*UL_CONTAINEROF*/
27 /* GNUC neat features */
30 #ifndef UL_ATTR_UNUSED
31 #define UL_ATTR_PRINTF( format_idx, arg_idx ) \
32 __attribute__((format (printf, format_idx, arg_idx)))
33 #define UL_ATTR_SCANF( format_idx, arg_idx ) \
34 __attribute__((format (scanf, format_idx, arg_idx)))
35 #define UL_ATTR_FORMAT( arg_idx ) \
36 __attribute__((format_arg (arg_idx)))
37 #define UL_ATTR_NORETURN \
38 __attribute__((noreturn))
39 #define UL_ATTR_CONST \
40 __attribute__((const))
41 #define UL_ATTR_UNUSED \
42 __attribute__((unused))
43 #define UL_ATTR_CONSTRUCTOR \
44 __attribute__((constructor))
45 #define UL_ATTR_DESCRUCTOR \
46 __attribute__((destructor))
47 #define UL_ATTR_ALWAYS_INLINE \
48 __attribute__((always_inline))
49 #define UL_ATTR_WEAK \
51 #endif /*UL_ATTR_UNUSED*/
53 #ifndef UL_ATTR_UNUSED
54 #define UL_ATTR_PRINTF( format_idx, arg_idx )
55 #define UL_ATTR_SCANF( format_idx, arg_idx )
56 #define UL_ATTR_FORMAT( arg_idx )
57 #define UL_ATTR_NORETURN
59 #define UL_ATTR_UNUSED
60 #define UL_ATTR_CONSTRUCTOR
61 #define UL_ATTR_DESCRUCTOR
62 #define UL_ATTR_ALWAYS_INLINE
64 #endif /*UL_ATTR_UNUSED*/
65 #endif /* !__GNUC__ */
67 #ifndef UL_ATTR_REENTRANT
69 #define UL_ATTR_REENTRANT
71 #define UL_ATTR_REENTRANT __reentrant
73 #endif /*UL_ATTR_REENTRANT*/
75 #endif /*_UL_UTSUBST_H*/