Skip to content

Commit

Permalink
Fixed 64-bit c function mocking, few weird minor fixes for Win64.
Browse files Browse the repository at this point in the history
  • Loading branch information
dascandy committed Jan 20, 2014
1 parent 09f7068 commit 431b008
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
10 changes: 7 additions & 3 deletions HippoMocks/hippomocks.h
Expand Up @@ -46,20 +46,20 @@
#define HM_NS HippoMocks::
#endif

#ifndef DEBUGBREAK
#ifdef _MSC_VER
#ifdef _WIN64
#define WINCALL
#else
#define WINCALL __stdcall
#endif
#endif
#ifndef DEBUGBREAK
extern "C" __declspec(dllimport) int WINCALL IsDebuggerPresent();
extern "C" __declspec(dllimport) void WINCALL DebugBreak();
#define DEBUGBREAK(e) if (IsDebuggerPresent()) DebugBreak(); else (void)0
#else
#define DEBUGBREAK(e)
#endif
#endif

#ifndef DONTCARE_NAME
#define DONTCARE_NAME _
Expand Down Expand Up @@ -90,7 +90,7 @@ extern "C" __declspec(dllimport) void WINCALL DebugBreak();
#endif

#if defined(__x86_64__) || defined(_M_X64)
#define CFUNC_MOCK_PLATFORMIS64BIT
#define CMOCK_FUNC_PLATFORMIS64BIT
#endif

#ifdef SOME_X86
Expand Down Expand Up @@ -193,7 +193,11 @@ ExceptionHolder *ExceptionHolder::Create(T ex)
}

// De-windows.h-ified import to avoid including that file.
#ifdef _WIN64
extern "C" __declspec(dllimport) int WINCALL VirtualProtect(void *func, unsigned long long byteCount, unsigned long flags, unsigned long *oldFlags);
#else
extern "C" __declspec(dllimport) int WINCALL VirtualProtect(void *func, unsigned long byteCount, unsigned long flags, unsigned long *oldFlags);
#endif

#ifndef PAGE_EXECUTE_READWRITE
#define PAGE_EXECUTE_READWRITE 0x40
Expand Down
2 changes: 1 addition & 1 deletion HippoMocksTest/Framework.cpp
Expand Up @@ -12,7 +12,7 @@ void check_equal<const char *, const char *>(const char *a, const char *b, const

bool TestRegistry::RunTests() {
char spinner[5] = "\\|/-";
size_t i = 0, s = 0;
unsigned long i = 0, s = 0;
size_t spinidx = 0;
for (std::vector<Test *>::iterator it = tests.begin(); it != tests.end(); ++it) {
Test *t = *it;
Expand Down
4 changes: 2 additions & 2 deletions HippoMocksTest/Framework.h
Expand Up @@ -12,9 +12,9 @@ class BaseException : public std::exception {
public:
BaseException(std::string fmt, ...) {
va_list l;
char buffer[4096];
static char buffer[4096];
va_start(l, fmt);
vsnprintf(buffer, 1024, fmt.c_str(), l);
vsnprintf(buffer, 4096, fmt.c_str(), l);
va_end(l);
error = buffer;
}
Expand Down
7 changes: 4 additions & 3 deletions HippoMocksTest/HippoMocksTest_2012.vcxproj
Expand Up @@ -124,13 +124,14 @@
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<PreprocessorDefinitions>_MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<TargetMachine>MachineX86</TargetMachine>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand Down

0 comments on commit 431b008

Please sign in to comment.