From 6d10ad9e524e863b30c87f361184f377f56c5b7e Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 21 Apr 2021 08:04:21 +0800 Subject: [PATCH] Restore deps/mman Accidentally purged in last commit, needed for lightrec/lightning --- deps/mman/.gitignore | 2 + deps/mman/.gitrepo | 12 ++ deps/mman/.vs/mman/v14/.suo | Bin 0 -> 26112 bytes deps/mman/CMakeLists.txt | 33 +++++ deps/mman/Makefile | 68 ++++++++++ deps/mman/README.md | 10 ++ deps/mman/UpgradeLog.htm | Bin 0 -> 37768 bytes deps/mman/configure | 170 ++++++++++++++++++++++++ deps/mman/mman-win32.pro | 13 ++ deps/mman/mman.c | 185 ++++++++++++++++++++++++++ deps/mman/mman.h | 76 +++++++++++ deps/mman/mman.sln | 28 ++++ deps/mman/mman.vcxproj | 122 +++++++++++++++++ deps/mman/mman.vcxproj.filters | 30 +++++ deps/mman/mman.vcxproj.user | 4 + deps/mman/test.c | 235 +++++++++++++++++++++++++++++++++ 16 files changed, 988 insertions(+) create mode 100644 deps/mman/.gitignore create mode 100644 deps/mman/.gitrepo create mode 100644 deps/mman/.vs/mman/v14/.suo create mode 100644 deps/mman/CMakeLists.txt create mode 100644 deps/mman/Makefile create mode 100644 deps/mman/README.md create mode 100644 deps/mman/UpgradeLog.htm create mode 100755 deps/mman/configure create mode 100644 deps/mman/mman-win32.pro create mode 100644 deps/mman/mman.c create mode 100644 deps/mman/mman.h create mode 100644 deps/mman/mman.sln create mode 100644 deps/mman/mman.vcxproj create mode 100644 deps/mman/mman.vcxproj.filters create mode 100644 deps/mman/mman.vcxproj.user create mode 100644 deps/mman/test.c diff --git a/deps/mman/.gitignore b/deps/mman/.gitignore new file mode 100644 index 00000000..5f778dba --- /dev/null +++ b/deps/mman/.gitignore @@ -0,0 +1,2 @@ +x64 +mman.VC.db \ No newline at end of file diff --git a/deps/mman/.gitrepo b/deps/mman/.gitrepo new file mode 100644 index 00000000..7e6585b3 --- /dev/null +++ b/deps/mman/.gitrepo @@ -0,0 +1,12 @@ +; DO NOT EDIT (unless you know what you are doing) +; +; This subdirectory is a git "subrepo", and this file is maintained by the +; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme +; +[subrepo] + remote = https://github.com/witwall/mman-win32 + branch = master + commit = 2d1c576e62b99e85d99407e1a88794c6e44c3310 + parent = 19599a744a114b242c401d5ac1f0bcfc369453ee + method = merge + cmdver = 0.4.1 diff --git a/deps/mman/.vs/mman/v14/.suo b/deps/mman/.vs/mman/v14/.suo new file mode 100644 index 0000000000000000000000000000000000000000..57e963c9bac2186628e4c976c053d502c511cecb GIT binary patch literal 26112 zcmeHPS!`p~8NSJ|%m9S~Q#wpp0yAu#iR0LD91mpRddo7|on>h+KQJxO)E+(q%P7xrM7DO0uL3c`aspEN))EwcbCL*;@EMP z$qYW$f6sEyJ^xw$|D6B-&pCeQ{EhFu_QwAAg)(#q<0>)ob( z%yhS&a|9R_VOHn^_6R~gVScS5R=m3f6j|EcD>AH-@B-36zM3=f%YuZ~dj(lgg}4w! zZDiD}x@!@dn{Gk2D*&uV^)CeQ)lxnaKii!VlIVe~hB<)RgaC4t0uKWJ0pz)P9rzzY zUYX1cw+HZXX$KnN85?J&H{}(|o zml6MKyi+g#o0MYC1LXG`%J|7Fn{yoBlmGeMb?|QjkpDSfuurc9Fwf`UGtYMLKj&ZK zYPj|Hz%%H(X8~UZJO}s+;CTSY@T>5@W`r4UxXZ5xDDlh)c}P4_P3~}O@<&KWKpIgX z2~j3gg()o*MoIznQ0hABkiR%rP@bSG$FE~jfmN4;MARcA3?i0B9rRTFOa0ji`R6tS zIe&3u&RG(JkkDTbKkO;6(X!F=WeXt?g+cfSyRBrxp0@jci$8m!a08cW)5C z8$B<9+oHgxfELrhJYbB67w@PAtmV-EnvQ-eGS%Au4URu+}bv-x+3S2(pXk@eaxW5ki=f{*A=>otj8MDru#*5@T3)0Djd0^LT zWLe}2kHIJUjD6IYf6YdV4k>V5rvwdZYU{~gH0HMLg!Pa*I9M#1C2s{-!;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&DY-N8c@WL9~9_t5!Q#eFtUEjSh`rOxgdPZvFqDtToLwUSn4= zeB&WjvFbSeS1o4ru6(&_2&iF6^)dDBvj44)Qs;(_`+;)3aILzz@1=jIkE;JBY_*_1 zu5hyFX;1!#cD!X?EYz@i_RW+pR%+Gm^{~*4w!02mNuF`L{~7)1BdBFtb$H|=l>TYf z$=QeWI#x}kp4a*~La9{sID;>aEZ(TAb`LMK)njc!JJ)KCy^KC62j+=|O%O)#DlpO0 z6?&{FI=vD8q<+LWb|G>fd5oQ9@!SHPy#;!NpFE0R_yu?&nvH;nMPV&{h4od6`x1Xc>&44&eZ^C^YnE+ogH7_c1oMR z^Cs=GbOi>!$7+~0`3+9_UCuZUXwPSB6&o}>H zJpLbEZ7H_?gZUqaOV!xNEFSaJ5pG>0r!IJPfqUnxU}K(VyOue78~+qJEp6Vpopk!xTtvLd&ZS)20`J_3j&)2?RnXwuHvO6Amz3T2n zbwrUb+L}dwG2zl0@y}zcwiIK1VKFWD&W#}EC$+2fV^6F4Ou0|~X6UEeGw&3GHzz8O zxPd3GUwU-h?Rj9$W8?Wb$0BDp)a`~;$9VkStr1lBXY^6zXzWA9(@P)IO2;_AI|02* zkQ)2A9rr4prL_I=c6eQ9<>+tTjm;~moG0bVCRTvPcVhMN3<}43X#ua_wb~+UyStP% zi6git;;Qd0bH#W=-Z_ygzi~%>yv}{kTph|>d zshYjgNk&^OW|a literal 0 HcmV?d00001 diff --git a/deps/mman/configure b/deps/mman/configure new file mode 100755 index 00000000..665cb1e9 --- /dev/null +++ b/deps/mman/configure @@ -0,0 +1,170 @@ +#!/bin/sh +# mmap-win32 configure script +# +# Parts copied from FFmpeg's configure +# + +set_all(){ + value=$1 + shift + for var in $*; do + eval $var=$value + done +} + +enable(){ + set_all yes $* +} + +disable(){ + set_all no $* +} + +enabled(){ + eval test "x\$$1" = "xyes" +} + +disabled(){ + eval test "x\$$1" = "xno" +} + +show_help(){ + echo "Usage: configure [options]" + echo "Options: [defaults in brackets after descriptions]" + echo "All \"enable\" options have \"disable\" counterparts" + echo + echo " --help print this message" + echo " --prefix=PREFIX install in PREFIX [$PREFIX]" + echo " --bindir=DIR install binaries in DIR [$PREFIX/bin]" + echo " --libdir=DIR install libs in DIR [$PREFIX/lib]" + echo " --incdir=DIR install includes in DIR [$PREFIX/include]" + echo " --enable-static build static libraries [yes]" + echo " --enable-shared build shared libraries [no]" + echo " --enable-msvc create msvc-compatible import lib [auto]" + echo + echo " --cc=CC use C compiler CC [$cc_default]" + echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]" + exit 1 +} + +die_unknown(){ + echo "Unknown option \"$1\"." + echo "See $0 --help for available options." + exit 1 +} + +PREFIX="/mingw" +ar="ar" +cc_default="gcc" +ranlib="ranlib" +strip="strip" + +DEFAULT="msvc +" + +DEFAULT_YES="static + stripping +" + +DEFAULT_NO="shared +" + +CMDLINE_SELECT="$DEFAULT + $DEFAULT_NO + $DEFAULT_YES +" + +enable $DEFAULT_YES +disable $DEFAULT_NO + +for opt do + optval="${opt#*=}" + case "$opt" in + --help) + show_help + ;; + --prefix=*) + PREFIX="$optval" + ;; + --bindir=*) + bindir="$optval" + ;; + --libdir=*) + libdir="$optval" + ;; + --incdir=*) + incdir="$optval" + ;; + --cc=*) + cc="$optval" + ;; + --cross-prefix=*) + cross_prefix="$optval" + ;; + --enable-?*|--disable-?*) + eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` + echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt + $action $option + ;; + *) + die_unknown $opt + ;; + esac +done + +bindir="${PREFIX}/bin" +libdir="${PREFIX}/lib" +incdir="${PREFIX}/include/sys" +ar="${cross_prefix}${ar}" +cc_default="${cross_prefix}${cc_default}" +ranlib="${cross_prefix}${ranlib}" +strip="${cross_prefix}${strip}" + +if ! test -z $cc; then + cc_default="${cc}" +fi +cc="${cc_default}" + +disabled static && disabled shared && { + echo "At least one library type must be set."; + exit 1; +} + +if enabled msvc; then + lib /? > /dev/null 2>&1 /dev/null || { + echo "MSVC's lib command not found." + echo "Make sure MSVC is installed and its bin folder is in your \$PATH." + exit 1 + } +fi + +if ! enabled stripping; then + strip="echo ignoring strip" +fi + +enabled msvc && libcmd="lib" || libcmd="echo ignoring lib" + +echo "# Automatically generated by configure" > config.mak +echo "PREFIX=$PREFIX" >> config.mak +echo "bindir=$bindir" >> config.mak +echo "libdir=$libdir" >> config.mak +echo "incdir=$incdir" >> config.mak +echo "AR=$ar" >> config.mak +echo "CC=$cc" >> config.mak +echo "RANLIB=$ranlib" >> config.mak +echo "STRIP=$strip" >> config.mak +echo "BUILD_STATIC=$static" >> config.mak +echo "BUILD_SHARED=$shared" >> config.mak +echo "BUILD_MSVC=$msvc" >> config.mak +echo "LIBCMD=$libcmd" >> config.mak + +echo "prefix: $PREFIX" +echo "bindir: $bindir" +echo "libdir: $libdir" +echo "incdir: $incdir" +echo "ar: $ar" +echo "cc: $cc" +echo "ranlib: $ranlib" +echo "strip: $strip" +echo "static: $static" +echo "shared: $shared" diff --git a/deps/mman/mman-win32.pro b/deps/mman/mman-win32.pro new file mode 100644 index 00000000..b58b4d95 --- /dev/null +++ b/deps/mman/mman-win32.pro @@ -0,0 +1,13 @@ +QT -= core gui + +TARGET = mman +TEMPLATE = lib + +DEFINES += MMAN_LIBRARY_DLL +DEFINES += MMAN_LIBRARY + +HEADERS += \ + mman.h + +SOURCES += \ + mman.c diff --git a/deps/mman/mman.c b/deps/mman/mman.c new file mode 100644 index 00000000..e71666cd --- /dev/null +++ b/deps/mman/mman.c @@ -0,0 +1,185 @@ + +#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, OffsetType off) +{ + HANDLE fm, h; + + void * map = MAP_FAILED; + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4293) +#endif + + const DWORD dwFileOffsetLow = (sizeof(OffsetType) <= sizeof(DWORD)) ? + (DWORD)off : (DWORD)(off & 0xFFFFFFFFL); + const DWORD dwFileOffsetHigh = (sizeof(OffsetType) <= 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 OffsetType maxSize = off + (OffsetType)len; + + const DWORD dwMaxSizeLow = (sizeof(OffsetType) <= sizeof(DWORD)) ? + (DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL); + const DWORD dwMaxSizeHigh = (sizeof(OffsetType) <= sizeof(DWORD)) ? + (DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL); + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + + errno = 0; + + if (len == 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; + } + + if ((flags & MAP_FIXED) == 0) + { + map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len); + } + else + { + map = MapViewOfFileEx(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len, addr); + } + + 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/deps/mman/mman.h b/deps/mman/mman.h new file mode 100644 index 00000000..047d3a03 --- /dev/null +++ b/deps/mman/mman.h @@ -0,0 +1,76 @@ +/* + * 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 + +#if defined(MMAN_LIBRARY_DLL) +/* Windows shared libraries (DLL) must be declared export when building the lib and import when building the +application which links against the library. */ +#if defined(MMAN_LIBRARY) +#define MMANSHARED_EXPORT __declspec(dllexport) +#else +#define MMANSHARED_EXPORT __declspec(dllimport) +#endif /* MMAN_LIBRARY */ +#else +/* Static libraries do not require a __declspec attribute.*/ +#define MMANSHARED_EXPORT +#endif /* MMAN_LIBRARY_DLL */ + +/* Determine offset type */ +#include +#if defined(_WIN64) +typedef int64_t OffsetType; +#else +typedef uint32_t OffsetType; +#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 + +MMANSHARED_EXPORT void* mmap(void *addr, size_t len, int prot, int flags, int fildes, OffsetType off); +MMANSHARED_EXPORT int munmap(void *addr, size_t len); +MMANSHARED_EXPORT int _mprotect(void *addr, size_t len, int prot); +MMANSHARED_EXPORT int msync(void *addr, size_t len, int flags); +MMANSHARED_EXPORT int mlock(const void *addr, size_t len); +MMANSHARED_EXPORT int munlock(const void *addr, size_t len); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MMAN_H_ */ diff --git a/deps/mman/mman.sln b/deps/mman/mman.sln new file mode 100644 index 00000000..69fb506f --- /dev/null +++ b/deps/mman/mman.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mman", "mman.vcxproj", "{592F578E-6F24-47C0-9F6C-07BC9B730E27}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Debug|x64.ActiveCfg = Debug|x64 + {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Debug|x64.Build.0 = Debug|x64 + {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Debug|x86.ActiveCfg = Debug|Win32 + {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Debug|x86.Build.0 = Debug|Win32 + {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Release|x64.ActiveCfg = Release|x64 + {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Release|x64.Build.0 = Release|x64 + {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Release|x86.ActiveCfg = Release|Win32 + {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/deps/mman/mman.vcxproj b/deps/mman/mman.vcxproj new file mode 100644 index 00000000..e8dffa2c --- /dev/null +++ b/deps/mman/mman.vcxproj @@ -0,0 +1,122 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {592F578E-6F24-47C0-9F6C-07BC9B730E27} + Win32Proj + 8.1 + + + + Application + true + v140 + + + Application + false + v140 + + + StaticLibrary + true + v140 + + + StaticLibrary + false + v140 + + + + + + + + + + + + + + + + + + + + + true + + + true + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + + + MachineX86 + true + Console + + + + + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + + + MachineX86 + true + Console + true + true + + + + + MultiThreadedDebug + + + + + MultiThreaded + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/deps/mman/mman.vcxproj.filters b/deps/mman/mman.vcxproj.filters new file mode 100644 index 00000000..a08c8d55 --- /dev/null +++ b/deps/mman/mman.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + + + Header Files + + + + + + \ No newline at end of file diff --git a/deps/mman/mman.vcxproj.user b/deps/mman/mman.vcxproj.user new file mode 100644 index 00000000..abe8dd89 --- /dev/null +++ b/deps/mman/mman.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/deps/mman/test.c b/deps/mman/test.c new file mode 100644 index 00000000..9374b9f1 --- /dev/null +++ b/deps/mman/test.c @@ -0,0 +1,235 @@ + +#include "mman.h" + +#include +#include +#include + +#ifndef NULL +#define NULL (void*)0 +#endif + +const char* map_file_name = "map_file.dat"; + +int test_anon_map_readwrite() +{ + void* map = mmap(NULL, 1024, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (map == MAP_FAILED) + { + printf("mmap (MAP_ANONYMOUS, PROT_READ | PROT_WRITE) returned unexpected error: %d\n", errno); + return -1; + } + + *((unsigned char*)map) = 1; + + int result = munmap(map, 1024); + + if (result != 0) + printf("munmap (MAP_ANONYMOUS, PROT_READ | PROT_WRITE) returned unexpected error: %d\n", errno); + + return result; +} + +int test_anon_map_readonly() +{ + void* map = mmap(NULL, 1024, PROT_READ, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (map == MAP_FAILED) + { + printf("mmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno); + return -1; + } + + *((unsigned char*)map) = 1; + + int result = munmap(map, 1024); + + if (result != 0) + printf("munmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno); + + return result; +} + +int test_anon_map_writeonly() +{ + void* map = mmap(NULL, 1024, PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (map == MAP_FAILED) + { + printf("mmap (MAP_ANONYMOUS, PROT_WRITE) returned unexpected error: %d\n", errno); + return -1; + } + + *((unsigned char*)map) = 1; + + int result = munmap(map, 1024); + + if (result != 0) + printf("munmap (MAP_ANONYMOUS, PROT_WRITE) returned unexpected error: %d\n", errno); + + return result; +} + +int test_anon_map_readonly_nowrite() +{ + void* map = mmap(NULL, 1024, PROT_READ, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (map == MAP_FAILED) + { + printf("mmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno); + return -1; + } + + if (*((unsigned char*)map) != 0) + printf("test_anon_map_readonly_nowrite (MAP_ANONYMOUS, PROT_READ) returned unexpected value: %d\n", + (int)*((unsigned char*)map)); + + int result = munmap(map, 1024); + + if (result != 0) + printf("munmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno); + + return result; +} + +int test_file_map_readwrite() +{ + mode_t mode = S_IRUSR | S_IWUSR; + int o = open(map_file_name, O_TRUNC | O_BINARY | O_RDWR | O_CREAT, mode); + + void* map = mmap(NULL, 1024, PROT_READ | PROT_WRITE, MAP_PRIVATE, o, 0); + if (map == MAP_FAILED) + { + printf("mmap returned unexpected error: %d\n", errno); + return -1; + } + + *((unsigned char*)map) = 1; + + int result = munmap(map, 1024); + + if (result != 0) + printf("munmap returned unexpected error: %d\n", errno); + + close(o); + + /*TODO: get file info and content and compare it with the sources conditions */ + unlink(map_file_name); + + return result; +} + +int test_file_map_mlock_munlock() +{ + const size_t map_size = 1024; + + int result = 0; + mode_t mode = S_IRUSR | S_IWUSR; + int o = open(map_file_name, O_TRUNC | O_BINARY | O_RDWR | O_CREAT, mode); + if (o == -1) + { + printf("unable to create file %s: %d\n", map_file_name, errno); + return -1; + } + + void* map = mmap(NULL, map_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, o, 0); + if (map == MAP_FAILED) + { + printf("mmap returned unexpected error: %d\n", errno); + result = -1; + goto done_close; + } + + if (mlock(map, map_size) != 0) + { + printf("mlock returned unexpected error: %d\n", errno); + result = -1; + goto done_munmap; + } + + *((unsigned char*)map) = 1; + + if (munlock(map, map_size) != 0) + { + printf("munlock returned unexpected error: %d\n", errno); + result = -1; + } + +done_munmap: + result = munmap(map, map_size); + + if (result != 0) + printf("munmap returned unexpected error: %d\n", errno); + +done_close: + close(o); + + unlink(map_file_name); +done: + return result; +} + +int test_file_map_msync() +{ + const size_t map_size = 1024; + + int result = 0; + mode_t mode = S_IRUSR | S_IWUSR; + int o = open(map_file_name, O_TRUNC | O_BINARY | O_RDWR | O_CREAT, mode); + if (o == -1) + { + printf("unable to create file %s: %d\n", map_file_name, errno); + return -1; + } + + void* map = mmap(NULL, map_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, o, 0); + if (map == MAP_FAILED) + { + printf("mmap returned unexpected error: %d\n", errno); + result = -1; + goto done_close; + } + + *((unsigned char*)map) = 1; + + if (msync(map, map_size, MS_SYNC) != 0) + { + printf("msync returned unexpected error: %d\n", errno); + result = -1; + } + + result = munmap(map, map_size); + + if (result != 0) + printf("munmap returned unexpected error: %d\n", errno); + +done_close: + close(o); + + unlink(map_file_name); +done: + return result; +} + +#define EXEC_TEST(name) \ + if (name() != 0) { result = -1; printf( #name ": fail\n"); } \ + else { printf(#name ": pass\n"); } + +int main() +{ + int result = 0; + + EXEC_TEST(test_anon_map_readwrite); + //NOTE: this test must cause an access violation exception + //EXEC_TEST(test_anon_map_readonly); + EXEC_TEST(test_anon_map_readonly_nowrite); + EXEC_TEST(test_anon_map_writeonly); + + EXEC_TEST(test_file_map_readwrite); + EXEC_TEST(test_file_map_mlock_munlock); + EXEC_TEST(test_file_map_msync); + //TODO: EXEC_TEST(test_file_map_mprotect); + + return result; +} -- 2.39.5