Skip to content

Commit

Permalink
fix linux
Browse files Browse the repository at this point in the history
  • Loading branch information
bha-evs committed Mar 24, 2024
1 parent d9b06bc commit aec55fe
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 82 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#
# History: 05 June 2004: BHA: Initial version
#compile with emscripten:
#cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=C:/pro/emsdk/upstream/emscripten/cmake/Modules/Platform/emscripten.cmake -DCMAKE_TOOLCHAIN_FILE=C:/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=wasm32-emscripten -DBUILD_SHARED_LIBS=OFF -DCMAKE_GENERATOR=Ninja -DCMAKE_BUILD_TYPE=Debug -SC:/pro/github/bofstd -BC:/bld/bofstd-web -DCMAKE_CROSSCOMPILING_EMULATOR=C:/pro/emsdk/node/16.20.0_64bit/bin/node.exe -G Ninja
#cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=C:/pro/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_TOOLCHAIN_FILE=C:/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=wasm32-emscripten -DBUILD_SHARED_LIBS=OFF -DRHEL:STRING="el9" -DCMAKE_GENERATOR=Ninja -DCMAKE_BUILD_TYPE=Debug -SC:/pro/github/bofstd -BC:/bld/bofstd-web -DCMAKE_CROSSCOMPILING_EMULATOR=C:/pro/emsdk/node/16.20.0_64bit/bin/node.exe -G Ninja
#cmake -DCMAKE_INSTALL_PREFIX=/home/bha/bld/bofstd-web/binaries -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/home/bha/pro/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_TOOLCHAIN_FILE=/home/bha/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=wasm32-emscripten -DBUILD_SHARED_LIBS=OFF -DRHEL:STRING="el9" -DCMAKE_BUILD_TYPE=Debug -S/home/bha/pro/evs-xts -B/home/bha/bld/bofstd-web -DCMAKE_CROSSCOMPILING_EMULATOR=/home/bha/pro/emsdk/node/16.20.0_64bit/bin/node -G Ninja
#run
#cd C:\bld\bofstd-web\binaries\bin
#node AppBofStd.js
Expand All @@ -21,7 +22,8 @@
#compil windows:
#cmake -DCMAKE_TOOLCHAIN_FILE=C:/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DBUILD_SHARED_LIBS=OFF -DVCPKG_OVERLAY_PORTS=C:/pro/vcpkg/ports -DCMAKE_INSTALL_PREFIX=C:/tmp/bofstd -SC:/pro/github/bofstd -BC:/bld/bofstd-win
#compil linux:
#cmake -DCMAKE_TOOLCHAIN_FILE=/home/bha/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux -DBUILD_SHARED_LIBS=OFF -DVCPKG_OVERLAY_PORTS=/home/bha/pro/vcpkg/ports -DCMAKE_INSTALL_PREFIX=/tmp/bofstd -S/home/bha/pro/github/bofstd -B/home/bha/bld/bofstd-lin
#cmake -DCMAKE_TOOLCHAIN_FILE=/home/bha/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux -DBUILD_SHARED_LIBS=OFF -DVCPKG_OVERLAY_PORTS=/home/bha/pro/vcpkg/ports -DCMAKE_INSTALL_PREFIX=/tmp/bofstd -DRHEL:STRING="el9" -S/home/bha/pro/github/bofstd -B/home/bha/bld/bofstd-lin


#cmake --build . --config Release -j 16
#cmake --install . --config Debug
Expand Down
47 changes: 23 additions & 24 deletions lib/src/bofprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,33 @@
// #include <string.h>

#if defined(_WIN32)
#define popen _popen
#define pclose _pclose
/* If WIFEXITED(STATUS), NOT IN WINDOWS:the low-order 8 bits of the status.*/
#define WEXITSTATUS(status) (status)
#define popen _popen
#define pclose _pclose
/* If WIFEXITED(STATUS), NOT IN WINDOWS:the low-order 8 bits of the status.*/
#define WEXITSTATUS(status) (status)

/* If WIFSIGNALED(STATUS), the terminating signal. */
#define WTERMSIG(status) ((status)&0x7f)
/* If WIFSIGNALED(STATUS), the terminating signal. */
#define WTERMSIG(status) ((status)&0x7f)

/* If WIFSTOPPED(STATUS), the signal that stopped the child. */
#define WSTOPSIG(status) WEXITSTATUS(status)
/* If WIFSTOPPED(STATUS), the signal that stopped the child. */
#define WSTOPSIG(status) WEXITSTATUS(status)

/* Nonzero if STATUS indicates normal termination. */
#define WIFEXITED(status) (WTERMSIG(status) == 0)
/* Nonzero if STATUS indicates normal termination. */
#define WIFEXITED(status) (WTERMSIG(status) == 0)
#else
#include <fcntl.h>
#include <poll.h>
#include <spawn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(__EMSCRIPTEN__)
#else
#include <sys/ptrace.h>
#endif
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
extern char **environ;
#include <fcntl.h>
#include <poll.h>
#include <spawn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(__EMSCRIPTEN__)
#else
#include <sys/ptrace.h>
#endif
#include <sys/types.h>
#include <sys/wait.h>
extern char **environ;
#endif

BEGIN_BOF_NAMESPACE()
Expand Down
98 changes: 49 additions & 49 deletions lib/src/bofsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,56 +110,56 @@ extern "C"
#endif

#if defined(_WIN32)
#include <Sddl.h>
//#include <Winsock2.h>
#include <conio.h>
//#include <windows.h>

PSECURITY_DESCRIPTOR CreateWinSecurityDescriptor(SECURITY_ATTRIBUTES *_pSecurityAttribute_X)
{
PSECURITY_DESCRIPTOR pRts_X = nullptr, pSecurityDescriptor_X = nullptr;

// PSID pSid_X=nullptr;
// PACL pAcl_X=nullptr;

if ((_pSecurityAttribute_X) && ((pSecurityDescriptor_X = LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH)) != 0))
{
memset(_pSecurityAttribute_X, 0, sizeof SECURITY_ATTRIBUTES);

if ((InitializeSecurityDescriptor(pSecurityDescriptor_X, SECURITY_DESCRIPTOR_REVISION)))
{
if (SetSecurityDescriptorDacl(pSecurityDescriptor_X, true, nullptr, false))
{
_pSecurityAttribute_X->nLength = sizeof(SECURITY_ATTRIBUTES);
_pSecurityAttribute_X->lpSecurityDescriptor = pSecurityDescriptor_X;
_pSecurityAttribute_X->bInheritHandle = false;
pRts_X = pSecurityDescriptor_X;
}
}
}

if (!pRts_X)
{
if (pSecurityDescriptor_X)
{
LocalFree(pSecurityDescriptor_X);
}
}
return pRts_X;
}

#include <Sddl.h>
//#include <Winsock2.h>
#include <conio.h>
//#include <windows.h>

PSECURITY_DESCRIPTOR CreateWinSecurityDescriptor(SECURITY_ATTRIBUTES *_pSecurityAttribute_X)
{
PSECURITY_DESCRIPTOR pRts_X = nullptr, pSecurityDescriptor_X = nullptr;

// PSID pSid_X=nullptr;
// PACL pAcl_X=nullptr;

if ((_pSecurityAttribute_X) && ((pSecurityDescriptor_X = LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH)) != 0))
{
memset(_pSecurityAttribute_X, 0, sizeof SECURITY_ATTRIBUTES);

if ((InitializeSecurityDescriptor(pSecurityDescriptor_X, SECURITY_DESCRIPTOR_REVISION)))
{
if (SetSecurityDescriptorDacl(pSecurityDescriptor_X, true, nullptr, false))
{
_pSecurityAttribute_X->nLength = sizeof(SECURITY_ATTRIBUTES);
_pSecurityAttribute_X->lpSecurityDescriptor = pSecurityDescriptor_X;
_pSecurityAttribute_X->bInheritHandle = false;
pRts_X = pSecurityDescriptor_X;
}
}
}

if (!pRts_X)
{
if (pSecurityDescriptor_X)
{
LocalFree(pSecurityDescriptor_X);
}
}
return pRts_X;
}
#else
#include <fcntl.h>
//#include <signal.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/shm.h>
#include <sys/statvfs.h>
#include <sys/syscall.h>
#include <sys/sysinfo.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
//#include <signal.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/shm.h>
#include <sys/statvfs.h>
#include <sys/syscall.h>
#include <sys/sysinfo.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#endif

BEGIN_BOF_NAMESPACE()
Expand Down
14 changes: 7 additions & 7 deletions tests/src/ut_circularbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ BOFERR PushValue(uint32_t _Id_U32, uint32_t _NbLoop_U32, BofCircularBuffer<uint6
// NbElem_U32 = _pBofCollection->GetNbElement();
// sprintf(GL_pDbgPush_c, "%03d:Push[%d] %d\n", _Id_U32, i_U32, BOF::Bof_GetMsTickCount());
Rts_E = _pBofCollection->Push(&Val_U64, 2000, nullptr, nullptr);
// printf("%03d:Push[%d]=%lld n=%d Rts %X\n", _Id_U32, i_U32, Val_U64, NbElem_U32, Rts_E);
// printf("%03d:Push[%d]=%zd n=%d Rts %X\n", _Id_U32, i_U32, Val_U64, NbElem_U32, Rts_E);
if (Rts_E)
{
// printf("%03d:Push[%d]->%d\n", _Id_U32, i_U32, BOF::Bof_GetMsTickCount());
Expand All @@ -179,7 +179,7 @@ BOFERR PopValue(uint32_t /*_Id_U32*/, uint32_t _NbLoop_U32, BofCircularBuffer<ui
// NbElem_U32 = _pBofCollection->GetNbElement();
// printf(" %03d:Pop[%d] n=%d\n", _Id_U32, i_U32, NbElem_U32);
Rts_E = _pBofCollection->Pop(&Val_U64, 2000, nullptr, nullptr);
// sprintf(GL_pDbgPop_c," %03d:Pop[%d]=%lld n=%d Rts %X at %d\n", _Id_U32, i_U32, Val_U64, NbElem_U32, Rts_E, BOF::Bof_GetMsTickCount());
// sprintf(GL_pDbgPop_c," %03d:Pop[%d]=%zd n=%d Rts %X at %d\n", _Id_U32, i_U32, Val_U64, NbElem_U32, Rts_E, BOF::Bof_GetMsTickCount());
EXPECT_EQ(Rts_E, 0);
// EXPECT_EQ(ExpectedVal_U64, Val_U64);
}
Expand Down Expand Up @@ -676,7 +676,7 @@ TEST(CircularBuffer_Test, Perf)
}
}
EXPECT_NE(Cb.Pop(&Item_X, 1000, nullptr, nullptr), BOF_ERR_NO_ERROR);
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));
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));
}

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 %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));
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));
EXPECT_EQ(Profiler.GetNbSample(i_U32), NB_QUEUE_OP);
for (j_U32 = 0; j_U32 < NbLastMax_U32; j_U32++)
{
printf(" Index %llu Max %llu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max);
printf(" Index %zu Max %zu\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 %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));
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));
EXPECT_EQ(Profiler.GetNbSample(i_U32), NB_QUEUE_OP);
for (j_U32 = 0; j_U32 < NbLastMax_U32; j_U32++)
{
printf(" Index %llu Max %llu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max);
printf(" Index %zu Max %zu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max);
}
}
}

0 comments on commit aec55fe

Please sign in to comment.