63 lines
942 B
C
Executable file
63 lines
942 B
C
Executable file
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#define BIT(n) (1L<<n)
|
|
|
|
union bits32
|
|
{
|
|
int32_t i32;
|
|
uint32_t ui32;
|
|
float f32;
|
|
int16_t i16[2];
|
|
uint16_t ui16[2];
|
|
int8_t i8[4];
|
|
uint8_t ui8[4];
|
|
};
|
|
|
|
union bits64
|
|
{
|
|
int64_t i64;
|
|
int32_t i32[2];
|
|
float f32[2];
|
|
int16_t i16[4];
|
|
int8_t i8[8];
|
|
};
|
|
|
|
typedef union bits32 BITS32;
|
|
typedef union bits64 BITS64;
|
|
|
|
typedef BITS32 bits32_t;
|
|
typedef BITS64 bits64_t;
|
|
|
|
|
|
static inline int32_t rol32(int32_t i,uint8_t n)
|
|
{
|
|
return (i << n) | (i >> (32 - n));
|
|
};
|
|
static inline int32_t ror32(int32_t i,uint8_t n)
|
|
{
|
|
return (i >> n) | (i << (32 - n));
|
|
};
|
|
|
|
static inline int16_t rol16(int16_t i,uint8_t n)
|
|
{
|
|
return (i << n) | (i >> (16 - n));
|
|
};
|
|
static inline int16_t ror16(int16_t i,uint8_t n)
|
|
{
|
|
return (i >> n) | (i << (16 - n));
|
|
};
|
|
|
|
static inline uint8_t rol8(uint8_t i,uint8_t n)
|
|
{
|
|
return (i << n) | (i >> (8 - n));
|
|
};
|
|
static inline uint8_t ror8(uint8_t i,uint8_t n)
|
|
{
|
|
return (i >> n) | (i << (8 - n));
|
|
};
|
|
|
|
|
|
|