From f00ff009cfc5dfefdf09ca241b9560e74575b3f5 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 15 Jan 2012 14:32:26 +0100 Subject: [PATCH] cec: refactored threading/locking - added windows native instead of pthread-win32, so we can compile native x64 too --- .gitignore | 35 +- include/cecloader.h | 9 + project/LibCecSharp.Net2.sln | 6 + project/LibCecSharp.Net2.vcproj | 162 +- project/LibCecSharp.vcxproj | 72 +- project/create-installer.cmd | 32 +- project/libCEC.nsi | 22 +- project/libcec.sln | 42 +- project/libcec.vcxproj | 134 +- project/libcec.vcxproj.filters | 83 +- project/testclient.vcxproj | 113 +- project/testclient.vcxproj.filters | 71 +- pthreadVC2.dll | Bin 30720 -> 0 bytes src/lib/AdapterCommunication.cpp | 34 +- src/lib/AdapterCommunication.h | 34 +- src/lib/AdapterDetection.cpp | 3 +- src/lib/CECProcessor.cpp | 35 +- src/lib/CECProcessor.h | 54 +- src/lib/LibCEC.cpp | 12 +- src/lib/LibCEC.h | 22 +- src/lib/Makefile.am | 4 +- src/lib/devices/CECAudioSystem.cpp | 17 +- src/lib/devices/CECBusDevice.cpp | 87 +- src/lib/devices/CECBusDevice.h | 7 +- src/lib/devices/CECPlaybackDevice.cpp | 11 +- src/lib/implementations/ANCommandHandler.cpp | 1 - src/lib/implementations/CECCommandHandler.cpp | 21 +- src/lib/implementations/CECCommandHandler.h | 27 +- src/lib/implementations/SLCommandHandler.cpp | 2 - src/lib/{util => platform}/StdString.h | 0 src/lib/{util => platform}/buffer.h | 15 +- src/lib/platform/os-dependent.h | 41 - src/lib/platform/{threads.cpp => os.h} | 85 +- src/lib/platform/posix/os-threads.h | 87 ++ .../platform/posix/{os_posix.h => os-types.h} | 5 +- src/lib/platform/posix/pthreads.cpp | 168 -- src/lib/platform/posix/serialport.cpp | 51 +- src/lib/platform/pthread_win32/pthread.h | 1368 ----------------- src/lib/platform/pthread_win32/pthreadVC2.lib | Bin 29052 -> 0 bytes src/lib/platform/pthread_win32/sched.h | 178 --- src/lib/platform/pthread_win32/semaphore.h | 166 -- src/lib/platform/{ => serialport}/baudrate.h | 9 +- .../platform/{ => serialport}/serialport.h | 37 +- src/lib/platform/threads.h | 98 -- src/lib/platform/threads/mutex.h | 188 +++ src/lib/platform/threads/threads.h | 137 ++ src/lib/platform/timeutils.h | 35 +- src/lib/platform/windows/os-threads.h | 65 + .../{posix/pthreads.h => windows/os-types.h} | 70 +- src/lib/platform/windows/os_windows.cpp | 44 - src/lib/platform/windows/os_windows.h | 77 - src/lib/platform/windows/serialport.cpp | 22 +- src/testclient/Makefile.am | 4 +- src/testclient/main.cpp | 10 +- 54 files changed, 1392 insertions(+), 2720 deletions(-) delete mode 100644 pthreadVC2.dll rename src/lib/{util => platform}/StdString.h (100%) rename src/lib/{util => platform}/buffer.h (89%) delete mode 100644 src/lib/platform/os-dependent.h rename src/lib/platform/{threads.cpp => os.h} (52%) create mode 100644 src/lib/platform/posix/os-threads.h rename src/lib/platform/posix/{os_posix.h => os-types.h} (95%) delete mode 100644 src/lib/platform/posix/pthreads.cpp delete mode 100644 src/lib/platform/pthread_win32/pthread.h delete mode 100644 src/lib/platform/pthread_win32/pthreadVC2.lib delete mode 100644 src/lib/platform/pthread_win32/sched.h delete mode 100644 src/lib/platform/pthread_win32/semaphore.h rename src/lib/platform/{ => serialport}/baudrate.h (95%) rename src/lib/platform/{ => serialport}/serialport.h (75%) delete mode 100644 src/lib/platform/threads.h create mode 100644 src/lib/platform/threads/mutex.h create mode 100644 src/lib/platform/threads/threads.h create mode 100644 src/lib/platform/windows/os-threads.h rename src/lib/platform/{posix/pthreads.h => windows/os-types.h} (58%) delete mode 100644 src/lib/platform/windows/os_windows.cpp delete mode 100644 src/lib/platform/windows/os_windows.h diff --git a/.gitignore b/.gitignore index 9abd286..6ec51bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,13 @@ -.project -.cproject -*.ilk -*.manifest -*.metagen -*.pdb +/.project +/.cproject +/*.dll +/*.exe +/*.exp +/*.ilk +/*.lib +/*.manifest +/*.metagen +/*.pdb aclocal.m4 autom4te.cache @@ -21,24 +25,6 @@ Makefile Makefile.in missing -libcec.dll -libcec.exp -libcec.ilk -libcec.lib -libcec.pdb -cec-client.exe -cec-client.ilk -cec-client.pdb -CecSharpClient.exe -CecSharpClient.pdb -CecSharpClient.vshost.exe -CecSharpClient.vshost.exe.manifest - -LibCecSharp.dll -LibCecSharp.Net2.dll -LibCecSharp.ilk -LibCecSharp.pdb - build include/boost @@ -55,6 +41,7 @@ project/*.opensdf project/Properties project/*.suo project/*.user +project/x64 src/lib/.deps src/lib/.libs diff --git a/include/cecloader.h b/include/cecloader.h index 49efbd7..1e6d716 100644 --- a/include/cecloader.h +++ b/include/cecloader.h @@ -1,3 +1,4 @@ +#pragma once /* * This file is part of the libCEC(R) library. * @@ -45,7 +46,11 @@ HINSTANCE g_libCEC = NULL; CEC::ICECAdapter *LoadLibCec(const char *strName, CEC::cec_logical_address iLogicalAddress = CEC::CECDEVICE_PLAYBACKDEVICE1, uint16_t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS, const char *strLib = NULL) { if (!g_libCEC) +#if defined(_WIN64) + g_libCEC = LoadLibrary(strLib ? strLib : "libcec.x64.dll"); +#else g_libCEC = LoadLibrary(strLib ? strLib : "libcec.dll"); +#endif if (!g_libCEC) return NULL; @@ -67,7 +72,11 @@ CEC::ICECAdapter *LoadLibCec(const char *strName, CEC::cec_logical_address iLogi CEC::ICECAdapter *LibCecInit(const char *strDeviceName, CEC::cec_device_type_list types, const char *strLib = NULL) { if (!g_libCEC) +#if defined(_WIN64) + g_libCEC = LoadLibrary(strLib ? strLib : "libcec.x64.dll"); +#else g_libCEC = LoadLibrary(strLib ? strLib : "libcec.dll"); +#endif if (!g_libCEC) return NULL; diff --git a/project/LibCecSharp.Net2.sln b/project/LibCecSharp.Net2.sln index b50b423..ac97f5f 100644 --- a/project/LibCecSharp.Net2.sln +++ b/project/LibCecSharp.Net2.sln @@ -6,13 +6,19 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {E54D4581-CD59-4687-BB10-694B8192EABA}.Debug|Win32.ActiveCfg = Debug|Win32 {E54D4581-CD59-4687-BB10-694B8192EABA}.Debug|Win32.Build.0 = Debug|Win32 + {E54D4581-CD59-4687-BB10-694B8192EABA}.Debug|x64.ActiveCfg = Debug|x64 + {E54D4581-CD59-4687-BB10-694B8192EABA}.Debug|x64.Build.0 = Debug|x64 {E54D4581-CD59-4687-BB10-694B8192EABA}.Release|Win32.ActiveCfg = Release|Win32 {E54D4581-CD59-4687-BB10-694B8192EABA}.Release|Win32.Build.0 = Release|Win32 + {E54D4581-CD59-4687-BB10-694B8192EABA}.Release|x64.ActiveCfg = Release|x64 + {E54D4581-CD59-4687-BB10-694B8192EABA}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/project/LibCecSharp.Net2.vcproj b/project/LibCecSharp.Net2.vcproj index 3fdfcae..e65be24 100644 --- a/project/LibCecSharp.Net2.vcproj +++ b/project/LibCecSharp.Net2.vcproj @@ -13,6 +13,9 @@ + @@ -91,6 +94,82 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - diff --git a/project/LibCecSharp.vcxproj b/project/LibCecSharp.vcxproj index 0a3e575..8b23d1e 100644 --- a/project/LibCecSharp.vcxproj +++ b/project/LibCecSharp.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7} @@ -23,39 +31,83 @@ true Unicode + + DynamicLibrary + true + true + Unicode + DynamicLibrary false true Unicode + + DynamicLibrary + false + true + MultiByte + + + + + + + - true $(SolutionDir)\..\include;$(IncludePath) $(ProjectName) $(SolutionDir)..\ $(SolutionDir)LibCecSharp.Net2-dev.snk + + true + $(SolutionDir)\..\include;$(IncludePath) + $(ProjectName).x64 + $(SolutionDir)..\ + $(SolutionDir)LibCecSharp.Net2-dev.snk + - false $(SolutionDir)\..\include;$(IncludePath) $(SolutionDir)LibCecSharp.Net2-dev.snk + $(SolutionDir)..\ + + + $(SolutionDir)\..\include;$(IncludePath) + $(SolutionDir)LibCecSharp.Net2-dev.snk + $(ProjectName).x64 + $(SolutionDir)..\ Level3 Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) + _DEBUG;%(PreprocessorDefinitions) + NotUsing + + + true + + + MachineX86 + + + + + Level3 + Disabled + _WIN64;_DEBUG;%(PreprocessorDefinitions) NotUsing @@ -67,7 +119,19 @@ Level3 - WIN32;NDEBUG;%(PreprocessorDefinitions) + NDEBUG;%(PreprocessorDefinitions) + NotUsing + + + true + + + + + + + Level3 + _WIN64;NDEBUG;%(PreprocessorDefinitions) NotUsing diff --git a/project/create-installer.cmd b/project/create-installer.cmd index 78daa7e..369e408 100644 --- a/project/create-installer.cmd +++ b/project/create-installer.cmd @@ -18,13 +18,24 @@ IF "%VS100COMNTOOLS%"=="" ( ) echo Cleaning libCEC -%COMPILER10% libcec.sln /clean Release +%COMPILER10% libcec.sln /clean "Release|Win32" echo Compiling libCEC -%COMPILER10% libcec.sln /build Release /project libcec +%COMPILER10% libcec.sln /build "Release|Win32" /project libcec echo Compiling cec-client -%COMPILER10% libcec.sln /build Release /project testclient +%COMPILER10% libcec.sln /build "Release|Win32" /project testclient echo Compiling LibCecSharp -%COMPILER10% libcec.sln /build Release /project LibCecSharp +%COMPILER10% libcec.sln /build "Release|Win32" /project LibCecSharp + +IF EXIST "%ProgramFiles(x86)%" ( +echo Cleaning libCEC x64 +%COMPILER10% libcec.sln /clean "Release|x64" +echo Compiling libCEC x64 +%COMPILER10% libcec.sln /build "Release|x64" /project libcec +echo Compiling cec-client x64 +%COMPILER10% libcec.sln /build "Release|x64" /project testclient +echo Compiling LibCecSharp x64 +%COMPILER10% libcec.sln /build "Release|x64" /project LibCecSharp +) IF "%VS90COMNTOOLS%"=="" ( set COMPILER9="%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\VCExpress.exe" @@ -34,8 +45,17 @@ IF "%VS90COMNTOOLS%"=="" ( set COMPILER9="%VS90COMNTOOLS%\..\IDE\devenv.exe" ) ELSE GOTO NOSDK9 +echo Cleaning LibCecSharp.Net2 +%COMPILER9% LibCecSharp.Net2.sln /clean "Release|Win32" echo Compiling LibCecSharp.Net2 -%COMPILER9% LibCecSharp.Net2.sln /build Release +%COMPILER9% LibCecSharp.Net2.sln /build "Release|Win32" + +IF EXIST "%ProgramFiles(x86)%" ( +echo Cleaning LibCecSharp.Net2 x64 +%COMPILER9% LibCecSharp.Net2.sln /clean "Release|x64" +echo Compiling LibCecSharp.Net2 x64 +%COMPILER9% LibCecSharp.Net2.sln /build "Release|x64" +) :NOSDK9 echo Copying driver installer @@ -56,4 +76,4 @@ GOTO EXIT :NODDK echo Windows DDK could not be found on your system -:EXIT \ No newline at end of file +:EXIT diff --git a/project/libCEC.nsi b/project/libCEC.nsi index 065544a..2ec8c06 100644 --- a/project/libCEC.nsi +++ b/project/libCEC.nsi @@ -47,12 +47,12 @@ Section "libCEC" SecLibCEC SectionIn 1 #section is in installtype Full SetOutPath "$INSTDIR" File "..\AUTHORS" - File "..\cec-client.exe" + File "..\cec*.exe" File "..\ChangeLog" File "..\COPYING" - File "..\*.dll" - File "..\libcec.lib" - File "Release\LibCecSharp.dll" + File "..\libcec*.dll" + File "..\libcec*.lib" + File "..\LibCecSharp*.dll" File "..\README" ; Copy to XBMC\system @@ -82,6 +82,11 @@ Section "libCEC" SecLibCEC CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk" "$INSTDIR\cec-client.exe" \ "" "$INSTDIR\cec-client.exe" 0 SW_SHOWNORMAL \ "" "Start the CEC Test client." + ${If} ${RunningX64} + CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk" "$INSTDIR\cec-client.x64.exe" \ + "" "$INSTDIR\cec-client.x64.exe" 0 SW_SHOWNORMAL \ + "" "Start the CEC Test client (x64)." + ${EndIf} CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall libCEC.lnk" "$INSTDIR\Uninstall.exe" \ "" "$INSTDIR\Uninstall.exe" 0 SW_SHOWNORMAL \ "" "Uninstall libCEC." @@ -131,12 +136,12 @@ Section "Uninstall" ExecWait '"$INSTDIR\driver\dpinst-x64.exe" /u "$INSTDIR\driver\OEM001.inf"' ${EndIf} Delete "$INSTDIR\AUTHORS" - Delete "$INSTDIR\cec-client.exe" + Delete "$INSTDIR\cec*.exe" Delete "$INSTDIR\ChangeLog" Delete "$INSTDIR\COPYING" Delete "$INSTDIR\*.dll" - Delete "$INSTDIR\libcec.lib" - Delete "$INSTDIR\libcec.pdb" + Delete "$INSTDIR\*.lib" + Delete "$INSTDIR\*.pdb" Delete "$INSTDIR\README" Delete "$INSTDIR\driver\OEM001.inf" Delete "$INSTDIR\driver\dpinst-amd64.exe" @@ -148,6 +153,9 @@ Section "Uninstall" !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk" + ${If} ${RunningX64} + Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk" + ${EndIf} Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall libCEC.lnk" Delete "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url" RMDir "$SMPROGRAMS\$StartMenuFolder" diff --git a/project/libcec.sln b/project/libcec.sln index df298f4..b1969d7 100644 --- a/project/libcec.sln +++ b/project/libcec.sln @@ -15,22 +15,36 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibCecSharp", "LibCecSharp. EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 + Debug|x64 = Debug|x64 + Debug|Win32 = Debug|Win32 + Release|x64 = Release|x64 + Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Debug|x86.ActiveCfg = Debug|Win32 - {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Debug|x86.Build.0 = Debug|Win32 - {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Release|x86.ActiveCfg = Release|Win32 - {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Release|x86.Build.0 = Release|Win32 - {F01222BF-6B3D-43BD-B254-434031CB9887}.Debug|x86.ActiveCfg = Debug|Win32 - {F01222BF-6B3D-43BD-B254-434031CB9887}.Debug|x86.Build.0 = Debug|Win32 - {F01222BF-6B3D-43BD-B254-434031CB9887}.Release|x86.ActiveCfg = Release|Win32 - {F01222BF-6B3D-43BD-B254-434031CB9887}.Release|x86.Build.0 = Release|Win32 - {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Debug|x86.ActiveCfg = Debug|Win32 - {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Debug|x86.Build.0 = Debug|Win32 - {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Release|x86.ActiveCfg = Release|Win32 - {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Release|x86.Build.0 = Release|Win32 + {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Debug|x64.ActiveCfg = Debug|x64 + {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Debug|x64.Build.0 = Debug|x64 + {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Debug|Win32.ActiveCfg = Debug|Win32 + {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Debug|Win32.Build.0 = Debug|Win32 + {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Release|x64.ActiveCfg = Release|x64 + {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Release|x64.Build.0 = Release|x64 + {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Release|Win32.ActiveCfg = Release|Win32 + {C04B0FB1-667D-4F1C-BDAE-A07CDFFAAAA0}.Release|Win32.Build.0 = Release|Win32 + {F01222BF-6B3D-43BD-B254-434031CB9887}.Debug|x64.ActiveCfg = Debug|x64 + {F01222BF-6B3D-43BD-B254-434031CB9887}.Debug|x64.Build.0 = Debug|x64 + {F01222BF-6B3D-43BD-B254-434031CB9887}.Debug|Win32.ActiveCfg = Debug|Win32 + {F01222BF-6B3D-43BD-B254-434031CB9887}.Debug|Win32.Build.0 = Debug|Win32 + {F01222BF-6B3D-43BD-B254-434031CB9887}.Release|x64.ActiveCfg = Release|x64 + {F01222BF-6B3D-43BD-B254-434031CB9887}.Release|x64.Build.0 = Release|x64 + {F01222BF-6B3D-43BD-B254-434031CB9887}.Release|Win32.ActiveCfg = Release|Win32 + {F01222BF-6B3D-43BD-B254-434031CB9887}.Release|Win32.Build.0 = Release|Win32 + {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Debug|x64.ActiveCfg = Debug|x64 + {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Debug|x64.Build.0 = Debug|x64 + {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Debug|Win32.ActiveCfg = Debug|Win32 + {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Debug|Win32.Build.0 = Debug|Win32 + {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Release|x64.ActiveCfg = Release|x64 + {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Release|x64.Build.0 = Release|x64 + {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Release|Win32.ActiveCfg = Release|Win32 + {1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/project/libcec.vcxproj b/project/libcec.vcxproj index d1a8ea0..4d320b3 100644 --- a/project/libcec.vcxproj +++ b/project/libcec.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + @@ -29,20 +37,16 @@ - - - - - - - - + + + + + + + - - - - - + + @@ -61,10 +65,6 @@ - - - - @@ -81,26 +81,49 @@ true MultiByte + + DynamicLibrary + true + MultiByte + DynamicLibrary false MultiByte + + DynamicLibrary + false + MultiByte + + + + + + + $(SolutionDir)..\ + + $(SolutionDir)..\ + - libcec + $(ProjectName) + .dll + + + $(ProjectName).x64 .dll @@ -109,27 +132,59 @@ false true + + *.cdf;*.cache;*.obj;*.ilk;*.resources;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;*.tlog;*.manifest;*.res;*.pch;*.exp;*.idb;*.rep;*.xdc;*.pdb;*_manifest.rc;*.bsc;*.sbr;*.xml;*.dll + $(SolutionDir)..\include;$(IncludePath) + false + true + $(SolutionDir)..\ libcec .dll *.cdf;*.cache;*.obj;*.ilk;*.resources;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;*.tlog;*.manifest;*.res;*.pch;*.exp;*.idb;*.rep;*.xdc;*.pdb;*_manifest.rc;*.bsc;*.sbr;*.xml;*.dll $(SolutionDir)..\include;$(IncludePath) - true + + + $(SolutionDir)..\ + $(ProjectName).x64 + .dll + *.cdf;*.cache;*.obj;*.ilk;*.resources;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;*.tlog;*.manifest;*.res;*.pch;*.exp;*.idb;*.rep;*.xdc;*.pdb;*_manifest.rc;*.bsc;*.sbr;*.xml;*.dll + $(SolutionDir)..\include;$(IncludePath) Level4 Disabled - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE_32BIT_TIME_T;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;__WINDOWS__;DLL_EXPORT;%(PreprocessorDefinitions) - $(SolutionDir)..\src\lib\platform\pthread_win32;$(SolutionDir)..\include;%(AdditionalIncludeDirectories) - 4996;4100;4309;4505 + _USE_32BIT_TIME_T;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions) + $(SolutionDir)..\include;%(AdditionalIncludeDirectories) + + true true - $(SolutionDir)..\libcec.dll - %(AdditionalDependencies);setupapi.lib;$(SolutionDir)..\src\lib\platform\pthread_win32\pthreadVC2.lib + $(SolutionDir)..\$(TargetName)$(TargetExt) + %(AdditionalDependencies);setupapi.lib + libcmtd + + + + + + + Level4 + Disabled + _WIN64;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions) + $(SolutionDir)..\include;%(AdditionalIncludeDirectories) + + + true + + + true + $(SolutionDir)..\$(TargetName)$(TargetExt) + %(AdditionalDependencies);setupapi.lib libcmtd @@ -142,8 +197,9 @@ true true $(SolutionDir)..\src\lib\platform\pthread_win32;$(SolutionDir)..\include;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE_32BIT_TIME_T;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;__WINDOWS__;DLL_EXPORT;%(PreprocessorDefinitions) - 4100;4309 + _USE_32BIT_TIME_T;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions) + + true Speed @@ -152,7 +208,31 @@ true true $(SolutionDir)..\libcec.dll - %(AdditionalDependencies);setupapi.lib;$(SolutionDir)..\src\lib\platform\pthread_win32\pthreadVC2.lib + %(AdditionalDependencies);setupapi.lib + libcmt + + + + + + + Level4 + Full + true + true + $(SolutionDir)..\include;%(AdditionalIncludeDirectories) + _WIN64;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions) + + + true + Speed + + + false + true + true + $(SolutionDir)..\$(TargetName)$(TargetExt) + %(AdditionalDependencies);setupapi.lib libcmt diff --git a/project/libcec.vcxproj.filters b/project/libcec.vcxproj.filters index 6eb8310..1298c5c 100644 --- a/project/libcec.vcxproj.filters +++ b/project/libcec.vcxproj.filters @@ -1,9 +1,6 @@  - - {4171e8da-4c9d-40dd-97a3-755ba5535ca6} - {cc48ddc0-be11-43ec-a805-3a9434f443ed} @@ -16,42 +13,24 @@ {bfc43a58-636d-4c1a-b191-486cb8509c7c} - - {61b13ee2-8a5b-4f05-9796-08138ee6ebc1} + + {fa3d5953-d288-45e9-93f4-8419e6b701c7} + + + {e3945145-efa2-4393-b201-f50e1e775008} + + + {38a27e9e-86ad-46f6-a4fb-e1e524267b74} - - util - - - util - - - platform - - - platform - - - platform - - - platform - platform - - platform - - - platform - exports @@ -76,7 +55,6 @@ devices - implementations @@ -95,17 +73,32 @@ devices - + platform - - platform\pthread_win32 + + platform\windows + + + platform\windows - - platform\pthread_win32 + + platform\serialport - - platform\pthread_win32 + + platform\serialport + + + platform\threads + + + platform\threads + + + platform + + + platform @@ -115,18 +108,6 @@ - - platform - - - platform - - - platform - - - platform - implementations @@ -157,8 +138,8 @@ devices - - platform + + platform\serialport diff --git a/project/testclient.vcxproj b/project/testclient.vcxproj index 3397574..1d1a9bd 100644 --- a/project/testclient.vcxproj +++ b/project/testclient.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {F01222BF-6B3D-43BD-B254-434031CB9887} @@ -21,47 +29,93 @@ true MultiByte + + Application + true + MultiByte + Application false MultiByte + + Application + false + MultiByte + + + + + + + true $(SolutionDir)..\ cec-client - + true + $(SolutionDir)..\ + cec-client.x64 + + $(SolutionDir)..\ cec-client + + $(SolutionDir)..\ + cec-client.x64 + Level4 Disabled - WIN32;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE_32BIT_TIME_T;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;__WINDOWS__;%(PreprocessorDefinitions) + _USE_32BIT_TIME_T;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;%(PreprocessorDefinitions) + true + + + $(SolutiontDir)..\include;%(AdditionalIncludeDirectories) + + + Console + true + %(AdditionalDependencies) + $(SolutionDir)..\$(TargetName)$(TargetExt) + + + + + + + + + Level4 + Disabled + _WIN64;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;%(PreprocessorDefinitions) true - 4100;4309;4505 + + $(SolutiontDir)..\include;%(AdditionalIncludeDirectories) Console true - $(ProjectDir)..\src\lib\platform\pthread_win32\pthreadVC2.lib;%(AdditionalDependencies) - $(SolutionDir)..\cec-client.exe + %(AdditionalDependencies) + $(SolutionDir)..\$(TargetName)$(TargetExt) @@ -74,9 +128,34 @@ Full false true - _WIN32;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE_32BIT_TIME_T;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;__WINDOWS__;%(PreprocessorDefinitions) + _USE_32BIT_TIME_T;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;%(PreprocessorDefinitions) + true + + + $(SolutionDir)..\include;%(AdditionalIncludeDirectories) + + + Console + false + true + true + %(AdditionalDependencies) + + + + + + + Level4 + + + Full + false + true + _WIN64;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;%(PreprocessorDefinitions) true - 4100;4309 + + $(SolutionDir)..\include;%(AdditionalIncludeDirectories) @@ -84,25 +163,25 @@ false true true - $(ProjectDir)..\src\lib\platform\pthread_win32\pthreadVC2.lib;%(AdditionalDependencies) + %(AdditionalDependencies) + $(SolutionDir)..\$(TargetName)$(TargetExt) - - - - - - + + + + + + + - - - + diff --git a/project/testclient.vcxproj.filters b/project/testclient.vcxproj.filters index 4dcb38c..45e1fe0 100644 --- a/project/testclient.vcxproj.filters +++ b/project/testclient.vcxproj.filters @@ -1,62 +1,55 @@  - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + {cc0a01c1-e1e7-4af8-9656-fa9463140613} - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd + + {f08c0a80-22d9-4bdd-90de-b9cf5fa88f99} - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {fb28e188-b2a5-48d3-9010-b56024b19850} + + + {a8b22b54-3252-44fb-a499-e42f9bac0e15} - - Header Files + + exports - - Header Files + + exports - - Header Files + + platform - - Header Files + + platform - - Header Files + + platform\windows - - Header Files + + platform\windows - - Header Files + + platform\windows - - Header Files + + platform\threads + + + platform\threads - - Source Files - - - Source Files - - - Source Files - - - Source Files + + + platform\windows - - Resource Files - + \ No newline at end of file diff --git a/pthreadVC2.dll b/pthreadVC2.dll deleted file mode 100644 index fdea6760d6cecac7d1d00ddde0e50c627551bbf1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 30720 zcmeHwdwf$>w*PLMmH>eUNU=hZh(S>S)23+~(v~8$6y=dNGy!WHN*icPU#2-cMkp|$ z&K!@qHYGY*FO-;?$zPrPhY+FeY}7C=_~i1;rHkH`v>CEdmqJn&#Iz(-{t8q+^7v_q^1t6#@!59$KTET zIhnCk{u;lt$B_Wy&G9EOWaEQMR4;bdnrUKe|3tXF9BiZL@Ipc#Kd9^v*J-Q8qjWcPk0O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{rU|yNMCc8a*Yxd6UJ=s6V{&Du9>|@y{vfs(Rh)tW!9D7b_&TToKoJ~0$ zIoosY%XuK@p`6Eaex37L&YPUeGaT1B@*Qg&O^&c*yW=O0UpW57alr8$elz0FjxQZ! za%bj-a{np!gWQ?U+0L7t+0J}t5x9N3v(mZNxz4%K+2-8r>~h}Ye8BmzbFcHqklUx6 zhnz1tUv<9k{Lnezyx=tDP05>`8HbF`rcI|il!u5pfX;+Wy zuL&VxDM&q2m6*zLGw*{x&_|LybNlmh<`s;ZDx diff --git a/src/lib/AdapterCommunication.cpp b/src/lib/AdapterCommunication.cpp index 9697759..faa15aa 100644 --- a/src/lib/AdapterCommunication.cpp +++ b/src/lib/AdapterCommunication.cpp @@ -33,11 +33,11 @@ #include "AdapterCommunication.h" #include "CECProcessor.h" -#include "platform/os-dependent.h" -#include "platform/serialport.h" +#include "platform/serialport/serialport.h" using namespace std; using namespace CEC; +using namespace PLATFORM; CCECAdapterMessage::CCECAdapterMessage(const cec_command &command) { @@ -248,7 +248,7 @@ CAdapterCommunication::CAdapterCommunication(CCECProcessor *processor) : m_processor(processor), m_iLineTimeout(0) { - m_port = new CSerialPort; + m_port = new PLATFORM::CSerialPort; } CAdapterCommunication::~CAdapterCommunication(void) @@ -267,7 +267,7 @@ bool CAdapterCommunication::Open(const char *strPort, uint16_t iBaudRate /* = 38 uint64_t iNow = GetTimeMs(); uint64_t iTimeout = iNow + iTimeoutMs; - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (!m_port) { @@ -307,7 +307,7 @@ bool CAdapterCommunication::Open(const char *strPort, uint16_t iBaudRate /* = 38 if (CreateThread()) { - m_startCondition.Wait(&m_mutex); + m_startCondition.Wait(m_mutex); m_processor->AddLog(CEC_LOG_DEBUG, "communication thread started"); return true; } @@ -321,7 +321,7 @@ bool CAdapterCommunication::Open(const char *strPort, uint16_t iBaudRate /* = 38 void CAdapterCommunication::Close(void) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); m_startCondition.Broadcast(); m_rcvCondition.Broadcast(); StopThread(); @@ -330,7 +330,7 @@ void CAdapterCommunication::Close(void) void *CAdapterCommunication::Process(void) { { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); m_startCondition.Signal(); } @@ -371,7 +371,7 @@ bool CAdapterCommunication::ReadFromDevice(uint32_t iTimeout) void CAdapterCommunication::AddData(uint8_t *data, uint8_t iLen) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); for (uint8_t iPtr = 0; iPtr < iLen; iPtr++) m_inBuffer.Push(data[iPtr]); @@ -387,8 +387,8 @@ void CAdapterCommunication::WriteNextCommand(void) void CAdapterCommunication::SendMessageToAdapter(CCECAdapterMessage *msg) { - CLockObject lock(&msg->mutex); - if (m_port->Write(msg) != (int32_t) msg->size()) + CLockObject lock(msg->mutex); + if (m_port->Write(msg->packet.data, msg->size()) != (int32_t) msg->size()) { CStdString strError; strError.Format("error writing to serial port: %s", m_port->GetError().c_str()); @@ -412,7 +412,7 @@ bool CAdapterCommunication::Write(CCECAdapterMessage *data) bool CAdapterCommunication::Read(CCECAdapterMessage &msg, uint32_t iTimeout) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); msg.clear(); uint64_t iNow = GetTimeMs(); @@ -426,7 +426,7 @@ bool CAdapterCommunication::Read(CCECAdapterMessage &msg, uint32_t iTimeout) uint8_t buf = 0; if (!m_inBuffer.Pop(buf)) { - if (!m_rcvCondition.Wait(&m_mutex, (uint32_t) (iTarget - iNow))) + if (!m_rcvCondition.Wait(m_mutex, (uint32_t) (iTarget - iNow))) return false; } @@ -483,9 +483,9 @@ bool CAdapterCommunication::StartBootloader(void) output->push_escaped(MSGCODE_START_BOOTLOADER); output->push_back(MSGEND); - CLockObject lock(&output->mutex); + CLockObject lock(output->mutex); if (Write(output)) - output->condition.Wait(&output->mutex); + output->condition.Wait(output->mutex); bReturn = output->state == ADAPTER_MESSAGE_STATE_SENT; delete output; @@ -505,9 +505,9 @@ bool CAdapterCommunication::PingAdapter(void) output->push_escaped(MSGCODE_PING); output->push_back(MSGEND); - CLockObject lock(&output->mutex); + CLockObject lock(output->mutex); if (Write(output)) - output->condition.Wait(&output->mutex); + output->condition.Wait(output->mutex); bReturn = output->state == ADAPTER_MESSAGE_STATE_SENT; delete output; @@ -535,7 +535,7 @@ bool CAdapterCommunication::SetLineTimeout(uint8_t iTimeout) return bReturn; } -bool CAdapterCommunication::IsOpen(void) const +bool CAdapterCommunication::IsOpen(void) { return !IsStopped() && m_port->IsOpen() && IsRunning(); } diff --git a/src/lib/AdapterCommunication.h b/src/lib/AdapterCommunication.h index d076a2f..97cd18d 100644 --- a/src/lib/AdapterCommunication.h +++ b/src/lib/AdapterCommunication.h @@ -32,9 +32,12 @@ */ #include -#include "util/buffer.h" -#include -#include "util/StdString.h" +#include "platform/os.h" + +namespace PLATFORM +{ + class CSerialPort; +} namespace CEC { @@ -85,14 +88,13 @@ namespace CEC cec_datapacket packet; cec_adapter_message_state state; int32_t transmit_timeout; - CMutex mutex; - CCondition condition; + PLATFORM::CMutex mutex; + PLATFORM::CCondition condition; }; - class CSerialPort; class CCECProcessor; - class CAdapterCommunication : private CThread + class CAdapterCommunication : private PLATFORM::CThread { public: CAdapterCommunication(CCECProcessor *processor); @@ -103,7 +105,7 @@ namespace CEC bool Write(CCECAdapterMessage *data); bool PingAdapter(void); void Close(void); - bool IsOpen(void) const; + bool IsOpen(void); std::string GetError(void) const; void *Process(void); @@ -117,13 +119,13 @@ namespace CEC void AddData(uint8_t *data, uint8_t iLen); bool ReadFromDevice(uint32_t iTimeout); - CSerialPort * m_port; - CCECProcessor * m_processor; - CecBuffer m_inBuffer; - CecBuffer m_outBuffer; - CMutex m_mutex; - CCondition m_rcvCondition; - CCondition m_startCondition; - uint8_t m_iLineTimeout; + PLATFORM::CSerialPort * m_port; + CCECProcessor * m_processor; + PLATFORM::SyncedBuffer m_inBuffer; + PLATFORM::SyncedBuffer m_outBuffer; + PLATFORM::CMutex m_mutex; + PLATFORM::CCondition m_rcvCondition; + PLATFORM::CCondition m_startCondition; + uint8_t m_iLineTimeout; }; }; diff --git a/src/lib/AdapterDetection.cpp b/src/lib/AdapterDetection.cpp index f068099..168f1a4 100644 --- a/src/lib/AdapterDetection.cpp +++ b/src/lib/AdapterDetection.cpp @@ -31,8 +31,7 @@ */ #include "AdapterDetection.h" -#include "platform/os-dependent.h" -#include "util/StdString.h" +#include "platform/os.h" #if defined(__APPLE__) #include diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 798c38a..9ed9b23 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -41,11 +41,10 @@ #include "devices/CECTV.h" #include "implementations/CECCommandHandler.h" #include "LibCEC.h" -#include "util/StdString.h" -#include "platform/timeutils.h" using namespace CEC; using namespace std; +using namespace PLATFORM; CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */, uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS*/) : m_bStarted(false), @@ -134,7 +133,7 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, bool bReturn(false); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); /* check for an already opened connection */ if (!m_communication || m_communication->IsOpen()) @@ -151,7 +150,7 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, } /* create the processor thread */ - if (!CreateThread() || !m_startCondition.Wait(&m_mutex) || !m_bStarted) + if (!CreateThread() || !m_startCondition.Wait(m_mutex) || !m_bStarted) { m_controller->AddLog(CEC_LOG_ERROR, "could not create a processor thread"); return bReturn; @@ -240,7 +239,7 @@ bool CCECProcessor::ChangeDeviceType(cec_device_type from, cec_device_type to) strLog.Format("changing device type '%s' into '%s'", ToString(from), ToString(to)); AddLog(CEC_LOG_NOTICE, strLog); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); CCECBusDevice *previousDevice = GetDeviceByType(from); m_logicalAddresses.primary = CECDEVICE_UNKNOWN; @@ -354,7 +353,7 @@ void *CCECProcessor::Process(void) CCECAdapterMessage msg; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); m_bStarted = true; m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started"); m_startCondition.Signal(); @@ -367,7 +366,7 @@ void *CCECProcessor::Process(void) msg.clear(); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_commandBuffer.Pop(command)) { bParseFrame = true; @@ -447,13 +446,13 @@ bool CCECProcessor::SetActiveSource(uint16_t iStreamPath) void CCECProcessor::SetStandardLineTimeout(uint8_t iTimeout) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); m_iStandardLineTimeout = iTimeout; } void CCECProcessor::SetRetryLineTimeout(uint8_t iTimeout) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); m_iRetryLineTimeout = iTimeout; } @@ -497,7 +496,7 @@ bool CCECProcessor::SetDeckInfo(cec_deck_info info, bool bSendUpdate /* = true * bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, bool bForce /* = false */) { bool bReturn(false); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); m_iBaseDevice = iBaseDevice; m_iHDMIPort = iPort; @@ -511,7 +510,7 @@ bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, uint16_t iPhysicalAddress(0); if (iBaseDevice > CECDEVICE_TV) { - lock.Leave(); + lock.Unlock(); iPhysicalAddress = m_busDevices[iBaseDevice]->GetPhysicalAddress(); lock.Lock(); } @@ -534,7 +533,7 @@ bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, m_controller->AddLog(CEC_LOG_ERROR, "failed to set the physical address"); else { - lock.Leave(); + lock.Unlock(); SetPhysicalAddress(iPhysicalAddress); } @@ -575,7 +574,7 @@ void CCECProcessor::LogOutput(const cec_command &data) bool CCECProcessor::SetLogicalAddress(cec_logical_address iLogicalAddress) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_logicalAddresses.primary != iLogicalAddress) { CStdString strLog; @@ -610,7 +609,7 @@ bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress, bool bSendUpda cec_logical_addresses sendUpdatesTo; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (!m_logicalAddresses.IsEmpty()) { bool bWasActiveSource(false); @@ -646,7 +645,7 @@ bool CCECProcessor::SwitchMonitoring(bool bEnable) m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str()); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); m_bMonitor = bEnable; } @@ -827,7 +826,7 @@ bool CCECProcessor::Transmit(const cec_command &data) bool CCECProcessor::Transmit(CCECAdapterMessage *output) { bool bReturn(false); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); { m_iLastTransmission = GetTimeMs(); m_communication->SetLineTimeout(m_iStandardLineTimeout); @@ -838,12 +837,12 @@ bool CCECProcessor::Transmit(CCECAdapterMessage *output) if (output->tries > 0) m_communication->SetLineTimeout(m_iRetryLineTimeout); - CLockObject msgLock(&output->mutex); + CLockObject msgLock(output->mutex); if (!m_communication || !m_communication->Write(output)) return bReturn; else { - output->condition.Wait(&output->mutex); + output->condition.Wait(output->mutex); if (output->state != ADAPTER_MESSAGE_STATE_SENT) { m_controller->AddLog(CEC_LOG_ERROR, "command was not sent"); diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 5064b9c..8e6fae9 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -34,9 +34,7 @@ #include #include #include "AdapterCommunication.h" -#include "platform/os-dependent.h" -#include "util/buffer.h" -#include "util/StdString.h" +#include "platform/os.h" class CSerialPort; @@ -46,7 +44,7 @@ namespace CEC class CAdapterCommunication; class CCECBusDevice; - class CCECProcessor : public CThread + class CCECProcessor : public PLATFORM::CThread { public: CCECProcessor(CLibCEC *controller, const char *strDeviceName, cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1, uint16_t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS); @@ -132,8 +130,8 @@ namespace CEC virtual bool StartBootloader(void); virtual bool PingAdapter(void); - CCECBusDevice *m_busDevices[16]; - CMutex m_transmitMutex; + CCECBusDevice * m_busDevices[16]; + PLATFORM::CMutex m_transmitMutex; private: void ReplaceHandlers(void); @@ -150,30 +148,30 @@ namespace CEC bool ParseMessage(const CCECAdapterMessage &msg); void ParseCommand(cec_command &command); - bool m_bStarted; - bool m_bInitialised; - uint8_t m_iHDMIPort; - cec_logical_address m_iBaseDevice; - cec_command m_currentframe; - cec_logical_addresses m_logicalAddresses; - cec_logical_address m_lastInitiator; - std::string m_strDeviceName; - cec_device_type_list m_types; - CMutex m_mutex; - CCondition m_startCondition; - CAdapterCommunication* m_communication; - CLibCEC* m_controller; - bool m_bMonitor; - CecBuffer m_commandBuffer; - cec_keypress m_previousKey; - CThread * m_busScan; - uint8_t m_iLineTimeout; - uint8_t m_iStandardLineTimeout; - uint8_t m_iRetryLineTimeout; - uint64_t m_iLastTransmission; + bool m_bStarted; + bool m_bInitialised; + uint8_t m_iHDMIPort; + cec_logical_address m_iBaseDevice; + cec_command m_currentframe; + cec_logical_addresses m_logicalAddresses; + cec_logical_address m_lastInitiator; + std::string m_strDeviceName; + cec_device_type_list m_types; + PLATFORM::CMutex m_mutex; + PLATFORM::CCondition m_startCondition; + CAdapterCommunication* m_communication; + CLibCEC* m_controller; + bool m_bMonitor; + PLATFORM::SyncedBuffer m_commandBuffer; + cec_keypress m_previousKey; + PLATFORM::CThread * m_busScan; + uint8_t m_iLineTimeout; + uint8_t m_iStandardLineTimeout; + uint8_t m_iRetryLineTimeout; + uint64_t m_iLastTransmission; }; - class CCECBusScan : public CThread + class CCECBusScan : public PLATFORM::CThread { public: CCECBusScan(CCECProcessor *processor) { m_processor = processor; } diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 52dfa51..29cc3f4 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -36,11 +36,11 @@ #include "AdapterDetection.h" #include "CECProcessor.h" #include "devices/CECBusDevice.h" -#include "util/StdString.h" #include "platform/timeutils.h" using namespace std; using namespace CEC; +using namespace PLATFORM; CLibCEC::CLibCEC(const char *strDeviceName, cec_device_type_list types) : m_iStartTime(GetTimeMs()), @@ -93,7 +93,7 @@ void CLibCEC::Close(void) bool CLibCEC::EnableCallbacks(void *cbParam, ICECCallbacks *callbacks) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_cec) { m_cbParam = cbParam; @@ -343,7 +343,7 @@ cec_osd_name CLibCEC::GetDeviceOSDName(cec_logical_address iAddress) void CLibCEC::AddLog(cec_log_level level, const string &strMessage) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_cec) { cec_log_message message; @@ -360,7 +360,7 @@ void CLibCEC::AddLog(cec_log_level level, const string &strMessage) void CLibCEC::AddKey(cec_keypress &key) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_callbacks) m_callbacks->CBCecKeyPress(m_cbParam, key); else @@ -371,7 +371,7 @@ void CLibCEC::AddKey(cec_keypress &key) void CLibCEC::AddKey(void) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN) { cec_keypress key; @@ -390,7 +390,7 @@ void CLibCEC::AddKey(void) void CLibCEC::AddCommand(const cec_command &command) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_callbacks) { m_callbacks->CBCecCommand(m_cbParam, command); diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index ef1ded2..20b6ccd 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -33,7 +33,7 @@ #include #include -#include "util/buffer.h" +#include "platform/os.h" namespace CEC { @@ -120,15 +120,15 @@ namespace CEC virtual void SetCurrentButton(cec_user_control_code iButtonCode); protected: - int64_t m_iStartTime; - cec_user_control_code m_iCurrentButton; - int64_t m_buttontime; - CCECProcessor *m_cec; - CecBuffer m_logBuffer; - CecBuffer m_keyBuffer; - CecBuffer m_commandBuffer; - ICECCallbacks *m_callbacks; - void *m_cbParam; - CMutex m_mutex; + int64_t m_iStartTime; + cec_user_control_code m_iCurrentButton; + int64_t m_buttontime; + CCECProcessor * m_cec; + PLATFORM::SyncedBuffer m_logBuffer; + PLATFORM::SyncedBuffer m_keyBuffer; + PLATFORM::SyncedBuffer m_commandBuffer; + ICECCallbacks * m_callbacks; + void * m_cbParam; + PLATFORM::CMutex m_mutex; }; }; diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index adcbafa..9ccd4c7 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -23,9 +23,7 @@ libcec_la_SOURCES = AdapterCommunication.cpp \ implementations/CECCommandHandler.cpp \ implementations/SLCommandHandler.cpp \ implementations/VLCommandHandler.cpp \ - platform/posix/serialport.cpp \ - platform/posix/pthreads.cpp \ - platform/threads.cpp + platform/posix/serialport.cpp libcec_la_LDFLAGS = @LIBS@ -version-info @VERSION@ libcec_la_CPPFLAGS = -I@abs_top_srcdir@/include diff --git a/src/lib/devices/CECAudioSystem.cpp b/src/lib/devices/CECAudioSystem.cpp index 87b4505..7bdb091 100644 --- a/src/lib/devices/CECAudioSystem.cpp +++ b/src/lib/devices/CECAudioSystem.cpp @@ -35,6 +35,7 @@ #include "../implementations/CECCommandHandler.h" using namespace CEC; +using namespace PLATFORM; #define ToString(p) m_processor->ToString(p) @@ -48,7 +49,7 @@ CCECAudioSystem::CCECAudioSystem(CCECProcessor *processor, cec_logical_address a bool CCECAudioSystem::SetAudioStatus(uint8_t status) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_audioStatus != status) { CStdString strLog; @@ -64,7 +65,7 @@ bool CCECAudioSystem::SetAudioStatus(uint8_t status) bool CCECAudioSystem::SetSystemAudioModeStatus(const cec_system_audio_status mode) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_systemAudioStatus != mode) { CStdString strLog; @@ -82,7 +83,7 @@ bool CCECAudioSystem::TransmitAudioStatus(cec_logical_address dest) { uint8_t state; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); CStdString strLog; strLog.Format("<< %x -> %x: audio status '%2x'", m_iLogicalAddress, dest, m_audioStatus); AddLog(CEC_LOG_NOTICE, strLog); @@ -96,7 +97,7 @@ bool CCECAudioSystem::TransmitSetSystemAudioMode(cec_logical_address dest) { cec_system_audio_status state; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); CStdString strLog; strLog.Format("<< %x -> %x: set system audio mode '%2x'", m_iLogicalAddress, dest, m_audioStatus); AddLog(CEC_LOG_NOTICE, strLog); @@ -110,7 +111,7 @@ bool CCECAudioSystem::TransmitSystemAudioModeStatus(cec_logical_address dest) { cec_system_audio_status state; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); CStdString strLog; strLog.Format("<< %x -> %x: system audio mode '%s'", m_iLogicalAddress, dest, ToString(m_systemAudioStatus)); AddLog(CEC_LOG_NOTICE, strLog); @@ -125,7 +126,7 @@ uint8_t CCECAudioSystem::VolumeUp(bool bSendRelease /* = true */) if (TransmitKeypress(CEC_USER_CONTROL_CODE_VOLUME_UP) && bSendRelease) TransmitKeyRelease(); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_audioStatus; } @@ -134,7 +135,7 @@ uint8_t CCECAudioSystem::VolumeDown(bool bSendRelease /* = true */) if (TransmitKeypress(CEC_USER_CONTROL_CODE_VOLUME_DOWN) && bSendRelease) TransmitKeyRelease(); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_audioStatus; } @@ -143,6 +144,6 @@ uint8_t CCECAudioSystem::MuteAudio(bool bSendRelease /* = true */) if (TransmitKeypress(CEC_USER_CONTROL_CODE_MUTE) && bSendRelease) TransmitKeyRelease(); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_audioStatus; } diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index d6e447f..a907fc8 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -36,9 +36,9 @@ #include "../implementations/CECCommandHandler.h" #include "../implementations/SLCommandHandler.h" #include "../implementations/VLCommandHandler.h" -#include "../platform/timeutils.h" using namespace CEC; +using namespace PLATFORM; #define ToString(p) m_processor->ToString(p) @@ -56,8 +56,7 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi m_iLastActive(0), m_iLastPowerStateUpdate(0), m_cecVersion(CEC_VERSION_UNKNOWN), - m_deviceStatus(CEC_DEVICE_STATUS_UNKNOWN), - m_handlerMutex(false) + m_deviceStatus(CEC_DEVICE_STATUS_UNKNOWN) { m_handler = new CCECCommandHandler(this); @@ -85,7 +84,7 @@ bool CCECBusDevice::HandleCommand(const cec_command &command) /* update "last active" */ { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); m_iLastActive = GetTimeMs(); if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC) @@ -98,7 +97,7 @@ bool CCECBusDevice::HandleCommand(const cec_command &command) /* change status to present */ if (bHandled) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC) { if (m_deviceStatus != CEC_DEVICE_STATUS_PRESENT) @@ -123,7 +122,7 @@ bool CCECBusDevice::PowerOn(void) if (m_handler->TransmitImageViewOn(GetMyLogicalAddress(), m_iLogicalAddress)) { { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); // m_powerStatus = CEC_POWER_STATUS_UNKNOWN; m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON; } @@ -159,7 +158,7 @@ cec_version CCECBusDevice::GetCecVersion(bool bUpdate /* = false */) { bool bRequestUpdate(false); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && (bUpdate || m_cecVersion == CEC_VERSION_UNKNOWN)); } @@ -167,7 +166,7 @@ cec_version CCECBusDevice::GetCecVersion(bool bUpdate /* = false */) if (bRequestUpdate) RequestCecVersion(); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_cecVersion; } @@ -197,7 +196,7 @@ cec_menu_language &CCECBusDevice::GetMenuLanguage(bool bUpdate /* = false */) { bool bRequestUpdate(false); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && (bUpdate || !strcmp(m_menuLanguage.language, "???"))); } @@ -205,7 +204,7 @@ cec_menu_language &CCECBusDevice::GetMenuLanguage(bool bUpdate /* = false */) if (bRequestUpdate) RequestMenuLanguage(); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_menuLanguage; } @@ -228,7 +227,7 @@ bool CCECBusDevice::RequestMenuLanguage(void) cec_menu_state CCECBusDevice::GetMenuState(void) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_menuState; } @@ -246,7 +245,7 @@ CStdString CCECBusDevice::GetOSDName(bool bUpdate /* = false */) { bool bRequestUpdate(false); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && (bUpdate || m_strDeviceName.Equals(ToString(m_iLogicalAddress))) && m_type != CEC_DEVICE_TYPE_TV); @@ -255,7 +254,7 @@ CStdString CCECBusDevice::GetOSDName(bool bUpdate /* = false */) if (bRequestUpdate) RequestOSDName(); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_strDeviceName; } @@ -280,7 +279,7 @@ uint16_t CCECBusDevice::GetPhysicalAddress(bool bUpdate /* = false */) { bool bRequestUpdate(false); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && (m_iPhysicalAddress == 0xFFFF || bUpdate)); } @@ -288,7 +287,7 @@ uint16_t CCECBusDevice::GetPhysicalAddress(bool bUpdate /* = false */) if (bRequestUpdate && !RequestPhysicalAddress()) AddLog(CEC_LOG_ERROR, "failed to request the physical address (1)"); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_iPhysicalAddress; } @@ -312,7 +311,7 @@ cec_power_status CCECBusDevice::GetPowerStatus(bool bUpdate /* = false */) { bool bRequestUpdate(false); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && (bUpdate || m_powerStatus == CEC_POWER_STATUS_UNKNOWN || m_powerStatus == CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON || @@ -323,7 +322,7 @@ cec_power_status CCECBusDevice::GetPowerStatus(bool bUpdate /* = false */) if (bRequestUpdate) RequestPowerStatus(); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_powerStatus; } @@ -348,7 +347,7 @@ cec_vendor_id CCECBusDevice::GetVendorId(bool bUpdate /* = false */) { bool bRequestUpdate(false); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && (bUpdate || m_vendor == CEC_VENDOR_UNKNOWN)); } @@ -356,7 +355,7 @@ cec_vendor_id CCECBusDevice::GetVendorId(bool bUpdate /* = false */) if (bRequestUpdate) RequestVendorId(); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_vendor; } @@ -437,11 +436,11 @@ bool CCECBusDevice::NeedsPoll(void) cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC && (m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN || bForcePoll)) { - lock.Leave(); + lock.Unlock(); bool bPollAcked(false); if (bForcePoll || NeedsPoll()) bPollAcked = m_processor->PollDevice(m_iLogicalAddress); @@ -468,7 +467,7 @@ void CCECBusDevice::SetCecVersion(const cec_version newVersion) void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (language.device == m_iLogicalAddress) { CStdString strLog; @@ -480,7 +479,7 @@ void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language) void CCECBusDevice::SetOSDName(CStdString strName) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_strDeviceName != strName) { CStdString strLog; @@ -492,7 +491,7 @@ void CCECBusDevice::SetOSDName(CStdString strName) void CCECBusDevice::SetMenuState(const cec_menu_state state) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_menuState != state) { CStdString strLog; @@ -505,7 +504,7 @@ void CCECBusDevice::SetMenuState(const cec_menu_state state) void CCECBusDevice::SetInactiveSource(void) { { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); m_bActiveSource = false; } @@ -515,7 +514,7 @@ void CCECBusDevice::SetInactiveSource(void) void CCECBusDevice::SetActiveSource(void) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (!m_bActiveSource) { CStdString strLog; @@ -555,7 +554,7 @@ bool CCECBusDevice::TryLogicalAddress(void) void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); switch (newStatus) { case CEC_DEVICE_STATUS_UNKNOWN: @@ -587,7 +586,7 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (iNewAddress > 0 && m_iPhysicalAddress != iNewAddress) { CStdString strLog; @@ -600,7 +599,7 @@ void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress) void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (iNewAddress > 0) { CStdString strLog; @@ -611,7 +610,7 @@ void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* if (iNewAddress > 0) { - lock.Leave(); + lock.Unlock(); SetPowerStatus(CEC_POWER_STATUS_ON); } } @@ -619,7 +618,7 @@ void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_powerStatus != powerStatus) { m_iLastPowerStateUpdate = GetTimeMs(); @@ -632,8 +631,8 @@ void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus) bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */) { - CLockObject lock(&m_mutex); - CLockObject handlerLock(&m_handlerMutex); + CLockObject lock(m_mutex); + CLockObject handlerLock(m_handlerMutex); if (m_vendor != m_handler->GetVendorId()) { @@ -683,7 +682,7 @@ bool CCECBusDevice::SetVendorId(uint64_t iVendorId) bool bVendorChanged(false); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); bVendorChanged = (m_vendor != (cec_vendor_id)iVendorId); m_vendor = (cec_vendor_id)iVendorId; } @@ -703,7 +702,7 @@ bool CCECBusDevice::TransmitActiveSource(void) bool bSendActiveSource(false); { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_powerStatus != CEC_POWER_STATUS_ON) { CStdString strLog; @@ -739,7 +738,7 @@ bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest) { cec_version version; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); CStdString strLog; strLog.Format("<< %s (%X) -> %s (%X): cec version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_cecVersion)); AddLog(CEC_LOG_NOTICE, strLog); @@ -753,7 +752,7 @@ bool CCECBusDevice::TransmitInactiveSource(void) { uint16_t iPhysicalAddress; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); CStdString strLog; strLog.Format("<< %s (%X) -> broadcast (F): inactive source", GetLogicalAddressName(), m_iLogicalAddress); AddLog(CEC_LOG_NOTICE, strLog); @@ -767,7 +766,7 @@ bool CCECBusDevice::TransmitMenuState(cec_logical_address dest) { cec_menu_state menuState; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); CStdString strLog; strLog.Format("<< %s (%X) -> %s (%X): menu state '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_menuState)); AddLog(CEC_LOG_NOTICE, strLog); @@ -781,7 +780,7 @@ bool CCECBusDevice::TransmitOSDName(cec_logical_address dest) { CStdString strDeviceName; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); CStdString strLog; strLog.Format("<< %s (%X) -> %s (%X): OSD name '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, m_strDeviceName.c_str()); AddLog(CEC_LOG_NOTICE, strLog.c_str()); @@ -809,7 +808,7 @@ bool CCECBusDevice::TransmitPhysicalAddress(void) uint16_t iPhysicalAddress; cec_device_type type; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_iPhysicalAddress == 0xffff) return false; @@ -840,7 +839,7 @@ bool CCECBusDevice::TransmitPoll(cec_logical_address dest) bReturn = m_handler->TransmitPoll(m_iLogicalAddress, dest); AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent"); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (bReturn) { m_iLastActive = GetTimeMs(); @@ -856,7 +855,7 @@ bool CCECBusDevice::TransmitPowerState(cec_logical_address dest) { cec_power_status state; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); CStdString strLog; strLog.Format("<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_powerStatus)); AddLog(CEC_LOG_NOTICE, strLog.c_str()); @@ -870,7 +869,7 @@ bool CCECBusDevice::TransmitVendorID(cec_logical_address dest, bool bSendAbort / { uint64_t iVendorId; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); iVendorId = (uint64_t)m_vendor; } @@ -918,7 +917,7 @@ void CCECBusDevice::SetUnsupportedFeature(cec_opcode opcode) bool CCECBusDevice::ActivateSource(void) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_handler->ActivateSource(); } diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index 5d835c7..412504e 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -33,8 +33,7 @@ #include #include -#include "../platform/os-dependent.h" -#include "../util/StdString.h" +#include "../platform/os.h" namespace CEC { @@ -136,7 +135,7 @@ namespace CEC cec_version m_cecVersion; cec_bus_device_status m_deviceStatus; std::set m_unsupportedFeatures; - CMutex m_mutex; - CMutex m_handlerMutex; + PLATFORM::CMutex m_mutex; + PLATFORM::CMutex m_handlerMutex; }; }; diff --git a/src/lib/devices/CECPlaybackDevice.cpp b/src/lib/devices/CECPlaybackDevice.cpp index 4969de5..f9689cb 100644 --- a/src/lib/devices/CECPlaybackDevice.cpp +++ b/src/lib/devices/CECPlaybackDevice.cpp @@ -35,6 +35,7 @@ #include "../CECProcessor.h" using namespace CEC; +using namespace PLATFORM; #define ToString(p) m_processor->ToString(p) @@ -48,13 +49,13 @@ CCECPlaybackDevice::CCECPlaybackDevice(CCECProcessor *processor, cec_logical_add cec_deck_info CCECPlaybackDevice::GetDeckStatus(void) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_deckStatus; } void CCECPlaybackDevice::SetDeckStatus(cec_deck_info deckStatus) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_deckStatus != deckStatus && m_deckStatus != CEC_DECK_INFO_OTHER_STATUS_LG) { CStdString strLog; @@ -67,13 +68,13 @@ void CCECPlaybackDevice::SetDeckStatus(cec_deck_info deckStatus) cec_deck_control_mode CCECPlaybackDevice::GetDeckControlMode(void) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_deckControlMode; } void CCECPlaybackDevice::SetDeckControlMode(cec_deck_control_mode mode) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_deckControlMode != mode) { CStdString strLog; @@ -88,7 +89,7 @@ bool CCECPlaybackDevice::TransmitDeckStatus(cec_logical_address dest) { cec_deck_info state; { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); CStdString strLog; strLog.Format("<< %s (%X) -> %s (%X): deck status '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_deckStatus)); AddLog(CEC_LOG_NOTICE, strLog); diff --git a/src/lib/implementations/ANCommandHandler.cpp b/src/lib/implementations/ANCommandHandler.cpp index 248a959..bf9dea5 100644 --- a/src/lib/implementations/ANCommandHandler.cpp +++ b/src/lib/implementations/ANCommandHandler.cpp @@ -33,7 +33,6 @@ #include "ANCommandHandler.h" #include "../devices/CECBusDevice.h" #include "../CECProcessor.h" -#include "../util/StdString.h" using namespace CEC; diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 5df30f4..d407e40 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -38,6 +38,7 @@ using namespace CEC; using namespace std; +using namespace PLATFORM; CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice) : m_busDevice(busDevice), @@ -55,8 +56,8 @@ CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice) : CCECCommandHandler::~CCECCommandHandler(void) { - CLockObject lock(&m_processor->m_transmitMutex); - CLockObject receiveLock(&m_receiveMutex); + CLockObject lock(m_processor->m_transmitMutex); + CLockObject receiveLock(m_receiveMutex); m_condition.Broadcast(); } @@ -194,7 +195,7 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) if (bHandled) { - CLockObject lock(&m_receiveMutex); + CLockObject lock(m_receiveMutex); if (m_expectedResponse == CEC_OPCODE_NONE || m_expectedResponse == command.opcode) m_condition.Signal(); @@ -426,7 +427,7 @@ bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command) m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str()); vector devices; - for (int iDevicePtr = GetMyDevices(devices) - 1; iDevicePtr >=0; iDevicePtr--) + for (size_t iDevicePtr = 0; iDevicePtr < GetMyDevices(devices); iDevicePtr++) devices[iDevicePtr]->TransmitActiveSource(); return true; @@ -964,8 +965,8 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* { uint8_t iTries(0), iMaxTries(command.opcode == CEC_OPCODE_NONE ? 1 : m_iTransmitRetries + 1); - CLockObject writeLock(&m_processor->m_transmitMutex); - CLockObject receiveLock(&m_receiveMutex); + CLockObject writeLock(m_processor->m_transmitMutex); + CLockObject receiveLock(m_receiveMutex); ++m_iUseCounter; while (!bReturn && ++iTries <= iMaxTries) { @@ -974,7 +975,7 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* { m_processor->AddLog(CEC_LOG_DEBUG, "command transmitted"); bReturn = bExpectResponse ? - m_condition.Wait(&m_receiveMutex, m_iTransmitWait) : + m_condition.Wait(m_receiveMutex, m_iTransmitWait) : true; } } @@ -1005,18 +1006,18 @@ bool CCECCommandHandler::ActivateSource(void) void CCECCommandHandler::MarkBusy(void) { - CLockObject receiveLock(&m_receiveMutex); + CLockObject receiveLock(m_receiveMutex); ++m_iUseCounter; } bool CCECCommandHandler::MarkReady(void) { - CLockObject receiveLock(&m_receiveMutex); + CLockObject receiveLock(m_receiveMutex); return m_iUseCounter > 0 ? (--m_iUseCounter == 0) : true; } bool CCECCommandHandler::InUse(void) { - CLockObject receiveLock(&m_receiveMutex); + CLockObject receiveLock(m_receiveMutex); return m_iUseCounter > 0; } diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index f3d3d0c..f1e0924 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -33,8 +33,7 @@ #include #include -#include "../util/StdString.h" -#include "../platform/os-dependent.h" +#include "../platform/os.h" namespace CEC { @@ -135,17 +134,17 @@ namespace CEC virtual bool Transmit(cec_command &command, bool bExpectResponse = true, cec_opcode expectedResponse = CEC_OPCODE_NONE); - CCECBusDevice *m_busDevice; - CCECProcessor *m_processor; - int32_t m_iTransmitTimeout; - int32_t m_iTransmitWait; - int8_t m_iTransmitRetries; - bool m_bHandlerInited; - uint8_t m_iUseCounter; - cec_opcode m_expectedResponse; - bool m_bOPTSendDeckStatusUpdateOnActiveSource; - cec_vendor_id m_vendorId; - CMutex m_receiveMutex; - CCondition m_condition; + CCECBusDevice * m_busDevice; + CCECProcessor * m_processor; + int32_t m_iTransmitTimeout; + int32_t m_iTransmitWait; + int8_t m_iTransmitRetries; + bool m_bHandlerInited; + uint8_t m_iUseCounter; + cec_opcode m_expectedResponse; + bool m_bOPTSendDeckStatusUpdateOnActiveSource; + cec_vendor_id m_vendorId; + PLATFORM::CMutex m_receiveMutex; + PLATFORM::CCondition m_condition; }; }; diff --git a/src/lib/implementations/SLCommandHandler.cpp b/src/lib/implementations/SLCommandHandler.cpp index 7a357d3..67018a8 100644 --- a/src/lib/implementations/SLCommandHandler.cpp +++ b/src/lib/implementations/SLCommandHandler.cpp @@ -34,8 +34,6 @@ #include "../devices/CECBusDevice.h" #include "../devices/CECPlaybackDevice.h" #include "../CECProcessor.h" -#include "../platform/timeutils.h" -#include "../platform/threads.h" using namespace CEC; diff --git a/src/lib/util/StdString.h b/src/lib/platform/StdString.h similarity index 100% rename from src/lib/util/StdString.h rename to src/lib/platform/StdString.h diff --git a/src/lib/util/buffer.h b/src/lib/platform/buffer.h similarity index 89% rename from src/lib/util/buffer.h rename to src/lib/platform/buffer.h index e0afddf..227b756 100644 --- a/src/lib/util/buffer.h +++ b/src/lib/platform/buffer.h @@ -31,22 +31,23 @@ * http://www.pulse-eight.net/ */ -#include "../platform/os-dependent.h" +#include "os.h" #include -namespace CEC +namespace PLATFORM { template - struct CecBuffer + struct SyncedBuffer { public: - CecBuffer(size_t iMaxSize = 100) + SyncedBuffer(size_t iMaxSize = 100) { m_maxSize = iMaxSize; } - virtual ~CecBuffer(void) + virtual ~SyncedBuffer(void) { + CLockObject lock(m_mutex, true); Clear(); } @@ -60,7 +61,7 @@ namespace CEC bool Push(_BType entry) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_buffer.size() == m_maxSize) return false; @@ -71,7 +72,7 @@ namespace CEC bool Pop(_BType &entry) { bool bReturn(false); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (!m_buffer.empty()) { entry = m_buffer.front(); diff --git a/src/lib/platform/os-dependent.h b/src/lib/platform/os-dependent.h deleted file mode 100644 index 90e42ab..0000000 --- a/src/lib/platform/os-dependent.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2011 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#if defined(_WIN32) || defined(_WIN64) -#ifndef __WINDOWS__ -#define __WINDOWS__ -#endif -#endif - -#if defined(__WINDOWS__) -#include "windows/os_windows.h" -#else -#include "posix/os_posix.h" -#endif - -#if !defined(TRUE) -#define TRUE 1 -#endif - -#if !defined(FALSE) -#define FALSE 0 -#endif - -#include "timeutils.h" diff --git a/src/lib/platform/threads.cpp b/src/lib/platform/os.h similarity index 52% rename from src/lib/platform/threads.cpp rename to src/lib/platform/os.h index c9f6c16..fbe0903 100644 --- a/src/lib/platform/threads.cpp +++ b/src/lib/platform/os.h @@ -1,3 +1,4 @@ +#pragma once /* * This file is part of the libCEC(R) library. * @@ -30,74 +31,18 @@ * http://www.pulse-eight.net/ */ -#include "threads.h" -#include "timeutils.h" -#include "os-dependent.h" - -using namespace CEC; - -CLockObject::CLockObject(IMutex *mutex, bool bTryLock /* = false */) : - m_mutex(mutex) -{ - if (m_mutex) - m_bLocked = bTryLock ? m_mutex->TryLock() : m_mutex->Lock(); -} - -CLockObject::~CLockObject(void) -{ - Leave(); - m_mutex = NULL; -} - -void CLockObject::Leave(void) -{ - if (m_mutex && m_bLocked) - { - m_bLocked = false; - m_mutex->Unlock(); - } -} - -void CLockObject::Lock(void) -{ - if (m_mutex) - m_bLocked = m_mutex->Lock(); -} +#if defined(_WIN32) || defined(_WIN64) +#ifndef __WINDOWS__ +#define __WINDOWS__ +#endif +#include "windows/os-types.h" +#include "windows/os-threads.h" +#else +#include "posix/os-types.h" +#include "posix/os-threads.h" +#endif -void ICondition::Sleep(uint32_t iTimeout) -{ - CCondition w; - CMutex m; - CLockObject lock(&m); - w.Wait(&m, iTimeout); -} - -IThread::IThread(void) : - m_bStop(false), - m_bRunning(false) -{ - m_threadCondition = new CCondition(); - m_threadMutex = new CMutex(); -} - -IThread::~IThread(void) -{ - StopThread(); - delete m_threadCondition; - delete m_threadMutex; -} - -bool IThread::StopThread(bool bWaitForExit /* = true */) -{ - m_bStop = true; - m_threadCondition->Broadcast(); - bWaitForExit = true; - - return false; -} - -bool IThread::Sleep(uint32_t iTimeout) -{ - CLockObject lock(m_threadMutex); - return m_bStop ? false : m_threadCondition->Wait(m_threadMutex, iTimeout); -} +#include "timeutils.h" +#include "threads/threads.h" +#include "buffer.h" +#include "StdString.h" diff --git a/src/lib/platform/posix/os-threads.h b/src/lib/platform/posix/os-threads.h new file mode 100644 index 0000000..9f7a688 --- /dev/null +++ b/src/lib/platform/posix/os-threads.h @@ -0,0 +1,87 @@ +#pragma once +/* + * This file is part of the libCEC(R) library. + * + * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is an original work, containing original code. + * + * libCEC(R) is a trademark of Pulse-Eight Limited. + * + * This program is dual-licensed; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + * Alternatively, you can license this library under a commercial license, + * please contact Pulse-Eight Licensing for more information. + * + * For more information contact: + * Pulse-Eight Licensing + * http://www.pulse-eight.com/ + * http://www.pulse-eight.net/ + */ + +namespace PLATFORM +{ + inline pthread_mutexattr_t *GetRecursiveMutexAttribute(void) + { + static pthread_mutexattr_t g_mutexAttr; + static bool bAttributeInitialised = false; + if (!bAttributeInitialised) + { + pthread_mutexattr_init(&g_mutexAttr); + pthread_mutexattr_settype(&g_mutexAttr, PTHREAD_MUTEX_RECURSIVE); + bAttributeInitialised = true; + } + return &g_mutexAttr; + } + + inline struct timespec GetAbsTime(uint64_t iIncreaseBy = 0) + { + struct timespec abstime; + struct timeval now; + gettimeofday(&now, NULL); + iIncreaseBy += now.tv_usec / 1000; + abstime.tv_sec = now.tv_sec + (time_t)(iIncreaseBy / 1000); + abstime.tv_nsec = (int32_t)((iIncreaseBy % (uint32_t)1000) * (uint32_t)1000000); + return abstime; + } + + typedef pthread_t thread_t; + + #define ThreadsCreate(thread, func, arg) (pthread_create(&thread, NULL, (void *(*) (void *))func, (void *)arg) == 0) + #define ThreadsWait(thread, retval) (pthread_join(thread, retval) == 0) + + typedef pthread_mutex_t mutex_t; + #define MutexCreate(mutex) pthread_mutex_init(&mutex, GetRecursiveMutexAttribute()); + #define MutexDelete(mutex) pthread_mutex_destroy(&mutex); + #define MutexLock(mutex) (pthread_mutex_lock(&mutex) == 0) + #define MutexTryLock(mutex) (pthread_mutex_trylock(&mutex) == 0) + #define MutexUnlock(mutex) pthread_mutex_unlock(&mutex) + + typedef pthread_cond_t condition_t; + #define ConditionCreate(cond) pthread_cond_init(&cond, NULL) + #define ConditionDelete(cond) pthread_cond_destroy(&cond) + #define ConditionSignal(cond) pthread_cond_signal(&cond) + #define ConditionBroadcast(cond) pthread_cond_broadcast(&cond) + inline bool ConditionWait(condition_t &cond, mutex_t &mutex, uint32_t iTimeout) + { + sched_yield(); + if (iTimeout > 0) + { + struct timespec timeout = GetAbsTime(iTimeout); + return (pthread_cond_timedwait(&cond, &mutex, &timeout) == 0); + } + return (pthread_cond_wait(&cond, &mutex) == 0); + } +} diff --git a/src/lib/platform/posix/os_posix.h b/src/lib/platform/posix/os-types.h similarity index 95% rename from src/lib/platform/posix/os_posix.h rename to src/lib/platform/posix/os-types.h index 65d2f27..99bacb3 100644 --- a/src/lib/platform/posix/os_posix.h +++ b/src/lib/platform/posix/os-types.h @@ -23,12 +23,13 @@ #include #include #ifndef __APPLE__ -#include +#include #endif #include #include #include +#include #define LIBTYPE #define DECLSPEC -#include "pthreads.h" + diff --git a/src/lib/platform/posix/pthreads.cpp b/src/lib/platform/posix/pthreads.cpp deleted file mode 100644 index e5b4cf1..0000000 --- a/src/lib/platform/posix/pthreads.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * This file is part of the libCEC(R) library. - * - * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. - * libCEC(R) is an original work, containing original code. - * - * libCEC(R) is a trademark of Pulse-Eight Limited. - * - * This program is dual-licensed; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * - * Alternatively, you can license this library under a commercial license, - * please contact Pulse-Eight Licensing for more information. - * - * For more information contact: - * Pulse-Eight Licensing - * http://www.pulse-eight.com/ - * http://www.pulse-eight.net/ - */ - -#include "../threads.h" -#include "../timeutils.h" - -using namespace CEC; - -CMutex::CMutex(bool bRecursive /* = true */) : - IMutex(bRecursive) -{ - pthread_mutex_init(&m_mutex, bRecursive ? GetMutexAttribute() : NULL); -} - -CMutex::~CMutex(void) -{ - pthread_mutex_destroy(&m_mutex); -} - -bool CMutex::TryLock(void) -{ - return (pthread_mutex_trylock(&m_mutex) == 0); -} - -bool CMutex::Lock(void) -{ - return (pthread_mutex_lock(&m_mutex) == 0); -} - -void CMutex::Unlock(void) -{ - pthread_mutex_unlock(&m_mutex); -} - -static pthread_mutexattr_t g_mutexAttr; -pthread_mutexattr_t *CMutex::GetMutexAttribute() -{ - static bool bAttributeInitialised = false; - if (!bAttributeInitialised) - { - pthread_mutexattr_init(&g_mutexAttr); - pthread_mutexattr_settype(&g_mutexAttr, PTHREAD_MUTEX_RECURSIVE); - bAttributeInitialised = true; - } - return &g_mutexAttr; -} - -CCondition::CCondition(void) -{ - pthread_cond_init(&m_cond, NULL); -} - -CCondition::~CCondition(void) -{ - pthread_cond_broadcast(&m_cond); - pthread_cond_destroy(&m_cond); -} - -void CCondition::Broadcast(void) -{ - pthread_cond_broadcast(&m_cond); -} - -void CCondition::Signal(void) -{ - pthread_cond_signal(&m_cond); -} - -bool CCondition::Wait(IMutex *mutex, uint32_t iTimeout /* = 0 */) -{ - bool bReturn(false); - sched_yield(); - CMutex *pmutex = static_cast(mutex); - if (pmutex) - { - if (iTimeout > 0) - { - struct timespec abstime; - struct timeval now; - gettimeofday(&now, NULL); - iTimeout += now.tv_usec / 1000; - abstime.tv_sec = now.tv_sec + (time_t)(iTimeout / 1000); - abstime.tv_nsec = (int32_t)((iTimeout % (uint32_t)1000) * (uint32_t)1000000); - bReturn = (pthread_cond_timedwait(&m_cond, &pmutex->m_mutex, &abstime) == 0); - } - else - { - bReturn = (pthread_cond_wait(&m_cond, &pmutex->m_mutex) == 0); - } - } - return bReturn; -} - -bool CThread::CreateThread(bool bWait /* = true */) -{ - bool bReturn(false); - CLockObject lock(m_threadMutex); - m_bStop = false; - if (!m_bRunning && pthread_create(&m_thread, NULL, (void *(*) (void *))&CThread::ThreadHandler, (void *)this) == 0) - { - if (bWait) - m_threadCondition->Wait(m_threadMutex); - bReturn = true; - } - return bReturn; -} - -bool CThread::StopThread(bool bWaitForExit /* = true */) -{ - bool bReturn = IThread::StopThread(bWaitForExit); - - void *retVal; - if (bWaitForExit && m_bRunning) - bReturn = (pthread_join(m_thread, &retVal) == 0); - - return bReturn; -} - -void *CThread::ThreadHandler(CThread *thread) -{ - void *retVal = NULL; - - if (thread) - { - CLockObject lock(thread->m_threadMutex); - thread->m_bRunning = true; - lock.Leave(); - thread->m_threadCondition->Broadcast(); - - retVal = thread->Process(); - - lock.Lock(); - thread->m_bRunning = false; - lock.Leave(); - thread->m_threadCondition->Broadcast(); - } - - return retVal; -} diff --git a/src/lib/platform/posix/serialport.cpp b/src/lib/platform/posix/serialport.cpp index f040857..ec8a5c1 100644 --- a/src/lib/platform/posix/serialport.cpp +++ b/src/lib/platform/posix/serialport.cpp @@ -32,8 +32,8 @@ #include #include -#include "../serialport.h" -#include "../baudrate.h" +#include "../serialport/serialport.h" +#include "../serialport/baudrate.h" #include "../timeutils.h" #if defined(__APPLE__) @@ -48,7 +48,7 @@ #endif #endif using namespace std; -using namespace CEC; +using namespace PLATFORM; CSerialPort::CSerialPort() { @@ -61,32 +61,33 @@ CSerialPort::~CSerialPort() Close(); } -int8_t CSerialPort::Write(CCECAdapterMessage *data) +int64_t CSerialPort::Write(uint8_t* data, uint32_t len) { fd_set port; - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_fd == -1) { m_error = "port closed"; return -1; } - int32_t byteswritten = 0; - - struct timeval timeout, *tv; - if (data->transmit_timeout <= 0) - { + int64_t byteswritten = 0; + struct timeval *tv; +//TODO +// struct timeval timeout, *tv; +// if (data->transmit_timeout <= 0) +// { tv = NULL; - } - else - { - timeout.tv_sec = (long int)data->transmit_timeout / (long int)1000.; - timeout.tv_usec = (long int)data->transmit_timeout % (long int)1000.; - tv = &timeout; - } - - while (byteswritten < (int32_t) data->size()) +// } +// else +// { +// timeout.tv_sec = (long int)data->transmit_timeout / (long int)1000.; +// timeout.tv_usec = (long int)data->transmit_timeout % (long int)1000.; +// tv = &timeout; +// } + + while (byteswritten < len) { FD_ZERO(&port); FD_SET(m_fd, &port); @@ -102,7 +103,7 @@ int8_t CSerialPort::Write(CCECAdapterMessage *data) return -1; } - returnv = write(m_fd, data->packet.data + byteswritten, data->size() - byteswritten); + returnv = write(m_fd, data + byteswritten, len - byteswritten); if (returnv == -1) { m_error = strerror(errno); @@ -116,7 +117,7 @@ int8_t CSerialPort::Write(CCECAdapterMessage *data) { printf("%s write:", m_name.c_str()); for (int i = 0; i < byteswritten; i++) - printf(" %02x", data->at(i)); + printf(" %02x", data[i]); printf("\n"); } @@ -131,7 +132,7 @@ int32_t CSerialPort::Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs /*= 0 int64_t now(0), target(0); int32_t bytesread = 0; - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_fd == -1) { m_error = "port closed"; @@ -202,7 +203,7 @@ bool CSerialPort::Open(string name, uint32_t baudrate, uint8_t databits /* = 8 * { m_name = name; m_error = strerror(errno); - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (databits < 5 || databits > 8) { @@ -290,7 +291,7 @@ bool CSerialPort::Open(string name, uint32_t baudrate, uint8_t databits /* = 8 * void CSerialPort::Close() { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_fd != -1) { close(m_fd); @@ -335,6 +336,6 @@ bool CSerialPort::SetBaudRate(uint32_t baudrate) bool CSerialPort::IsOpen() { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_fd != -1; } diff --git a/src/lib/platform/pthread_win32/pthread.h b/src/lib/platform/pthread_win32/pthread.h deleted file mode 100644 index a3140e1..0000000 --- a/src/lib/platform/pthread_win32/pthread.h +++ /dev/null @@ -1,1368 +0,0 @@ -/* This is an implementation of the threads API of POSIX 1003.1-2001. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * The current list of contributors is contained - * in the file CONTRIBUTORS included with the source - * code distribution. The list can also be seen at the - * following World Wide Web location: - * http://sources.redhat.com/pthreads-win32/contributors.html - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file COPYING.LIB; - * if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#if !defined( PTHREAD_H ) -#define PTHREAD_H - -/* - * See the README file for an explanation of the pthreads-win32 version - * numbering scheme and how the DLL is named etc. - */ -#define PTW32_VERSION 2,8,0,0 -#define PTW32_VERSION_STRING "2, 8, 0, 0\0" - -/* There are three implementations of cancel cleanup. - * Note that pthread.h is included in both application - * compilation units and also internally for the library. - * The code here and within the library aims to work - * for all reasonable combinations of environments. - * - * The three implementations are: - * - * WIN32 SEH - * C - * C++ - * - * Please note that exiting a push/pop block via - * "return", "exit", "break", or "continue" will - * lead to different behaviour amongst applications - * depending upon whether the library was built - * using SEH, C++, or C. For example, a library built - * with SEH will call the cleanup routine, while both - * C++ and C built versions will not. - */ - -/* - * Define defaults for cleanup code. - * Note: Unless the build explicitly defines one of the following, then - * we default to standard C style cleanup. This style uses setjmp/longjmp - * in the cancelation and thread exit implementations and therefore won't - * do stack unwinding if linked to applications that have it (e.g. - * C++ apps). This is currently consistent with most/all commercial Unix - * POSIX threads implementations. - */ -#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C ) -# define __CLEANUP_C -#endif - -#if defined( __CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined(PTW32_RC_MSC)) -#error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler. -#endif - -/* - * Stop here if we are being included by the resource compiler. - */ -#ifndef RC_INVOKED - -#undef PTW32_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_LEVEL -#define PTW32_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_LEVEL -#define PTW32_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_LEVEL_MAX 3 - -#if !defined(PTW32_LEVEL) -#define PTW32_LEVEL PTW32_LEVEL_MAX -/* Include everything */ -#endif - -#ifdef _UWIN -# define HAVE_STRUCT_TIMESPEC 1 -# define HAVE_SIGNAL_H 1 -# undef HAVE_CONFIG_H -# pragma comment(lib, "pthread") -#endif - -/* - * ------------------------------------------------------------- - * - * - * Module: pthread.h - * - * Purpose: - * Provides an implementation of PThreads based upon the - * standard: - * - * POSIX 1003.1-2001 - * and - * The Single Unix Specification version 3 - * - * (these two are equivalent) - * - * in order to enhance code portability between Windows, - * various commercial Unix implementations, and Linux. - * - * See the ANNOUNCE file for a full list of conforming - * routines and defined constants, and a list of missing - * routines and constants not defined in this implementation. - * - * Authors: - * There have been many contributors to this library. - * The initial implementation was contributed by - * John Bossom, and several others have provided major - * sections or revisions of parts of the implementation. - * Often significant effort has been contributed to - * find and fix important bugs and other problems to - * improve the reliability of the library, which sometimes - * is not reflected in the amount of code which changed as - * result. - * As much as possible, the contributors are acknowledged - * in the ChangeLog file in the source code distribution - * where their changes are noted in detail. - * - * Contributors are listed in the CONTRIBUTORS file. - * - * As usual, all bouquets go to the contributors, and all - * brickbats go to the project maintainer. - * - * Maintainer: - * The code base for this project is coordinated and - * eventually pre-tested, packaged, and made available by - * - * Ross Johnson - * - * QA Testers: - * Ultimately, the library is tested in the real world by - * a host of competent and demanding scientists and - * engineers who report bugs and/or provide solutions - * which are then fixed or incorporated into subsequent - * versions of the library. Each time a bug is fixed, a - * test case is written to prove the fix and ensure - * that later changes to the code don't reintroduce the - * same error. The number of test cases is slowly growing - * and therefore so is the code reliability. - * - * Compliance: - * See the file ANNOUNCE for the list of implemented - * and not-implemented routines and defined options. - * Of course, these are all defined is this file as well. - * - * Web site: - * The source code and other information about this library - * are available from - * - * http://sources.redhat.com/pthreads-win32/ - * - * ------------------------------------------------------------- - */ - -/* Try to avoid including windows.h */ -#if defined(__MINGW32__) && defined(__cplusplus) -#define PTW32_INCLUDE_WINDOWS_H -#endif - -#ifdef PTW32_INCLUDE_WINDOWS_H -#include -#endif - -#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__) -/* - * VC++6.0 or early compiler's header has no DWORD_PTR type. - */ -typedef unsigned long DWORD_PTR; -#endif -/* - * ----------------- - * autoconf switches - * ----------------- - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#ifndef NEED_FTIME -#include -#else /* NEED_FTIME */ -/* use native WIN32 time API */ -#endif /* NEED_FTIME */ - -#if HAVE_SIGNAL_H -#include -#endif /* HAVE_SIGNAL_H */ - -#include -#include - -/* - * Boolean values to make us independent of system includes. - */ -enum { - PTW32_FALSE = 0, - PTW32_TRUE = (! PTW32_FALSE) -}; - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#ifndef PTW32_CONFIG_H -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -#ifdef NEED_ERRNO -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Several systems don't define some error numbers. - */ -#ifndef ENOTSUP -# define ENOTSUP 48 /* This is the value in Solaris. */ -#endif - -#ifndef ETIMEDOUT -# define ETIMEDOUT 10060 /* This is the value in winsock.h. */ -#endif - -#ifndef ENOSYS -# define ENOSYS 140 /* Semi-arbitrary value */ -#endif - -#ifndef EDEADLK -# ifdef EDEADLOCK -# define EDEADLK EDEADLOCK -# else -# define EDEADLK 36 /* This is the value in MSVC. */ -# endif -#endif - -#include "sched.h" - -/* - * To avoid including windows.h we define only those things that we - * actually need from it. - */ -#ifndef PTW32_INCLUDE_WINDOWS_H -#ifndef HANDLE -# define PTW32__HANDLE_DEF -# define HANDLE void * -#endif -#ifndef DWORD -# define PTW32__DWORD_DEF -# define DWORD unsigned long -#endif -#endif - -#ifndef HAVE_STRUCT_TIMESPEC -#define HAVE_STRUCT_TIMESPEC 1 -struct timespec { - long tv_sec; - long tv_nsec; -}; -#endif /* HAVE_STRUCT_TIMESPEC */ - -#ifndef SIG_BLOCK -#define SIG_BLOCK 0 -#endif /* SIG_BLOCK */ - -#ifndef SIG_UNBLOCK -#define SIG_UNBLOCK 1 -#endif /* SIG_UNBLOCK */ - -#ifndef SIG_SETMASK -#define SIG_SETMASK 2 -#endif /* SIG_SETMASK */ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* - * ------------------------------------------------------------- - * - * POSIX 1003.1-2001 Options - * ========================= - * - * Options are normally set in , which is not provided - * with pthreads-win32. - * - * For conformance with the Single Unix Specification (version 3), all of the - * options below are defined, and have a value of either -1 (not supported) - * or 200112L (supported). - * - * These options can neither be left undefined nor have a value of 0, because - * either indicates that sysconf(), which is not implemented, may be used at - * runtime to check the status of the option. - * - * _POSIX_THREADS (== 200112L) - * If == 200112L, you can use threads - * - * _POSIX_THREAD_ATTR_STACKSIZE (== 200112L) - * If == 200112L, you can control the size of a thread's - * stack - * pthread_attr_getstacksize - * pthread_attr_setstacksize - * - * _POSIX_THREAD_ATTR_STACKADDR (== -1) - * If == 200112L, you can allocate and control a thread's - * stack. If not supported, the following functions - * will return ENOSYS, indicating they are not - * supported: - * pthread_attr_getstackaddr - * pthread_attr_setstackaddr - * - * _POSIX_THREAD_PRIORITY_SCHEDULING (== -1) - * If == 200112L, you can use realtime scheduling. - * This option indicates that the behaviour of some - * implemented functions conforms to the additional TPS - * requirements in the standard. E.g. rwlocks favour - * writers over readers when threads have equal priority. - * - * _POSIX_THREAD_PRIO_INHERIT (== -1) - * If == 200112L, you can create priority inheritance - * mutexes. - * pthread_mutexattr_getprotocol + - * pthread_mutexattr_setprotocol + - * - * _POSIX_THREAD_PRIO_PROTECT (== -1) - * If == 200112L, you can create priority ceiling mutexes - * Indicates the availability of: - * pthread_mutex_getprioceiling - * pthread_mutex_setprioceiling - * pthread_mutexattr_getprioceiling - * pthread_mutexattr_getprotocol + - * pthread_mutexattr_setprioceiling - * pthread_mutexattr_setprotocol + - * - * _POSIX_THREAD_PROCESS_SHARED (== -1) - * If set, you can create mutexes and condition - * variables that can be shared with another - * process.If set, indicates the availability - * of: - * pthread_mutexattr_getpshared - * pthread_mutexattr_setpshared - * pthread_condattr_getpshared - * pthread_condattr_setpshared - * - * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L) - * If == 200112L you can use the special *_r library - * functions that provide thread-safe behaviour - * - * _POSIX_READER_WRITER_LOCKS (== 200112L) - * If == 200112L, you can use read/write locks - * - * _POSIX_SPIN_LOCKS (== 200112L) - * If == 200112L, you can use spin locks - * - * _POSIX_BARRIERS (== 200112L) - * If == 200112L, you can use barriers - * - * + These functions provide both 'inherit' and/or - * 'protect' protocol, based upon these macro - * settings. - * - * ------------------------------------------------------------- - */ - -/* - * POSIX Options - */ -#undef _POSIX_THREADS -#define _POSIX_THREADS 200112L - -#undef _POSIX_READER_WRITER_LOCKS -#define _POSIX_READER_WRITER_LOCKS 200112L - -#undef _POSIX_SPIN_LOCKS -#define _POSIX_SPIN_LOCKS 200112L - -#undef _POSIX_BARRIERS -#define _POSIX_BARRIERS 200112L - -#undef _POSIX_THREAD_SAFE_FUNCTIONS -#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L - -#undef _POSIX_THREAD_ATTR_STACKSIZE -#define _POSIX_THREAD_ATTR_STACKSIZE 200112L - -/* - * The following options are not supported - */ -#undef _POSIX_THREAD_ATTR_STACKADDR -#define _POSIX_THREAD_ATTR_STACKADDR -1 - -#undef _POSIX_THREAD_PRIO_INHERIT -#define _POSIX_THREAD_PRIO_INHERIT -1 - -#undef _POSIX_THREAD_PRIO_PROTECT -#define _POSIX_THREAD_PRIO_PROTECT -1 - -/* TPS is not fully supported. */ -#undef _POSIX_THREAD_PRIORITY_SCHEDULING -#define _POSIX_THREAD_PRIORITY_SCHEDULING -1 - -#undef _POSIX_THREAD_PROCESS_SHARED -#define _POSIX_THREAD_PROCESS_SHARED -1 - - -/* - * POSIX 1003.1-2001 Limits - * =========================== - * - * These limits are normally set in , which is not provided with - * pthreads-win32. - * - * PTHREAD_DESTRUCTOR_ITERATIONS - * Maximum number of attempts to destroy - * a thread's thread-specific data on - * termination (must be at least 4) - * - * PTHREAD_KEYS_MAX - * Maximum number of thread-specific data keys - * available per process (must be at least 128) - * - * PTHREAD_STACK_MIN - * Minimum supported stack size for a thread - * - * PTHREAD_THREADS_MAX - * Maximum number of threads supported per - * process (must be at least 64). - * - * SEM_NSEMS_MAX - * The maximum number of semaphores a process can have. - * (must be at least 256) - * - * SEM_VALUE_MAX - * The maximum value a semaphore can have. - * (must be at least 32767) - * - */ -#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 - -#undef PTHREAD_DESTRUCTOR_ITERATIONS -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS - -#undef _POSIX_THREAD_KEYS_MAX -#define _POSIX_THREAD_KEYS_MAX 128 - -#undef PTHREAD_KEYS_MAX -#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX - -#undef PTHREAD_STACK_MIN -#define PTHREAD_STACK_MIN 0 - -#undef _POSIX_THREAD_THREADS_MAX -#define _POSIX_THREAD_THREADS_MAX 64 - - /* Arbitrary value */ -#undef PTHREAD_THREADS_MAX -#define PTHREAD_THREADS_MAX 2019 - -#undef _POSIX_SEM_NSEMS_MAX -#define _POSIX_SEM_NSEMS_MAX 256 - - /* Arbitrary value */ -#undef SEM_NSEMS_MAX -#define SEM_NSEMS_MAX 1024 - -#undef _POSIX_SEM_VALUE_MAX -#define _POSIX_SEM_VALUE_MAX 32767 - -#undef SEM_VALUE_MAX -#define SEM_VALUE_MAX INT_MAX - - -#if __GNUC__ && ! defined (__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#endif - -/* - * When building the DLL code, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the DLL, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. - */ -#ifndef PTW32_STATIC_LIB -# ifdef PTW32_BUILD -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * The Open Watcom C/C++ compiler uses a non-standard calling convention - * that passes function args in registers unless __cdecl is explicitly specified - * in exposed function prototypes. - * - * We force all calls to cdecl even though this could slow Watcom code down - * slightly. If you know that the Watcom compiler will be used to build both - * the DLL and application, then you can probably define this as a null string. - * Remember that pthread.h (this file) is used for both the DLL and application builds. - */ -#define PTW32_CDECL __cdecl - -#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX -# include -#else -/* - * Generic handle type - intended to extend uniqueness beyond - * that available with a simple pointer. It should scale for either - * IA-32 or IA-64. - */ -typedef struct { - void * p; /* Pointer to actual object */ - unsigned int x; /* Extra information - reuse count etc */ -} ptw32_handle_t; - -typedef ptw32_handle_t pthread_t; -typedef struct pthread_attr_t_ * pthread_attr_t; -typedef struct pthread_once_t_ pthread_once_t; -typedef struct pthread_key_t_ * pthread_key_t; -typedef struct pthread_mutex_t_ * pthread_mutex_t; -typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t; -typedef struct pthread_cond_t_ * pthread_cond_t; -typedef struct pthread_condattr_t_ * pthread_condattr_t; -#endif -typedef struct pthread_rwlock_t_ * pthread_rwlock_t; -typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t; -typedef struct pthread_spinlock_t_ * pthread_spinlock_t; -typedef struct pthread_barrier_t_ * pthread_barrier_t; -typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t; - -/* - * ==================== - * ==================== - * POSIX Threads - * ==================== - * ==================== - */ - -enum { -/* - * pthread_attr_{get,set}detachstate - */ - PTHREAD_CREATE_JOINABLE = 0, /* Default */ - PTHREAD_CREATE_DETACHED = 1, - -/* - * pthread_attr_{get,set}inheritsched - */ - PTHREAD_INHERIT_SCHED = 0, - PTHREAD_EXPLICIT_SCHED = 1, /* Default */ - -/* - * pthread_{get,set}scope - */ - PTHREAD_SCOPE_PROCESS = 0, - PTHREAD_SCOPE_SYSTEM = 1, /* Default */ - -/* - * pthread_setcancelstate paramters - */ - PTHREAD_CANCEL_ENABLE = 0, /* Default */ - PTHREAD_CANCEL_DISABLE = 1, - -/* - * pthread_setcanceltype parameters - */ - PTHREAD_CANCEL_ASYNCHRONOUS = 0, - PTHREAD_CANCEL_DEFERRED = 1, /* Default */ - -/* - * pthread_mutexattr_{get,set}pshared - * pthread_condattr_{get,set}pshared - */ - PTHREAD_PROCESS_PRIVATE = 0, - PTHREAD_PROCESS_SHARED = 1, - -/* - * pthread_barrier_wait - */ - PTHREAD_BARRIER_SERIAL_THREAD = -1 -}; - -/* - * ==================== - * ==================== - * Cancelation - * ==================== - * ==================== - */ -#define PTHREAD_CANCELED ((void *) -1) - - -/* - * ==================== - * ==================== - * Once Key - * ==================== - * ==================== - */ -#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0} - -struct pthread_once_t_ -{ - int done; /* indicates if user function has been executed */ - void * lock; - int reserved1; - int reserved2; -}; - - -/* - * ==================== - * ==================== - * Object initialisers - * ==================== - * ==================== - */ -#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1) -#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t) -2) -#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t) -3) - -/* - * Compatibility with LinuxThreads - */ -#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER -#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER - -#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) -1) - -#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1) - -#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t) -1) - - -/* - * Mutex types. - */ -enum -{ - /* Compatibility with LinuxThreads */ - PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP, - /* For compatibility with POSIX */ - PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL -}; - - -typedef struct ptw32_cleanup_t ptw32_cleanup_t; - -#if defined(_MSC_VER) -/* Disable MSVC 'anachronism used' warning */ -#pragma warning( disable : 4229 ) -#endif - -typedef void (* PTW32_CDECL ptw32_cleanup_callback_t)(void *); - -#if defined(_MSC_VER) -#pragma warning( default : 4229 ) -#endif - -struct ptw32_cleanup_t -{ - ptw32_cleanup_callback_t routine; - void *arg; - struct ptw32_cleanup_t *prev; -}; - -#ifdef __CLEANUP_SEH - /* - * WIN32 SEH version of cancel cleanup. - */ - -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - ptw32_cleanup_t _cleanup; \ - \ - _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \ - _cleanup.arg = (_arg); \ - __try \ - { \ - -#define pthread_cleanup_pop( _execute ) \ - } \ - __finally \ - { \ - if( _execute || AbnormalTermination()) \ - { \ - (*(_cleanup.routine))( _cleanup.arg ); \ - } \ - } \ - } - -#else /* __CLEANUP_SEH */ - -#ifdef __CLEANUP_C - - /* - * C implementation of PThreads cancel cleanup - */ - -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - ptw32_cleanup_t _cleanup; \ - \ - ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \ - -#define pthread_cleanup_pop( _execute ) \ - (void) ptw32_pop_cleanup( _execute ); \ - } - -#else /* __CLEANUP_C */ - -#ifdef __CLEANUP_CXX - - /* - * C++ version of cancel cleanup. - * - John E. Bossom. - */ - - class PThreadCleanup { - /* - * PThreadCleanup - * - * Purpose - * This class is a C++ helper class that is - * used to implement pthread_cleanup_push/ - * pthread_cleanup_pop. - * The destructor of this class automatically - * pops the pushed cleanup routine regardless - * of how the code exits the scope - * (i.e. such as by an exception) - */ - ptw32_cleanup_callback_t cleanUpRout; - void * obj; - int executeIt; - - public: - PThreadCleanup() : - cleanUpRout( 0 ), - obj( 0 ), - executeIt( 0 ) - /* - * No cleanup performed - */ - { - } - - PThreadCleanup( - ptw32_cleanup_callback_t routine, - void * arg ) : - cleanUpRout( routine ), - obj( arg ), - executeIt( 1 ) - /* - * Registers a cleanup routine for 'arg' - */ - { - } - - ~PThreadCleanup() - { - if ( executeIt && ((void *) cleanUpRout != (void *) 0) ) - { - (void) (*cleanUpRout)( obj ); - } - } - - void execute( int exec ) - { - executeIt = exec; - } - }; - - /* - * C++ implementation of PThreads cancel cleanup; - * This implementation takes advantage of a helper - * class who's destructor automatically calls the - * cleanup routine if we exit our scope weirdly - */ -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \ - (void *) (_arg) ); - -#define pthread_cleanup_pop( _execute ) \ - cleanup.execute( _execute ); \ - } - -#else - -#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. - -#endif /* __CLEANUP_CXX */ - -#endif /* __CLEANUP_C */ - -#endif /* __CLEANUP_SEH */ - -/* - * =============== - * =============== - * Methods - * =============== - * =============== - */ - -/* - * PThread Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr, - int *detachstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr, - void **stackaddr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr, - size_t * stacksize); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr, - int detachstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr, - void *stackaddr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr, - size_t stacksize); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr, - struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, - const struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, - int); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (pthread_attr_t *, - int *); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, - int inheritsched); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(pthread_attr_t * attr, - int * inheritsched); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, - int); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *, - int *); - -/* - * PThread Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid, - const pthread_attr_t * attr, - void *(*start) (void *), - void *arg); - -PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid); - -PTW32_DLLPORT int PTW32_CDECL pthread_equal (pthread_t t1, - pthread_t t2); - -PTW32_DLLPORT void PTW32_CDECL pthread_exit (void *value_ptr); - -PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread, - void **value_ptr); - -PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void); - -PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread); - -PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state, - int *oldstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type, - int *oldtype); - -PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void); - -PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control, - void (*init_routine) (void)); - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute); - -PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup, - void (*routine) (void *), - void *arg); -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Thread Specific Data Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key, - void (*destructor) (void *)); - -PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key); - -PTW32_DLLPORT int PTW32_CDECL pthread_setspecific (pthread_key_t key, - const void *value); - -PTW32_DLLPORT void * PTW32_CDECL pthread_getspecific (pthread_key_t key); - - -/* - * Mutex Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t - * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, - int pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind); - -/* - * Barrier Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t - * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, - int pshared); - -/* - * Mutex Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex, - const pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t *mutex, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex); - -/* - * Spinlock Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock); - -/* - * Barrier Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier, - const pthread_barrierattr_t * attr, - unsigned int count); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier); - -/* - * Condition Variable Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr, - int pshared); - -/* - * Condition Variable Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond, - const pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond, - pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond); - -/* - * Scheduling - */ -PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam (pthread_t thread, - int policy, - const struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread, - int *policy, - struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int); - -PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void); - -/* - * Read-Write Lock Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock, - const pthread_rwlockattr_t *attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_tryrdlock(pthread_rwlock_t *); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, - int pshared); - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 - -/* - * Signal Functions. Should be defined in but MSVC and MinGW32 - * already have signal.h that don't define these. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig); - -/* - * Non-portable functions - */ - -/* - * Compatibility with Linux. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, - int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, - int *kind); - -/* - * Possibly supported by other POSIX threads implementations - */ -PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval); -PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); - -/* - * Useful if an application wants to statically link - * the lib rather than load the DLL at run-time. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_attach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_detach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void); - -/* - * Features that are auto-detected at load/run time. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_win32_test_features_np(int); -enum ptw32_features { - PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */ - PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */ -}; - -/* - * Register a system time change with the library. - * Causes the library to perform various functions - * in response to the change. Should be called whenever - * the application's top level window receives a - * WM_TIMECHANGE message. It can be passed directly to - * pthread_create() as a new thread if desired. - */ -PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *); - -#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - -/* - * Returns the Win32 HANDLE for the POSIX thread. - */ -PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); - - -/* - * Protected Methods - * - * This function blocks until the given WIN32 handle - * is signaled or pthread_cancel had been called. - * This function allows the caller to hook into the - * PThreads cancel mechanism. It is implemented using - * - * WaitForMultipleObjects - * - * on 'waitHandle' and a manually reset WIN32 Event - * used to implement pthread_cancel. The 'timeout' - * argument to TimedWait is simply passed to - * WaitForMultipleObjects. - */ -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle); -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, - DWORD timeout); - -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Thread-Safe C Runtime Library Mappings. - */ -#ifndef _UWIN -# if defined(NEED_ERRNO) - PTW32_DLLPORT int * PTW32_CDECL _errno( void ); -# else -# ifndef errno -# if (defined(_MT) || defined(_DLL)) - __declspec(dllimport) extern int * __cdecl _errno(void); -# define errno (*_errno()) -# endif -# endif -# endif -#endif - -/* - * WIN32 C runtime library had been made thread-safe - * without affecting the user interface. Provide - * mappings from the UNIX thread-safe versions to - * the standard C runtime library calls. - * Only provide function mappings for functions that - * actually exist on WIN32. - */ - -#if !defined(__MINGW32__) -#define strtok_r( _s, _sep, _lasts ) \ - ( *(_lasts) = strtok( (_s), (_sep) ) ) -#endif /* !__MINGW32__ */ - -#define asctime_r( _tm, _buf ) \ - ( strcpy( (_buf), asctime( (_tm) ) ), \ - (_buf) ) - -#define ctime_r( _clock, _buf ) \ - ( strcpy( (_buf), ctime( (_clock) ) ), \ - (_buf) ) - -#define gmtime_r( _clock, _result ) \ - ( *(_result) = *gmtime( (_clock) ), \ - (_result) ) - -#define localtime_r( _clock, _result ) \ - ( *(_result) = *localtime( (_clock) ), \ - (_result) ) - -#define rand_r( _seed ) \ - ( _seed == _seed? rand() : rand() ) - - -/* - * Some compiler environments don't define some things. - */ -#if defined(__BORLANDC__) -# define _ftime ftime -# define _timeb timeb -#endif - -#ifdef __cplusplus - -/* - * Internal exceptions - */ -class ptw32_exception {}; -class ptw32_exception_cancel : public ptw32_exception {}; -class ptw32_exception_exit : public ptw32_exception {}; - -#endif - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - -/* FIXME: This is only required if the library was built using SEH */ -/* - * Get internal SEH tag - */ -PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); - -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -#ifndef PTW32_BUILD - -#ifdef __CLEANUP_SEH - -/* - * Redefine the SEH __except keyword to ensure that applications - * propagate our internal exceptions up to the library's internal handlers. - */ -#define __except( E ) \ - __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \ - ? EXCEPTION_CONTINUE_SEARCH : ( E ) ) - -#endif /* __CLEANUP_SEH */ - -#ifdef __CLEANUP_CXX - -/* - * Redefine the C++ catch keyword to ensure that applications - * propagate our internal exceptions up to the library's internal handlers. - */ -#ifdef _MSC_VER - /* - * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' - * if you want Pthread-Win32 cancelation and pthread_exit to work. - */ - -#ifndef PtW32NoCatchWarn - -#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.") -#pragma message("------------------------------------------------------------------") -#pragma message("When compiling applications with MSVC++ and C++ exception handling:") -#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads") -#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread") -#pragma message(" cancelation and pthread_exit to work. For example:") -#pragma message("") -#pragma message(" #ifdef PtW32CatchAll") -#pragma message(" PtW32CatchAll") -#pragma message(" #else") -#pragma message(" catch(...)") -#pragma message(" #endif") -#pragma message(" {") -#pragma message(" /* Catchall block processing */") -#pragma message(" }") -#pragma message("------------------------------------------------------------------") - -#endif - -#define PtW32CatchAll \ - catch( ptw32_exception & ) { throw; } \ - catch( ... ) - -#else /* _MSC_VER */ - -#define catch( E ) \ - catch( ptw32_exception & ) { throw; } \ - catch( E ) - -#endif /* _MSC_VER */ - -#endif /* __CLEANUP_CXX */ - -#endif /* ! PTW32_BUILD */ - -#ifdef __cplusplus -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#ifdef PTW32__HANDLE_DEF -# undef HANDLE -#endif -#ifdef PTW32__DWORD_DEF -# undef DWORD -#endif - -#undef PTW32_LEVEL -#undef PTW32_LEVEL_MAX - -#endif /* ! RC_INVOKED */ - -#endif /* PTHREAD_H */ diff --git a/src/lib/platform/pthread_win32/pthreadVC2.lib b/src/lib/platform/pthread_win32/pthreadVC2.lib deleted file mode 100644 index bc36770d52c3a3880e1fbd6924387256ca17829e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 29052 zcmd^HJ8WFX)jpyU*;W)sk!2^gWt+BXS+-?~qDab8WQn5Q67`~}_hYr(U5YC$cUMbN z55qv3z?I?VcM+rrQW(Zx2u6^~2>!wdj37k{7k^<0K`Ivs5CkrQAYJm!%$P8vESP_|J(H9sj`4S#3Mc3~eD*TQ}(N*NH zsIbq_wH-u?M*nPR_iEH1wCiI-d%i)tfp$G(=)?n*8*~G5MK@O^^e;RW{mf9UMx>~Y zdMm1ZZK#Q|DJuQV(5YV&DLQ%5(C8$}0lJ2^P*mzMboyJg6KJAr=*&3U2{iF1Lrv5{ zQ5`yp8W#=Cp#2n;uNtZxAW~HR%FzDb5GkrcN70R5Lx=xPr0CE`hAx7y==2IhQ=5ns zT>-wL$qx(Ea#C8IKN=*;n>g?)P__Q0q*(<~sHJ6i_|*DG^{ z%H2|>Iah7e3$vBh?P{qqTPQWk6oU+Za1l@9FcCOX9=c%V$ z!2$&?SLTYP>DjsBoGzn-;|m4**_gdA6zl;3*pI>sB`lS02s|G(ZzgflNmQE5T#WgCo=8KL>lH@wb9~CXlw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c1m(??eL#F6hnU%Nr3l_p7Eg7&RD92hNX zp6K-vV-sY@b&bV2FN?_G>9NyV$965Rh}hlm}V#hTO^s|~3`xv%)Ym(>R z`TCO{0eYkMW#GN$;-wd?i$;vpa6L!V7r2YY3q)`)qK2=#c;evC`sD%-tmBz}C~z{T?lU&IXwJ(EONqJJ$HW|@zGhx5 zW~^2F8K!#qVzFqkHEfHEX5O|41c1C0?fo{^mjiiJY1!f3W(ug+({*#3Ml zkEugI37D5-0qq-^0fz+Kc+JOh!algh+aku4AW5FjcN&EW7 z?h4+Kk+IU*H-R|XL-(6=bvAQA!cO1WTuS7FGIE#d9E)lX3CMCN!t1{{zdkIW%9ZUDHRfAK z@~E)@sB_;6%pPk0c{G6Cz4NzNbUhY8@5cNU+jSoc;CAl}F19WmchU9h%G{eek1}KH z(g}{nUWZ;ZZe)!(DdKh`+KAQml#l9sk+GDu9rth_&56}%AGJ#-R z-^hK_nH*|2=7`vPHfM8)UD@+TcHif6i1tf>MYn8V1yJ$h`5bDO*4e<$SDgf2a50?^ z85Ud5*qncnVTvD0c^ydk;9m~oXP;p#7C+$I>OF`n zdHmd0Bp!U{aZUvPs(|l*rLvUxg&=;g`8%%vw!kfw`V`}u!Eg7Kjn@P`*?t7X=F?(U z0{0^x4$-mC$IhrH9YpsVArG?Sc8X diff --git a/src/lib/platform/pthread_win32/sched.h b/src/lib/platform/pthread_win32/sched.h deleted file mode 100644 index dfb8e93..0000000 --- a/src/lib/platform/pthread_win32/sched.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Module: sched.h - * - * Purpose: - * Provides an implementation of POSIX realtime extensions - * as defined in - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * The current list of contributors is contained - * in the file CONTRIBUTORS included with the source - * code distribution. The list can also be seen at the - * following World Wide Web location: - * http://sources.redhat.com/pthreads-win32/contributors.html - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file COPYING.LIB; - * if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ -#ifndef _SCHED_H -#define _SCHED_H - -#undef PTW32_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_LEVEL -#define PTW32_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_LEVEL -#define PTW32_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_LEVEL_MAX 3 - -#if !defined(PTW32_LEVEL) -#define PTW32_LEVEL PTW32_LEVEL_MAX -/* Include everything */ -#endif - - -#if __GNUC__ && ! defined (__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#endif - -/* - * When building the DLL code, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the DLL, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. - */ -#ifndef PTW32_STATIC_LIB -# ifdef PTW32_BUILD -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#ifndef PTW32_CONFIG_H -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -#ifdef NEED_ERRNO -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -#if defined(__MINGW32__) || defined(_UWIN) -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -/* For pid_t */ -# include -/* Required by Unix 98 */ -# include -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ -#else -typedef int pid_t; -#endif - -/* Thread scheduling policies */ - -enum { - SCHED_OTHER = 0, - SCHED_FIFO, - SCHED_RR, - SCHED_MIN = SCHED_OTHER, - SCHED_MAX = SCHED_RR -}; - -struct sched_param { - int sched_priority; -}; - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -PTW32_DLLPORT int __cdecl sched_yield (void); - -PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy); - -PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy); - -PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy); - -PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid); - -/* - * Note that this macro returns ENOTSUP rather than - * ENOSYS as might be expected. However, returning ENOSYS - * should mean that sched_get_priority_{min,max} are - * not implemented as well as sched_rr_get_interval. - * This is not the case, since we just don't support - * round-robin scheduling. Therefore I have chosen to - * return the same value as sched_setscheduler when - * SCHED_RR is passed to it. - */ -#define sched_rr_get_interval(_pid, _interval) \ - ( errno = ENOTSUP, (int) -1 ) - - -#ifdef __cplusplus -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#undef PTW32_LEVEL -#undef PTW32_LEVEL_MAX - -#endif /* !_SCHED_H */ - diff --git a/src/lib/platform/pthread_win32/semaphore.h b/src/lib/platform/pthread_win32/semaphore.h deleted file mode 100644 index a3330a6..0000000 --- a/src/lib/platform/pthread_win32/semaphore.h +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Module: semaphore.h - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * The current list of contributors is contained - * in the file CONTRIBUTORS included with the source - * code distribution. The list can also be seen at the - * following World Wide Web location: - * http://sources.redhat.com/pthreads-win32/contributors.html - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file COPYING.LIB; - * if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ -#if !defined( SEMAPHORE_H ) -#define SEMAPHORE_H - -#undef PTW32_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_LEVEL -#define PTW32_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_LEVEL -#define PTW32_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_LEVEL_MAX 3 - -#if !defined(PTW32_LEVEL) -#define PTW32_LEVEL PTW32_LEVEL_MAX -/* Include everything */ -#endif - -#if __GNUC__ && ! defined (__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#endif - -/* - * When building the DLL code, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the DLL, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. - */ -#ifndef PTW32_STATIC_LIB -# ifdef PTW32_BUILD -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#ifndef PTW32_CONFIG_H -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -#ifdef NEED_ERRNO -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -#define _POSIX_SEMAPHORES - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#ifndef HAVE_MODE_T -typedef unsigned int mode_t; -#endif - - -typedef struct sem_t_ * sem_t; - -PTW32_DLLPORT int __cdecl sem_init (sem_t * sem, - int pshared, - unsigned int value); - -PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem, - const struct timespec * abstime); - -PTW32_DLLPORT int __cdecl sem_post (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem, - int count); - -PTW32_DLLPORT int __cdecl sem_open (const char * name, - int oflag, - mode_t mode, - unsigned int value); - -PTW32_DLLPORT int __cdecl sem_close (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_unlink (const char * name); - -PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem, - int * sval); - -#ifdef __cplusplus -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#undef PTW32_LEVEL -#undef PTW32_LEVEL_MAX - -#endif /* !SEMAPHORE_H */ diff --git a/src/lib/platform/baudrate.h b/src/lib/platform/serialport/baudrate.h similarity index 95% rename from src/lib/platform/baudrate.h rename to src/lib/platform/serialport/baudrate.h index 98521bb..bfdb2d7 100644 --- a/src/lib/platform/baudrate.h +++ b/src/lib/platform/serialport/baudrate.h @@ -34,19 +34,18 @@ //every baudrate I could find is in here in an #ifdef block //so it should compile on everything -#include "os-dependent.h" - #ifndef __WINDOWS__ #include #endif -namespace CEC +namespace PLATFORM { static struct sbaudrate { int32_t rate; int32_t symbol; } + baudrates[] = { #ifdef B50 @@ -199,9 +198,9 @@ namespace CEC { -1, -1} }; - static int32_t IntToBaudrate(uint32_t baudrate) + inline int32_t IntToBaudrate(uint32_t baudrate) { - for (unsigned int i = 0; i < sizeof(baudrates) / sizeof(CEC::sbaudrate) - 1; i++) + for (unsigned int i = 0; i < sizeof(baudrates) / sizeof(PLATFORM::sbaudrate) - 1; i++) { if (baudrates[i].rate == (int32_t) baudrate) return baudrates[i].symbol; diff --git a/src/lib/platform/serialport.h b/src/lib/platform/serialport/serialport.h similarity index 75% rename from src/lib/platform/serialport.h rename to src/lib/platform/serialport/serialport.h index f5035b9..3710bfe 100644 --- a/src/lib/platform/serialport.h +++ b/src/lib/platform/serialport/serialport.h @@ -31,20 +31,15 @@ * http://www.pulse-eight.net/ */ -#include "os-dependent.h" -#include +#include "../os.h" #include #include -#include "../AdapterCommunication.h" -#include "../platform/threads.h" #ifndef __WINDOWS__ #include -#else -#include "../util/buffer.h" #endif -namespace CEC +namespace PLATFORM { #define PAR_NONE 0 #define PAR_EVEN 1 @@ -60,7 +55,7 @@ namespace CEC bool IsOpen(); void Close(); - int8_t Write(CCECAdapterMessage *data); + int64_t Write(uint8_t* data, uint32_t len); int32_t Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs = 0); std::string GetError() { return m_error; } @@ -69,23 +64,23 @@ namespace CEC private: bool SetBaudRate(uint32_t baudrate); - std::string m_error; - std::string m_name; - CMutex m_mutex; - bool m_tostdout; + std::string m_error; + std::string m_name; + CMutex m_mutex; + bool m_tostdout; #ifdef __WINDOWS__ bool SetTimeouts(bool bBlocking); - HANDLE m_handle; - bool m_bIsOpen; - uint32_t m_iBaudrate; - uint8_t m_iDatabits; - uint8_t m_iStopbits; - uint8_t m_iParity; - int64_t m_iTimeout; - CecBuffer m_buffer; - HANDLE m_ovHandle; + HANDLE m_handle; + bool m_bIsOpen; + uint32_t m_iBaudrate; + uint8_t m_iDatabits; + uint8_t m_iStopbits; + uint8_t m_iParity; + int64_t m_iTimeout; + SyncedBuffer m_buffer; + HANDLE m_ovHandle; #else struct termios m_options; int m_fd; diff --git a/src/lib/platform/threads.h b/src/lib/platform/threads.h deleted file mode 100644 index 2c3c2c5..0000000 --- a/src/lib/platform/threads.h +++ /dev/null @@ -1,98 +0,0 @@ -#pragma once -/* - * This file is part of the libCEC(R) library. - * - * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. - * libCEC(R) is an original work, containing original code. - * - * libCEC(R) is a trademark of Pulse-Eight Limited. - * - * This program is dual-licensed; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * - * Alternatively, you can license this library under a commercial license, - * please contact Pulse-Eight Licensing for more information. - * - * For more information contact: - * Pulse-Eight Licensing - * http://www.pulse-eight.com/ - * http://www.pulse-eight.net/ - */ - -#include - -namespace CEC -{ - class IMutex - { - public: - IMutex(bool bRecursive = true) { m_bRecursive = bRecursive ; }; - virtual ~IMutex(void) {}; - - virtual bool TryLock(void) = 0; - virtual bool Lock(void) = 0; - virtual void Unlock(void) = 0; - - protected: - bool m_bRecursive; - }; - - class ICondition - { - public: - virtual void Broadcast(void) = 0; - virtual void Signal(void) = 0; - virtual bool Wait(IMutex *mutex, uint32_t iTimeout = 0) = 0; - - static void Sleep(uint32_t iTimeout); - }; - - class IThread - { - public: - IThread(void); - virtual ~IThread(void); - - virtual bool IsRunning(void) const { return m_bRunning; }; - virtual bool CreateThread(bool bWait = true) = 0; - virtual bool IsStopped(void) const { return m_bStop; }; - - virtual bool StopThread(bool bWaitForExit = true); - virtual bool Sleep(uint32_t iTimeout); - - virtual void *Process(void) = 0; - - protected: - bool m_bStop; - bool m_bRunning; - ICondition *m_threadCondition; - IMutex *m_threadMutex; - }; - - class CLockObject - { - public: - CLockObject(IMutex *mutex, bool bTryLock = false); - ~CLockObject(void); - - bool IsLocked(void) const { return m_bLocked; } - void Leave(void); - void Lock(void); - - private: - IMutex *m_mutex; - bool m_bLocked; - }; -}; diff --git a/src/lib/platform/threads/mutex.h b/src/lib/platform/threads/mutex.h new file mode 100644 index 0000000..4a2ad79 --- /dev/null +++ b/src/lib/platform/threads/mutex.h @@ -0,0 +1,188 @@ +#pragma once +/* + * This file is part of the libCEC(R) library. + * + * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is an original work, containing original code. + * + * libCEC(R) is a trademark of Pulse-Eight Limited. + * + * This program is dual-licensed; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + * Alternatively, you can license this library under a commercial license, + * please contact Pulse-Eight Licensing for more information. + * + * For more information contact: + * Pulse-Eight Licensing + * http://www.pulse-eight.com/ + * http://www.pulse-eight.net/ + */ + +namespace PLATFORM +{ + class PreventCopy + { + public: + inline PreventCopy(void) {} + inline ~PreventCopy(void) {} + + private: + inline PreventCopy(const PreventCopy &c) { *this = c; } + inline PreventCopy &operator=(const PreventCopy &c){ *this = c; return *this; } + }; + + class CCondition; + + class CMutex : public PreventCopy + { + friend class CCondition; + public: + inline CMutex(void) : + m_iLockCount(0) + { + MutexCreate(m_mutex); + } + + inline ~CMutex(void) + { + Clear(); + MutexDelete(m_mutex); + } + + inline bool TryLock(void) + { + if (MutexTryLock(m_mutex)) + { + ++m_iLockCount; + return true; + } + return false; + } + + inline bool Lock(void) + { + MutexLock(m_mutex); + ++m_iLockCount; + return true; + } + + inline void Unlock(void) + { + --m_iLockCount; + MutexUnlock(m_mutex); + } + + inline bool Clear(void) + { + bool bReturn(false); + if (TryLock()) + { + unsigned int iLockCount = m_iLockCount; + for (unsigned int iPtr = 0; iPtr < iLockCount; iPtr++) + Unlock(); + bReturn = true; + } + return bReturn; + } + + private: + mutex_t m_mutex; + unsigned int m_iLockCount; + }; + + class CLockObject : public PreventCopy + { + public: + inline CLockObject(CMutex &mutex, bool bClearOnExit = false) : + m_mutex(mutex), + m_bClearOnExit(bClearOnExit) + { + m_mutex.Lock(); + } + + inline ~CLockObject(void) + { + if (m_bClearOnExit) + Clear(); + else + Unlock(); + } + + inline bool TryLock(void) + { + return m_mutex.TryLock(); + } + + inline void Unlock(void) + { + m_mutex.Unlock(); + } + + inline bool Clear(void) + { + return m_mutex.Clear(); + } + + inline bool Lock(void) + { + return m_mutex.Lock(); + } + + private: + CMutex &m_mutex; + bool m_bClearOnExit; + }; + + class CCondition : public PreventCopy + { + public: + inline CCondition(void) + { + ConditionCreate(m_condition); + } + + inline ~CCondition(void) + { + Broadcast(); + ConditionDelete(m_condition); + } + + inline void Broadcast(void) + { + ConditionBroadcast(m_condition); + } + + inline void Signal(void) + { + ConditionSignal(m_condition); + } + + inline bool Wait(CMutex &mutex, uint32_t iTimeout = 0) + { + return ConditionWait(m_condition, mutex.m_mutex, iTimeout); + } + + static void Sleep(uint32_t iTimeout) + { + CCondition w; + CMutex m; + CLockObject lock(m); + w.Wait(m, iTimeout); + } + + condition_t m_condition; + }; +} diff --git a/src/lib/platform/threads/threads.h b/src/lib/platform/threads/threads.h new file mode 100644 index 0000000..74d683f --- /dev/null +++ b/src/lib/platform/threads/threads.h @@ -0,0 +1,137 @@ +#pragma once +/* + * This file is part of the libCEC(R) library. + * + * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is an original work, containing original code. + * + * libCEC(R) is a trademark of Pulse-Eight Limited. + * + * This program is dual-licensed; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + * Alternatively, you can license this library under a commercial license, + * please contact Pulse-Eight Licensing for more information. + * + * For more information contact: + * Pulse-Eight Licensing + * http://www.pulse-eight.com/ + * http://www.pulse-eight.net/ + */ + +#include "mutex.h" + +namespace PLATFORM +{ + class CThread + { + public: + CThread(void) : + m_bStop(false), + m_bRunning(false) {} + + virtual ~CThread(void) + { + StopThread(); + } + + static void *ThreadHandler(CThread *thread) + { + void *retVal = NULL; + + if (thread) + { + CLockObject lock(thread->m_threadMutex); + thread->m_bRunning = true; + lock.Unlock(); + thread->m_threadCondition.Broadcast(); + + retVal = thread->Process(); + + lock.Lock(); + thread->m_bRunning = false; + lock.Unlock(); + thread->m_threadCondition.Broadcast(); + } + + return retVal; + } + + inline bool IsRunning(void) + { + CLockObject lock(m_threadMutex); + return m_bRunning; + } + + inline bool IsStopped(void) + { + CLockObject lock(m_threadMutex); + return m_bStop; + } + + inline bool CreateThread(bool bWait = true) + { + bool bReturn(false); + CLockObject lock(m_threadMutex); + if (!IsRunning()) + { + if (ThreadsCreate(m_thread, CThread::ThreadHandler, ((void*)static_cast(this)))) + { + if (bWait) + m_threadCondition.Wait(m_threadMutex); + bReturn = true; + } + } + return bReturn; + } + + inline bool StopThread(bool bWaitForExit = true) + { + bool bReturn(true); + bool bRunning(false); + { + CLockObject lock(m_threadMutex); + bRunning = IsRunning(); + m_bStop = true; + m_threadCondition.Broadcast(); + } + + if (bRunning && bWaitForExit) + { + void *retVal = NULL; + bReturn = ThreadsWait(m_thread, &retVal); + } + return true; + } + + inline bool Sleep(uint32_t iTimeout) + { + CLockObject lock(m_threadMutex); + return m_bStop ? false : m_threadCondition.Wait(m_threadMutex, iTimeout); + } + + virtual void *Process(void) = 0; + + protected: + void SetRunning(bool bSetTo); + + private: + bool m_bStop; + bool m_bRunning; + CCondition m_threadCondition; + CMutex m_threadMutex; + thread_t m_thread; + }; +}; diff --git a/src/lib/platform/timeutils.h b/src/lib/platform/timeutils.h index f05f7e7..b2f613a 100644 --- a/src/lib/platform/timeutils.h +++ b/src/lib/platform/timeutils.h @@ -41,10 +41,41 @@ #include #endif -#include "os-dependent.h" +#include "os.h" -namespace CEC +namespace PLATFORM { + #if defined(__WINDOWS__) + struct timezone + { + int tz_minuteswest; + int tz_dsttime; + }; + + #define usleep(t) Sleep((DWORD)(t)/1000) + + inline int gettimeofday(struct timeval *pcur_time, struct timezone *tz) + { + if (pcur_time == NULL) + { + SetLastError(EFAULT); + return -1; + } + struct _timeb current; + + _ftime(¤t); + + pcur_time->tv_sec = (long) current.time; + pcur_time->tv_usec = current.millitm * 1000L; + if (tz) + { + tz->tz_minuteswest = current.timezone; /* minutes west of Greenwich */ + tz->tz_dsttime = current.dstflag; /* type of dst correction */ + } + return 0; + } + #endif + inline int64_t GetTimeMs() { #if defined(__APPLE__) diff --git a/src/lib/platform/windows/os-threads.h b/src/lib/platform/windows/os-threads.h new file mode 100644 index 0000000..0e73868 --- /dev/null +++ b/src/lib/platform/windows/os-threads.h @@ -0,0 +1,65 @@ +#pragma once +/* + * This file is part of the libCEC(R) library. + * + * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is an original work, containing original code. + * + * libCEC(R) is a trademark of Pulse-Eight Limited. + * + * This program is dual-licensed; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + * Alternatively, you can license this library under a commercial license, + * please contact Pulse-Eight Licensing for more information. + * + * For more information contact: + * Pulse-Eight Licensing + * http://www.pulse-eight.com/ + * http://www.pulse-eight.net/ + */ + +namespace PLATFORM +{ + #define thread_t HANDLE + #define ThreadsWait(thread, retVal) (::WaitForSingleObject(thread, INFINITE) < 0) + #define ThreadsCreate(thread, func, arg) ((thread = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, NULL)) == NULL ? false : true) + + typedef CRITICAL_SECTION* mutex_t; + #define MutexCreate(mutex) ::InitializeCriticalSection(mutex = new CRITICAL_SECTION) + #define MutexDelete(mutex) ::DeleteCriticalSection(mutex); delete mutex + #define MutexLock(mutex) ::EnterCriticalSection(mutex) + #define MutexTryLock(mutex) (::TryEnterCriticalSection(mutex) != 0) + #define MutexUnlock(mutex) ::LeaveCriticalSection(mutex) + + #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + typedef CONDITION_VARIABLE* condition_t; + #define ConditionCreate(cond) ::InitializeConditionVariable(cond = new CONDITION_VARIABLE) + #define ConditionDelete(cond) delete cond + #define ConditionSignal(cond) ::WakeConditionVariable(cond) + #define ConditionBroadcast(cond) ::WakeAllConditionVariable(cond) + #define ConditionWait(cond, mutex, timeout) (::SleepConditionVariableCS(cond, mutex, timeout <= 0 ? INFINITE : timeout) ? true : false) + #else + typedef HANDLE condition_t; + #define ConditionCreate(cond) (cond = ::CreateEvent(NULL, TRUE, FALSE, NULL)) + #define ConditionDelete(cond) ::CloseHandle(cond) + #define ConditionSignal(cond) ::SetEvent(cond) + #define ConditionBroadcast(cond) ::SetEvent(cond) + #define ConditionWait(cond, mutex, timeout) ::ResetEvent(cond); \ + MutexUnlock(mutex); \ + ::WaitForSingleObject(cond, timeout <= 0 ? 1000 : timeout); \ + MutexLock(mutex) + #endif +} diff --git a/src/lib/platform/posix/pthreads.h b/src/lib/platform/windows/os-types.h similarity index 58% rename from src/lib/platform/posix/pthreads.h rename to src/lib/platform/windows/os-types.h index b39c1e9..3943510 100644 --- a/src/lib/platform/posix/pthreads.h +++ b/src/lib/platform/windows/os-types.h @@ -31,52 +31,36 @@ * http://www.pulse-eight.net/ */ -#include "../threads.h" +#pragma warning(disable:4005) // Disable "warning C4005: '_WINSOCKAPI_' : macro redefinition" +#include +#pragma warning(default:4005) -namespace CEC -{ - class CMutex : public IMutex - { - public: - CMutex(bool bRecursive = true); - virtual ~CMutex(void); +#include +#include +#include +#include +#include +#include - virtual bool TryLock(void); - virtual bool Lock(void); - virtual void Unlock(void); +typedef signed __int8 int8_t; +typedef signed __int16 int16_t; +typedef signed __int32 int32_t; +typedef signed __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; - pthread_mutex_t m_mutex; +#define snprintf _snprintf - private: - static pthread_mutexattr_t *GetMutexAttribute(); - }; +#if defined(_MSC_VER) +#pragma warning (push) +#endif - class CCondition : public ICondition - { - public: - CCondition(void); - virtual ~CCondition(void); +#define NOGDI +#if defined(_MSC_VER) /* prevent inclusion of wingdi.h */ +#pragma warning (pop) +#endif - virtual void Broadcast(void); - virtual void Signal(void); - virtual bool Wait(IMutex *mutex, uint32_t iTimeout = 0); - - private: - pthread_cond_t m_cond; - }; - - class CThread : public IThread - { - public: - CThread(void) { }; - virtual ~CThread(void) { }; - - virtual bool CreateThread(bool bWait = true); - virtual bool StopThread(bool bWaitForExit = true); - - static void *ThreadHandler(CThread *thread); - - private: - pthread_t m_thread; - }; -}; +#pragma warning(disable:4189) /* disable 'defined but not used' */ +#pragma warning(disable:4100) /* disable 'unreferenced formal parameter' */ diff --git a/src/lib/platform/windows/os_windows.cpp b/src/lib/platform/windows/os_windows.cpp deleted file mode 100644 index 429730d..0000000 --- a/src/lib/platform/windows/os_windows.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2005-2011 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "os_windows.h" -#include - -int gettimeofday(struct timeval *pcur_time, struct timezone *tz) -{ - if (pcur_time == NULL) - { - SetLastError(EFAULT); - return -1; - } - struct _timeb current; - - _ftime(¤t); - - pcur_time->tv_sec = (long) current.time; - pcur_time->tv_usec = current.millitm * 1000L; - if (tz) - { - tz->tz_minuteswest = current.timezone; /* minutes west of Greenwich */ - tz->tz_dsttime = current.dstflag; /* type of dst correction */ - } - return 0; -} diff --git a/src/lib/platform/windows/os_windows.h b/src/lib/platform/windows/os_windows.h deleted file mode 100644 index 90cc75e..0000000 --- a/src/lib/platform/windows/os_windows.h +++ /dev/null @@ -1,77 +0,0 @@ -#pragma once -/* - * Copyright (C) 2011 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#pragma warning(disable:4005) // Disable "warning C4005: '_WINSOCKAPI_' : macro redefinition" -#include -#pragma warning(default:4005) - -#if defined(_WIN32) -#include "../pthread_win32/pthread.h" -#include "../posix/pthreads.h" -#endif - -#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 -# define __USE_FILE_OFFSET64 1 -#endif - -typedef signed __int32 int32_t; -typedef signed __int64 int64_t; -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; - -#if defined __USE_FILE_OFFSET64 -typedef int64_t off_t; -typedef uint64_t ino_t; -#endif - -#define usleep(t) Sleep((t)/1000) -#define snprintf _snprintf - -#include -#include -#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ -#pragma warning (push) -#endif -/* prevent inclusion of wingdi.h */ -#define NOGDI -#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */ -#pragma warning (pop) -#endif -#include -#include -#include - -struct timezone -{ - int tz_minuteswest; /* minutes west of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; - -/*! - \brief implements similar unix call under windows - \return 0 on success, -1 on failure (if pcur_time was NULL) - \param pcur_time points to a timeval structure, should not be NULL - \param tz points to a timezone structure, may be NULL - */ -extern int gettimeofday(struct timeval *pcur_time, struct timezone *tz); diff --git a/src/lib/platform/windows/serialport.cpp b/src/lib/platform/windows/serialport.cpp index 9e4cc48..8e513fc 100644 --- a/src/lib/platform/windows/serialport.cpp +++ b/src/lib/platform/windows/serialport.cpp @@ -30,12 +30,12 @@ * http://www.pulse-eight.net/ */ -#include "../serialport.h" -#include "../baudrate.h" +#include "../serialport/serialport.h" +#include "../serialport/baudrate.h" #include "../timeutils.h" using namespace std; -using namespace CEC; +using namespace PLATFORM; void FormatWindowsError(int iErrorCode, string &strMessage) { @@ -66,7 +66,7 @@ CSerialPort::~CSerialPort(void) bool CSerialPort::Open(string name, uint32_t baudrate, uint8_t databits, uint8_t stopbits, uint8_t parity) { CStdString strComPath = "\\\\.\\" + name; - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); m_handle = CreateFile(strComPath.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (m_handle == INVALID_HANDLE_VALUE) { @@ -159,7 +159,7 @@ bool CSerialPort::SetTimeouts(bool bBlocking) void CSerialPort::Close(void) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); if (m_bIsOpen) { CloseHandle(m_handle); @@ -167,26 +167,26 @@ void CSerialPort::Close(void) } } -int8_t CSerialPort::Write(CCECAdapterMessage *data) +int64_t CSerialPort::Write(uint8_t* data, uint32_t len) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); DWORD iBytesWritten = 0; if (!m_bIsOpen) return -1; - if (!WriteFile(m_handle, data->packet.data, data->size(), &iBytesWritten, NULL)) + if (!WriteFile(m_handle, data, len, &iBytesWritten, NULL)) { m_error = "Error while writing to COM port"; FormatWindowsError(GetLastError(), m_error); return -1; } - return (int8_t)iBytesWritten; + return (int64_t)iBytesWritten; } int32_t CSerialPort::Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs /* = 0 */) { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); int32_t iReturn(-1); DWORD iBytesRead = 0; if (m_handle == 0) @@ -256,6 +256,6 @@ bool CSerialPort::SetBaudRate(uint32_t baudrate) bool CSerialPort::IsOpen() { - CLockObject lock(&m_mutex); + CLockObject lock(m_mutex); return m_bIsOpen; } diff --git a/src/testclient/Makefile.am b/src/testclient/Makefile.am index 14b36f8..726cf62 100644 --- a/src/testclient/Makefile.am +++ b/src/testclient/Makefile.am @@ -1,7 +1,5 @@ bin_PROGRAMS = cec-client -cec_client_SOURCES = main.cpp \ - ../lib/platform/threads.cpp \ - ../lib/platform/posix/pthreads.cpp +cec_client_SOURCES = main.cpp cec_client_CPPFLAGS = -I@abs_top_srcdir@/include cec_client_LDFLAGS = @LIBS_DL@ \ No newline at end of file diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 256a484..8178449 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -38,12 +38,12 @@ #include #include #include -#include "../lib/platform/threads.h" -#include "../lib/util/StdString.h" +#include "../lib/platform/os.h" #include "../lib/implementations/CECCommandHandler.h" using namespace CEC; using namespace std; +using namespace PLATFORM; #define CEC_TEST_CLIENT_VERSION 1 @@ -62,7 +62,7 @@ ICECCallbacks g_callbacks; inline void PrintToStdOut(const char *strOut) { - CLockObject lock(&g_outputMutex); + CLockObject lock(g_outputMutex); cout << strOut << endl; } @@ -207,7 +207,7 @@ void ListDevices(ICECAdapter *parser) void ShowHelpCommandLine(const char* strExec) { - CLockObject lock(&g_outputMutex); + CLockObject lock(g_outputMutex); cout << endl << strExec << " {-h|--help|-l|--list-devices|[COM PORT]}" << endl << endl << @@ -254,7 +254,7 @@ ICECAdapter *CreateParser(cec_device_type_list typeList) void ShowHelpConsole(void) { - CLockObject lock(&g_outputMutex); + CLockObject lock(g_outputMutex); cout << endl << "================================================================================" << endl << "Available commands:" << endl << -- 2.34.1