From 6d4303cd949755cb97079c961acb97155e6e380f Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 19 Dec 2019 18:07:08 +0000 Subject: [PATCH] Added option to force 32bit compilation (useful for debug). Fixed various warnings when compiling in a 32 bit arch. --- CMakeLists.txt | 9 +++++++++ lib/include/srslte/asn1/asn1_utils.h | 2 +- lib/src/phy/rf/rf_zmq_imp.c | 6 +++--- lib/src/phy/rf/rf_zmq_imp.h | 2 +- lib/src/phy/rf/rf_zmq_imp_rx.c | 2 +- srsue/test/ttcn3/hdr/ttcn3_syssim.h | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ba963cdd..0521d6df7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,8 @@ option(USE_LTE_RATES "Use standard LTE sampling rates" OFF) option(USE_GLIBC_IPV6 "Use glibc's own ipv6.h" ON) option(USE_MKL "Use MKL instead of fftw" OFF) +option(FORCE_32BIT "Add flags to force 32 bit compilation" OFF) + if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") set(GCC_ARCH armv8-a CACHE STRING "GCC compile for specific architecture.") message(STATUS "Detected aarch64 processor") @@ -329,6 +331,13 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(NOT WIN32) ADD_CXX_COMPILER_FLAG_IF_AVAILABLE(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_CXX) endif(NOT WIN32) + + if(FORCE_32BIT) + ADD_C_COMPILER_FLAG_IF_AVAILABLE("-m32" HAVE_WNO_UNUSED_BUT_SET_VARIABLE) + ADD_CXX_COMPILER_FLAG_IF_AVAILABLE("-m32" HAVE_WNO_UNUSED_BUT_SET_VARIABLE) + set(CMAKE_SHARED_LINKER_FLAGS "-m32") + endif(FORCE_32BIT) + endif(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") ADD_C_COMPILER_FLAG_IF_AVAILABLE("-Werror=incompatible-pointer-types" HAVE_ERROR_INCOMPATIBLE) diff --git a/lib/include/srslte/asn1/asn1_utils.h b/lib/include/srslte/asn1/asn1_utils.h index 0e17c564b..ba21c9f74 100644 --- a/lib/include/srslte/asn1/asn1_utils.h +++ b/lib/include/srslte/asn1/asn1_utils.h @@ -260,7 +260,7 @@ private: * @tparam T * @tparam Nthres number of elements T that can be stored in the stack */ -template +template class ext_array { public: diff --git a/lib/src/phy/rf/rf_zmq_imp.c b/lib/src/phy/rf/rf_zmq_imp.c index 18a795a89..b04b3cd84 100644 --- a/lib/src/phy/rf/rf_zmq_imp.c +++ b/lib/src/phy/rf/rf_zmq_imp.c @@ -625,7 +625,7 @@ int rf_zmq_recv_with_time_multi(void* h, // Check available buffer size if (nbytes > ZMQ_MAX_BUFFER_SIZE) { fprintf(stderr, - "[zmq] Error: Trying to receive %d B but buffer is only %ld B at channel %d.\n", + "[zmq] Error: Trying to receive %d B but buffer is only %zu B at channel %d.\n", nbytes, ZMQ_MAX_BUFFER_SIZE, 0); @@ -762,7 +762,7 @@ int rf_zmq_send_timed_multi(void* h, uint32_t nbytes_baseband = NSAMPLES2NBYTES(nsamples_baseband); if (nbytes_baseband > ZMQ_MAX_BUFFER_SIZE) { - fprintf(stderr, "Error: trying to transmit too many samples (%d > %ld).\n", nbytes, ZMQ_MAX_BUFFER_SIZE); + fprintf(stderr, "Error: trying to transmit too many samples (%d > %zu).\n", nbytes, ZMQ_MAX_BUFFER_SIZE); goto clean_exit; } @@ -790,7 +790,7 @@ int rf_zmq_send_timed_multi(void* h, if (num_tx_gap_samples < 0) { fprintf(stderr, - "[zmq] Error: tx time is %.3f ms in the past (%ld < %ld)\n", + "[zmq] Error: tx time is %.3f ms in the past (%" PRIu64 " < %" PRIu64 ")\n", -1000.0 * num_tx_gap_samples / handler->base_srate, tx_ts, handler->transmitter[0].nsamples); diff --git a/lib/src/phy/rf/rf_zmq_imp.h b/lib/src/phy/rf/rf_zmq_imp.h index 73c6e3312..bf167576a 100644 --- a/lib/src/phy/rf/rf_zmq_imp.h +++ b/lib/src/phy/rf/rf_zmq_imp.h @@ -20,7 +20,7 @@ */ #include -#include +#include #include "srslte/config.h" #include "srslte/phy/rf/rf.h" diff --git a/lib/src/phy/rf/rf_zmq_imp_rx.c b/lib/src/phy/rf/rf_zmq_imp_rx.c index b88ac658a..e8aeef169 100644 --- a/lib/src/phy/rf/rf_zmq_imp_rx.c +++ b/lib/src/phy/rf/rf_zmq_imp_rx.c @@ -67,7 +67,7 @@ static void* rf_zmq_async_rx_thread(void* h) } else if (n > ZMQ_MAX_BUFFER_SIZE) { fprintf(stderr, - "[zmq] Error: receiver expected <= %ld bytes and received %d at channel %d.\n", + "[zmq] Error: receiver expected <= %zu bytes and received %d at channel %d.\n", ZMQ_MAX_BUFFER_SIZE, n, 0); diff --git a/srsue/test/ttcn3/hdr/ttcn3_syssim.h b/srsue/test/ttcn3/hdr/ttcn3_syssim.h index 59da1ddee..37dac4a7a 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_syssim.h +++ b/srsue/test/ttcn3/hdr/ttcn3_syssim.h @@ -567,7 +567,7 @@ public: if (lcid == 0) { if (mac_msg_dl.new_subh()) { if (mac_msg_dl.get()->set_con_res_id(conres_id)) { - log.info("CE: Added Contention Resolution ID=0x%lx\n", conres_id); + log.info("CE: Added Contention Resolution ID=0x%" PRIx64 "\n", conres_id); } else { log.error("CE: Setting Contention Resolution ID CE\n"); }