Skip to content

Commit

Permalink
5.6.0.4: fix emscripten build
Browse files Browse the repository at this point in the history
  • Loading branch information
bha-evs committed May 31, 2024
1 parent c119149 commit acb6d5a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
22 changes: 16 additions & 6 deletions lib/include/bofstd/bofstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ cmake -DCMAKE_TOOLCHAIN_FILE=C:/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DBUI
#include <Windows.h>
typedef bool(WINAPI *BofSignalHandler)(uint32_t);
#else
typedef bool (*BofSignalHandler)(uint32_t);
#endif
using BofAssertCallback = std::function<BOFERR(const std::string &_rFile_S, uint32_t _Line_U32, const std::string &_rMasg_S)>;
#if defined(__EMSCRIPTEN__)
#include <emscripten/html5.h> //for emscripten_performance_now in Bof_RdTsc
using BofEmscriptenCallback = std::function<BOFERR(void *)>;
#else
#include <x86intrin.h> //for __rdtsc in Bof_RdTsc
#endif
typedef bool (*BofSignalHandler)(uint32_t);
#endif

using BofAssertCallback = std::function<BOFERR(const std::string &_rFile_S, uint32_t _Line_U32, const std::string &_rMasg_S)>;
#include <bofstd_export.h> //Autogenerated by cmake

#define BOF onbings::bof
Expand Down Expand Up @@ -646,10 +650,16 @@ extern uint32_t GL_BofDbgPrintfStartTime_U32;
// Intrinsyc fct
inline BOFSTD_EXPORT uint64_t Bof_RdTsc()
{
// uint32_t low, high;
// asm volatile ("rdtsc" : "=a" (low), "=d" (high));
// return (((uint64_t)high << 32) | low);
#if defined(__EMSCRIPTEN__)
/*
uint32_t Low_U32, High_U32;
asm volatile ("rdtsc" : "=a" (Low_U32), "=d" (High_U32));
return (((uint64_t)High_U32 << 32) | Low_U32);
*/
return static_cast<uint64_t>(emscripten_performance_now() * 1000000.0); //Calls JavaScript performance.now(), returns a high precision wallclock time value in msecs.
#else
return __rdtsc();
#endif
}
BOFSTD_EXPORT uint32_t Bof_MeasureCpuSpeedInMHz();

Expand Down
12 changes: 6 additions & 6 deletions tests/src/ut_circularbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ TEST(CircularBuffer_Test, Perf)
Index_U32 = 0;
}
}
printf("%zd Push Min %zd Mean %zd Max %zd Lck %zd\n", Profiler.GetNbSample(0), Profiler.GetMin(0), Profiler.GetMean(0), Profiler.GetMax(0), Profiler.GetLockCount(0));
printf("%llu Push Min %llu Mean %llu Max %llu Lck %llu\n", Profiler.GetNbSample(0), Profiler.GetMin(0), Profiler.GetMean(0), Profiler.GetMax(0), Profiler.GetLockCount(0));

Index_U32 = 0;
for (i_U32 = 0; i_U32 < NB_QUEUE_OP; i_U32++)
Expand All @@ -676,7 +676,7 @@ TEST(CircularBuffer_Test, Perf)
}
}
EXPECT_NE(Cb.Pop(&Item_X, 1000, nullptr, nullptr), BOF_ERR_NO_ERROR);
printf("%zu Pop Min %zu Mean %zu Max %zu Lck %zu\n", Profiler.GetNbSample(1), Profiler.GetMin(1), Profiler.GetMean(1), Profiler.GetMax(1), Profiler.GetLockCount(1));
printf("%llu Pop Min %llu Mean %llu Max %llu Lck %llu\n", Profiler.GetNbSample(1), Profiler.GetMin(1), Profiler.GetMean(1), Profiler.GetMax(1), Profiler.GetLockCount(1));
}

TEST(CircularBuffer_Test, PerfThread)
Expand Down Expand Up @@ -765,22 +765,22 @@ TEST(CircularBuffer_Test, PerfThread)
for (i_U32 = 0; i_U32 < NB_QUEUE_PRODUCER_CONSUMER; i_U32++)
{
NbLastMax_U32 = Profiler.GetLastMax(i_U32, pLastMax_X);
printf("NbOp %zu NbMax %d Push[%d] Min %zu Mean %zu Max %zu Lck %zu\n", Profiler.GetNbSample(i_U32), NbLastMax_U32, i_U32, Profiler.GetMin(i_U32), Profiler.GetMean(i_U32), Profiler.GetMax(i_U32), Profiler.GetLockCount(i_U32));
printf("NbOp %llu NbMax %d Push[%d] Min %llu Mean %llu Max %llu Lck %llu\n", Profiler.GetNbSample(i_U32), NbLastMax_U32, i_U32, Profiler.GetMin(i_U32), Profiler.GetMean(i_U32), Profiler.GetMax(i_U32), Profiler.GetLockCount(i_U32));
EXPECT_EQ(Profiler.GetNbSample(i_U32), NB_QUEUE_OP);
for (j_U32 = 0; j_U32 < NbLastMax_U32; j_U32++)
{
printf(" Index %zu Max %zu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max);
printf(" Index %llu Max %llu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max);
}
}
printf("---POP---------------------------\n");
for (i_U32 = NB_QUEUE_PRODUCER_CONSUMER; i_U32 < (NB_QUEUE_PRODUCER_CONSUMER + NB_QUEUE_PRODUCER_CONSUMER); i_U32++)
{
NbLastMax_U32 = Profiler.GetLastMax(i_U32, pLastMax_X);
printf("NbOp %zu NbMax %d Pop[%d] Min %zu Mean %zu Max %zu Lck %zu\n", Profiler.GetNbSample(i_U32), NbLastMax_U32, i_U32, Profiler.GetMin(i_U32), Profiler.GetMean(i_U32), Profiler.GetMax(i_U32), Profiler.GetLockCount(i_U32));
printf("NbOp %llu NbMax %d Pop[%d] Min %llu Mean %llu Max %llu Lck %llu\n", Profiler.GetNbSample(i_U32), NbLastMax_U32, i_U32, Profiler.GetMin(i_U32), Profiler.GetMean(i_U32), Profiler.GetMax(i_U32), Profiler.GetLockCount(i_U32));
EXPECT_EQ(Profiler.GetNbSample(i_U32), NB_QUEUE_OP);
for (j_U32 = 0; j_U32 < NbLastMax_U32; j_U32++)
{
printf(" Index %zu Max %zu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max);
printf(" Index %llu Max %llu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max);
}
}
}
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bofstd",
"version": "5.6.0.3",
"version": "5.6.0.4",
"description": "The onbings general purpose C++ Multiplatform library",
"dependencies": [
{
Expand Down

0 comments on commit acb6d5a

Please sign in to comment.