EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testtime", "test\testtime.vcxproj", "{B74812A1-C67D-4568-AF84-26CE2004D8BF}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testmmap", "test\testmmap.vcxproj", "{7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
{B74812A1-C67D-4568-AF84-26CE2004D8BF}.Release|x64.Build.0 = Release|x64
{B74812A1-C67D-4568-AF84-26CE2004D8BF}.Release|x86.ActiveCfg = Release|Win32
{B74812A1-C67D-4568-AF84-26CE2004D8BF}.Release|x86.Build.0 = Release|Win32
- {7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03}.Debug|x64.ActiveCfg = Debug|x64
- {7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03}.Debug|x64.Build.0 = Debug|x64
- {7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03}.Debug|x86.ActiveCfg = Debug|Win32
- {7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03}.Debug|x86.Build.0 = Debug|Win32
- {7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03}.Release|x64.ActiveCfg = Release|x64
- {7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03}.Release|x64.Build.0 = Release|x64
- {7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03}.Release|x86.ActiveCfg = Release|Win32
- {7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
<ClCompile Include="src\ks_time.c" />
<ClCompile Include="src\kws.c" />
<ClCompile Include="src\simclist.c" />
- <ClCompile Include="src\win\mman.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="crypt\aes.h" />
<ClInclude Include="src\include\kws.h" />
<ClInclude Include="src\include\simclist.h" />
<ClInclude Include="src\win\mman.h" />
- <ClInclude Include="src\win\sys\mman.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<ClCompile Include="src\simclist.c">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\win\mman.c">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\ks_pool.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClInclude Include="crypt\sha2.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\win\sys\mman.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\include\ks_acl.h">
<Filter>Header Files</Filter>
</ClInclude>
+++ /dev/null
-
-#include <windows.h>
-#include <errno.h>
-#include <io.h>
-
-#include "mman.h"
-
-#ifndef FILE_MAP_EXECUTE
-#define FILE_MAP_EXECUTE 0x0020
-#endif /* FILE_MAP_EXECUTE */
-
-static int __map_mman_error(const DWORD err, const int deferr)
-{
- if (err == 0)
- return 0;
- //TODO: implement
- return err;
-}
-
-static DWORD __map_mmap_prot_page(const int prot)
-{
- DWORD protect = 0;
-
- if (prot == PROT_NONE)
- return protect;
-
- if ((prot & PROT_EXEC) != 0) {
- protect = ((prot & PROT_WRITE) != 0) ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ;
- } else {
- protect = ((prot & PROT_WRITE) != 0) ? PAGE_READWRITE : PAGE_READONLY;
- }
-
- return protect;
-}
-
-static DWORD __map_mmap_prot_file(const int prot)
-{
- DWORD desiredAccess = 0;
-
- if (prot == PROT_NONE)
- return desiredAccess;
-
- if ((prot & PROT_READ) != 0)
- desiredAccess |= FILE_MAP_READ;
- if ((prot & PROT_WRITE) != 0)
- desiredAccess |= FILE_MAP_WRITE;
- if ((prot & PROT_EXEC) != 0)
- desiredAccess |= FILE_MAP_EXECUTE;
-
- return desiredAccess;
-}
-
-void *mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
-{
- HANDLE fm, h;
-
- void *map = MAP_FAILED;
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable: 4293)
-#endif
-
- const DWORD dwFileOffsetLow = (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD) off : (DWORD) (off & 0xFFFFFFFFL);
- const DWORD dwFileOffsetHigh = (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD) 0 : (DWORD) ((off >> 32) & 0xFFFFFFFFL);
- const DWORD protect = __map_mmap_prot_page(prot);
- const DWORD desiredAccess = __map_mmap_prot_file(prot);
-
- const off_t maxSize = off + (off_t) len;
-
- const DWORD dwMaxSizeLow = (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD) maxSize : (DWORD) (maxSize & 0xFFFFFFFFL);
- const DWORD dwMaxSizeHigh = (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD) 0 : (DWORD) ((maxSize >> 32) & 0xFFFFFFFFL);
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
- errno = 0;
-
- if (len == 0
- /* Unsupported flag combinations */
- || (flags & MAP_FIXED) != 0
- /* Usupported protection combinations */
- || prot == PROT_EXEC) {
- errno = EINVAL;
- return MAP_FAILED;
- }
-
- h = ((flags & MAP_ANONYMOUS) == 0) ? (HANDLE) _get_osfhandle(fildes) : INVALID_HANDLE_VALUE;
-
- if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE) {
- errno = EBADF;
- return MAP_FAILED;
- }
-
- fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL);
-
- if (fm == NULL) {
- errno = __map_mman_error(GetLastError(), EPERM);
- return MAP_FAILED;
- }
-
- map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len);
-
- CloseHandle(fm);
-
- if (map == NULL) {
- errno = __map_mman_error(GetLastError(), EPERM);
- return MAP_FAILED;
- }
-
- return map;
-}
-
-int munmap(void *addr, size_t len)
-{
- if (UnmapViewOfFile(addr))
- return 0;
-
- errno = __map_mman_error(GetLastError(), EPERM);
-
- return -1;
-}
-
-int _mprotect(void *addr, size_t len, int prot)
-{
- DWORD newProtect = __map_mmap_prot_page(prot);
- DWORD oldProtect = 0;
-
- if (VirtualProtect(addr, len, newProtect, &oldProtect))
- return 0;
-
- errno = __map_mman_error(GetLastError(), EPERM);
-
- return -1;
-}
-
-int msync(void *addr, size_t len, int flags)
-{
- if (FlushViewOfFile(addr, len))
- return 0;
-
- errno = __map_mman_error(GetLastError(), EPERM);
-
- return -1;
-}
-
-int mlock(const void *addr, size_t len)
-{
- if (VirtualLock((LPVOID) addr, len))
- return 0;
-
- errno = __map_mman_error(GetLastError(), EPERM);
-
- return -1;
-}
-
-int munlock(const void *addr, size_t len)
-{
- if (VirtualUnlock((LPVOID) addr, len))
- return 0;
-
- errno = __map_mman_error(GetLastError(), EPERM);
-
- return -1;
-}
+++ /dev/null
-/*
- * sys/mman.h
- * mman-win32
- */
-
-#ifndef _SYS_MMAN_H_
-#define _SYS_MMAN_H_
-
-#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
-#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
-#endif
-
-/* All the headers include this file. */
-#ifndef _MSC_VER
-#include <_mingw.h>
-#endif
-
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define PROT_NONE 0
-#define PROT_READ 1
-#define PROT_WRITE 2
-#define PROT_EXEC 4
-
-#define MAP_FILE 0
-#define MAP_SHARED 1
-#define MAP_PRIVATE 2
-#define MAP_TYPE 0xf
-#define MAP_FIXED 0x10
-#define MAP_ANONYMOUS 0x20
-#define MAP_ANON MAP_ANONYMOUS
-
-#define MAP_FAILED ((void *)-1)
-
-/* Flags for msync. */
-#define MS_ASYNC 1
-#define MS_SYNC 2
-#define MS_INVALIDATE 4
-
- void *mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
- int munmap(void *addr, size_t len);
- int _mprotect(void *addr, size_t len, int prot);
- int msync(void *addr, size_t len, int flags);
- int mlock(const void *addr, size_t len);
- int munlock(const void *addr, size_t len);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif /* _SYS_MMAN_H_ */
testpools_CFLAGS = $(AM_CFLAGS)
testpools_LDADD = $(TEST_LDADD)
-check_PROGRAMS += testmmap
-testmmap_SOURCES = testmmap.c tap.c
-testmmap_CFLAGS = $(AM_CFLAGS)
-testmmap_LDADD = $(TEST_LDADD)
-
check_PROGRAMS += testacl
testacl_SOURCES = testacl.c tap.c
testacl_CFLAGS = $(AM_CFLAGS)
+++ /dev/null
-#include "ks.h"
-#include "tap.h"
-
-static ks_pool_t *pool = NULL;
-
-#define LOOP_COUNT 1000000
-
-ks_status_t test1()
-{
- int i;
- void *mem, *last_mem = NULL;
-
- for (i = 0; i < LOOP_COUNT; i++) {
- if (last_mem) {
- ks_pool_free(pool, &last_mem);
- }
- mem = ks_pool_alloc(pool, 1024);
- last_mem = mem;
- }
-
- return KS_STATUS_SUCCESS;
-}
-
-int main(int argc, char **argv)
-{
- ks_init();
-
- ok(ks_pool_open(&pool) == KS_STATUS_SUCCESS);
-
- ok(test1() == KS_STATUS_SUCCESS);
-
- ok(ks_pool_close(&pool) == KS_STATUS_SUCCESS);
-
- ks_shutdown();
-
- done_testing();
-
- return 0;
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>testmmap</RootNamespace>
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v140_xp</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v140_xp</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v140_xp</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v140_xp</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="Shared">
- </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 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 Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <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|x64'">
- <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>
- <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
- <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
- <IncludePath>$(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include;$(IncludePath)</IncludePath>
- <LibraryPath>$(SolutionDir)\openssl\lib;$(LibraryPath)</LibraryPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
- <IncludePath>$(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include64;$(IncludePath)</IncludePath>
- <LibraryPath>$(SolutionDir)\openssl\lib64;$(LibraryPath)</LibraryPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
- <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
- <IncludePath>$(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include;$(IncludePath)</IncludePath>
- <LibraryPath>$(SolutionDir)\openssl\lib;$(LibraryPath)</LibraryPath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- <IntDir>$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
- <IncludePath>$(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include64;$(IncludePath)</IncludePath>
- <LibraryPath>$(SolutionDir)\openssl\lib64;$(LibraryPath)</LibraryPath>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>../src/include;.</AdditionalIncludeDirectories>
- <DisableSpecificWarnings>4090</DisableSpecificWarnings>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>../src/include;.</AdditionalIncludeDirectories>
- <DisableSpecificWarnings>4090</DisableSpecificWarnings>
- </ClCompile>
- <Link>
- <SubSystem>Console</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_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>../src/include;.</AdditionalIncludeDirectories>
- <DisableSpecificWarnings>4090</DisableSpecificWarnings>
- </ClCompile>
- <Link>
- <SubSystem>Console</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_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>../src/include;.</AdditionalIncludeDirectories>
- <DisableSpecificWarnings>4090</DisableSpecificWarnings>
- </ClCompile>
- <Link>
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ProjectReference Include="..\libks.vcxproj">
- <Project>{70d178d8-1100-4152-86c0-809a91cff832}</Project>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="tap.c" />
- <ClCompile Include="testmmap.c" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
\ No newline at end of file