diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b1ed4bb3..087d9aaa9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,16 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.9) project(slsDetectorPackage) set(PROJECT_VERSION 5.0.0) +include(CheckIPOSupported) + check_ipo_supported(RESULT result) + if(result) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE) + endif() + + include(cmake/project_version.cmake) @@ -53,10 +61,14 @@ add_library(slsProjectWarnings INTERFACE) target_compile_features(slsProjectOptions INTERFACE cxx_std_11) target_compile_options(slsProjectWarnings INTERFACE -Wall + -Wextra + -Wno-unused-parameter #Needs to be slowly mitigated + # -Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual -Wdouble-promotion -Wformat=2 + -Wredundant-decls ) diff --git a/integrationTests/src/a.cpp b/integrationTests/src/a.cpp index ff02ffbe4..14407da60 100644 --- a/integrationTests/src/a.cpp +++ b/integrationTests/src/a.cpp @@ -35,43 +35,49 @@ std::ostream &operator<<(std::ostream &out, const ROI &r) { } int main() { + // uint32_t imageSize = 101; + // uint32_t packetSize = 100; + // std::cout << "a: " << std::ceil((double)imageSize / (double)packetSize) <<'\n'; + // std::cout << "b: " << imageSize / packetSize <<'\n'; + // std::cout << "c: " << static_cast(imageSize / packetSize) << '\n'; + // std::cout << "c: " << (imageSize + packetSize-1) / packetSize << '\n'; - slsDetectorDefs::ROI roilimits[5]; - roilimits[0].xmin = 5; - roilimits[0].xmax = 12; - roilimits[0].ymin = 5; - roilimits[0].ymax = 15; + // slsDetectorDefs::ROI roilimits[5]; + // roilimits[0].xmin = 5; + // roilimits[0].xmax = 12; + // roilimits[0].ymin = 5; + // roilimits[0].ymax = 15; - roilimits[1].xmin = 0; - roilimits[1].xmax = 3; - roilimits[1].ymin = 20; - roilimits[1].ymax = 25; + // roilimits[1].xmin = 0; + // roilimits[1].xmax = 3; + // roilimits[1].ymin = 20; + // roilimits[1].ymax = 25; - roilimits[2].xmin = 500; - roilimits[2].xmax = 600; - roilimits[2].ymin = 100; - roilimits[2].ymax = 200; + // roilimits[2].xmin = 500; + // roilimits[2].xmax = 600; + // roilimits[2].ymin = 100; + // roilimits[2].ymax = 200; - roilimits[3].xmin = 300; - roilimits[3].xmax = 500; - roilimits[3].ymin = 800; - roilimits[3].ymax = 900; + // roilimits[3].xmin = 300; + // roilimits[3].xmax = 500; + // roilimits[3].ymin = 800; + // roilimits[3].ymax = 900; - roilimits[4].xmin = 1000; - roilimits[4].xmax = 2000; - roilimits[4].ymin = 300; - roilimits[4].ymax = 500; + // roilimits[4].xmin = 1000; + // roilimits[4].xmax = 2000; + // roilimits[4].ymin = 300; + // roilimits[4].ymax = 500; - std::cout << "Before sorting:\n"; - for (auto r : roilimits) { - std::cout << r << '\n'; - } + // std::cout << "Before sorting:\n"; + // for (auto r : roilimits) { + // std::cout << r << '\n'; + // } - std::sort(std::begin(roilimits), std::end(roilimits), - [](ROI a, ROI b) { return a.xmin < b.xmin; }); + // std::sort(std::begin(roilimits), std::end(roilimits), + // [](ROI a, ROI b) { return a.xmin < b.xmin; }); - std::cout << "After sorting: \n"; - for (auto r : roilimits) { - std::cout << r << '\n'; - } + // std::cout << "After sorting: \n"; + // for (auto r : roilimits) { + // std::cout << r << '\n'; + // } } diff --git a/slsDetectorSoftware/include/SharedMemory.h b/slsDetectorSoftware/include/SharedMemory.h index 24c2f5aa5..8a6bb92b5 100644 --- a/slsDetectorSoftware/include/SharedMemory.h +++ b/slsDetectorSoftware/include/SharedMemory.h @@ -279,7 +279,7 @@ class SharedMemory { } //size does not match - long unsigned int sz = (long unsigned int)sb.st_size; + auto sz = static_cast(sb.st_size); if (sz != expectedSize) { std::string msg = "Existing shared memory " + name + " size does not match" + "Expected " + std::to_string(expectedSize) + ", found " + std::to_string(sz); FILE_LOG(logERROR) << msg; diff --git a/slsReceiverSoftware/include/GeneralData.h b/slsReceiverSoftware/include/GeneralData.h index 66ac0617e..a6513bae8 100644 --- a/slsReceiverSoftware/include/GeneralData.h +++ b/slsReceiverSoftware/include/GeneralData.h @@ -10,7 +10,7 @@ #include "sls_detector_defs.h" #include "receiver_defs.h" #include "logger.h" -#include //ceil +#include //ceil #include @@ -706,7 +706,7 @@ public: dataSize = 8192; packetSize = headerSizeinPacket + dataSize; imageSize = nPixelsX * nPixelsY * 2; - packetsPerFrame = ceil((double)imageSize / (double)packetSize); + packetsPerFrame = (imageSize + packetSize - 1) / packetSize; standardheader = false; } // 1g udp (via fifo readout) @@ -715,8 +715,8 @@ public: dataSize = UDP_PACKET_DATA_BYTES; packetSize = headerSizeinPacket + dataSize; imageSize = nPixelsX * nPixelsY * 2; - packetsPerFrame = ceil((double)imageSize / (double)UDP_PACKET_DATA_BYTES); - standardheader = true; + packetsPerFrame = (imageSize + UDP_PACKET_DATA_BYTES - 1) / UDP_PACKET_DATA_BYTES; + standardheader = true; } } }; diff --git a/slsReceiverSoftware/tests/test-GeneralData.cpp b/slsReceiverSoftware/tests/test-GeneralData.cpp index a7bca1ebf..996ad612f 100644 --- a/slsReceiverSoftware/tests/test-GeneralData.cpp +++ b/slsReceiverSoftware/tests/test-GeneralData.cpp @@ -11,14 +11,6 @@ TEST_CASE("Parse jungfrauctb header", "[receiver]") { - // typedef struct { - // unsigned char emptyHeader[6]; - // unsigned char reserved[4]; - // unsigned char packetNumber[1]; - // unsigned char frameNumber[3]; - // unsigned char bunchid[8]; - // } jfrauctb_packet_header_t; - struct packet { unsigned char emptyHeader[6]; unsigned char reserved[4]; @@ -29,26 +21,21 @@ TEST_CASE("Parse jungfrauctb header", "[receiver]") { } __attribute__((packed)); MoenchData data; - // GetHeaderInfo(int index, char *packetData, uint32_t dynamicRange, - // bool oddStartingPacket, uint64_t &frameNumber, - // uint32_t &packetNumber, uint32_t &subFrameNumber, - // uint64_t &bunchId) - packet test_packet; - test_packet.packetNumber[0] = (unsigned char)53; - test_packet.frameNumber[0] = (unsigned char)32; - test_packet.frameNumber[1] = (unsigned char)15; - test_packet.frameNumber[2] = (unsigned char)91; + test_packet.packetNumber[0] = 53u; + test_packet.frameNumber[0] = 32u; + test_packet.frameNumber[1] = 15u; + test_packet.frameNumber[2] = 91u; - test_packet.bunchid[0] = (unsigned char)91; - test_packet.bunchid[1] = (unsigned char)25; - test_packet.bunchid[2] = (unsigned char)15; - test_packet.bunchid[3] = (unsigned char)1; - test_packet.bunchid[4] = (unsigned char)32; - test_packet.bunchid[5] = (unsigned char)251; - test_packet.bunchid[6] = (unsigned char)18; - test_packet.bunchid[7] = (unsigned char)240; + test_packet.bunchid[0] = 91u; + test_packet.bunchid[1] = 25u; + test_packet.bunchid[2] = 15u; + test_packet.bunchid[3] = 1u; + test_packet.bunchid[4] = 32u; + test_packet.bunchid[5] = 251u; + test_packet.bunchid[6] = 18u; + test_packet.bunchid[7] = 240u; int index = 0; char *packetData = reinterpret_cast(&test_packet);