]> rtime.felk.cvut.cz Git - sysless.git/blob - arch/mcs51/generic/libs/ulan/ul_utsubst.h
8e245c2bcb35b29e58efef6b0b8a2a4b0017dcc9
[sysless.git] / arch / mcs51 / generic / libs / ulan / ul_utsubst.h
1 #ifndef _UL_UTSUBST_H
2 #define _UL_UTSUBST_H
3
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;
8 #endif
9
10 #ifndef UL_OFFSETOF
11 /* offset of structure field */
12 #define UL_OFFSETOF(_type,_member) \
13                 ((size_t)&(((_type*)0)->_member))
14 #endif /*UL_OFFSET*/
15
16 #ifndef UL_CONTAINEROF
17 #ifdef  __GNUC__
18 #define UL_CONTAINEROF(_ptr, _type, _member) ({ \
19         const typeof( ((_type *)0)->_member ) *__mptr = (_ptr); \
20         (_type *)( (char *)__mptr - UL_OFFSETOF(_type,_member) );})
21 #else /*!__GNUC__*/
22 #define UL_CONTAINEROF(_ptr, _type, _member) \
23         ((_type *)( (char *)_ptr - UL_OFFSETOF(_type,_member)))
24 #endif /*__GNUC__*/
25 #endif /*UL_CONTAINEROF*/
26
27 /* GNUC neat features */
28
29 #ifdef  __GNUC__
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                            \
50   __attribute__((weak))
51 #endif  /*UL_ATTR_UNUSED*/
52 #else   /* !__GNUC__ */
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
58 #define UL_ATTR_CONST
59 #define UL_ATTR_UNUSED
60 #define UL_ATTR_CONSTRUCTOR
61 #define UL_ATTR_DESCRUCTOR
62 #define UL_ATTR_ALWAYS_INLINE
63 #define UL_ATTR_WEAK
64 #endif  /*UL_ATTR_UNUSED*/
65 #endif  /* !__GNUC__ */
66
67 #ifndef UL_ATTR_REENTRANT
68 #ifndef SDCC
69   #define UL_ATTR_REENTRANT
70 #else
71   #define UL_ATTR_REENTRANT __reentrant
72 #endif
73 #endif /*UL_ATTR_REENTRANT*/
74
75 #endif /*_UL_UTSUBST_H*/