libtools
tools.h
Go to the documentation of this file.
1 
20 #ifndef __TOOLS_TOOLS_H
21 #define __TOOLS_TOOLS_H
22 
33 /*------------------------------------------------------------------------*/
34 
43 /*------------------------------------------------------------------------*/
44 
52 /*------------------------------------------------------------------------*/
53 
63 /*------------------------------------------------------------------------*/
64 
70 #ifndef countof
71 # define countof(x) (sizeof(x) / sizeof(x[0]))
72 #endif /* countof */
73 
80 #ifndef unused
81 # define unused(x) ((void)x)
82 #endif /* unused */
83 
89 #ifndef min
90 # define min(a, b) __extension__ ({ \
91  typeof (a) _a = (a); \
92  typeof (b) _b = (b); \
93  _a > _b ? _b : _a; \
94  })
95 #endif /* min */
96 
102 #ifndef max
103 # define max(a, b) __extension__ ({ \
104  typeof (a) _a = (a); \
105  typeof (b) _b = (b); \
106  _a < _b ? _b : _a; \
107  })
108 #endif /* max */
109 
116 #ifndef cast_ptr
117 # define cast_ptr(t, x) __extension__ ({ \
118  (typeof(t)*)x; \
119  })
120 #endif /* cast_ptr */
121 
124 #endif /* __TOOLS_TOOLS_H */