Get gmqcc/qcvm compiling on windows again. Plus work in progress support for the...
authorDale Weiler <killfieldengine@gmail.com>
Fri, 21 Dec 2012 06:00:51 +0000 (01:00 -0500)
committerDale Weiler <killfieldengine@gmail.com>
Fri, 21 Dec 2012 06:00:51 +0000 (01:00 -0500)
conout.c
exec.c
ftepp.c
gmqcc.h
gmqcc.vcxproj [deleted file]
msvc/gmqcc.sln [new file with mode: 0644]
msvc/gmqcc.vcxproj [new file with mode: 0644]
msvc/qcvm.vcxproj [new file with mode: 0644]
msvc/testsuite.vcxproj [new file with mode: 0644]
test.c

index 169aaa74fd70aa8825c1640dbe6d9486d426a07f..ff012c72067fbb6d7a4e34d97ee3aebc88690121 100644 (file)
--- a/conout.c
+++ b/conout.c
@@ -110,7 +110,6 @@ static void win_fputs(char *str, FILE *h) {
     int icolor;
 
     int state;
-    int place;
 
     /* attributes */
     int intense  =  -1;
@@ -219,7 +218,7 @@ static int con_write(FILE *handle, const char *fmt, va_list va) {
         data[ln] = 0;
         vsprintf(data, fmt, va);
         if (GMQCC_IS_DEFINE(handle))
-            ln = win_fputs(data, handle);
+            win_fputs(data, handle);
         else
             ln = fputs(data, handle);
         free(data);
diff --git a/exec.c b/exec.c
index 5af67851bf046ea43b62c5497abe5b0d3cfb3c79..6e51c027930a8a44c7dd360fd1443b029473b8c9 100644 (file)
--- a/exec.c
+++ b/exec.c
 
 #include "gmqcc.h"
 
-/*
-(prog_section_statement, code)
-(prog_section_def,       defs)
-(prog_section_def,       fields)
-(prog_section_function,  functions)
-(char,                   strings)
-(qcint,                  globals)
-(qcint,                  entitydata)
-(bool,                   entitypool)
-(qcint,         localstack)
-(qc_exec_stack, stack)
-(size_t, profile)
-(prog_builtin, builtins)
-(const char*, function_stack)
-*/
-
 static void loaderror(const char *fmt, ...)
 {
     int     err = errno;
diff --git a/ftepp.c b/ftepp.c
index 323514740cae1583ce113f0c8e66e0efd54925ca..96c20bf4f937f7ad0d55c9050e31b6813a3ab1a3 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -217,7 +217,7 @@ static void ftepp_macro_delete(ftepp_t *ftepp, const char *name)
     }
 }
 
-static inline int ftepp_next(ftepp_t *ftepp)
+static GMQCC_INLINE int ftepp_next(ftepp_t *ftepp)
 {
     return (ftepp->token = lex_do(ftepp->lex));
 }
diff --git a/gmqcc.h b/gmqcc.h
index 71873dc72ac53019c4673724706dfa2773cffe41..4c4d129df3aa868f251274962911c81fd4ce1d14 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -39,6 +39,7 @@
 #      pragma warning(disable : 4018 ) /* signed/unsigned mismatch                                */
 #      pragma warning(disable : 4996 ) /* This function or variable may be unsafe                 */
 #      pragma warning(disable : 4700 ) /* uninitialized local variable used                       */
+#      pragma warning(disable : 4129 ) /* unrecognized character secape sequence                  */
 #endif
 
 #define GMQCC_VERSION_MAJOR 0
 #    define GMQCC_NORETURN
 #endif
 
-/* TODO: visual studiblows work around */
 #ifndef _MSC_VER
 #   include <stdint.h>
+#else
+    typedef unsigned __int8  uint8_t;
+    typedef unsigned __int16 uint16_t;
+    typedef unsigned __int32 uint32_t;
+    typedef unsigned __int64 uint64_t;
+
+    typedef __int16          int16_t;
+    typedef __int32          int32_t;
+    typedef __int64          int64_t;
+#endif
+
+/* 
+ *windows makes these prefixed because they're C99
+ * TODO: utility versions that are type-safe and not
+ * just plain textual subsitution.
+ */
+#ifdef _MSC_VER
+#      define snprintf(X, Y, Z, ...) _snprintf(X, Y, Z, __VA_ARGS__)
+    /* strtof doesn't exist -> strtod does though :) */
+#      define strtof(X, Y)          (float)(strtod(X, Y))
 #endif
 
+
 /*
  * Very roboust way at determining endianess at compile time: this handles
  * almost every possible situation.  Otherwise a runtime check has to be
@@ -263,7 +284,7 @@ uint32_t util_crc32(uint32_t crc, const char *data, size_t len);
 /*
  * TODO: make these safer to use.  Currently this only works on
  * x86 and x86_64, some systems will likely not like this. Such
- * as BE systems.
+ * as BE systems. (and clean this up to use a structure ... )
  */
 #define FLT2INT(Y) *((int32_t*)&(Y))
 #define INT2FLT(Y) *((float  *)&(Y))
@@ -290,6 +311,7 @@ void _util_vec_grow(void **a, size_t i, size_t s);
 #define vec_shrinkto(A,N)    (_vec_end(A) = (N))
 #define vec_shrinkby(A,N)    (_vec_end(A) -= (N))
 
+/* vec_upload needs to be cleaned up as well to be a function */
 #define vec_upload(X,Y,S)      \
     do {                       \
         size_t E = 0;          \
@@ -365,11 +387,10 @@ enum {
 };
 
 /* const/var qualifiers */
-#define CV_NONE  0
-#define CV_CONST 1
-#define CV_VAR  -1
-/* magic number to help parsing */
-#define CV_WRONG  0x8000
+#define CV_NONE   0
+#define CV_CONST  1
+#define CV_VAR   -1
+#define CV_WRONG  0x8000 /* magic number to help parsing */
 
 extern const char *type_name        [TYPE_COUNT];
 extern uint16_t    type_store_instr [TYPE_COUNT];
@@ -580,6 +601,7 @@ enum {
     VINSTR_NRCALL
 };
 
+/* TODO: cleanup this mess */
 extern prog_section_statement *code_statements;
 extern int                    *code_linenums;
 extern prog_section_def       *code_defs;
@@ -589,6 +611,7 @@ extern int                    *code_globals;
 extern char                   *code_chars;
 extern uint16_t code_crc;
 
+/* uhh? */
 typedef float   qcfloat;
 typedef int32_t qcint;
 
@@ -663,6 +686,7 @@ bool GMQCC_WARN vcompile_warning(lex_ctx ctx, int warntype, const char *fmt, va_
 /*===================================================================*/
 /*========================= assembler.c =============================*/
 /*===================================================================*/
+/* TODO: remove this ... */
 static const struct {
     const char  *m; /* menomic     */
     const size_t o; /* operands    */
diff --git a/gmqcc.vcxproj b/gmqcc.vcxproj
deleted file mode 100755 (executable)
index 40111c9..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <ItemGroup Label="ProjectConfigurations">\r
-    <ProjectConfiguration Include="Debug|Win32">\r
-      <Configuration>Debug</Configuration>\r
-      <Platform>Win32</Platform>\r
-    </ProjectConfiguration>\r
-    <ProjectConfiguration Include="Release|Win32">\r
-      <Configuration>Release</Configuration>\r
-      <Platform>Win32</Platform>\r
-    </ProjectConfiguration>\r
-  </ItemGroup>\r
-  <PropertyGroup Label="Globals">\r
-    <ProjectGuid>{85C266A8-7938-4AE6-AB64-428DC32B1ACD}</ProjectGuid>\r
-    <RootNamespace>gmqcc</RootNamespace>\r
-  </PropertyGroup>\r
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
-    <ConfigurationType>Application</ConfigurationType>\r
-    <UseDebugLibraries>true</UseDebugLibraries>\r
-    <CharacterSet>NotSet</CharacterSet>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
-    <ConfigurationType>Application</ConfigurationType>\r
-    <UseDebugLibraries>false</UseDebugLibraries>\r
-    <WholeProgramOptimization>true</WholeProgramOptimization>\r
-    <CharacterSet>NotSet</CharacterSet>\r
-  </PropertyGroup>\r
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
-  <ImportGroup Label="ExtensionSettings">\r
-  </ImportGroup>\r
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
-  </ImportGroup>\r
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
-  </ImportGroup>\r
-  <PropertyGroup Label="UserMacros" />\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
-    <OutDir>.\</OutDir>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
-    <IntDir>.\</IntDir>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
-    <TargetName>gmqcc</TargetName>\r
-    <GenerateManifest>false</GenerateManifest>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
-    <OutDir>.</OutDir>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
-    <IntDir>.</IntDir>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
-    <TargetName>gmqcc</TargetName>\r
-    <GenerateManifest>false</GenerateManifest>\r
-  </PropertyGroup>\r
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
-    <ClCompile>\r
-      <WarningLevel>Level3</WarningLevel>\r
-      <Optimization>Disabled</Optimization>\r
-      <AdditionalIncludeDirectories>.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <ExceptionHandling>false</ExceptionHandling>\r
-      <BufferSecurityCheck>false</BufferSecurityCheck>\r
-      <FloatingPointModel>Fast</FloatingPointModel>\r
-      <PrecompiledHeaderFile>\r
-      </PrecompiledHeaderFile>\r
-      <PrecompiledHeaderOutputFile>\r
-      </PrecompiledHeaderOutputFile>\r
-    </ClCompile>\r
-    <Link>\r
-      <GenerateDebugInformation>true</GenerateDebugInformation>\r
-      <ManifestFile>\r
-      </ManifestFile>\r
-      <ProgramDatabaseFile>$(TargetName).pdb</ProgramDatabaseFile>\r
-      <SubSystem>Console</SubSystem>\r
-    </Link>\r
-  </ItemDefinitionGroup>\r
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
-    <ClCompile>\r
-      <WarningLevel>Level3</WarningLevel>\r
-      <Optimization>MaxSpeed</Optimization>\r
-      <FunctionLevelLinking>true</FunctionLevelLinking>\r
-      <IntrinsicFunctions>true</IntrinsicFunctions>\r
-      <AdditionalIncludeDirectories>.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <ExceptionHandling>false</ExceptionHandling>\r
-      <BufferSecurityCheck>false</BufferSecurityCheck>\r
-      <FloatingPointModel>Fast</FloatingPointModel>\r
-      <PrecompiledHeaderFile>\r
-      </PrecompiledHeaderFile>\r
-      <PrecompiledHeaderOutputFile>\r
-      </PrecompiledHeaderOutputFile>\r
-    </ClCompile>\r
-    <Link>\r
-      <GenerateDebugInformation>true</GenerateDebugInformation>\r
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
-      <OptimizeReferences>true</OptimizeReferences>\r
-      <ManifestFile>\r
-      </ManifestFile>\r
-      <ProgramDatabaseFile>$(TargetName).pdb</ProgramDatabaseFile>\r
-      <SubSystem>Console</SubSystem>\r
-    </Link>\r
-  </ItemDefinitionGroup>\r
-  <ItemGroup>\r
-    <ClCompile Include="asm.c" />\r
-    <ClCompile Include="ast.c" />\r
-    <ClCompile Include="code.c" />\r
-    <ClCompile Include="error.c" />\r
-    <ClCompile Include="exec.c" />\r
-    <ClCompile Include="ir.c" />\r
-    <ClCompile Include="lexer.c" />\r
-    <ClCompile Include="main.c" />\r
-    <ClCompile Include="parser.c" />\r
-    <ClCompile Include="util.c" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClInclude Include="ast.h" />\r
-    <ClInclude Include="execloop.h" />\r
-    <ClInclude Include="gmqcc.h" />\r
-    <ClInclude Include="ir.h" />\r
-    <ClInclude Include="lexer.h" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <None Include="flags.def" />\r
-    <None Include="warns.def" />\r
-  </ItemGroup>\r
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
-  <ImportGroup Label="ExtensionTargets">\r
-  </ImportGroup>\r
-</Project>
\ No newline at end of file
diff --git a/msvc/gmqcc.sln b/msvc/gmqcc.sln
new file mode 100644 (file)
index 0000000..8d3de2e
--- /dev/null
@@ -0,0 +1,32 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qcvm", "qcvm.vcxproj", "{8DC505A6-6047-4683-BA81-BC4B7A839352}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmqcc", "gmqcc.vcxproj", "{0F0B0779-1A2F-43E9-B833-18C443F7229E}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsuite", "testsuite.vcxproj", "{3F8F0021-66B8-43ED-906C-1CFE204E5673}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Win32 = Debug|Win32
+               Release|Win32 = Release|Win32
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {8DC505A6-6047-4683-BA81-BC4B7A839352}.Debug|Win32.ActiveCfg = Debug|Win32
+               {8DC505A6-6047-4683-BA81-BC4B7A839352}.Debug|Win32.Build.0 = Debug|Win32
+               {8DC505A6-6047-4683-BA81-BC4B7A839352}.Release|Win32.ActiveCfg = Release|Win32
+               {8DC505A6-6047-4683-BA81-BC4B7A839352}.Release|Win32.Build.0 = Release|Win32
+               {0F0B0779-1A2F-43E9-B833-18C443F7229E}.Debug|Win32.ActiveCfg = Debug|Win32
+               {0F0B0779-1A2F-43E9-B833-18C443F7229E}.Debug|Win32.Build.0 = Debug|Win32
+               {0F0B0779-1A2F-43E9-B833-18C443F7229E}.Release|Win32.ActiveCfg = Release|Win32
+               {0F0B0779-1A2F-43E9-B833-18C443F7229E}.Release|Win32.Build.0 = Release|Win32
+               {3F8F0021-66B8-43ED-906C-1CFE204E5673}.Debug|Win32.ActiveCfg = Debug|Win32
+               {3F8F0021-66B8-43ED-906C-1CFE204E5673}.Debug|Win32.Build.0 = Debug|Win32
+               {3F8F0021-66B8-43ED-906C-1CFE204E5673}.Release|Win32.ActiveCfg = Release|Win32
+               {3F8F0021-66B8-43ED-906C-1CFE204E5673}.Release|Win32.Build.0 = Release|Win32
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/msvc/gmqcc.vcxproj b/msvc/gmqcc.vcxproj
new file mode 100644 (file)
index 0000000..8c03288
--- /dev/null
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{0F0B0779-1A2F-43E9-B833-18C443F7229E}</ProjectGuid>
+    <RootNamespace>gmqcc</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup />
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="..\ast.c" />
+    <ClCompile Include="..\code.c" />
+    <ClCompile Include="..\conout.c" />
+    <ClCompile Include="..\ftepp.c" />
+    <ClCompile Include="..\ir.c" />
+    <ClCompile Include="..\lexer.c" />
+    <ClCompile Include="..\main.c" />
+    <ClCompile Include="..\opts.c" />
+    <ClCompile Include="..\parser.c" />
+    <ClCompile Include="..\util.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\ast.h" />
+    <ClInclude Include="..\gmqcc.h" />
+    <ClInclude Include="..\ir.h" />
+    <ClInclude Include="..\lexer.h" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/msvc/qcvm.vcxproj b/msvc/qcvm.vcxproj
new file mode 100644 (file)
index 0000000..48d06df
--- /dev/null
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{8DC505A6-6047-4683-BA81-BC4B7A839352}</ProjectGuid>
+    <RootNamespace>qcvm</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+    <UseOfMfc>false</UseOfMfc>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup />
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Full</Optimization>
+      <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <OmitFramePointers>true</OmitFramePointers>
+      <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
+      <PreprocessorDefinitions>QCVM_EXECUTOR=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Full</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+      <OmitFramePointers>true</OmitFramePointers>
+      <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
+      <PreprocessorDefinitions>QCVM_EXECUTOR=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="..\conout.c" />
+    <ClCompile Include="..\exec.c" />
+    <ClCompile Include="..\util.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\gmqcc.h" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/msvc/testsuite.vcxproj b/msvc/testsuite.vcxproj
new file mode 100644 (file)
index 0000000..cfe055f
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{3F8F0021-66B8-43ED-906C-1CFE204E5673}</ProjectGuid>
+    <RootNamespace>testsuite</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup />
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="..\conout.c" />
+    <ClCompile Include="..\test.c" />
+    <ClCompile Include="..\util.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\gmqcc.h" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/test.c b/test.c
index 6ca4fec8ca92ab1a06b1dd0beba7cf99f7d0dc47..ed0abc1f85c51062763c015fc7643b98deca17b2 100644 (file)
--- a/test.c
+++ b/test.c
@@ -23,7 +23,6 @@
 #include "gmqcc.h"
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <dirent.h>
 
 opts_cmd_t opts;
 
@@ -50,6 +49,7 @@ char *task_bins[] = {
 #ifndef _WIN32
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <dirent.h>
 #include <unistd.h>
 typedef struct {
     FILE *handles[3];
@@ -156,7 +156,86 @@ int task_pclose(FILE **handles) {
     return status;
 }
 #else
-#error "There is no support for windows yet ... this is not a FTBFS bug"
+#      ifdef __MINGW32__
+        /* mingw32 has dirent.h */
+#              include <dirent.h>
+#      elif defined (_MSC_VER)
+#              define _WIN32_LEAN_AND_MEAN
+#              include <Windows.h>
+#              include <io.h>
+        /* 
+         * visual studio lacks dirent.h it's a posix thing
+         * so we emulate it with the WinAPI.
+         */
+
+        struct dirent {
+            long           d_ino;
+            unsigned short d_reclen;
+            unsigned short d_namlen;
+            char           d_name[FILENAME_MAX];
+        };
+
+        typedef struct {
+            struct _finddata_t dd_dta;
+            struct dirent      dd_dir;
+            long               dd_handle;
+            int                dd_stat;
+            char               dd_name[1];
+        } DIR;
+
+        DIR *opendir(const char *name) {
+            DIR *dir = (DIR*)mem_a(sizeof(DIR) + strlen(name));
+            if (!dir)
+                return NULL;
+
+            strcpy(dir->dd_name, name);
+            return dir;
+        }
+            
+        int closedir(DIR *dir) {
+            FindClose((HANDLE)dir->dd_handle);
+            mem_d ((void*)dir);
+            return 0;
+        }
+
+        struct dirent *readdir(DIR *dir) {
+            WIN32_FIND_DATA info;
+            struct dirent  *data;
+            int             rets;
+
+            if (!dir->dd_handle) {
+                char *dirname;
+                if (*dir->dd_name) {
+                    size_t n = strlen(dir->dd_name);
+                    if ((dirname  = (char*)mem_a(n + 5) /* 4 + 1 */)) {
+                        strcpy(dirname,     dir->dd_name);
+                        strcpy(dirname + n, "\\*.*");   /* 4 + 1 */
+                    }
+                } else {
+                    if (!(dirname = util_strdup("\\*.*")))
+                        return NULL;
+                }
+
+                dir->dd_handle = (long)FindFirstFile(dirname, &info);
+                mem_d(dirname);
+                rets = !(!dir->dd_handle);
+            } else if (dir->dd_handle != -11) {
+                rets = FindNextFile ((HANDLE)dir->dd_handle, &info);
+            } else {
+                rets = 0;
+            }
+
+            if (!rets)
+                return NULL;
+            
+            if ((data = (struct dirent*)mem_a(sizeof(struct dirent)))) {
+                strncpy(data->d_name, info.cFileName, FILENAME_MAX - 1);
+                data->d_name[FILENAME_MAX - 1] = '\0'; /* terminate */
+                data->d_namlen                 = strlen(data->d_name);
+            }
+            return data;
+        }
+#      endif
 #endif
 
 #define TASK_COMPILE 0