cec: refactored threading/locking - added windows native instead of pthread-win32...
authorLars Op den Kamp <lars@opdenkamp.eu>
Sun, 15 Jan 2012 13:32:26 +0000 (14:32 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 17 Jan 2012 11:56:31 +0000 (12:56 +0100)
54 files changed:
.gitignore
include/cecloader.h
project/LibCecSharp.Net2.sln
project/LibCecSharp.Net2.vcproj
project/LibCecSharp.vcxproj
project/create-installer.cmd
project/libCEC.nsi
project/libcec.sln
project/libcec.vcxproj
project/libcec.vcxproj.filters
project/testclient.vcxproj
project/testclient.vcxproj.filters
pthreadVC2.dll [deleted file]
src/lib/AdapterCommunication.cpp
src/lib/AdapterCommunication.h
src/lib/AdapterDetection.cpp
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h
src/lib/LibCEC.cpp
src/lib/LibCEC.h
src/lib/Makefile.am
src/lib/devices/CECAudioSystem.cpp
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h
src/lib/devices/CECPlaybackDevice.cpp
src/lib/implementations/ANCommandHandler.cpp
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/CECCommandHandler.h
src/lib/implementations/SLCommandHandler.cpp
src/lib/platform/StdString.h [moved from src/lib/util/StdString.h with 100% similarity]
src/lib/platform/buffer.h [moved from src/lib/util/buffer.h with 89% similarity]
src/lib/platform/os-dependent.h [deleted file]
src/lib/platform/os.h [moved from src/lib/platform/threads.cpp with 52% similarity]
src/lib/platform/posix/os-threads.h [new file with mode: 0644]
src/lib/platform/posix/os-types.h [moved from src/lib/platform/posix/os_posix.h with 95% similarity]
src/lib/platform/posix/pthreads.cpp [deleted file]
src/lib/platform/posix/serialport.cpp
src/lib/platform/pthread_win32/pthread.h [deleted file]
src/lib/platform/pthread_win32/pthreadVC2.lib [deleted file]
src/lib/platform/pthread_win32/sched.h [deleted file]
src/lib/platform/pthread_win32/semaphore.h [deleted file]
src/lib/platform/serialport/baudrate.h [moved from src/lib/platform/baudrate.h with 95% similarity]
src/lib/platform/serialport/serialport.h [moved from src/lib/platform/serialport.h with 75% similarity]
src/lib/platform/threads.h [deleted file]
src/lib/platform/threads/mutex.h [new file with mode: 0644]
src/lib/platform/threads/threads.h [new file with mode: 0644]
src/lib/platform/timeutils.h
src/lib/platform/windows/os-threads.h [new file with mode: 0644]
src/lib/platform/windows/os-types.h [moved from src/lib/platform/posix/pthreads.h with 58% similarity]
src/lib/platform/windows/os_windows.cpp [deleted file]
src/lib/platform/windows/os_windows.h [deleted file]
src/lib/platform/windows/serialport.cpp
src/testclient/Makefile.am
src/testclient/main.cpp

index 9abd286b8b901875e5aeb3784ca5cc4c68ed4e60..6ec51bd6a6b3c1b3d610ceca52d4119223fc01b4 100644 (file)
@@ -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
index 49efbd747c5cd8b537a3a704218ef3f5e5beb202..1e6d7167710053aa5d5222b87f0748748e849ac1 100644 (file)
@@ -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;
 
index b50b423a0af7454cdcce7bca3f62331fe84fdd3b..ac97f5f6afd4df99f338bc9a378367bcc02c4602 100644 (file)
@@ -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
index 3fdfcae8503eaf78420c0c15fcd5994df8608fd9..e65be244f75a01e96b68522c75b758908e8d7701 100644 (file)
@@ -13,6 +13,9 @@
                <Platform
                        Name="Win32"
                />
+               <Platform
+                       Name="x64"
+               />
        </Platforms>
        <ToolFiles>
        </ToolFiles>
                                Name="VCPostBuildEventTool"
                        />
                </Configuration>
+               <Configuration
+                       Name="Debug|x64"
+                       OutputDirectory="$(SolutionDir).."
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       ConfigurationType="2"
+                       CharacterSet="1"
+                       ManagedExtensions="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="&quot;$(SolutionDir)..\include&quot;;&quot;$(SolutionDir)..\src\lib\platform\windows&quot;"
+                               PreprocessorDefinitions="_DEBUG"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               WarnAsError="true"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="$(SolutionDir)..\libcec.x64.lib $(NOINHERIT)"
+                               OutputFile="$(OutDir)\$(ProjectName).x64.dll"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="true"
+                               AssemblyDebug="1"
+                               TargetMachine="17"
+                               KeyFile="$(SolutionDir)LibCecSharp.Net2-dev.snk"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
                <Configuration
                        Name="Release|Win32"
                        OutputDirectory="$(SolutionDir).."
                                Name="VCPostBuildEventTool"
                        />
                </Configuration>
+               <Configuration
+                       Name="Release|x64"
+                       OutputDirectory="$(SolutionDir).."
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       ConfigurationType="2"
+                       CharacterSet="1"
+                       ManagedExtensions="1"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="&quot;$(SolutionDir)..\include&quot;;&quot;$(SolutionDir)..\src\lib\platform\windows&quot;"
+                               PreprocessorDefinitions="NDEBUG"
+                               RuntimeLibrary="2"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               WarnAsError="true"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="$(SolutionDir)..\libcec.x64.lib $(NoInherit)"
+                               OutputFile="$(OutDir)\$(ProjectName).x64.dll"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="true"
+                               TargetMachine="17"
+                               KeyFile="$(SolutionDir)LibCecSharp.Net2-dev.snk"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
        </Configurations>
        <References>
                <AssemblyReference
                                RelativePath="..\src\LibCecSharp\LibCecSharp.cpp"
                                >
                        </File>
-                       <File
-                               RelativePath="..\src\LibCecSharp\Stdafx.cpp"
-                               >
-                       </File>
                </Filter>
                <Filter
                        Name="Header Files"
                                RelativePath="..\src\LibCecSharp\resource.h"
                                >
                        </File>
-                       <File
-                               RelativePath="..\src\LibCecSharp\Stdafx.h"
-                               >
-                       </File>
                </Filter>
        </Files>
        <Globals>
index 0a3e575a56248c1d629f35d20e78076dad71a8ef..8b23d1e7fac07f35d86d7159abb24ca2edc1efc3 100644 (file)
@@ -5,10 +5,18 @@
       <Configuration>Debug</Configuration>
       <Platform>Win32</Platform>
     </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
     <ProjectConfiguration Include="Release|Win32">
       <Configuration>Release</Configuration>
       <Platform>Win32</Platform>
     </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
   </ItemGroup>
   <PropertyGroup Label="Globals">
     <ProjectGuid>{1AC27FBD-653A-4F5F-ADBC-2A8FD074EEB7}</ProjectGuid>
     <CLRSupport>true</CLRSupport>
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CLRSupport>true</CLRSupport>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>false</UseDebugLibraries>
     <CLRSupport>true</CLRSupport>
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <CLRSupport>true</CLRSupport>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <ImportGroup Label="ExtensionSettings">
   </ImportGroup>
   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
     <IncludePath>$(SolutionDir)\..\include;$(IncludePath)</IncludePath>
     <TargetName>$(ProjectName)</TargetName>
     <OutDir>$(SolutionDir)..\</OutDir>
     <LinkKeyFile>$(SolutionDir)LibCecSharp.Net2-dev.snk</LinkKeyFile>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+    <IncludePath>$(SolutionDir)\..\include;$(IncludePath)</IncludePath>
+    <TargetName>$(ProjectName).x64</TargetName>
+    <OutDir>$(SolutionDir)..\</OutDir>
+    <LinkKeyFile>$(SolutionDir)LibCecSharp.Net2-dev.snk</LinkKeyFile>
+  </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
     <IncludePath>$(SolutionDir)\..\include;$(IncludePath)</IncludePath>
     <LinkKeyFile>$(SolutionDir)LibCecSharp.Net2-dev.snk</LinkKeyFile>
+    <OutDir>$(SolutionDir)..\</OutDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <IncludePath>$(SolutionDir)\..\include;$(IncludePath)</IncludePath>
+    <LinkKeyFile>$(SolutionDir)LibCecSharp.Net2-dev.snk</LinkKeyFile>
+    <TargetName>$(ProjectName).x64</TargetName>
+    <OutDir>$(SolutionDir)..\</OutDir>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>
+      </AdditionalDependencies>
+      <TargetMachine>MachineX86</TargetMachine>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_WIN64;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
     </ClCompile>
     <Link>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <WarningLevel>Level3</WarningLevel>
-      <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>
+      </AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PreprocessorDefinitions>_WIN64;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
     </ClCompile>
     <Link>
index 78daa7ef8039112107265e27ad3544929028e5b5..369e40842acaf3eaae6f19024fcb0be926d852f7 100644 (file)
@@ -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
index 065544a785158677a26fe2be4936dd7c398f7deb..2ec8c069b126e23e1b4689b7a4910e98e787dfe9 100644 (file)
@@ -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"  
index df298f499904290cd6a0438d4bafa698a167d180..b1969d7f45d430d1a6ba4b1019ccf4d0befd4581 100644 (file)
@@ -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
index d1a8ea00c99a46a49bff3735adec5d293f7c3c72..4d320b3fff668b6434115749b60a3f9b7d9aa239 100644 (file)
@@ -5,10 +5,18 @@
       <Configuration>Debug</Configuration>
       <Platform>Win32</Platform>
     </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
     <ProjectConfiguration Include="Release|Win32">
       <Configuration>Release</Configuration>
       <Platform>Win32</Platform>
     </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\include\cec.h" />
     <ClInclude Include="..\src\lib\implementations\SLCommandHandler.h" />
     <ClInclude Include="..\src\lib\implementations\VLCommandHandler.h" />
     <ClInclude Include="..\src\lib\LibCEC.h" />
-    <ClInclude Include="..\src\lib\platform\baudrate.h" />
-    <ClInclude Include="..\src\lib\platform\os-dependent.h" />
-    <ClInclude Include="..\src\lib\platform\posix\pthreads.h" />
-    <ClInclude Include="..\src\lib\platform\pthread_win32\pthread.h" />
-    <ClInclude Include="..\src\lib\platform\pthread_win32\sched.h" />
-    <ClInclude Include="..\src\lib\platform\pthread_win32\semaphore.h" />
-    <ClInclude Include="..\src\lib\platform\serialport.h" />
-    <ClInclude Include="..\src\lib\platform\threads.h" />
+    <ClInclude Include="..\src\lib\platform\buffer.h" />
+    <ClInclude Include="..\src\lib\platform\os.h" />
+    <ClInclude Include="..\src\lib\platform\serialport\baudrate.h" />
+    <ClInclude Include="..\src\lib\platform\serialport\serialport.h" />
+    <ClInclude Include="..\src\lib\platform\StdString.h" />
+    <ClInclude Include="..\src\lib\platform\threads\mutex.h" />
+    <ClInclude Include="..\src\lib\platform\threads\threads.h" />
     <ClInclude Include="..\src\lib\platform\timeutils.h" />
-    <ClInclude Include="..\src\lib\platform\windows\dlfcn-win32.h" />
-    <ClInclude Include="..\src\lib\platform\windows\os_windows.h" />
-    <ClInclude Include="..\src\lib\util\buffer.h" />
-    <ClInclude Include="..\src\lib\util\StdString.h" />
-    <ClInclude Include="resource.h" />
+    <ClInclude Include="..\src\lib\platform\windows\os-threads.h" />
+    <ClInclude Include="..\src\lib\platform\windows\os-types.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\src\lib\AdapterCommunication.cpp" />
     <ClCompile Include="..\src\lib\LibCEC.cpp" />
     <ClCompile Include="..\src\lib\LibCECC.cpp" />
     <ClCompile Include="..\src\lib\LibCECDll.cpp" />
-    <ClCompile Include="..\src\lib\platform\posix\pthreads.cpp" />
-    <ClCompile Include="..\src\lib\platform\threads.cpp" />
-    <ClCompile Include="..\src\lib\platform\windows\dlfcn-win32.cpp" />
-    <ClCompile Include="..\src\lib\platform\windows\os_windows.cpp" />
     <ClCompile Include="..\src\lib\platform\windows\serialport.cpp" />
   </ItemGroup>
   <ItemGroup>
     <UseDebugLibraries>true</UseDebugLibraries>
     <CharacterSet>MultiByte</CharacterSet>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>false</UseDebugLibraries>
     <CharacterSet>MultiByte</CharacterSet>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <ImportGroup Label="ExtensionSettings">
   </ImportGroup>
   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <OutDir>$(SolutionDir)..\</OutDir>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <OutDir>$(SolutionDir)..\</OutDir>
+  </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <TargetName>libcec</TargetName>
+    <TargetName>$(ProjectName)</TargetName>
+    <TargetExt>.dll</TargetExt>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <TargetName>$(ProjectName).x64</TargetName>
     <TargetExt>.dll</TargetExt>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <IgnoreImportLibrary>false</IgnoreImportLibrary>
     <LinkIncremental>true</LinkIncremental>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ExtensionsToDeleteOnClean>*.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</ExtensionsToDeleteOnClean>
+    <IncludePath>$(SolutionDir)..\include;$(IncludePath)</IncludePath>
+    <IgnoreImportLibrary>false</IgnoreImportLibrary>
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <OutDir>$(SolutionDir)..\</OutDir>
     <TargetName>libcec</TargetName>
     <TargetExt>.dll</TargetExt>
     <ExtensionsToDeleteOnClean>*.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</ExtensionsToDeleteOnClean>
     <IncludePath>$(SolutionDir)..\include;$(IncludePath)</IncludePath>
-    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <OutDir>$(SolutionDir)..\</OutDir>
+    <TargetName>$(ProjectName).x64</TargetName>
+    <TargetExt>.dll</TargetExt>
+    <ExtensionsToDeleteOnClean>*.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</ExtensionsToDeleteOnClean>
+    <IncludePath>$(SolutionDir)..\include;$(IncludePath)</IncludePath>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <WarningLevel>Level4</WarningLevel>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE_32BIT_TIME_T;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;__WINDOWS__;DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>$(SolutionDir)..\src\lib\platform\pthread_win32;$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <DisableSpecificWarnings>4996;4100;4309;4505</DisableSpecificWarnings>
+      <PreprocessorDefinitions>_USE_32BIT_TIME_T;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <DisableSpecificWarnings>
+      </DisableSpecificWarnings>
       <TreatWarningAsError>true</TreatWarningAsError>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <OutputFile>$(SolutionDir)..\libcec.dll</OutputFile>
-      <AdditionalDependencies>%(AdditionalDependencies);setupapi.lib;$(SolutionDir)..\src\lib\platform\pthread_win32\pthreadVC2.lib</AdditionalDependencies>
+      <OutputFile>$(SolutionDir)..\$(TargetName)$(TargetExt)</OutputFile>
+      <AdditionalDependencies>%(AdditionalDependencies);setupapi.lib</AdditionalDependencies>
+      <IgnoreSpecificDefaultLibraries>libcmtd</IgnoreSpecificDefaultLibraries>
+      <Version>
+      </Version>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <WarningLevel>Level4</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_WIN64;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <DisableSpecificWarnings>
+      </DisableSpecificWarnings>
+      <TreatWarningAsError>true</TreatWarningAsError>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <OutputFile>$(SolutionDir)..\$(TargetName)$(TargetExt)</OutputFile>
+      <AdditionalDependencies>%(AdditionalDependencies);setupapi.lib</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>libcmtd</IgnoreSpecificDefaultLibraries>
       <Version>
       </Version>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <AdditionalIncludeDirectories>$(SolutionDir)..\src\lib\platform\pthread_win32;$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE_32BIT_TIME_T;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;__WINDOWS__;DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <DisableSpecificWarnings>4100;4309</DisableSpecificWarnings>
+      <PreprocessorDefinitions>_USE_32BIT_TIME_T;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <DisableSpecificWarnings>
+      </DisableSpecificWarnings>
       <TreatWarningAsError>true</TreatWarningAsError>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
     </ClCompile>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <OutputFile>$(SolutionDir)..\libcec.dll</OutputFile>
-      <AdditionalDependencies>%(AdditionalDependencies);setupapi.lib;$(SolutionDir)..\src\lib\platform\pthread_win32\pthreadVC2.lib</AdditionalDependencies>
+      <AdditionalDependencies>%(AdditionalDependencies);setupapi.lib</AdditionalDependencies>
+      <IgnoreSpecificDefaultLibraries>libcmt</IgnoreSpecificDefaultLibraries>
+      <Version>
+      </Version>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level4</WarningLevel>
+      <Optimization>Full</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>_WIN64;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <DisableSpecificWarnings>
+      </DisableSpecificWarnings>
+      <TreatWarningAsError>true</TreatWarningAsError>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <OutputFile>$(SolutionDir)..\$(TargetName)$(TargetExt)</OutputFile>
+      <AdditionalDependencies>%(AdditionalDependencies);setupapi.lib</AdditionalDependencies>
       <IgnoreSpecificDefaultLibraries>libcmt</IgnoreSpecificDefaultLibraries>
       <Version>
       </Version>
index 6eb83102eed2031e3080ce0daae6a6f7d35f8a0d..1298c5c374bc4092c659f6cde11316bc5be12961 100644 (file)
@@ -1,9 +1,6 @@
 ï»¿<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
-    <Filter Include="util">
-      <UniqueIdentifier>{4171e8da-4c9d-40dd-97a3-755ba5535ca6}</UniqueIdentifier>
-    </Filter>
     <Filter Include="platform">
       <UniqueIdentifier>{cc48ddc0-be11-43ec-a805-3a9434f443ed}</UniqueIdentifier>
     </Filter>
     <Filter Include="devices">
       <UniqueIdentifier>{bfc43a58-636d-4c1a-b191-486cb8509c7c}</UniqueIdentifier>
     </Filter>
-    <Filter Include="platform\pthread_win32">
-      <UniqueIdentifier>{61b13ee2-8a5b-4f05-9796-08138ee6ebc1}</UniqueIdentifier>
+    <Filter Include="platform\windows">
+      <UniqueIdentifier>{fa3d5953-d288-45e9-93f4-8419e6b701c7}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="platform\serialport">
+      <UniqueIdentifier>{e3945145-efa2-4393-b201-f50e1e775008}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="platform\threads">
+      <UniqueIdentifier>{38a27e9e-86ad-46f6-a4fb-e1e524267b74}</UniqueIdentifier>
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="..\src\lib\util\buffer.h">
-      <Filter>util</Filter>
-    </ClInclude>
-    <ClInclude Include="..\src\lib\util\StdString.h">
-      <Filter>util</Filter>
-    </ClInclude>
     <ClInclude Include="..\src\lib\AdapterCommunication.h" />
     <ClInclude Include="..\src\lib\AdapterDetection.h" />
     <ClInclude Include="..\src\lib\CECProcessor.h" />
     <ClInclude Include="..\src\lib\LibCEC.h" />
-    <ClInclude Include="..\src\lib\platform\baudrate.h">
-      <Filter>platform</Filter>
-    </ClInclude>
-    <ClInclude Include="..\src\lib\platform\os-dependent.h">
-      <Filter>platform</Filter>
-    </ClInclude>
-    <ClInclude Include="..\src\lib\platform\serialport.h">
-      <Filter>platform</Filter>
-    </ClInclude>
-    <ClInclude Include="..\src\lib\platform\threads.h">
-      <Filter>platform</Filter>
-    </ClInclude>
     <ClInclude Include="..\src\lib\platform\timeutils.h">
       <Filter>platform</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\lib\platform\windows\dlfcn-win32.h">
-      <Filter>platform</Filter>
-    </ClInclude>
-    <ClInclude Include="..\src\lib\platform\windows\os_windows.h">
-      <Filter>platform</Filter>
-    </ClInclude>
     <ClInclude Include="..\include\cec.h">
       <Filter>exports</Filter>
     </ClInclude>
@@ -76,7 +55,6 @@
     <ClInclude Include="..\src\lib\devices\CECBusDevice.h">
       <Filter>devices</Filter>
     </ClInclude>
-    <ClInclude Include="resource.h" />
     <ClInclude Include="..\src\lib\implementations\VLCommandHandler.h">
       <Filter>implementations</Filter>
     </ClInclude>
     <ClInclude Include="..\src\lib\devices\CECTV.h">
       <Filter>devices</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\lib\platform\posix\pthreads.h">
+    <ClInclude Include="..\src\lib\platform\os.h">
       <Filter>platform</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\lib\platform\pthread_win32\pthread.h">
-      <Filter>platform\pthread_win32</Filter>
+    <ClInclude Include="..\src\lib\platform\windows\os-threads.h">
+      <Filter>platform\windows</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\lib\platform\windows\os-types.h">
+      <Filter>platform\windows</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\lib\platform\pthread_win32\sched.h">
-      <Filter>platform\pthread_win32</Filter>
+    <ClInclude Include="..\src\lib\platform\serialport\baudrate.h">
+      <Filter>platform\serialport</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\lib\platform\pthread_win32\semaphore.h">
-      <Filter>platform\pthread_win32</Filter>
+    <ClInclude Include="..\src\lib\platform\serialport\serialport.h">
+      <Filter>platform\serialport</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\lib\platform\threads\mutex.h">
+      <Filter>platform\threads</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\lib\platform\threads\threads.h">
+      <Filter>platform\threads</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\lib\platform\buffer.h">
+      <Filter>platform</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\lib\platform\StdString.h">
+      <Filter>platform</Filter>
     </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\src\lib\LibCEC.cpp" />
     <ClCompile Include="..\src\lib\LibCECC.cpp" />
     <ClCompile Include="..\src\lib\LibCECDll.cpp" />
-    <ClCompile Include="..\src\lib\platform\threads.cpp">
-      <Filter>platform</Filter>
-    </ClCompile>
-    <ClCompile Include="..\src\lib\platform\windows\dlfcn-win32.cpp">
-      <Filter>platform</Filter>
-    </ClCompile>
-    <ClCompile Include="..\src\lib\platform\windows\os_windows.cpp">
-      <Filter>platform</Filter>
-    </ClCompile>
-    <ClCompile Include="..\src\lib\platform\windows\serialport.cpp">
-      <Filter>platform</Filter>
-    </ClCompile>
     <ClCompile Include="..\src\lib\implementations\ANCommandHandler.cpp">
       <Filter>implementations</Filter>
     </ClCompile>
     <ClCompile Include="..\src\lib\devices\CECTV.cpp">
       <Filter>devices</Filter>
     </ClCompile>
-    <ClCompile Include="..\src\lib\platform\posix\pthreads.cpp">
-      <Filter>platform</Filter>
+    <ClCompile Include="..\src\lib\platform\windows\serialport.cpp">
+      <Filter>platform\serialport</Filter>
     </ClCompile>
   </ItemGroup>
   <ItemGroup>
index 3397574854b1f219863d69ce808cb6377afa75d1..1d1a9bdf8ab5cfc9f4ebae9970611871b6293b1d 100644 (file)
@@ -5,10 +5,18 @@
       <Configuration>Debug</Configuration>
       <Platform>Win32</Platform>
     </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
     <ProjectConfiguration Include="Release|Win32">
       <Configuration>Release</Configuration>
       <Platform>Win32</Platform>
     </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
   </ItemGroup>
   <PropertyGroup Label="Globals">
     <ProjectGuid>{F01222BF-6B3D-43BD-B254-434031CB9887}</ProjectGuid>
     <UseDebugLibraries>true</UseDebugLibraries>
     <CharacterSet>MultiByte</CharacterSet>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
     <UseDebugLibraries>false</UseDebugLibraries>
     <CharacterSet>MultiByte</CharacterSet>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <ImportGroup Label="ExtensionSettings">
   </ImportGroup>
   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
     <OutDir>$(SolutionDir)..\</OutDir>
     <TargetName>cec-client</TargetName>
   </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <LinkIncremental>true</LinkIncremental>
+    <OutDir>$(SolutionDir)..\</OutDir>
+    <TargetName>cec-client.x64</TargetName>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <OutDir>$(SolutionDir)..\</OutDir>
     <TargetName>cec-client</TargetName>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <OutDir>$(SolutionDir)..\</OutDir>
+    <TargetName>cec-client.x64</TargetName>
+  </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <PrecompiledHeader>
       </PrecompiledHeader>
       <WarningLevel>Level4</WarningLevel>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE_32BIT_TIME_T;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;__WINDOWS__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_USE_32BIT_TIME_T;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <TreatWarningAsError>true</TreatWarningAsError>
+      <DisableSpecificWarnings>
+      </DisableSpecificWarnings>
+      <AdditionalIncludeDirectories>$(SolutiontDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+      <OutputFile>$(SolutionDir)..\$(TargetName)$(TargetExt)</OutputFile>
+      <Version>
+      </Version>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level4</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_WIN64;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <TreatWarningAsError>true</TreatWarningAsError>
-      <DisableSpecificWarnings>4100;4309;4505</DisableSpecificWarnings>
+      <DisableSpecificWarnings>
+      </DisableSpecificWarnings>
       <AdditionalIncludeDirectories>$(SolutiontDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <SubSystem>Console</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>$(ProjectDir)..\src\lib\platform\pthread_win32\pthreadVC2.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <OutputFile>$(SolutionDir)..\cec-client.exe</OutputFile>
+      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+      <OutputFile>$(SolutionDir)..\$(TargetName)$(TargetExt)</OutputFile>
       <Version>
       </Version>
     </Link>
       <Optimization>Full</Optimization>
       <FunctionLevelLinking>false</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>_WIN32;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE_32BIT_TIME_T;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;__WINDOWS__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_USE_32BIT_TIME_T;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <TreatWarningAsError>true</TreatWarningAsError>
+      <DisableSpecificWarnings>
+      </DisableSpecificWarnings>
+      <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>false</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
+      <Version>
+      </Version>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level4</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>Full</Optimization>
+      <FunctionLevelLinking>false</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>_WIN64;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <TreatWarningAsError>true</TreatWarningAsError>
-      <DisableSpecificWarnings>4100;4309</DisableSpecificWarnings>
+      <DisableSpecificWarnings>
+      </DisableSpecificWarnings>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>false</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>$(ProjectDir)..\src\lib\platform\pthread_win32\pthreadVC2.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
       <Version>
       </Version>
+      <OutputFile>$(SolutionDir)..\$(TargetName)$(TargetExt)</OutputFile>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClInclude Include="..\include\cec.h" />
     <ClInclude Include="..\include\cecloader.h" />
-    <ClInclude Include="..\src\lib\platform\os-dependent.h" />
-    <ClInclude Include="..\src\lib\platform\posix\pthreads.h" />
-    <ClInclude Include="..\src\lib\platform\threads.h" />
-    <ClInclude Include="..\src\lib\platform\windows\os_windows.h" />
-    <ClInclude Include="..\src\lib\util\StdString.h" />
-    <ClInclude Include="resource1.h" />
+    <ClInclude Include="..\src\lib\platform\os.h" />
+    <ClInclude Include="..\src\lib\platform\threads\mutex.h" />
+    <ClInclude Include="..\src\lib\platform\threads\threads.h" />
+    <ClInclude Include="..\src\lib\platform\timeutils.h" />
+    <ClInclude Include="..\src\lib\platform\windows\dlfcn-win32.h" />
+    <ClInclude Include="..\src\lib\platform\windows\os-threads.h" />
+    <ClInclude Include="..\src\lib\platform\windows\os-types.h" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="..\src\lib\platform\posix\pthreads.cpp" />
-    <ClCompile Include="..\src\lib\platform\threads.cpp" />
-    <ClCompile Include="..\src\lib\platform\windows\os_windows.cpp" />
+    <ClCompile Include="..\src\lib\platform\windows\dlfcn-win32.cpp" />
     <ClCompile Include="..\src\testclient\main.cpp" />
   </ItemGroup>
   <ItemGroup>
index 4dcb38c5ac08b8793ae16aff149dd65c08bc0113..45e1fe0ece70c9e6c66d01c962bc453cb0913a59 100644 (file)
@@ -1,62 +1,55 @@
 ï»¿<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    <Filter Include="exports">
+      <UniqueIdentifier>{cc0a01c1-e1e7-4af8-9656-fa9463140613}</UniqueIdentifier>
     </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    <Filter Include="platform">
+      <UniqueIdentifier>{f08c0a80-22d9-4bdd-90de-b9cf5fa88f99}</UniqueIdentifier>
     </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    <Filter Include="platform\threads">
+      <UniqueIdentifier>{fb28e188-b2a5-48d3-9010-b56024b19850}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="platform\windows">
+      <UniqueIdentifier>{a8b22b54-3252-44fb-a499-e42f9bac0e15}</UniqueIdentifier>
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="..\src\lib\util\StdString.h">
-      <Filter>Header Files</Filter>
+    <ClInclude Include="..\include\cec.h">
+      <Filter>exports</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\lib\platform\threads.h">
-      <Filter>Header Files</Filter>
+    <ClInclude Include="..\include\cecloader.h">
+      <Filter>exports</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\lib\platform\os-dependent.h">
-      <Filter>Header Files</Filter>
+    <ClInclude Include="..\src\lib\platform\os.h">
+      <Filter>platform</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\lib\platform\windows\os_windows.h">
-      <Filter>Header Files</Filter>
+    <ClInclude Include="..\src\lib\platform\timeutils.h">
+      <Filter>platform</Filter>
     </ClInclude>
-    <ClInclude Include="..\include\cec.h">
-      <Filter>Header Files</Filter>
+    <ClInclude Include="..\src\lib\platform\windows\dlfcn-win32.h">
+      <Filter>platform\windows</Filter>
     </ClInclude>
-    <ClInclude Include="..\include\cecloader.h">
-      <Filter>Header Files</Filter>
+    <ClInclude Include="..\src\lib\platform\windows\os-threads.h">
+      <Filter>platform\windows</Filter>
     </ClInclude>
-    <ClInclude Include="resource1.h">
-      <Filter>Header Files</Filter>
+    <ClInclude Include="..\src\lib\platform\windows\os-types.h">
+      <Filter>platform\windows</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\lib\platform\posix\pthreads.h">
-      <Filter>Header Files</Filter>
+    <ClInclude Include="..\src\lib\platform\threads\mutex.h">
+      <Filter>platform\threads</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\lib\platform\threads\threads.h">
+      <Filter>platform\threads</Filter>
     </ClInclude>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="..\src\testclient\main.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\src\lib\platform\threads.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\src\lib\platform\windows\os_windows.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\src\lib\platform\posix\pthreads.cpp">
-      <Filter>Source Files</Filter>
+    <ClCompile Include="..\src\testclient\main.cpp" />
+    <ClCompile Include="..\src\lib\platform\windows\dlfcn-win32.cpp">
+      <Filter>platform\windows</Filter>
     </ClCompile>
   </ItemGroup>
   <ItemGroup>
-    <ResourceCompile Include="testclient.rc">
-      <Filter>Resource Files</Filter>
-    </ResourceCompile>
+    <ResourceCompile Include="testclient.rc" />
   </ItemGroup>
 </Project>
\ No newline at end of file
diff --git a/pthreadVC2.dll b/pthreadVC2.dll
deleted file mode 100644 (file)
index fdea676..0000000
Binary files a/pthreadVC2.dll and /dev/null differ
index 9697759e4e081bfa65da88a235148e456b229725..faa15aa27100e2f1dcc32e9b86aafd047c999b53 100644 (file)
 #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();
 }
index d076a2facec6ce2a3f4f42c0d59096908c0fdf05..97cd18d2f3b1debbc01207509dbe4ac94e4103d5 100644 (file)
  */
 
 #include <cectypes.h>
-#include "util/buffer.h"
-#include <string>
-#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<uint8_t>               m_inBuffer;
-    CecBuffer<CCECAdapterMessage *>  m_outBuffer;
-    CMutex                           m_mutex;
-    CCondition                       m_rcvCondition;
-    CCondition                       m_startCondition;
-    uint8_t                          m_iLineTimeout;
+    PLATFORM::CSerialPort *                      m_port;
+    CCECProcessor *                              m_processor;
+    PLATFORM::SyncedBuffer<uint8_t>              m_inBuffer;
+    PLATFORM::SyncedBuffer<CCECAdapterMessage *> m_outBuffer;
+    PLATFORM::CMutex                             m_mutex;
+    PLATFORM::CCondition                         m_rcvCondition;
+    PLATFORM::CCondition                         m_startCondition;
+    uint8_t                                      m_iLineTimeout;
   };
 };
index f06809975abc49300558e06780b4445633f6dd6c..168f1a4d1424eeac2811affd99980fc8290ebd6d 100644 (file)
@@ -31,8 +31,7 @@
  */
 
 #include "AdapterDetection.h"
-#include "platform/os-dependent.h"
-#include "util/StdString.h"
+#include "platform/os.h"
 
 #if defined(__APPLE__)
 #include <dirent.h>
index 798c38a422cda0c8a855cac235a898d849961cc3..9ed9b23b8405c63b811bb2d065cad7a26a8698b9 100644 (file)
 #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");
index 5064b9c561271cf47f50c897b2fabbbfb75efde4..8e6fae9044180b50fd7ace5d224f261e9e86fe39 100644 (file)
@@ -34,9 +34,7 @@
 #include <string>
 #include <cectypes.h>
 #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<cec_command> 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<cec_command> 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; }
index 52dfa515776a7beada82a77e5c831b7f24209945..29cc3f48abaf944e5214eed70158e7a509815c7c 100644 (file)
 #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);
index ef1ded29f5c5fdee7272f4fd44f5f8b1e33513b9..20b6ccd6f8cd0879bfe8d083a8cbe9c42a60a26a 100644 (file)
@@ -33,7 +33,7 @@
 
 #include <string>
 #include <cec.h>
-#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<cec_log_message> m_logBuffer;
-      CecBuffer<cec_keypress>    m_keyBuffer;
-      CecBuffer<cec_command>     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<cec_log_message> m_logBuffer;
+      PLATFORM::SyncedBuffer<cec_keypress>    m_keyBuffer;
+      PLATFORM::SyncedBuffer<cec_command>     m_commandBuffer;
+      ICECCallbacks *                         m_callbacks;
+      void *                                  m_cbParam;
+      PLATFORM::CMutex                        m_mutex;
   };
 };
index adcbafab0d7d52ba3397a4fc9514955264ac67b3..9ccd4c7ffc00c3c648395e5d5251610a4a17c464 100644 (file)
@@ -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
index 87b45057d3060d9d2475158d73682f1df6baa167..7bdb0912de46d6b2b80431535f0daa1badc6cc93 100644 (file)
@@ -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;
 }
index d6e447f96303f44cf91735807601704451a01df0..a907fc8fd22d2950c649d8e49123adc52a344443 100644 (file)
@@ -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();
 }
 
index 5d835c7b47eaf52115b58442a716a13ca0711166..412504e1987286b1d849eebee53c2de7b4516b61 100644 (file)
@@ -33,8 +33,7 @@
 
 #include <cectypes.h>
 #include <set>
-#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<cec_opcode>  m_unsupportedFeatures;
-    CMutex                m_mutex;
-    CMutex                m_handlerMutex;
+    PLATFORM::CMutex      m_mutex;
+    PLATFORM::CMutex      m_handlerMutex;
   };
 };
index 4969de58c4af45bc442a0953016c3638d1014a1d..f9689cbe81a5ffb8816f12bed4995802f382a5b0 100644 (file)
@@ -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);
index 248a959368c6eacdf9f6cf470958a5711af720ad..bf9dea52a25d982c027bc5345f06421f0094561a 100644 (file)
@@ -33,7 +33,6 @@
 #include "ANCommandHandler.h"
 #include "../devices/CECBusDevice.h"
 #include "../CECProcessor.h"
-#include "../util/StdString.h"
 
 using namespace CEC;
 
index 5df30f44a272a172ba5e7fb65dfefe46696a96b7..d407e40221df6aad75f61c354ee5d8ddca96a455 100644 (file)
@@ -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<CCECBusDevice *> 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;
 }
index f3d3d0c5fa4cb2bb06609bc1c823d7b01a2abf3d..f1e0924e9db5ebd0caa7ee2a71e3f21f8c91633d 100644 (file)
@@ -33,8 +33,7 @@
 
 #include <cectypes.h>
 #include <vector>
-#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;
   };
 };
index 7a357d319f7d003c5ab086f191448c460016006a..67018a8e82b60a5ee27f812994d9d610e5f762ac 100644 (file)
@@ -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;
 
similarity index 89%
rename from src/lib/util/buffer.h
rename to src/lib/platform/buffer.h
index e0afddfa16d1daaf52af97f6fee5fbd5c7e4b0e9..227b7565edcd7a438991d12b6355301336df65f9 100644 (file)
  *     http://www.pulse-eight.net/
  */
 
-#include "../platform/os-dependent.h"
+#include "os.h"
 #include <queue>
 
-namespace CEC
+namespace PLATFORM
 {
   template<typename _BType>
-    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 (file)
index 90e42ab..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- *
- */
-
-#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"
similarity index 52%
rename from src/lib/platform/threads.cpp
rename to src/lib/platform/os.h
index c9f6c16214f652fb0179e669014cd44885da34f6..fbe090342986ce0e7bc67fd5ad3099ce33994df6 100644 (file)
@@ -1,3 +1,4 @@
+#pragma once
 /*
  * This file is part of the libCEC(R) library.
  *
  *     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 (file)
index 0000000..9f7a688
--- /dev/null
@@ -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       <license@pulse-eight.com>
+ *     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);
+  }
+}
similarity index 95%
rename from src/lib/platform/posix/os_posix.h
rename to src/lib/platform/posix/os-types.h
index 65d2f27eda0425f6b57ccad0ad661457c9d6b2bb..99bacb3a0ee868683384ab5e72843824516037cb 100644 (file)
 #include <errno.h>
 #include <sys/time.h>
 #ifndef __APPLE__
-#include <sys/prctl.h> 
+#include <sys/prctl.h>
 #endif
 #include <pthread.h>
 #include <poll.h>
 #include <semaphore.h>
+#include <stdint.h>
 
 #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 (file)
index e5b4cf1..0000000
+++ /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       <license@pulse-eight.com>
- *     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<CMutex *>(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;
-}
index f0408574dad1670238a571ab0dcadfb8acedcff3..ec8a5c1d48e2f4ea14160ab5bd51719de318a81b 100644 (file)
@@ -32,8 +32,8 @@
 
 #include <stdio.h>
 #include <fcntl.h>
-#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 (file)
index a3140e1..0000000
+++ /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 <rpj@callisto.canberra.edu.au>
- *
- * 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 <windows.h>
-#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 <time.h>
-#else /* NEED_FTIME */
-/* use native WIN32 time API */
-#endif /* NEED_FTIME */
-
-#if HAVE_SIGNAL_H
-#include <signal.h>
-#endif /* HAVE_SIGNAL_H */
-
-#include <setjmp.h>
-#include <limits.h>
-
-/*
- * 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 <errno.h>
-#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 <unistd.h>, 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 <limits.h>, 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     <sys/types.h>
-#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 <signal.h> 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 (file)
index bc36770..0000000
Binary files a/src/lib/platform/pthread_win32/pthreadVC2.lib and /dev/null differ
diff --git a/src/lib/platform/pthread_win32/sched.h b/src/lib/platform/pthread_win32/sched.h
deleted file mode 100644 (file)
index dfb8e93..0000000
+++ /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 <errno.h>
-#endif
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-#if defined(__MINGW32__) || defined(_UWIN)
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-/* For pid_t */
-#  include <sys/types.h>
-/* Required by Unix 98 */
-#  include <time.h>
-#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 (file)
index a3330a6..0000000
+++ /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 <errno.h>
-#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 */
similarity index 95%
rename from src/lib/platform/baudrate.h
rename to src/lib/platform/serialport/baudrate.h
index 98521bbb8a9361c1d6d09e19f018eaef6644787e..bfdb2d73e87e386621cc34694f521d54cea03e20 100644 (file)
 //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 <termios.h>
 #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;
similarity index 75%
rename from src/lib/platform/serialport.h
rename to src/lib/platform/serialport/serialport.h
index f5035b908f21705a57bdee173b5e127784145198..3710bfecd52fb0579ad83810a875c6e4513cdfb4 100644 (file)
  *     http://www.pulse-eight.net/
  */
 
-#include "os-dependent.h"
-#include <cectypes.h>
+#include "../os.h"
 #include <string>
 #include <stdint.h>
-#include "../AdapterCommunication.h"
-#include "../platform/threads.h"
 
 #ifndef __WINDOWS__
 #include <termios.h>
-#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<uint8_t> 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<uint8_t> 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 (file)
index 2c3c2c5..0000000
+++ /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       <license@pulse-eight.com>
- *     http://www.pulse-eight.com/
- *     http://www.pulse-eight.net/
- */
-
-#include <stdint.h>
-
-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 (file)
index 0000000..4a2ad79
--- /dev/null
@@ -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       <license@pulse-eight.com>
+ *     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 (file)
index 0000000..74d683f
--- /dev/null
@@ -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       <license@pulse-eight.com>
+ *     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<CThread *>(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;
+  };
+};
index f05f7e7139b598b98c820c7bf8c6091e46461847..b2f613add0d85657015a72ab667f46360c9699a4 100644 (file)
 #include <sys/time.h>
 #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(&current);
+
+    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 (file)
index 0000000..0e73868
--- /dev/null
@@ -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       <license@pulse-eight.com>
+ *     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
+}
similarity index 58%
rename from src/lib/platform/posix/pthreads.h
rename to src/lib/platform/windows/os-types.h
index b39c1e99cda2e24764143b43eceaa18a68103735..3943510fbad76ec8e55097d411d770b88044a331 100644 (file)
  *     http://www.pulse-eight.net/
  */
 
-#include "../threads.h"
+#pragma warning(disable:4005) // Disable "warning C4005: '_WINSOCKAPI_' : macro redefinition"
+#include <winsock2.h>
+#pragma warning(default:4005)
 
-namespace CEC
-{
-  class CMutex : public IMutex
-  {
-  public:
-    CMutex(bool bRecursive = true);
-    virtual ~CMutex(void);
+#include <sys/timeb.h>
+#include <io.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stddef.h>
+#include <process.h>
 
-    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 (file)
index 429730d..0000000
+++ /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 <sys/timeb.h>
-
-int gettimeofday(struct timeval *pcur_time, struct timezone *tz)
-{
-  if (pcur_time == NULL)
-  {
-    SetLastError(EFAULT);
-    return -1;
-  }
-  struct _timeb current;
-
-  _ftime(&current);
-
-  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 (file)
index 90cc75e..0000000
+++ /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 <winsock2.h>
-#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 <stddef.h>
-#include <process.h>
-#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 <io.h>
-#include <stdlib.h>
-#include <errno.h>
-
-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);
index 9e4cc486e64138a56185f1f3d30b357cc74005bd..8e513fc7f1c6c87f607603786a16ddbf79552090 100644 (file)
  *     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;
 }
index 14b36f818821ddbe2d679ae9872428d9d84fb5c0..726cf621d352212e7b03306d8d975f1f263387bb 100644 (file)
@@ -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
index 256a484e47cb91e8da42a21dca9d04619e025cd5..8178449cee36d7f805d7e4923b783ed404ec7852 100644 (file)
 #include <fstream>
 #include <string>
 #include <sstream>
-#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 <<