VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform/Unix/SyncEvent.cpp
blob: d58240e882b3ee2b1474e9677d942d68d3e31de5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.

 Governed by the TrueCrypt License 3.0 the full text of which is contained in
 the file License.txt included in TrueCrypt binary and source code distribution
 packages.
*/

#include "Platform/Exception.h"
#include "Platform/SyncEvent.h"
#include "Platform/SystemException.h"

namespace VeraCrypt
{
	SyncEvent::SyncEvent ()
	{
		int status = pthread_cond_init (&SystemSyncEvent, nullptr);
		if (status != 0)
			throw SystemException (SRC_POS, status);

		Signaled = false;
		Initialized = true;
	}

	SyncEvent::~SyncEvent ()
	{
#ifdef DEBUG
		int status =
#endif
		pthread_cond_destroy (&SystemSyncEvent);

#ifdef DEBUG
		if (status != 0)
			SystemLog::WriteException (SystemException (SRC_POS, status));
#endif

		Initialized = false;
	}

	void SyncEvent::Signal ()
	{
		assert (Initialized);

		ScopeLock lock (EventMutex);

		Signaled = true;

		int status = pthread_cond_signal (&SystemSyncEvent);
		if (status != 0)
			throw SystemException (SRC_POS, status);
	}

	void SyncEvent::Wait ()
	{
		assert (Initialized);

		ScopeLock lock (EventMutex);

		while (!Signaled)
		{
			int status = pthread_cond_wait (&SystemSyncEvent, EventMutex.GetSystemHandle());
			if (status != 0)
				throw SystemException (SRC_POS, status);
		}
		
		Signaled = false;
	}
}
kground-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <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>
    <ClCompile Include="libzip\mkstemp.c" />
    <ClCompile Include="libzip\zip_add.c" />
    <ClCompile Include="libzip\zip_add_dir.c" />
    <ClCompile Include="libzip\zip_add_entry.c" />
    <ClCompile Include="libzip\zip_algorithm_deflate.c" />
    <ClCompile Include="libzip\zip_buffer.c" />
    <ClCompile Include="libzip\zip_close.c" />
    <ClCompile Include="libzip\zip_delete.c" />
    <ClCompile Include="libzip\zip_dirent.c" />
    <ClCompile Include="libzip\zip_dir_add.c" />
    <ClCompile Include="libzip\zip_discard.c" />
    <ClCompile Include="libzip\zip_entry.c" />
    <ClCompile Include="libzip\zip_error.c" />
    <ClCompile Include="libzip\zip_error_clear.c" />
    <ClCompile Include="libzip\zip_error_get.c" />
    <ClCompile Include="libzip\zip_error_get_sys_type.c" />
    <ClCompile Include="libzip\zip_error_strerror.c" />
    <ClCompile Include="libzip\zip_err_str.c" />
    <ClCompile Include="libzip\zip_extra_field.c" />
    <ClCompile Include="libzip\zip_extra_field_api.c" />
    <ClCompile Include="libzip\zip_fclose.c" />
    <ClCompile Include="libzip\zip_fdopen.c" />
    <ClCompile Include="libzip\zip_filerange_crc.c" />
    <ClCompile Include="libzip\zip_file_add.c" />
    <ClCompile Include="libzip\zip_file_error_clear.c" />
    <ClCompile Include="libzip\zip_file_error_get.c" />
    <ClCompile Include="libzip\zip_file_get_comment.c" />
    <ClCompile Include="libzip\zip_file_get_external_attributes.c" />
    <ClCompile Include="libzip\zip_file_get_offset.c" />
    <ClCompile Include="libzip\zip_file_rename.c" />
    <ClCompile Include="libzip\zip_file_replace.c" />
    <ClCompile Include="libzip\zip_file_set_comment.c" />
    <ClCompile Include="libzip\zip_file_set_external_attributes.c" />
    <ClCompile Include="libzip\zip_file_set_mtime.c" />
    <ClCompile Include="libzip\zip_file_strerror.c" />
    <ClCompile Include="libzip\zip_fopen.c" />
    <ClCompile Include="libzip\zip_fopen_encrypted.c" />
    <ClCompile Include="libzip\zip_fopen_index.c" />
    <ClCompile Include="libzip\zip_fopen_index_encrypted.c" />
    <ClCompile Include="libzip\zip_fread.c" />
    <ClCompile Include="libzip\zip_get_archive_comment.c" />
    <ClCompile Include="libzip\zip_get_archive_flag.c" />
    <ClCompile Include="libzip\zip_get_encryption_implementation.c" />
    <ClCompile Include="libzip\zip_get_file_comment.c" />
    <ClCompile Include="libzip\zip_get_name.c" />
    <ClCompile Include="libzip\zip_get_num_entries.c" />
    <ClCompile Include="libzip\zip_get_num_files.c" />
    <ClCompile Include="libzip\zip_hash.c" />
    <ClCompile Include="libzip\zip_io_util.c" />
    <ClCompile Include="libzip\zip_memdup.c" />
    <ClCompile Include="libzip\zip_name_locate.c" />
    <ClCompile Include="libzip\zip_new.c" />
    <ClCompile Include="libzip\zip_open.c" />
    <ClCompile Include="libzip\zip_progress.c" />
    <ClCompile Include="libzip\zip_rename.c" />
    <ClCompile Include="libzip\zip_replace.c" />
    <ClCompile Include="libzip\zip_set_archive_comment.c" />
    <ClCompile Include="libzip\zip_set_archive_flag.c" />
    <ClCompile Include="libzip\zip_set_default_password.c" />
    <ClCompile Include="libzip\zip_set_file_comment.c" />
    <ClCompile Include="libzip\zip_set_file_compression.c" />
    <ClCompile Include="libzip\zip_set_name.c" />
    <ClCompile Include="libzip\zip_source_begin_write.c" />
    <ClCompile Include="libzip\zip_source_begin_write_cloning.c" />
    <ClCompile Include="libzip\zip_source_buffer.c" />
    <ClCompile Include="libzip\zip_source_call.c" />
    <ClCompile Include="libzip\zip_source_close.c" />
    <ClCompile Include="libzip\zip_source_commit_write.c" />
    <ClCompile Include="libzip\zip_source_compress.c" />
    <ClCompile Include="libzip\zip_source_crc.c" />
    <ClCompile Include="libzip\zip_source_deflate.c" />
    <ClCompile Include="libzip\zip_source_error.c" />
    <ClCompile Include="libzip\zip_source_filep.c" />
    <ClCompile Include="libzip\zip_source_free.c" />
    <ClCompile Include="libzip\zip_source_function.c" />
    <ClCompile Include="libzip\zip_source_get_compression_flags.c" />
    <ClCompile Include="libzip\zip_source_is_deleted.c" />
    <ClCompile Include="libzip\zip_source_layered.c" />
    <ClCompile Include="libzip\zip_source_open.c" />
    <ClCompile Include="libzip\zip_source_pkware.c" />
    <ClCompile Include="libzip\zip_source_read.c" />
    <ClCompile Include="libzip\zip_source_remove.c" />
    <ClCompile Include="libzip\zip_source_rollback_write.c" />
    <ClCompile Include="libzip\zip_source_seek.c" />
    <ClCompile Include="libzip\zip_source_seek_write.c" />
    <ClCompile Include="libzip\zip_source_stat.c" />
    <ClCompile Include="libzip\zip_source_supports.c" />
    <ClCompile Include="libzip\zip_source_tell.c" />
    <ClCompile Include="libzip\zip_source_tell_write.c" />
    <ClCompile Include="libzip\zip_source_win32a.c" />
    <ClCompile Include="libzip\zip_source_win32handle.c" />
    <ClCompile Include="libzip\zip_source_win32utf8.c" />
    <ClCompile Include="libzip\zip_source_win32w.c" />
    <ClCompile Include="libzip\zip_source_window.c" />
    <ClCompile Include="libzip\zip_source_write.c" />
    <ClCompile Include="libzip\zip_source_zip.c" />
    <ClCompile Include="libzip\zip_source_zip_new.c" />
    <ClCompile Include="libzip\zip_stat.c" />
    <ClCompile Include="libzip\zip_stat_index.c" />
    <ClCompile Include="libzip\zip_stat_init.c" />
    <ClCompile Include="libzip\zip_strerror.c" />
    <ClCompile Include="libzip\zip_string.c" />
    <ClCompile Include="libzip\zip_unchange.c" />
    <ClCompile Include="libzip\zip_unchange_all.c" />
    <ClCompile Include="libzip\zip_unchange_archive.c" />
    <ClCompile Include="libzip\zip_unchange_data.c" />
    <ClCompile Include="libzip\zip_utf-8.c" />
    <ClCompile Include="zlib\adler32.c" />
    <ClCompile Include="zlib\compress.c" />
    <ClCompile Include="zlib\crc32.c" />
    <ClCompile Include="zlib\deflate.c" />
    <ClCompile Include="zlib\inffast.c" />
    <ClCompile Include="zlib\inflate.c" />
    <ClCompile Include="zlib\inftrees.c" />
    <ClCompile Include="zlib\trees.c" />
    <ClCompile Include="zlib\uncompr.c" />
    <ClCompile Include="zlib\zutil.c" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="libzip\compat.h" />
    <ClInclude Include="libzip\config.h" />
    <ClInclude Include="libzip\zconf.h" />
    <ClInclude Include="libzip\zip.h" />
    <ClInclude Include="libzip\zipconf.h" />
    <ClInclude Include="libzip\zipint.h" />
    <ClInclude Include="libzip\zipwin32.h" />
    <ClInclude Include="zlib\crc32.h" />
    <ClInclude Include="zlib\deflate.h" />
    <ClInclude Include="zlib\inffast.h" />
    <ClInclude Include="zlib\inffixed.h" />
    <ClInclude Include="zlib\inflate.h" />
    <ClInclude Include="zlib\inftrees.h" />
    <ClInclude Include="zlib\trees.h" />
    <ClInclude Include="zlib\zconf.h" />
    <ClInclude Include="zlib\zlib.h" />
    <ClInclude Include="zlib\zutil.h" />
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}</ProjectGuid>
    <Keyword>Win32Proj</Keyword>
    <RootNamespace>Zip</RootNamespace>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <CharacterSet>Unicode</CharacterSet>
    <PlatformToolset>Windows7.1SDK</PlatformToolset>
    <WholeProgramOptimization>false</WholeProgramOptimization>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <CharacterSet>Unicode</CharacterSet>
    <PlatformToolset>Windows7.1SDK</PlatformToolset>
    <WholeProgramOptimization>false</WholeProgramOptimization>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>false</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
    <PlatformToolset>Windows7.1SDK</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>StaticLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>false</WholeProgramOptimization>
    <CharacterSet>Unicode</CharacterSet>
    <PlatformToolset>Windows7.1SDK</PlatformToolset>
  </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|x64'">
    <OutDir>$(Platform)\$(Configuration)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <OutDir>$(Platform)\$(Configuration)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <OutDir>$(Configuration)\</OutDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <OutDir>$(Configuration)\</OutDir>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_LIB;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
      <AdditionalIncludeDirectories>zlib;libzip</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_LIB;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
      <AdditionalIncludeDirectories>zlib;libzip</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_LIB;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
      <AdditionalIncludeDirectories>zlib;libzip</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_LIB;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
      <AdditionalIncludeDirectories>zlib;libzip</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
    </Link>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>