From 17f7afe76a7c97d0097b0d3674514b64f3b99131 Mon Sep 17 00:00:00 2001 From: Mike Jerris Date: Fri, 4 Sep 2015 12:58:46 -0400 Subject: [PATCH] almost working windows build --- libs/libks/libks.props | 13 +++ libs/libks/libks.sln | 28 ++++++ libs/libks/libks.vcxproj | 146 ++++++++++++++++++++++++++++ libs/libks/libks.vcxproj.filters | 87 +++++++++++++++++ libs/libks/src/include/ks.h | 2 + libs/libks/src/mpool.c | 12 ++- libs/libks/src/simclist.c | 2 + libs/libks/src/win/{ => sys}/mman.h | 0 8 files changed, 286 insertions(+), 4 deletions(-) create mode 100644 libs/libks/libks.props create mode 100644 libs/libks/libks.sln create mode 100644 libs/libks/libks.vcxproj create mode 100644 libs/libks/libks.vcxproj.filters rename libs/libks/src/win/{ => sys}/mman.h (100%) diff --git a/libs/libks/libks.props b/libs/libks/libks.props new file mode 100644 index 0000000000..0abff0f3a4 --- /dev/null +++ b/libs/libks/libks.props @@ -0,0 +1,13 @@ + + + + + + + + SIMCLIST_NO_DUMPRESTORE;_CRT_SECURE_NO_WARNINGS;KS_EXPORTS;%(PreprocessorDefinitions) + $(ProjectDir)\src\include;$(ProjectDir)\src\win\sys;$(ProjectDir)\src\win;%(AdditionalIncludeDirectories) + + + + \ No newline at end of file diff --git a/libs/libks/libks.sln b/libs/libks/libks.sln new file mode 100644 index 0000000000..d57322d2ef --- /dev/null +++ b/libs/libks/libks.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libks", "libks.vcxproj", "{70D178D8-1100-4152-86C0-809A91CFF832}" +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 + {70D178D8-1100-4152-86C0-809A91CFF832}.Debug|x64.ActiveCfg = Debug|x64 + {70D178D8-1100-4152-86C0-809A91CFF832}.Debug|x64.Build.0 = Debug|x64 + {70D178D8-1100-4152-86C0-809A91CFF832}.Debug|x86.ActiveCfg = Debug|Win32 + {70D178D8-1100-4152-86C0-809A91CFF832}.Debug|x86.Build.0 = Debug|Win32 + {70D178D8-1100-4152-86C0-809A91CFF832}.Release|x64.ActiveCfg = Release|x64 + {70D178D8-1100-4152-86C0-809A91CFF832}.Release|x64.Build.0 = Release|x64 + {70D178D8-1100-4152-86C0-809A91CFF832}.Release|x86.ActiveCfg = Release|Win32 + {70D178D8-1100-4152-86C0-809A91CFF832}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/libks/libks.vcxproj b/libs/libks/libks.vcxproj new file mode 100644 index 0000000000..390aa9a439 --- /dev/null +++ b/libs/libks/libks.vcxproj @@ -0,0 +1,146 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {70D178D8-1100-4152-86C0-809A91CFF832} + Win32Proj + + + + DynamicLibrary + true + v140 + + + DynamicLibrary + false + v140 + + + Application + true + v140 + + + Application + false + v140 + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBKS_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + %(AdditionalIncludeDirectories) + + + MachineX86 + true + Windows + + + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBKS_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + %(AdditionalIncludeDirectories) + + + MachineX86 + true + Windows + true + true + + + + + %(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBKS_EXPORTS;%(PreprocessorDefinitions) + + + + + %(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBKS_EXPORTS;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/libks/libks.vcxproj.filters b/libs/libks/libks.vcxproj.filters new file mode 100644 index 0000000000..6b78a8a9ba --- /dev/null +++ b/libs/libks/libks.vcxproj.filters @@ -0,0 +1,87 @@ + + + + + {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 + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/libs/libks/src/include/ks.h b/libs/libks/src/include/ks.h index 2b14891ac4..1807d73c4c 100644 --- a/libs/libks/src/include/ks.h +++ b/libs/libks/src/include/ks.h @@ -160,9 +160,11 @@ typedef enum { #ifndef strncasecmp #define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n) #endif +#if (_MSC_VER < 1900) /* VC 2015 */ #ifndef snprintf #define snprintf _snprintf #endif +#endif #ifndef S_IRUSR #define S_IRUSR _S_IREAD #endif diff --git a/libs/libks/src/mpool.c b/libs/libks/src/mpool.c index 1c2d032067..8668821f5d 100644 --- a/libs/libks/src/mpool.c +++ b/libs/libks/src/mpool.c @@ -37,7 +37,9 @@ #include #include #include +#ifndef _MSC_VER #include +#endif #include #ifdef DMALLOC @@ -240,8 +242,9 @@ static void *alloc_pages(mpool_t *mp_p, const unsigned int page_n, #ifdef DEBUG (void)printf("allocating %u pages or %lu bytes\n", page_n, size); #endif - + if (BIT_IS_SET(mp_p->mp_flags, MPOOL_FLAG_USE_SBRK)) { +#ifndef WIN32 mem = sbrk(size); if (mem == (void *)-1) { SET_POINTER(error_p, MPOOL_ERROR_NO_MEM); @@ -262,6 +265,7 @@ static void *alloc_pages(mpool_t *mp_p, const unsigned int page_n, } mem = (char *)mem + fill; } +#endif } else { state = MAP_PRIVATE; @@ -273,7 +277,7 @@ static void *alloc_pages(mpool_t *mp_p, const unsigned int page_n, #endif /* mmap from /dev/zero */ - mem = mmap((caddr_t)mp_p->mp_addr, size, mp_p->mp_mmflags, state, + mem = mmap(mp_p->mp_addr, size, mp_p->mp_mmflags, state, mp_p->mp_fd, mp_p->mp_top); if (mem == (void *)MAP_FAILED) { if (errno == ENOMEM) { @@ -321,7 +325,7 @@ static int free_pages(void *pages, const unsigned long size, const int sbrk_b) { if (! sbrk_b) { - (void)munmap((caddr_t)pages, size); + (void)munmap(pages, size); } return MPOOL_ERROR_NONE; @@ -1124,7 +1128,7 @@ int mpool_close(mpool_t *mp_p) } size = SIZE_OF_PAGES(mp_p, PAGES_IN_SIZE(mp_p, sizeof(mpool_t))); - (void)munmap((caddr_t)addr, size); + (void)munmap(addr, size); } return final; diff --git a/libs/libks/src/simclist.c b/libs/libks/src/simclist.c index 6796a8cd48..cd41c057a5 100755 --- a/libs/libks/src/simclist.c +++ b/libs/libks/src/simclist.c @@ -29,6 +29,8 @@ /* not in Windows! */ # include # include +#else +#include #endif #ifndef SIMCLIST_NO_DUMPRESTORE /* includes for dump/restore */ diff --git a/libs/libks/src/win/mman.h b/libs/libks/src/win/sys/mman.h similarity index 100% rename from libs/libks/src/win/mman.h rename to libs/libks/src/win/sys/mman.h