2010-12-12 17:31:13 +01:00
|
|
|
#ifndef TOOLS_H_
|
|
|
|
#define TOOLS_H_
|
|
|
|
|
2012-02-09 22:18:16 +01:00
|
|
|
/* Constants */
|
|
|
|
#define KB_SIZE 1024.0f
|
|
|
|
#define MB_SIZE 1048576.0f
|
|
|
|
#define GB_SIZE 1073741824.0f
|
|
|
|
|
|
|
|
#define round_up(x,n) (-(-(x) & -(n)))
|
|
|
|
|
2011-06-14 19:53:19 +02:00
|
|
|
#define ABS(x) ( (x) >= (0) ? (x) : (-(x)) )
|
2011-11-17 04:28:54 +01:00
|
|
|
#define LIMIT(x, min, max) \
|
|
|
|
({ \
|
|
|
|
typeof( x ) _x = x; \
|
|
|
|
typeof( min ) _min = min; \
|
|
|
|
typeof( max ) _max = max; \
|
|
|
|
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \
|
|
|
|
})
|
2010-12-27 10:44:27 +01:00
|
|
|
#define ALIGN(x) (((x) + 3) & ~3)
|
|
|
|
#define ALIGN32(x) (((x) + 31) & ~31)
|
2010-12-12 17:31:13 +01:00
|
|
|
|
|
|
|
#endif
|