diff --git a/bindings/msvc_native/msvc_native.sln b/bindings/msvc_native/msvc_native.sln
index 2571942c..b8d3053c 100644
--- a/bindings/msvc_native/msvc_native.sln
+++ b/bindings/msvc_native/msvc_native.sln
@@ -3,16 +3,61 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x86_64-softmmu", "x86_64-softmmu\x86_64-softmmu.vcxproj", "{17077E86-AE7C-41AF-86ED-2BAC03B019BC}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unicorn", "unicorn\unicorn.vcxproj", "{B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}"
+ ProjectSection(ProjectDependencies) = postProject
+ {17077E86-AE7C-41AF-86ED-2BAC03B019BC} = {17077E86-AE7C-41AF-86ED-2BAC03B019BC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample_x86", "sample_x86\sample_x86.vcxproj", "{F8053D66-8267-433A-BF2C-E07E2298C338}"
+ ProjectSection(ProjectDependencies) = postProject
+ {17077E86-AE7C-41AF-86ED-2BAC03B019BC} = {17077E86-AE7C-41AF-86ED-2BAC03B019BC}
+ {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96} = {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Debug|Win32.ActiveCfg = Debug|Win32
{17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Debug|Win32.Build.0 = Debug|Win32
+ {17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Debug|x64.ActiveCfg = Debug|x64
+ {17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Debug|x64.Build.0 = Debug|x64
+ {17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Release|Mixed Platforms.Build.0 = Release|Win32
{17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Release|Win32.ActiveCfg = Release|Win32
{17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Release|Win32.Build.0 = Release|Win32
+ {17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Release|x64.ActiveCfg = Release|x64
+ {17077E86-AE7C-41AF-86ED-2BAC03B019BC}.Release|x64.Build.0 = Release|x64
+ {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Debug|Mixed Platforms.ActiveCfg = Debug|x64
+ {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Debug|Mixed Platforms.Build.0 = Debug|x64
+ {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}.Debug|x64.ActiveCfg = Debug|x64
+ {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Debug|x64.Build.0 = Debug|x64
+ {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Release|Win32.ActiveCfg = Release|Win32
+ {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Release|Win32.Build.0 = Release|Win32
+ {B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}.Release|x64.ActiveCfg = Release|Win32
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Debug|Win32.Build.0 = Debug|Win32
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Debug|x64.ActiveCfg = Debug|x64
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Debug|x64.Build.0 = Debug|x64
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Release|Win32.ActiveCfg = Release|Win32
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Release|Win32.Build.0 = Release|Win32
+ {F8053D66-8267-433A-BF2C-E07E2298C338}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/bindings/msvc_native/readme.txt b/bindings/msvc_native/readme.txt
index 0703b072..f859d689 100644
--- a/bindings/msvc_native/readme.txt
+++ b/bindings/msvc_native/readme.txt
@@ -263,3 +263,11 @@ config-host.h is bindings/msvc_native/config-host.h
:: Other things
* GNU seems to rely on __i386__ or __x86_64__ defined if the host is 32bit or 64bit respectively.
+ So when building 32bit libs in msvc we define __i386__.
+ And when building 64bit libs in msvc we define __x86_64__.
+
+* There is a tcg-target.c for each target that is included into tcg.c.
+ It is NOT built separately as part of the *.c files built for the project.
+
+
+
diff --git a/bindings/msvc_native/unicorn/unicorn.vcxproj b/bindings/msvc_native/unicorn/unicorn.vcxproj
index 452809fd..080d702f 100644
--- a/bindings/msvc_native/unicorn/unicorn.vcxproj
+++ b/bindings/msvc_native/unicorn/unicorn.vcxproj
@@ -5,39 +5,25 @@
Debug
Win32
+
+ Debug
+ x64
+
Release
Win32
+
+ Release
+ x64
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -58,77 +44,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -157,13 +73,6 @@
-
-
-
-
-
-
-
@@ -255,79 +164,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{B6EFD6D7-C2D4-4FBB-B363-2E08CE09CC96}
@@ -341,6 +180,12 @@
v110_xp
MultiByte
+
+ StaticLibrary
+ true
+ v110_xp
+ MultiByte
+
StaticLibrary
false
@@ -348,15 +193,28 @@
true
MultiByte
+
+ StaticLibrary
+ false
+ v110_xp
+ true
+ MultiByte
+
+
+
+
+
+
+
@@ -365,9 +223,28 @@
Level3
Disabled
- WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;inline=__inline;__func__=__FUNCTION__;UNICORN_HAS_X86;UNICORN_HAS_ARM;UNICORN_HAS_M68K;UNICORN_HAS_ARM64;UNICORN_HAS_MIPS;UNICORN_HAS_MIPSEL;UNICORN_HAS_MIPS64;UNICORN_HAS_MIPS64EL;UNICORN_HAS_SPARC
+ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;inline=__inline;__func__=__FUNCTION__;__i386__;UNICORN_HAS_X86
MultiThreadedDebug
- ../../..;../../../include;../../../qemu;../../../qemu/include;../../../qemu/tcg;
+ .;..;../../../include;../../../qemu;../../../qemu/include;../../../qemu/tcg
+ /wd4018 /wd4244 /wd4267 %(AdditionalOptions)
+ false
+
+
+ Windows
+ true
+
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;inline=__inline;__func__=__FUNCTION__;__x86_64__;UNICORN_HAS_X86
+ MultiThreadedDebug
+ .;..;../../../include;../../../qemu;../../../qemu/include;../../../qemu/tcg
+ /wd4018 /wd4244 /wd4267 %(AdditionalOptions)
+ false
Windows
@@ -382,9 +259,32 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;;inline=__inline;__func__=__FUNCTION__;UNICORN_HAS_X86;UNICORN_HAS_ARM;UNICORN_HAS_M68K;UNICORN_HAS_ARM64;UNICORN_HAS_MIPS;UNICORN_HAS_MIPSEL;UNICORN_HAS_MIPS64;UNICORN_HAS_MIPS64EL;UNICORN_HAS_SPARC
+ WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;inline=__inline;__func__=__FUNCTION__;__i386__;UNICORN_HAS_X86
MultiThreadedDebug
- ../../..;../../../include;../../../qemu;../../../qemu/include;../../../qemu/tcg;
+ .;..;../../../include;../../../qemu;../../../qemu/include;../../../qemu/tcg
+ /wd4018 /wd4244 /wd4267 %(AdditionalOptions)
+ false
+
+
+ Windows
+ true
+ true
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;inline=__inline;__func__=__FUNCTION__;__x86_64__;UNICORN_HAS_X86
+ MultiThreadedDebug
+ .;..;../../../include;../../../qemu;../../../qemu/include;../../../qemu/tcg
+ /wd4018 /wd4244 /wd4267 %(AdditionalOptions)
+ false
Windows
diff --git a/bindings/msvc_native/unicorn/unicorn.vcxproj.filters b/bindings/msvc_native/unicorn/unicorn.vcxproj.filters
index 73c943b4..b9537f69 100644
--- a/bindings/msvc_native/unicorn/unicorn.vcxproj.filters
+++ b/bindings/msvc_native/unicorn/unicorn.vcxproj.filters
@@ -10,9 +10,6 @@
{1f3288bd-38e9-49c1-ae30-6ac4bc1b86c4}
-
- {c0201656-497d-4ed6-8a56-dd0762761a3e}
-
{d98a987f-6e81-4454-9bb4-f79d49d1d8fa}
@@ -25,75 +22,9 @@
{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}
@@ -139,33 +70,6 @@
{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}
-
@@ -174,30 +78,9 @@
qemu
-
- qemu
-
-
- qemu
-
-
- qemu
-
-
- qemu
-
qemu
-
- qemu
-
-
- qemu
-
-
- qemu
-
qemu
@@ -213,63 +96,15 @@
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
@@ -318,213 +153,6 @@
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
@@ -576,72 +204,15 @@
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
@@ -915,180 +486,6 @@
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
-
diff --git a/include/platform.h b/include/platform.h
index 2ba818c7..8c34bcfb 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -195,11 +195,16 @@ static int gettimeofday(struct timeval* t, void* timezone)
// TODO: add unistd stuff here ...
static int usleep(uint32_t t) {
+ int ret, err_code;
long value = t; // time in microseconds
struct timeval tv;
+ FD_SET dummy_set;
+ FD_ZERO(&dummy_set);
tv.tv_sec = value / 1000000;
tv.tv_usec = value % 1000000;
- return select(0, NULL, NULL, NULL, &tv)==0 ? 0 : -1;
+ ret = select(0, &dummy_set, NULL, NULL, &tv);
+ err_code = WSAGetLastError();
+ return ret==0 ? 0 : -1;
}
/*
#include
diff --git a/qemu/hw/core/machine.c b/qemu/hw/core/machine.c
index 4512985f..8e53263b 100644
--- a/qemu/hw/core/machine.c
+++ b/qemu/hw/core/machine.c
@@ -21,13 +21,24 @@ static void machine_finalize(struct uc_struct *uc, Object *obj, void *opaque)
}
static const TypeInfo machine_info = {
- .name = TYPE_MACHINE,
- .parent = TYPE_OBJECT,
- .abstract = true,
- .class_size = sizeof(MachineClass),
- .instance_size = sizeof(MachineState),
- .instance_init = machine_initfn,
- .instance_finalize = machine_finalize,
+ TYPE_MACHINE,
+ TYPE_OBJECT,
+
+ sizeof(MachineClass),
+ sizeof(MachineState),
+ NULL,
+
+ machine_initfn,
+ NULL,
+ machine_finalize,
+
+ NULL,
+
+ NULL,
+ NULL,
+ NULL,
+
+ true,
};
void machine_register_types(struct uc_struct *uc)
diff --git a/qemu/hw/core/qdev.c b/qemu/hw/core/qdev.c
index 14e3ccec..17b3fe7d 100644
--- a/qemu/hw/core/qdev.c
+++ b/qemu/hw/core/qdev.c
@@ -280,16 +280,24 @@ Object *qdev_get_machine(struct uc_struct *uc)
}
static const TypeInfo device_type_info = {
- .name = TYPE_DEVICE,
- .parent = TYPE_OBJECT,
- .instance_size = sizeof(DeviceState),
- .instance_init = device_initfn,
- .instance_post_init = device_post_init,
- .instance_finalize = device_finalize,
- .class_base_init = device_class_base_init,
- .class_init = device_class_init,
- .abstract = true,
- .class_size = sizeof(DeviceClass),
+ TYPE_DEVICE,
+ TYPE_OBJECT,
+
+ sizeof(DeviceClass),
+ sizeof(DeviceState),
+ NULL,
+
+ device_initfn,
+ device_post_init,
+ device_finalize,
+
+ NULL,
+
+ device_class_init,
+ device_class_base_init,
+ NULL,
+
+ true,
};
static void qbus_initfn(struct uc_struct *uc, Object *obj, void *opaque)
@@ -309,14 +317,24 @@ static void qbus_finalize(struct uc_struct *uc, Object *obj, void *opaque)
}
static const TypeInfo bus_info = {
- .name = TYPE_BUS,
- .parent = TYPE_OBJECT,
- .instance_size = sizeof(BusState),
- .abstract = true,
- .class_size = sizeof(BusClass),
- .instance_init = qbus_initfn,
- .instance_finalize = qbus_finalize,
- .class_init = bus_class_init,
+ TYPE_BUS,
+ TYPE_OBJECT,
+
+ sizeof(BusClass),
+ sizeof(BusState),
+ NULL,
+
+ qbus_initfn,
+ NULL,
+ qbus_finalize,
+
+ NULL,
+
+ bus_class_init,
+ NULL,
+ NULL,
+
+ true,
};
void qdev_register_types(struct uc_struct *uc)
diff --git a/qemu/include/exec/cpu-defs.h b/qemu/include/exec/cpu-defs.h
index 5b456add..2396e751 100644
--- a/qemu/include/exec/cpu-defs.h
+++ b/qemu/include/exec/cpu-defs.h
@@ -94,10 +94,14 @@ typedef struct CPUTLBEntry {
use the corresponding iotlb value. */
uintptr_t addend;
/* padding to get a power of two size */
- uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
+#if defined(_MSC_VER) && defined(_WIN64)
+ // dummy would be size 0 which isnt supported by msvc, so we remove it
+#else
+ uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
(sizeof(target_ulong) * 3 +
(((-(int)sizeof(target_ulong)) * 3) & (sizeof(uintptr_t) - 1)) +
sizeof(uintptr_t))];
+#endif
} CPUTLBEntry;
QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS));
diff --git a/qemu/include/qemu/atomic.h b/qemu/include/qemu/atomic.h
index b4d5d6b0..f9fbd7ca 100644
--- a/qemu/include/qemu/atomic.h
+++ b/qemu/include/qemu/atomic.h
@@ -199,18 +199,13 @@
/* Provide shorter names for GCC atomic builtins. */
#ifdef _MSC_VER
-#ifdef _WIN64
-#define atomic_fetch_inc(ptr) InterlockedIncrement64(ptr)
-#define atomic_fetch_dec(ptr) InterlockedDecrement64(ptr)
-#define atomic_fetch_add(ptr, n) InterlockedAdd64(ptr, n)
-#define atomic_fetch_sub(ptr, n) InterlockedAdd64(ptr, -n)
-#else
-#define atomic_fetch_inc(ptr) InterlockedIncrement(ptr)
-#define atomic_fetch_dec(ptr) InterlockedDecrement(ptr)
-#define atomic_fetch_add(ptr, n) InterlockedAdd(ptr, n)
-#define atomic_fetch_sub(ptr, n) InterlockedAdd(ptr, -n)
-#endif
+// these return the new value (so we make it return the previous value)
+#define atomic_fetch_inc(ptr) ((InterlockedIncrement(ptr))-1)
+#define atomic_fetch_dec(ptr) ((InterlockedDecrement(ptr))+1)
+#define atomic_fetch_add(ptr, n) ((InterlockedAdd(ptr, n))-n)
+#define atomic_fetch_sub(ptr, n) ((InterlockedAdd(ptr, -n))+n)
#else
+// these return the previous value
#define atomic_fetch_inc(ptr) __sync_fetch_and_add(ptr, 1)
#define atomic_fetch_dec(ptr) __sync_fetch_and_add(ptr, -1)
#define atomic_fetch_add __sync_fetch_and_add
@@ -222,17 +217,10 @@
/* And even shorter names that return void. */
#ifdef _MSC_VER
-#ifdef _WIN64
-#define atomic_inc(ptr) ((void) InterlockedIncrement64(ptr))
-#define atomic_dec(ptr) ((void) InterlockedDecrement64(ptr))
-#define atomic_add(ptr, n) ((void) InterlockedAdd64(ptr, n))
-#define atomic_sub(ptr, n) ((void) InterlockedAdd64(ptr, -n))
-#else
#define atomic_inc(ptr) ((void) InterlockedIncrement(ptr))
#define atomic_dec(ptr) ((void) InterlockedDecrement(ptr))
#define atomic_add(ptr, n) ((void) InterlockedAdd(ptr, n))
#define atomic_sub(ptr, n) ((void) InterlockedAdd(ptr, -n))
-#endif
#else
#define atomic_inc(ptr) ((void) __sync_fetch_and_add(ptr, 1))
#define atomic_dec(ptr) ((void) __sync_fetch_and_add(ptr, -1))
diff --git a/qemu/include/qemu/timer.h b/qemu/include/qemu/timer.h
index 5cc5c8aa..da2dfbe1 100644
--- a/qemu/include/qemu/timer.h
+++ b/qemu/include/qemu/timer.h
@@ -558,6 +558,9 @@ static inline int64_t cpu_get_real_ticks(void)
static inline int64_t cpu_get_real_ticks(void)
{
+#ifdef _MSC_VER
+ return __rdtsc();
+#else
uint32_t low,high;
int64_t val;
asm volatile("rdtsc" : "=a" (low), "=d" (high));
@@ -565,6 +568,7 @@ static inline int64_t cpu_get_real_ticks(void)
val <<= 32;
val |= low;
return val;
+#endif
}
#elif defined(__hppa__)
diff --git a/qemu/include/sysemu/os-win32.h b/qemu/include/sysemu/os-win32.h
index b0494872..6e5f3b71 100644
--- a/qemu/include/sysemu/os-win32.h
+++ b/qemu/include/sysemu/os-win32.h
@@ -56,7 +56,7 @@
# define EWOULDBLOCK WSAEWOULDBLOCK
#endif
-#if defined(_WIN64)
+#if defined(_WIN64) && !defined(_MSC_VER)
/* On w64, setjmp is implemented by _setjmp which needs a second parameter.
* If this parameter is NULL, longjump does no stack unwinding.
* That is what we need for QEMU. Passing the value of register rsp (default)
diff --git a/qemu/memory.c b/qemu/memory.c
index 0aa1df68..e47765a8 100644
--- a/qemu/memory.c
+++ b/qemu/memory.c
@@ -400,7 +400,7 @@ static void flatview_destroy(FlatView *view)
static void flatview_ref(FlatView *view)
{
- atomic_inc(&view->ref);
+ atomic_inc(&view->ref);
}
static void flatview_unref(FlatView *view)
diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h
index 5f3921d6..b0686884 100644
--- a/qemu/target-i386/cpu.h
+++ b/qemu/target-i386/cpu.h
@@ -977,7 +977,16 @@ typedef struct CPUX86State {
uint8_t nmi_injected;
uint8_t nmi_pending;
- CPU_COMMON
+#if NB_MMU_MODES == 0
+#error NB_MMU_MODES is zero
+#endif
+#if CPU_TLB_SIZE == 0
+#error CPU_TLB_SIZE is zero
+#endif
+#if CPU_VTLB_SIZE == 0
+#error CPU_VTLB_SIZE is zero
+#endif
+ CPU_COMMON
/* Fields from here on are preserved across CPU reset. */
diff --git a/qemu/tcg/tcg.c b/qemu/tcg/tcg.c
index 624ef8d8..a1549993 100644
--- a/qemu/tcg/tcg.c
+++ b/qemu/tcg/tcg.c
@@ -2375,7 +2375,11 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def,
flags = args[nb_oargs + nb_iargs + 1];
nb_regs = ARRAY_SIZE(tcg_target_call_iarg_regs);
- if (nb_regs > nb_params) {
+#if TCG_TARGET_REG_BITS == 32
+ // do this because msvc cannot have arrays with 0 entries.
+ nb_regs = 0;
+#endif
+ if (nb_regs > nb_params) {
nb_regs = nb_params;
}
diff --git a/qemu/util/qemu-thread-win32.c b/qemu/util/qemu-thread-win32.c
index f587953f..1c2878a9 100644
--- a/qemu/util/qemu-thread-win32.c
+++ b/qemu/util/qemu-thread-win32.c
@@ -127,7 +127,9 @@ void *qemu_thread_join(QemuThread *thread)
ret = data->ret;
assert(data->mode != QEMU_THREAD_DETACHED);
DeleteCriticalSection(&data->cs);
+ data->uc->qemu_thread_data = NULL;
g_free(data);
+ data = NULL;
return ret;
}
diff --git a/samples/sample_x86.c b/samples/sample_x86.c
index ca4309f7..609304ad 100644
--- a/samples/sample_x86.c
+++ b/samples/sample_x86.c
@@ -3,6 +3,14 @@
/* Sample code to demonstrate how to emulate X86 code */
+#include "platform.h"
+#include
+
+#pragma comment(lib, "ws2_32.lib")
+#pragma comment(lib, "unicorn.lib")
+#pragma comment(lib, "x86_64-softmmu.lib")
+
+/*
// windows specific
#ifdef _MSC_VER
#include
@@ -25,6 +33,7 @@
#include "platform.h"
#include
#endif // _MSC_VER
+*/
// common includes
#include
@@ -1005,7 +1014,7 @@ int main(int argc, char **argv, char **envp)
test_x86_16();
}
else if (!strcmp(argv[1], "-32")) {
- test_i386();
+ test_i386();
test_i386_map_ptr();
test_i386_inout();
test_i386_context_save();
diff --git a/uc.c b/uc.c
index d7d6becc..ca01a093 100644
--- a/uc.c
+++ b/uc.c
@@ -270,7 +270,15 @@ uc_err uc_open(uc_arch arch, uc_mode mode, uc_engine **result)
if (uc->reg_reset)
uc->reg_reset(uc);
- return UC_ERR_OK;
+ // init winsock sockets so we can use select() for usleep() implementation
+#ifdef _MSC_VER
+ {
+ WSADATA wsa_data;
+ WSAStartup(0x202, &wsa_data);
+ }
+#endif
+
+ return UC_ERR_OK;
} else {
return UC_ERR_ARCH;
}
@@ -312,7 +320,7 @@ uc_err uc_close(uc_engine *uc)
// Thread relateds.
if (uc->qemu_thread_data)
- free(uc->qemu_thread_data);
+ g_free(uc->qemu_thread_data);
// Other auxilaries.
free(uc->l1_map);
@@ -349,7 +357,14 @@ uc_err uc_close(uc_engine *uc)
memset(uc, 0, sizeof(*uc));
free(uc);
- return UC_ERR_OK;
+ // free winsock sockets - used so we can use select() for usleep() implementation
+#ifdef _MSC_VER
+ {
+ WSACleanup();
+ }
+#endif
+
+ return UC_ERR_OK;
}