19 #ifndef __CDIO_UTIL_H__
20 #define __CDIO_UTIL_H__
32 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
35 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
38 #define IN(x, low, high) ((x) >= (low) && (x) <= (high))
41 #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
43 static inline uint32_t
44 _cdio_len2blocks (uint32_t i_len, uint16_t i_blocksize)
48 i_blocks = i_len / (uint32_t) i_blocksize;
49 if (i_len % i_blocksize)
56 static inline unsigned
57 _cdio_ceil2block (
unsigned offset, uint16_t i_blocksize)
59 return _cdio_len2blocks (offset, i_blocksize) * i_blocksize;
62 static inline unsigned int
63 _cdio_ofs_add (
unsigned offset,
unsigned length, uint16_t i_blocksize)
65 if (i_blocksize - (offset % i_blocksize) < length)
66 offset = _cdio_ceil2block (offset, i_blocksize);
73 static inline const char *
74 _cdio_bool_str (
bool b)
76 return b ?
"yes" :
"no";
105 #ifdef WANT_FOLLOW_SYMLINK_COMPATIBILITY
106 # define cdio_follow_symlink cdio_realpath