]> rtime.felk.cvut.cz Git - canping.git/blob - include/ul_utdefs.h
Updated copyright
[canping.git] / include / ul_utdefs.h
1 /*******************************************************************
2   uLan Communication - C interface library
3
4   ul_utdefs.h   - common defines used in uLan utilities library
5
6  *******************************************************************/
7
8
9 #ifndef _UL_UTDEFS_H
10 #define _UL_UTDEFS_H
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 #if defined(_WIN32)&&defined(_MSC_VER)&&!defined(inline)
17 #define inline _inline
18 #endif
19
20 #ifndef UL_OFFSETOF
21 /* offset of structure field */
22 #define UL_OFFSETOF(_type,_member) \
23                 ((int)&(((_type*)0)->_member))
24 #endif /*UL_OFFSET*/
25
26 #ifndef UL_CONTAINEROF
27 #ifdef  __GNUC__
28 #define UL_CONTAINEROF(_ptr, _type, _member) ({ \
29         const typeof( ((_type *)0)->_member ) *__mptr = (_ptr); \
30         (_type *)( (char *)__mptr - UL_OFFSETOF(_type,_member) );})
31 #else /*!__GNUC__*/
32 #define UL_CONTAINEROF(_ptr, _type, _member) \
33         ((_type *)( (char *)_ptr - UL_OFFSETOF(_type,_member)))
34 #endif /*__GNUC__*/
35 #endif /*UL_CONTAINEROF*/
36
37
38
39 #ifdef __cplusplus
40 } /* extern "C"*/
41 #endif
42
43 #endif /* _UL_UTDEFS_H */