71 #if !defined( _CSFAR ) 85 #if defined( _USE_PACK ) 86 #pragma pack( 1 ) // set byte alignment 87 #define _USING_BYTE_ALIGNMENT 91 #if MBG_TGT_HAS_64BIT_TYPES 92 #define _frac( _x ) ( ( (_x) == 0.0 ) ? 0.0 : ( (_x) - (double) ( (int64_t) (_x) ) ) ) 94 #define _frac( _x ) ( ( (_x) == 0.0 ) ? 0.0 : ( (_x) - (double) ( (long) (_x) ) ) ) 98 #define _eos( _s ) ( &(_s)[strlen( _s )] ) 101 #define MIN( _x, _y ) ( ( (_x) < (_y) ) ? (_x) : (_y) ) 105 #define MAX( _x, _y ) ( ( (_x) > (_y) ) ? (_x) : (_y) ) 108 #define SWAP( _x, _y ) { temp = (_x); (_x) = (_y); (_y) = temp; } 109 #define SQR( _x ) ( (_x) * (_x) ) 111 #define DP (double *) 113 #define bcd_from_bin( _x ) ( ( ( (_x) / 10 ) << 4 ) | ( (_x) % 10 ) ) 114 #define bin_from_bcd( _x ) ( ( ( (_x) >> 4 ) * 10 ) + ( (_x) & 0x0F ) ) 123 #if defined( _CC51 ) || defined( _SH2 ) 135 #ifndef _CSUM_DEFINED 137 #define _CSUM_DEFINED 142 #define _csum( _p ) checksum( (void _CSFAR *)(_p), sizeof( *(_p) ) ) 145 #define _set_csum( _p ) (_p)->csum = _csum( (_p) ) 148 #define _valid_csum( _p ) ( (_p)->csum == _csum( (_p) ) ) 151 #define _inrange( _val, _min, _max ) \ 152 ( ( (_val) >= (_min) ) && ( (_val) <= (_max) ) ) 155 #define _mask( _n ) \ 156 ( ( 1UL << (_n) ) - 1 ) 159 #define _idx_bit( _i ) \ 163 #define _is_supported( _i, _msk ) \ 164 ( ( (_msk) & _idx_bit( _i ) ) != 0 ) 167 #define _sgn( _x ) ( ( ( _x ) < 0 ) ? -1 : 1 ) 171 #define _m( _Y1, _X1, _Y2, _X2 ) ( ( _Y2 -_Y1 ) / ( _X2 -_X1 ) ) 172 #define _b( _Y1, _X1, _Y2, _X2 ) ( ( ( _Y1 * _X2 ) - ( _Y2 * _X1 ) ) / ( _X2 -_X1 ) ) 180 #define _strncpy_0( _dst, _src ) \ 182 int n = sizeof( _dst ) - 1; \ 184 strncpy( _dst, _src, n ); \ 194 #define _memfill( _p, _v ) \ 195 memset( _p, _v, sizeof( *(_p) ) ) 197 #define _memclr( _p ) \ 203 #define _dos_idle() geninterrupt( 0x28 ) 240 #if defined( _USING_BYTE_ALIGNMENT ) 241 #pragma pack() // set default alignment 242 #undef _USING_BYTE_ALIGNMENT
uint16_t CSUM
checksum used by some structures stored in non-volatile memory
void spaces_to_zeros(char *s)
Replace whitespace ' ' characters by 0 characters.
CSUM checksum(const void *vp, int n)
Create a simple checksum.