4 #ifndef _SIZE_T_DEFINED
5 #define _SIZE_T_DEFINED
6 typedef unsigned int size_t;
10 /* offset of structure field */
11 #define UL_OFFSETOF(_type,_member) \
12 ((size_t)&(((_type*)0)->_member))
15 #ifndef UL_CONTAINEROF
17 #define UL_CONTAINEROF(_ptr, _type, _member) ({ \
18 const typeof( ((_type *)0)->_member ) *__mptr = (_ptr); \
19 (_type *)( (char *)__mptr - UL_OFFSETOF(_type,_member) );})
21 #define UL_CONTAINEROF(_ptr, _type, _member) \
22 ((_type *)( (char *)_ptr - UL_OFFSETOF(_type,_member)))
24 #endif /*UL_CONTAINEROF*/
26 /* GNUC neat features */
29 #ifndef UL_ATTR_UNUSED
30 #define UL_ATTR_PRINTF( format_idx, arg_idx ) \
31 __attribute__((format (printf, format_idx, arg_idx)))
32 #define UL_ATTR_SCANF( format_idx, arg_idx ) \
33 __attribute__((format (scanf, format_idx, arg_idx)))
34 #define UL_ATTR_FORMAT( arg_idx ) \
35 __attribute__((format_arg (arg_idx)))
36 #define UL_ATTR_NORETURN \
37 __attribute__((noreturn))
38 #define UL_ATTR_CONST \
39 __attribute__((const))
40 #define UL_ATTR_UNUSED \
41 __attribute__((unused))
42 #define UL_ATTR_CONSTRUCTOR \
43 __attribute__((constructor))
44 #define UL_ATTR_DESCRUCTOR \
45 __attribute__((destructor))
46 #define UL_ATTR_ALWAYS_INLINE \
47 __attribute__((always_inline))
48 #define UL_ATTR_WEAK \
50 #endif /*UL_ATTR_UNUSED*/
52 #ifndef UL_ATTR_UNUSED
53 #define UL_ATTR_PRINTF( format_idx, arg_idx )
54 #define UL_ATTR_SCANF( format_idx, arg_idx )
55 #define UL_ATTR_FORMAT( arg_idx )
56 #define UL_ATTR_NORETURN
58 #define UL_ATTR_UNUSED
59 #define UL_ATTR_CONSTRUCTOR
60 #define UL_ATTR_DESCRUCTOR
61 #define UL_ATTR_ALWAYS_INLINE
63 #endif /*UL_ATTR_UNUSED*/
64 #endif /* !__GNUC__ */
66 #ifndef UL_ATTR_REENTRANT
68 #define UL_ATTR_REENTRANT
70 #define UL_ATTR_REENTRANT __reentrant
72 #endif /*UL_ATTR_REENTRANT*/
74 #endif /*_UL_UTSUBST_H*/