15 #ifndef STATIC_ASSERT_H
22 #define pt_assert(bed) arb_assert(bed)
42 static inline unsigned short bswap_16(
unsigned short x) {
43 return (x>>8) | (x<<8);
46 static inline unsigned int bswap_32(
unsigned int x) {
47 return (bswap_16(x&0xffff)<<16) | bswap_16(x>>16);
50 static inline unsigned long long bswap_64(
unsigned long long x) {
51 return (((
unsigned long long)bswap_32(x&0xffffffffull))<<32) | bswap_32(x>>32);
75 inline uint_64 PT_read_long (
const void *fromMem) {
return bswap_64(*(
uint_64*)fromMem); }
85 inline void PT_write_long (
void *toMem,
uint_64 i) { *(
uint_64*)toMem = bswap_64(i); }
112 reserved_bits = reserved_bits << (8-R);
149 reserved_bits = nat >> (8-R);
185 write_nat_with_reserved_bits<R+1>(toMem, i<0 ? -i-1 : i, (reserved_bits<<1)|(i<0));
189 uint_32 nat = read_nat_with_reserved_bits<R+1>(fromMem, reserved_bits);
190 bool isNeg = reserved_bits&1;
191 reserved_bits = reserved_bits>>1;
192 return isNeg ? -nat-1 :
nat;
208 template<
typename POINTED>
217 #error PT_tools.h included twice