1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-07-01 01:22:54 +00:00
gnss-sdr/src/algorithms/tracking/libs/saturated_arithmetic.h
Javier Arribas 5ba12c6fdb Added 16 bits short int complex ultra-fast resampler,
carrier wipe-off and correlator kernels (250% faster than
gr_complex) enabled in tracking GPS_L1_CA_DLL_PLL_C_Aid_Tracking_16sc
tracking
2016-01-11 16:49:37 +01:00

32 lines
648 B
C

#ifndef SATURATED_ARITHMETIC_H_
#define SATURATED_ARITHMETIC_H_
#include <limits.h>
//#include <types.h>
static inline int16_t sat_adds16b(int16_t x, int16_t y)
{
// int16_t ux = x;
// int16_t uy = y;
// int16_t res = ux + uy;
//
// /* Calculate overflowed result. (Don't change the sign bit of ux) */
// ux = (ux >> 15) + SHRT_MAX;
//
// /* Force compiler to use cmovns instruction */
// if ((int16_t) ((ux ^ uy) | ~(uy ^ res)) >= 0)
// {
// res = ux;
// }
//
// return res;
int32_t res = (int32_t) x + (int32_t) y;
if (res < SHRT_MIN) res = SHRT_MIN;
if (res > SHRT_MAX) res = SHRT_MAX;
return res;
}
#endif /*SATURATED_ARITHMETIC_H_*/