cu/size.h: Functions on Sizes and Pointer Diffs
[Data Types]

Functions

size_t cu_size_min (size_t n, size_t m)
size_t cu_size_max (size_t n, size_t m)
int cu_size_cmp (size_t n, size_t m)
size_t cu_size_lmask (unsigned int b)
size_t cu_size_dcover (size_t x)
size_t cu_size_ucover (size_t x)
size_t cu_size_ceil_div (size_t n, size_t m)
size_t cu_size_mulceil (size_t n, size_t m)
size_t cu_size_mulfloor (size_t n, size_t m)
size_t cu_size_scal2ceil (size_t n, unsigned int b)
size_t cu_size_scal2floor (size_t n, unsigned int b)
size_t cu_size_alignceil (size_t n)
size_t cu_size_alignfloor (size_t n)
size_t cu_size_exp2ceil (size_t n)
size_t cu_size_exp2floor (size_t n)
unsigned int cu_size_floor_log2 (size_t n)
unsigned int cu_size_ceil_log2 (size_t n)
unsigned int cu_size_log2_lowbit (size_t n)
ptrdiff_t cu_ptrdiff_min (ptrdiff_t n, ptrdiff_t m)
ptrdiff_t cu_ptrdiff_max (ptrdiff_t n, ptrdiff_t m)
ptrdiff_t cu_ptrdiff_abs (ptrdiff_t n)

Function Documentation

ptrdiff_t cu_ptrdiff_abs ( ptrdiff_t  n  ) 

Returns the absolute value of n.

ptrdiff_t cu_ptrdiff_max ( ptrdiff_t  n,
ptrdiff_t  m 
)

Returns the smallest argument.

ptrdiff_t cu_ptrdiff_min ( ptrdiff_t  n,
ptrdiff_t  m 
)

Returns the greatest argument.

size_t cu_size_alignceil ( size_t  n  ) 

Round up n to the nearest fully aligned size.

size_t cu_size_alignfloor ( size_t  n  ) 

Round down n to the nearest fully aligned size.

size_t cu_size_ceil_div ( size_t  n,
size_t  m 
)

Returns $\lceil\frac{n}{m}\rceil$.

unsigned int cu_size_ceil_log2 ( size_t  n  ) 

Returns $ \lceil \mathrm{log}_2 n \rceil $.

Precondition:
n > 0.
int cu_size_cmp ( size_t  n,
size_t  m 
)

Returns -1 if n < m, 1 if n = m, and 0 otherwise.

size_t cu_size_dcover ( size_t  x  ) 

Returns a bitmask from the uppermost non-zero bit in x and downwards.

size_t cu_size_exp2ceil ( size_t  n  ) 

Returns $ 2^{\lceil \mathrm{log}_2 n\rceil} $, i.e. the smallest power of 2 which is greater or equal to n.

size_t cu_size_exp2floor ( size_t  n  ) 

Returns $ 2^{\lfloor \mathrm{log}_2 n\rfloor} $, i.e. the greatest power of 2 which is smaller or equal to n.

unsigned int cu_size_floor_log2 ( size_t  n  ) 

Returns $ \lfloor \mathrm{log}_2 n \rfloor $.

Precondition:
n > 0.
size_t cu_size_lmask ( unsigned int  b  ) 

Returs a number with the lowest b bits set, and the remaining bits cleared.

unsigned int cu_size_log2_lowbit ( size_t  n  ) 

The exponent of the lowermost non-zero bit in n.

size_t cu_size_max ( size_t  n,
size_t  m 
)

Returns the smallest argument.

size_t cu_size_min ( size_t  n,
size_t  m 
)

Returns the greatest argument.

size_t cu_size_mulceil ( size_t  n,
size_t  m 
)

Returns $ m \lceil \frac{n}{m} \rceil $, i.e. n rounded up to the nearest multiple of m.

size_t cu_size_mulfloor ( size_t  n,
size_t  m 
)

Returns $ m \lfloor \frac{n}{m} \rfloor $, i.e. n rounded down to the nearest multiple of m.

size_t cu_size_scal2ceil ( size_t  n,
unsigned int  b 
)

Returns $ 2^b\lceil 2^{-b}n \rceil$, i.e. n rounded up to the nearest multiple of $2^b$.

size_t cu_size_scal2floor ( size_t  n,
unsigned int  b 
)

Returns $ 2^b\lfloor 2^{-b}n \rfloor$, i.e. n rounded down to the nearest multiple of $2^b$.

size_t cu_size_ucover ( size_t  x  ) 

Returns a bitmask from the lowermost non-zero bit in x and upwards.

Generated 2009-11-23 for culibs-0.25 using Doxygen. Maintained by Petter Urkedal.