#include <cutils/base.h>
#include <ctype.h>
Go to the source code of this file.
Function Documentation
M_INLINE uint32_t UTIL_align |
( |
uint32_t |
num, |
|
|
uint32_t |
align |
|
) |
| |
Definition at line 43 of file util.h.
{
return (num + align - 1 ) & (~(align - 1));
}
M_INLINE int UTIL_is_power_of_two |
( |
uint32_t |
num | ) |
|
Definition at line 31 of file util.h.
{
return (num & (num - 1)) == 0;
}
M_INLINE size_t UTIL_log_base_2_of_n |
( |
size_t |
num | ) |
|
Definition at line 101 of file util.h.
{
size_t ret = 0;
while( num ) {
num >>= 1;
ret ++;
}
return ret;
}
M_INLINE void* UTIL_ptr_align |
( |
void * |
ptr, |
|
|
size_t |
align |
|
) |
| |
Definition at line 56 of file util.h.
{
return (void *) ( (((ptrdiff_t) ptr) & ~(align - 1)) + align );
}
M_INLINE int UTIL_ptr_in_range |
( |
void * |
ptr, |
|
|
void * |
from, |
|
|
void * |
to |
|
) |
| |
Definition at line 85 of file util.h.
{
return (uint8_t *) ptr >= (uint8_t *) from && (uint8_t *) ptr < (uint8_t *) to;
}
M_INLINE int UTIL_ptr_is_aligned |
( |
void * |
ptr, |
|
|
size_t |
page_size |
|
) |
| |
Definition at line 76 of file util.h.
{
return ( ((ptrdiff_t) ptr) & ((ptrdiff_t) page_size - 1) ) == 0;
}
M_INLINE void* UTIL_ptr_page_start |
( |
void * |
ptr, |
|
|
size_t |
page_size |
|
) |
| |
Definition at line 64 of file util.h.
{
return (void *) ( ((ptrdiff_t) ptr) & ~ ((ptrdiff_t) page_size - 1) );
}
M_INLINE size_t UTIL_round_to_power_of_n |
( |
size_t |
num | ) |
|
Definition at line 91 of file util.h.
{
size_t n = 1;
while( n < num ) {
n <<= 1;
}
return n;
}
M_INLINE char* UTIL_skip_nspace |
( |
const char * |
p | ) |
|
Definition at line 121 of file util.h.
{
while( *p != '\0' && !isspace((int) *p)) {
++p;
}
return (char *) p;
}
M_INLINE char* UTIL_skip_spaces |
( |
const char * |
p | ) |
|
Definition at line 114 of file util.h.
{
while( *p != '\0' && isspace((int) *p)) {
++p;
}
return (char *) p;
}
M_INLINE void UTIL_swapbytes |
( |
unsigned char * |
src, |
|
|
unsigned char * |
dst, |
|
|
size_t |
size |
|
) |
| |
Definition at line 13 of file util.h.
{
unsigned char tmp;
while(size>0) {
tmp = *src;
*src = *dst;
*dst = tmp;
++src;
++dst;
--size;
}
}