fix snprintf of uint64 for ARM

master
Andre Puschmann 5 years ago
parent 75c00ba1b0
commit 6f72cbffab

@ -23,6 +23,7 @@
#define SRSLTE_DYN_BITSET_H
#include <cstdint>
#include <inttypes.h>
#include <string>
#define CEILFRAC(x, y) (((x) > 0) ? ((((x)-1) / (y)) + 1) : 0)
@ -52,7 +53,7 @@ public:
void resize(size_t new_size) noexcept
{
if (new_size > max_size()) {
printf("ERROR: bitset resize out of bounds: %lu>=%lu\n", max_size(), new_size);
printf("ERROR: bitset resize out of bounds: %zd>=%zd\n", max_size(), new_size);
return;
} else if (new_size == cur_size) {
return;
@ -67,7 +68,7 @@ public:
void set(size_t pos) noexcept
{
if (pos >= size()) {
printf("ERROR: bitset out of bounds: %lu>=%lu\n", pos, size());
printf("ERROR: bitset out of bounds: %zd>=%zd\n", pos, size());
return;
}
set_(pos);
@ -76,7 +77,7 @@ public:
void reset(size_t pos) noexcept
{
if (pos >= size()) {
printf("ERROR: bitset out of bounds: %lu>=%lu\n", pos, size());
printf("ERROR: bitset out of bounds: %zd>=%zd\n", pos, size());
return;
}
reset_(pos);
@ -92,7 +93,7 @@ public:
bool test(size_t pos) const noexcept
{
if (pos >= size()) {
printf("ERROR: bitset out of bounds: %lu>=%lu\n", pos, size());
printf("ERROR: bitset out of bounds: %zd>=%zd\n", pos, size());
return false;
}
return test_(pos);
@ -110,7 +111,7 @@ public:
bounded_bitset<N, reversed>& fill(size_t startpos, size_t endpos, bool value = true) noexcept
{
if (endpos > size() or startpos > endpos) {
printf("ERROR: bounds (%lu, %lu) are not valid for bitset of size: %lu\n", startpos, endpos, size());
printf("ERROR: bounds (%zd, %zd) are not valid for bitset of size: %zd\n", startpos, endpos, size());
return *this;
}
// NOTE: can be optimized
@ -154,7 +155,7 @@ public:
bool any(size_t start, size_t stop) const noexcept
{
if (start > stop or stop > size()) {
printf("ERROR: bounds (%lu, %lu) are not valid for bitset of size: %lu\n", start, stop, size());
printf("ERROR: bounds (%zd, %zd) are not valid for bitset of size: %zd\n", start, stop, size());
return false;
}
// NOTE: can be optimized
@ -198,7 +199,7 @@ public:
bounded_bitset<N, reversed>& operator|=(const bounded_bitset<N, reversed>& other) noexcept
{
if (other.size() != size()) {
printf("ERROR: operator|= called for bitsets of different sizes (%lu!=%lu)\n", size(), other.size());
printf("ERROR: operator|= called for bitsets of different sizes (%zd!=%zd)\n", size(), other.size());
return *this;
}
for (size_t i = 0; i < nof_words_(); ++i) {
@ -210,7 +211,7 @@ public:
bounded_bitset<N, reversed>& operator&=(const bounded_bitset<N, reversed>& other) noexcept
{
if (other.size() != size()) {
printf("ERROR: operator&= called for bitsets of different sizes (%lu!=%lu)\n", size(), other.size());
printf("ERROR: operator&= called for bitsets of different sizes (%zd!=%zd)\n", size(), other.size());
return *this;
}
for (size_t i = 0; i < nof_words_(); ++i) {
@ -249,7 +250,7 @@ public:
uint64_t to_uint64() const noexcept
{
if (nof_words_() > 1) {
printf("ERROR: cannot convert bitset of size %lu bits to uint64_t\n", size());
printf("ERROR: cannot convert bitset of size %zd bits to uint64_t\n", size());
return 0;
}
return get_word_(0);
@ -262,7 +263,7 @@ public:
size_t count = 0;
for (int i = nof_words_() - 1; i >= 0; --i) {
count += sprintf(&cstr[count], "%016lx", buffer[i]);
count += sprintf(&cstr[count], "%016" PRIx64, buffer[i]);
}
size_t skip = nof_words_() * bits_per_word / 4 - nof_digits;

@ -20,9 +20,10 @@
*/
#include <cstdlib>
#include <inttypes.h>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string.h>
#include <sys/time.h>
@ -233,7 +234,7 @@ void log_filter::now_time(char* buffer, const uint32_t buffer_len)
strncat(buffer, us, buffer_len - dest_len - 1);
} else {
usec_epoch = rawtime.tv_sec * 1000000 + rawtime.tv_usec;
snprintf(buffer, buffer_len, "%ld", usec_epoch);
snprintf(buffer, buffer_len, "%" PRIu64, usec_epoch);
}
} else {
now = time_src->get_time();
@ -242,7 +243,7 @@ void log_filter::now_time(char* buffer, const uint32_t buffer_len)
snprintf(buffer, buffer_len, "%ld:%06u", now.full_secs, (uint32_t)(now.frac_secs * 1e6));
} else {
usec_epoch = now.full_secs * 1000000 + (uint32_t) (now.frac_secs * 1e6);
snprintf(buffer, buffer_len, "%ld", usec_epoch);
snprintf(buffer, buffer_len, "%" PRIu64, usec_epoch);
}
}
}

@ -19,6 +19,7 @@
*
*/
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
@ -783,7 +784,7 @@ void sch_subh::fprint(FILE* stream)
} else {
switch (lcid) {
case CON_RES_ID:
fprintf(stream, "Contention Resolution ID CE: 0x%lx\n", get_con_res_id());
fprintf(stream, "Contention Resolution ID CE: 0x%" PRIx64 "\n", get_con_res_id());
break;
case TA_CMD:
fprintf(stream, "Time Advance Command CE: %d\n", get_ta_cmd());

@ -19,6 +19,7 @@
*
*/
#include <inttypes.h>
#include <iostream>
#include <string.h>
@ -406,7 +407,7 @@ void ue::allocate_ce(srslte::sch_pdu *pdu, uint32_t lcid)
case srslte::sch_subh::CON_RES_ID:
if (pdu->new_subh()) {
if (pdu->get()->set_con_res_id(conres_id)) {
Info("CE: Added Contention Resolution ID=0x%lx\n", conres_id);
Info("CE: Added Contention Resolution ID=0x%" PRIx64 "\n", conres_id);
} else {
Error("CE: Setting Contention Resolution ID CE\n");
}

@ -98,7 +98,7 @@ bool sf_worker::set_cell(uint32_t cc_idx, srslte_cell_t cell_)
goto unlock;
}
} else {
Error("Setting cell for cc=%d; Not enough CC workers (%ld);\n", cc_idx, cc_workers.size());
Error("Setting cell for cc=%d; Not enough CC workers (%zd);\n", cc_idx, cc_workers.size());
}
if (cc_idx == 0) {

@ -580,7 +580,7 @@ bool ra_proc::contention_resolution_id_received(uint64_t rx_contention_id)
uecri_successful = true;
complete();
} else {
rInfo("Transmitted UE Contention Id differs from received Contention ID (0x%lx != 0x%lx)\n",
rInfo("Transmitted UE Contention Id differs from received Contention ID (0x%" PRIx64 " != 0x%" PRIx64 ")\n",
transmitted_contention_id,
rx_contention_id);

Loading…
Cancel
Save