System info & network
This commit is contained in:
26
code/lib/bits.h
Normal file
26
code/lib/bits.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef _PIUMA_LIB_BITS_H_
|
||||
#define _PIUMA_LIB_BITS_H_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
inline u32 bits_endian_swap(u32 x)
|
||||
{
|
||||
return
|
||||
(x << 24 ) |
|
||||
(x << 8 & 0x00FF0000) |
|
||||
(x >> 8 & 0x0000FF00) |
|
||||
(x >> 24 );
|
||||
}
|
||||
|
||||
inline u32 bits_reverse(u32 x)
|
||||
{
|
||||
u32 result = 0;
|
||||
for(int i = 0; i < 32; i++)
|
||||
{
|
||||
result = result << 1 | (x & 1);
|
||||
x = x >> 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user