Get gmqcc/qcvm compiling on windows again. Plus work in progress support for the testsuite on windows (does not compile yet).

This commit is contained in:
Dale Weiler 2012-12-21 01:00:51 -05:00
parent 0be55824d4
commit 3c003bc168
9 changed files with 388 additions and 158 deletions

View file

@ -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);

16
exec.c
View file

@ -29,22 +29,6 @@
#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;

View file

@ -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));
}

38
gmqcc.h
View file

@ -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
@ -134,11 +135,31 @@
# 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 */

32
msvc/gmqcc.sln Normal file
View file

@ -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

212
gmqcc.vcxproj → msvc/gmqcc.vcxproj Executable file → Normal file
View file

@ -1,131 +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>{85C266A8-7938-4AE6-AB64-428DC32B1ACD}</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>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</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 Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>.\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IntDir>.\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>gmqcc</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>.</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IntDir>.</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>gmqcc</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ExceptionHandling>false</ExceptionHandling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointModel>Fast</FloatingPointModel>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ManifestFile>
</ManifestFile>
<ProgramDatabaseFile>$(TargetName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ExceptionHandling>false</ExceptionHandling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointModel>Fast</FloatingPointModel>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ManifestFile>
</ManifestFile>
<ProgramDatabaseFile>$(TargetName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="asm.c" />
<ClCompile Include="ast.c" />
<ClCompile Include="code.c" />
<ClCompile Include="error.c" />
<ClCompile Include="exec.c" />
<ClCompile Include="ir.c" />
<ClCompile Include="lexer.c" />
<ClCompile Include="main.c" />
<ClCompile Include="parser.c" />
<ClCompile Include="util.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="ast.h" />
<ClInclude Include="execloop.h" />
<ClInclude Include="gmqcc.h" />
<ClInclude Include="ir.h" />
<ClInclude Include="lexer.h" />
</ItemGroup>
<ItemGroup>
<None Include="flags.def" />
<None Include="warns.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<?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>

87
msvc/qcvm.vcxproj Normal file
View file

@ -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>

73
msvc/testsuite.vcxproj Normal file
View file

@ -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>

83
test.c
View file

@ -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