mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-11-16 23:04:57 +00:00
Fix C compilation errors in c11 compilers
This commit is contained in:
parent
b96d1707a9
commit
4477da0f75
@ -53,8 +53,8 @@ u8 parity(u32 x)
|
|||||||
u32 getbitu(const u8 *buff, u32 pos, u8 len)
|
u32 getbitu(const u8 *buff, u32 pos, u8 len)
|
||||||
{
|
{
|
||||||
u32 bits = 0;
|
u32 bits = 0;
|
||||||
|
u32 i=0;
|
||||||
for (u32 i = pos; i < pos + len; i++) {
|
for ( i= pos; i < pos + len; i++) {
|
||||||
bits = (bits << 1) +
|
bits = (bits << 1) +
|
||||||
((buff[i/8] >> (7 - i%8)) & 1u);
|
((buff[i/8] >> (7 - i%8)) & 1u);
|
||||||
}
|
}
|
||||||
@ -99,8 +99,8 @@ void setbitu(u8 *buff, u32 pos, u32 len, u32 data)
|
|||||||
|
|
||||||
if (len <= 0 || 32 < len)
|
if (len <= 0 || 32 < len)
|
||||||
return;
|
return;
|
||||||
|
u32 i=0;
|
||||||
for (u32 i = pos; i < pos + len; i++, mask >>= 1) {
|
for (i = pos; i < pos + len; i++, mask >>= 1) {
|
||||||
if (data & mask)
|
if (data & mask)
|
||||||
buff[i/8] |= 1u << (7 - i % 8);
|
buff[i/8] |= 1u << (7 - i % 8);
|
||||||
else
|
else
|
||||||
@ -156,7 +156,8 @@ void bitshl(void *buf, u32 size, u32 shift)
|
|||||||
} else {
|
} else {
|
||||||
/* Create an accumulator: it will hold a value of two consecutive bytes */
|
/* Create an accumulator: it will hold a value of two consecutive bytes */
|
||||||
u32 acc = *src++;
|
u32 acc = *src++;
|
||||||
for (u32 i = 0; i < full_bytes; ++i) {
|
u32 i=0;
|
||||||
|
for (i = 0; i < full_bytes; ++i) {
|
||||||
acc = (acc << CHAR_BIT) | *src++;
|
acc = (acc << CHAR_BIT) | *src++;
|
||||||
*dst++ = acc >> byte_shift;
|
*dst++ = acc >> byte_shift;
|
||||||
}
|
}
|
||||||
@ -188,8 +189,8 @@ void bitcopy(void *dst, u32 dst_index, const void *src, u32 src_index,
|
|||||||
{
|
{
|
||||||
u32 limit1 = count / 32;
|
u32 limit1 = count / 32;
|
||||||
u32 limit2 = count % 32;
|
u32 limit2 = count % 32;
|
||||||
|
u32 idx=0;
|
||||||
for (u32 idx = 0; idx < limit1; ++idx) {
|
for (idx = 0; idx < limit1; ++idx) {
|
||||||
u32 tmp = getbitu(src, src_index, 32);
|
u32 tmp = getbitu(src, src_index, 32);
|
||||||
setbitu(dst, dst_index, 32, tmp);
|
setbitu(dst, dst_index, 32, tmp);
|
||||||
src_index += 32;
|
src_index += 32;
|
||||||
@ -212,7 +213,8 @@ void bitcopy(void *dst, u32 dst_index, const void *src, u32 src_index,
|
|||||||
u8 count_bits_u64(u64 v, u8 bv)
|
u8 count_bits_u64(u64 v, u8 bv)
|
||||||
{
|
{
|
||||||
u8 r = 0;
|
u8 r = 0;
|
||||||
for (int i = 0; i < 16; i++)
|
int i =0;
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
r += bitn[(v >> (i*4)) & 0xf];
|
r += bitn[(v >> (i*4)) & 0xf];
|
||||||
return bv == 1 ? r : 64 - r;
|
return bv == 1 ? r : 64 - r;
|
||||||
}
|
}
|
||||||
@ -228,7 +230,8 @@ u8 count_bits_u64(u64 v, u8 bv)
|
|||||||
u8 count_bits_u32(u32 v, u8 bv)
|
u8 count_bits_u32(u32 v, u8 bv)
|
||||||
{
|
{
|
||||||
u8 r = 0;
|
u8 r = 0;
|
||||||
for (int i = 0; i < 8; i++)
|
int i=0;
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
r += bitn[(v >> (i*4)) & 0xf];
|
r += bitn[(v >> (i*4)) & 0xf];
|
||||||
return bv == 1 ? r : 32 - r;
|
return bv == 1 ? r : 32 - r;
|
||||||
}
|
}
|
||||||
@ -244,7 +247,8 @@ u8 count_bits_u32(u32 v, u8 bv)
|
|||||||
u8 count_bits_u16(u16 v, u8 bv)
|
u8 count_bits_u16(u16 v, u8 bv)
|
||||||
{
|
{
|
||||||
u8 r = 0;
|
u8 r = 0;
|
||||||
for (int i = 0; i < 4; i++)
|
int i =0;
|
||||||
|
for (i= 0; i < 4; i++)
|
||||||
r += bitn[(v >> (i*4)) & 0xf];
|
r += bitn[(v >> (i*4)) & 0xf];
|
||||||
return bv == 1 ? r : 16 - r;
|
return bv == 1 ? r : 16 - r;
|
||||||
}
|
}
|
||||||
@ -260,7 +264,8 @@ u8 count_bits_u16(u16 v, u8 bv)
|
|||||||
u8 count_bits_u8(u8 v, u8 bv)
|
u8 count_bits_u8(u8 v, u8 bv)
|
||||||
{
|
{
|
||||||
u8 r = 0;
|
u8 r = 0;
|
||||||
for (int i = 0; i < 2; i++)
|
int i=0;
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
r += bitn[(v >> (i*4)) & 0xf];
|
r += bitn[(v >> (i*4)) & 0xf];
|
||||||
return bv == 1 ? r : 8 - r;
|
return bv == 1 ? r : 8 - r;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,9 @@ static void _cnav_rescan_preamble(cnav_v27_part_t *part)
|
|||||||
part->preamble_seen = false;
|
part->preamble_seen = false;
|
||||||
|
|
||||||
if (part->n_decoded > GPS_CNAV_PREAMBLE_LENGTH + 1) {
|
if (part->n_decoded > GPS_CNAV_PREAMBLE_LENGTH + 1) {
|
||||||
for (size_t i = 1, j = part->n_decoded - GPS_CNAV_PREAMBLE_LENGTH;
|
size_t i=0;
|
||||||
|
size_t j=0;
|
||||||
|
for (i = 1, j = part->n_decoded - GPS_CNAV_PREAMBLE_LENGTH;
|
||||||
i < j; ++i) {
|
i < j; ++i) {
|
||||||
u32 c = getbitu(part->decoded, i, GPS_CNAV_PREAMBLE_LENGTH);
|
u32 c = getbitu(part->decoded, i, GPS_CNAV_PREAMBLE_LENGTH);
|
||||||
if (GPS_CNAV_PREAMBLE1 == c || GPS_CNAV_PREAMBLE2 == c) {
|
if (GPS_CNAV_PREAMBLE1 == c || GPS_CNAV_PREAMBLE2 == c) {
|
||||||
@ -259,7 +261,8 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch)
|
|||||||
*/
|
*/
|
||||||
static void _cnav_msg_invert(cnav_v27_part_t *part)
|
static void _cnav_msg_invert(cnav_v27_part_t *part)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < sizeof(part->decoded); i++) {
|
size_t i = 0;
|
||||||
|
for (i = 0; i < sizeof(part->decoded); i++) {
|
||||||
part->decoded[i] ^= 0xFFu;
|
part->decoded[i] ^= 0xFFu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,8 @@ static const u32 crc24qtab[256] = {
|
|||||||
*/
|
*/
|
||||||
u32 crc24q(const u8 *buf, u32 len, u32 crc)
|
u32 crc24q(const u8 *buf, u32 len, u32 crc)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < len; i++)
|
u32 i=0;
|
||||||
|
for ( i= 0; i < len; i++)
|
||||||
crc = ((crc << 8) & 0xFFFFFF) ^ crc24qtab[((crc >> 16) ^ buf[i]) & 0xff];
|
crc = ((crc << 8) & 0xFFFFFF) ^ crc24qtab[((crc >> 16) ^ buf[i]) & 0xff];
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
@ -98,7 +99,8 @@ u32 crc24q_bits(u32 crc, const u8 *buf, u32 n_bits, bool invert)
|
|||||||
u8 b = 0;
|
u8 b = 0;
|
||||||
u32 shift = 8 - n_bits % 8;
|
u32 shift = 8 - n_bits % 8;
|
||||||
|
|
||||||
for (u32 i = 0; i < n_bits / 8; ++i) {
|
u32 i=0;
|
||||||
|
for ( i= 0; i < n_bits / 8; ++i) {
|
||||||
acc = (acc << 8) | *buf++;
|
acc = (acc << 8) | *buf++;
|
||||||
if (invert) {
|
if (invert) {
|
||||||
acc ^= 0xFFu;
|
acc ^= 0xFFu;
|
||||||
|
Loading…
Reference in New Issue
Block a user