From 940c857987bf1af7a248a4f80fe7c45128067180 Mon Sep 17 00:00:00 2001 From: xorstream Date: Mon, 16 Jan 2017 17:21:12 +1100 Subject: [PATCH] Started the port for MSVC native support. --- bindings/msvc_native/config-host.h | 17 + bindings/msvc_native/msvc_native.sln | 20 + bindings/msvc_native/unicorn/unicorn.vcxproj | 398 ++++++ .../unicorn/unicorn.vcxproj.filters | 1103 +++++++++++++++++ include/platform.h | 250 ++++ 5 files changed, 1788 insertions(+) create mode 100644 bindings/msvc_native/config-host.h create mode 100644 bindings/msvc_native/msvc_native.sln create mode 100644 bindings/msvc_native/unicorn/unicorn.vcxproj create mode 100644 bindings/msvc_native/unicorn/unicorn.vcxproj.filters create mode 100644 include/platform.h diff --git a/bindings/msvc_native/config-host.h b/bindings/msvc_native/config-host.h new file mode 100644 index 00000000..b01191af --- /dev/null +++ b/bindings/msvc_native/config-host.h @@ -0,0 +1,17 @@ +/* This is a hand made version for MSVC support */ +#define CONFIG_QEMU_CONFDIR "c:/Program Files/QEMU" +#define CONFIG_QEMU_DATADIR "" +#define CONFIG_QEMU_DOCDIR "c:/Program Files/QEMU" +#define CONFIG_QEMU_MODDIR "c:/Program Files/QEMU/lib" +#define CONFIG_QEMU_HELPERDIR "c:/Program Files/QEMU/libexec" +#define HOST_I386 1 +#define CONFIG_WIN32 1 +#define CONFIG_FILEVERSION 2,2,1,0 +#define CONFIG_PRODUCTVERSION 2,2,1,0 +#define QEMU_VERSION "2.2.1" +#define QEMU_PKGVERSION "" +#define CONFIG_ZERO_MALLOC 1 +#define CONFIG_CPUID_H 1 +#define CONFIG_THREAD_SETNAME_BYTHREAD 1 +#define CONFIG_PTHREAD_SETNAME_NP 1 +#define HOST_DSOSUF ".dll" diff --git a/bindings/msvc_native/msvc_native.sln b/bindings/msvc_native/msvc_native.sln new file mode 100644 index 00000000..c26a4eb3 --- /dev/null +++ b/bindings/msvc_native/msvc_native.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unicorn", "unicorn\unicorn.vcxproj", "{B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Debug|Win32.ActiveCfg = Debug|Win32 + {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Debug|Win32.Build.0 = Debug|Win32 + {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Release|Win32.ActiveCfg = Release|Win32 + {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/bindings/msvc_native/unicorn/unicorn.vcxproj b/bindings/msvc_native/unicorn/unicorn.vcxproj new file mode 100644 index 00000000..d8a259de --- /dev/null +++ b/bindings/msvc_native/unicorn/unicorn.vcxproj @@ -0,0 +1,398 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96} + Win32Proj + unicorn + + + + StaticLibrary + true + v110_xp + MultiByte + + + StaticLibrary + false + v110_xp + true + MultiByte + + + + + + + + + + + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;inline=__inline;__func__=__FUNCTION__ + MultiThreadedDebug + ../../..;../../../include;../../../qemu;../../../qemu/include;../../../qemu/tcg; + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;;inline=__inline;__func__=__FUNCTION__ + MultiThreadedDebug + + + Windows + true + true + true + + + + + + \ No newline at end of file diff --git a/bindings/msvc_native/unicorn/unicorn.vcxproj.filters b/bindings/msvc_native/unicorn/unicorn.vcxproj.filters new file mode 100644 index 00000000..73c943b4 --- /dev/null +++ b/bindings/msvc_native/unicorn/unicorn.vcxproj.filters @@ -0,0 +1,1103 @@ + + + + + {13755027-3a13-46c3-9468-ed380fcef603} + + + {4f904f9f-fd99-4ebe-8db7-2ee2c644c6e4} + + + {1f3288bd-38e9-49c1-ae30-6ac4bc1b86c4} + + + {c0201656-497d-4ed6-8a56-dd0762761a3e} + + + {d98a987f-6e81-4454-9bb4-f79d49d1d8fa} + + + {9b261303-0cae-4e60-8bc9-c63cd6abd5bc} + + + {4078dd72-489d-48e6-a7c7-e27149f9513d} + + + {9264dcdf-55d8-4416-9b53-7962937b4db5} + + + {11627444-6a62-44fe-b8fc-774a6067f8cc} + + + {2429788d-aad9-4ca7-9d54-35a822230a07} + + + {340ebf7e-2f53-4b12-95d4-e70fc2b11a5d} + + + {6b30f3e8-9f55-4988-a9dd-ff3c57308816} + + + {f8014ce9-b821-4489-80b3-6c16b5b071ef} + + + {cfff595c-b2bf-4a2e-a855-68c9fef221b0} + + + {973f87b6-2729-473f-bda6-d61d8c799a77} + + + {e5fc48fc-fe02-45ed-92d2-2dd0b4adef2d} + + + {ffb1f350-eddc-4580-b5bc-0faeecd99f67} + + + {f8f12737-01ce-4367-bb90-6445527c8fce} + + + {783f8a18-9df3-4a38-b4ea-0ddf0c87d4ae} + + + {12bbb3c0-b269-4d05-9765-a6b9f2125c8e} + + + {e7582a4a-8013-41f3-94fa-761bd5c3a8d6} + + + {88817e6c-d61b-4d46-b9f2-0e408e87c1fa} + + + {f7414536-2ff3-4c82-8143-89f2808c7cf4} + + + {0d6f8e4a-029f-458b-a6f0-c7361c979b30} + + + {2516f9cb-907d-4cb8-8f6a-f3670918ed93} + + + {f5268739-450f-4fdf-94ae-26eb57c40e8b} + + + {1b964d24-ad70-4c4f-beba-7bda6dc53647} + + + {39c6e228-c856-4d92-91a2-c09a8674c963} + + + {1444105b-8d4f-47a2-a554-21f938a2bd5e} + + + {66c03921-c358-480e-91f8-2ea74fabd50b} + + + {abc1e0f7-8597-49c4-ad32-abecfa273617} + + + {235236d2-79fa-48f5-b496-cb79a9290f6b} + + + {4bb86c12-fd75-40be-9891-e4a84ca60703} + + + {b210c6e7-454a-400c-84c4-d2a10d96db1d} + + + {8bdec3ae-c802-4443-a6f4-e26bd030a1cf} + + + {e7cfa963-4fb5-4c9a-a264-402decbea01d} + + + {1890ac05-1098-492d-bc0d-50b6e8dd7fc0} + + + {76e19a4b-1143-456a-900c-9ce6c9c0d267} + + + {0e879645-49d7-4d24-9736-f85d69acceda} + + + {9ecedd1d-44a7-40d1-ad99-f06e49b39aa8} + + + {50ff932c-1464-4742-af74-fc9b42e4ef3a} + + + {ea61989d-dc0a-4146-87a0-63e5131d5302} + + + {044502cd-501d-40eb-86d0-4c8db24104c7} + + + {b1debb6d-f445-4f95-9778-d6b926541606} + + + {c5faa816-aae6-41b7-ac8d-40a9783786e0} + + + {62c5db3f-0d6d-4a3a-92b7-0cd602058a62} + + + {6ce87816-6698-4c16-8acf-8a459854f6f4} + + + {491f047e-eace-42b6-87a1-ee60dccbcd35} + + + {02648fb9-3b9f-4439-99a6-5ecb75c8a5cb} + + + {f0d04c05-527b-400a-accf-153b826e1f59} + + + {05f49c70-b00f-4771-95db-c3f85d93bc0a} + + + {2228e25b-0e64-4642-afe2-840ddced695c} + + + {06dbbe01-5d7d-4b1e-93ec-61a1251c03a6} + + + {d3bdc96b-d4f2-4aa7-9182-4670d57d642f} + + + {3bd33e7d-394d-4418-9350-e18e249d7c45} + + + + + priv + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu\fpu + + + qemu\hw\arm + + + qemu\hw\arm + + + qemu\hw\core + + + qemu\hw\core + + + qemu\hw\i386 + + + qemu\hw\i386 + + + qemu\hw\intc + + + qemu\hw\intc + + + qemu\hw\m68k + + + qemu\hw\mips + + + qemu\hw\mips + + + qemu\hw\mips + + + qemu\hw\mips + + + qemu\hw\sparc + + + qemu\hw\sparc + + + qemu\hw\sparc64 + + + qemu\qapi + + + qemu\qapi + + + qemu\qapi + + + qemu\qapi + + + qemu\qapi + + + qemu\qobject + + + qemu\qobject + + + qemu\qobject + + + qemu\qobject + + + qemu\qobject + + + qemu\qobject + + + qemu\qobject + + + qemu\qom + + + qemu\qom + + + qemu\qom + + + qemu\qom + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-m68k + + + qemu\target-m68k + + + qemu\target-m68k + + + qemu\target-m68k + + + qemu\target-m68k + + + qemu\target-m68k + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\tcg + + + qemu\tcg + + + qemu\tcg\aarch64 + + + qemu\tcg\arm + + + qemu\tcg\i386 + + + qemu\tcg\ia64 + + + qemu\tcg\mips + + + qemu\tcg\ppc + + + qemu\tcg\s390 + + + qemu\tcg\sparc + + + qemu\util + + + qemu\util + + + qemu\util + + + qemu\util + + + qemu\util + + + qemu\util + + + qemu\util + + + qemu\util + + + qemu\util + + + qemu\util + + + qemu\util + + + qemu\util + + + qemu\util + + + + + + priv + + + priv + + + priv + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu + + + qemu\aarch64-softmmu + + + qemu\arm-softmmu + + + qemu\fpu + + + qemu\fpu + + + qemu\include + + + qemu\include + + + qemu\include + + + qemu\include + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\exec + + + qemu\include\fpu + + + qemu\include\hw + + + qemu\include\hw + + + qemu\include\hw + + + qemu\include\hw + + + qemu\include\hw + + + qemu\include\hw\arm + + + qemu\include\hw\cpu + + + qemu\include\hw\i386 + + + qemu\include\hw\i386 + + + qemu\include\hw\i386 + + + qemu\include\hw\m68k + + + qemu\include\hw\m68k + + + qemu\include\hw\mips + + + qemu\include\hw\mips + + + qemu\include\hw\mips + + + qemu\include\hw\sparc + + + qemu\include\hw\sparc + + + qemu\include\hw\sparc + + + qemu\include\hw\sparc + + + qemu\include\qapi + + + qemu\include\qapi + + + qemu\include\qapi + + + qemu\include\qapi + + + qemu\include\qapi + + + qemu\include\qapi + + + qemu\include\qapi + + + qemu\include\qapi + + + qemu\include\qapi\qmp + + + qemu\include\qapi\qmp + + + qemu\include\qapi\qmp + + + qemu\include\qapi\qmp + + + qemu\include\qapi\qmp + + + qemu\include\qapi\qmp + + + qemu\include\qapi\qmp + + + qemu\include\qapi\qmp + + + qemu\include\qapi\qmp + + + qemu\include\qapi\qmp + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qemu + + + qemu\include\qom + + + qemu\include\qom + + + qemu\include\qom + + + qemu\include\sysemu + + + qemu\include\sysemu + + + qemu\include\sysemu + + + qemu\include\sysemu + + + qemu\include\sysemu + + + qemu\m68k-softmmu + + + qemu\mips-softemu + + + qemu\mip64-softmmu + + + qemu\mips64el-softmmu + + + qemu\mipsel-softmmu + + + qemu\sparc-softmmu + + + qemu\sparc64-softmmu + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-arm + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-i386 + + + qemu\target-m68k + + + qemu\target-m68k + + + qemu\target-m68k + + + qemu\target-m68k + + + qemu\target-m68k + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-mips + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\target-sparc + + + qemu\tcg + + + qemu\tcg + + + qemu\tcg + + + qemu\tcg + + + qemu\tcg + + + qemu\tcg + + + qemu\tcg\aarch64 + + + qemu\tcg\arm + + + qemu\tcg\i386 + + + qemu\tcg\ia64 + + + qemu\tcg\mips + + + qemu\tcg\ppc + + + qemu\tcg\s390 + + + qemu\tcg\sparc + + + qemu\x86_64-softmmu + + + + + + + + + + priv + + + \ No newline at end of file diff --git a/include/platform.h b/include/platform.h new file mode 100644 index 00000000..36a0dcfe --- /dev/null +++ b/include/platform.h @@ -0,0 +1,250 @@ +/* + This file is primarily to support header files that are missing in MSVC and other non-standard compilers. +*/ + +#ifndef UNICORN_PLATFORM_H +#define UNICORN_PLATFORM_H + +/* +These are the various MSVC versions as given by _MSC_VER: +MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) +MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013) +MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012) +MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) +MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008) +MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005) +MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio 2003) +MSVC++ 7.0 _MSC_VER == 1300 +MSVC++ 6.0 _MSC_VER == 1200 +MSVC++ 5.0 _MSC_VER == 1100 +*/ +#define MSC_VER_VS2003 1310 +#define MSC_VER_VS2005 1400 +#define MSC_VER_VS2008 1500 +#define MSC_VER_VS2010 1600 +#define MSC_VER_VS2012 1700 +#define MSC_VER_VS2013 1800 +#define MSC_VER_VS2015 1900 + + + +// handle stdbool.h compatibility +#if !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)) +// MSVC + +// stdbool.h +#if (_MSC_VER < MSC_VER_VS2013) || defined(_KERNEL_MODE) +// this system does not have stdbool.h +#ifndef __cplusplus +typedef unsigned char bool; +#define false 0 +#define true 1 +#endif // __cplusplus + +#else +// VisualStudio 2013+ -> C99 is supported +#include +#endif // (_MSC_VER < MSC_VER_VS2013) || defined(_KERNEL_MODE) + +#else +// not MSVC -> C99 is supported +#include +#endif // !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)) + + + + +// handle stdint.h compatibility +#if defined(_WIN32_WCE) && (_WIN32_WCE < 0x800) +#include "windowsce/stdint.h" +#endif // defined(_WIN32_WCE) && (_WIN32_WCE < 0x800) + +#if (defined(_MSC_VER) && (_MSC_VER < MSC_VER_VS2010)) || defined(_KERNEL_MODE) +// this system does not have stdint.h +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; + +#ifndef _INTPTR_T_DEFINED + #define _INTPTR_T_DEFINED + #ifdef _WIN64 +typedef long long intptr_t; + #else /* _WIN64 */ +typedef _W64 int intptr_t; + #endif /* _WIN64 */ +#endif /* _INTPTR_T_DEFINED */ + +#ifndef _UINTPTR_T_DEFINED + #define _UINTPTR_T_DEFINED + #ifdef _WIN64 +typedef unsigned long long uintptr_t; + #else /* _WIN64 */ +typedef _W64 unsigned int uintptr_t; + #endif /* _WIN64 */ +#endif /* _UINTPTR_T_DEFINED */ + +#define INT8_MIN (-127i8 - 1) +#define INT16_MIN (-32767i16 - 1) +#define INT32_MIN (-2147483647i32 - 1) +#define INT64_MIN (-9223372036854775807i64 - 1) +#define INT8_MAX 127i8 +#define INT16_MAX 32767i16 +#define INT32_MAX 2147483647i32 +#define INT64_MAX 9223372036854775807i64 +#define UINT8_MAX 0xffui8 +#define UINT16_MAX 0xffffui16 +#define UINT32_MAX 0xffffffffui32 +#define UINT64_MAX 0xffffffffffffffffui64 +#else +#include +#endif // (defined(_MSC_VER) && (_MSC_VER < MSC_VER_VS2010)) || defined(_KERNEL_MODE) + + + + +// handle inttypes.h compatibility +#if defined(UNICORN_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER < MSC_VER_VS2013)) || defined(_KERNEL_MODE) +// this system does not have inttypes.h + +#if (defined(_MSC_VER) && (_MSC_VER < MSC_VER_VS2013)) || defined(_KERNEL_MODE) + +#define __PRI_8_LENGTH_MODIFIER__ "hh" +#define __PRI_64_LENGTH_MODIFIER__ "ll" + +#define PRId8 __PRI_8_LENGTH_MODIFIER__ "d" +#define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i" +#define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o" +#define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u" +#define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x" +#define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X" + +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIo16 "ho" +#define PRIu16 "hu" +#define PRIx16 "hx" +#define PRIX16 "hX" + +#if defined(_MSC_VER) && (_MSC_VER <= MSC_VER_VS2012) +#define PRId32 "ld" +#define PRIi32 "li" +#define PRIo32 "lo" +#define PRIu32 "lu" +#define PRIx32 "lx" +#define PRIX32 "lX" +#else // OSX +#define PRId32 "d" +#define PRIi32 "i" +#define PRIo32 "o" +#define PRIu32 "u" +#define PRIx32 "x" +#define PRIX32 "X" +#endif // defined(_MSC_VER) && (_MSC_VER <= MSC_VER_VS2012) + +#if defined(_MSC_VER) && (_MSC_VER <= MSC_VER_VS2012) +// redefine functions from inttypes.h used in cstool +#define strtoull _strtoui64 +#endif + +#define PRId64 __PRI_64_LENGTH_MODIFIER__ "d" +#define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i" +#define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o" +#define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u" +#define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x" +#define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X" + +#else +// this system has inttypes.h by default +#include +#endif // #if defined(_MSC_VER) && (_MSC_VER < MSC_VER_VS2013) || defined(_KERNEL_MODE) + +#endif // #if defined(UNICORN_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER < MSC_VER_VS2013)) || defined(_KERNEL_MODE) + + + + +// sys/time.h compatibility +#if defined(_MSC_VER) +#include +#include +#include + +static int gettimeofday(struct timeval* t, void* timezone) +{ + struct _timeb timebuffer; + _ftime( &timebuffer ); + t->tv_sec = (long)timebuffer.time; + t->tv_usec = 1000*timebuffer.millitm; + return 0; +} + +#else +#include +#endif + + + + +// unistd.h compatibility +#if defined(_MSC_VER) +// TODO: add unistd stuff here ... + +static int usleep(uint32_t t) { + long value = t; // time in microseconds + struct timeval tv; + tv.tv_sec = value / 1000000; + tv.tv_usec = value % 1000000; + return select(0, NULL, NULL, NULL, &tv)==0 ? 0 : -1; +} +/* +#include +#include +static void usleep(const int64_t &t) { + std::this_thread::sleep_for(std::chrono::microseconds(t)); +} +*/ + +#else +#include +#endif + + + + +// termios.h compatibility +#if defined(_MSC_VER) +// TODO: termios stuff here ... +#else +#include +#endif + + + + +// strings.h compatibility +#if defined(_MSC_VER) +// TODO: strings stuff here ... +#else +#include +#endif + + + + +// misc support +#if defined(_MSC_VER) +#define snprintf _snprintf +#define strcasecmp _stricmp +#if (_MSC_VER <= MSC_VER_VS2013) +#define strtoll _strtoi64 +#endif +#endif + + + +#endif // UNICORN_PLATFORM_H