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