diff --git a/libs/libks/libks.sln b/libs/libks/libks.sln index 72a14904b4..7cd03516d1 100644 --- a/libs/libks/libks.sln +++ b/libs/libks/libks.sln @@ -17,8 +17,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsock", "test\testsock.v 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 @@ -83,14 +81,6 @@ Global {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 diff --git a/libs/libks/libks.vcxproj b/libs/libks/libks.vcxproj index b84b387dac..32ab14ae12 100644 --- a/libs/libks/libks.vcxproj +++ b/libs/libks/libks.vcxproj @@ -192,7 +192,6 @@ - @@ -226,7 +225,6 @@ - diff --git a/libs/libks/libks.vcxproj.filters b/libs/libks/libks.vcxproj.filters index 8e710f64f0..d76a361ee7 100644 --- a/libs/libks/libks.vcxproj.filters +++ b/libs/libks/libks.vcxproj.filters @@ -42,9 +42,6 @@ Source Files - - Source Files - Source Files @@ -161,9 +158,6 @@ Header Files - - Header Files - Header Files diff --git a/libs/libks/src/win/mman.c b/libs/libks/src/win/mman.c deleted file mode 100644 index d61571fbc3..0000000000 --- a/libs/libks/src/win/mman.c +++ /dev/null @@ -1,166 +0,0 @@ - -#include -#include -#include - -#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; -} diff --git a/libs/libks/src/win/sys/mman.h b/libs/libks/src/win/sys/mman.h deleted file mode 100644 index e003da8260..0000000000 --- a/libs/libks/src/win/sys/mman.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 - -#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_ */ diff --git a/libs/libks/test/Makefile.am b/libs/libks/test/Makefile.am index 933b8db8b6..17bd30d05e 100644 --- a/libs/libks/test/Makefile.am +++ b/libs/libks/test/Makefile.am @@ -9,11 +9,6 @@ testpools_SOURCES = testpools.c tap.c 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) diff --git a/libs/libks/test/testmmap.c b/libs/libks/test/testmmap.c deleted file mode 100644 index d2da12ff29..0000000000 --- a/libs/libks/test/testmmap.c +++ /dev/null @@ -1,39 +0,0 @@ -#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; -} diff --git a/libs/libks/test/testmmap.vcxproj b/libs/libks/test/testmmap.vcxproj deleted file mode 100644 index d795d27d05..0000000000 --- a/libs/libks/test/testmmap.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {7BA42C3F-B5F6-4C48-AFED-B50EB35C4F03} - Win32Proj - testmmap - 8.1 - - - - Application - true - v140_xp - Unicode - - - Application - false - v140_xp - true - Unicode - - - Application - true - v140_xp - Unicode - - - Application - false - v140_xp - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - $(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include;$(IncludePath) - $(SolutionDir)\openssl\lib;$(LibraryPath) - - - true - $(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include64;$(IncludePath) - $(SolutionDir)\openssl\lib64;$(LibraryPath) - - - false - $(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include;$(IncludePath) - $(SolutionDir)\openssl\lib;$(LibraryPath) - - - false - $(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include64;$(IncludePath) - $(SolutionDir)\openssl\lib64;$(LibraryPath) - - - - - - Level3 - Disabled - _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - ../src/include;. - 4090 - - - Console - true - - - - - - - Level3 - Disabled - _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - ../src/include;. - 4090 - - - Console - true - - - - - Level3 - - - MaxSpeed - true - true - _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - ../src/include;. - 4090 - - - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - ../src/include;. - 4090 - - - Console - true - true - true - - - - - {70d178d8-1100-4152-86c0-809a91cff832} - - - - - - - - - - \ No newline at end of file