Skip to content

Commit

Permalink
64-bit: Try to detect at compile time
Browse files Browse the repository at this point in the history
Also, the debug build now verifies that the 64-bit
settings are correct at runtime.
  • Loading branch information
skyjake committed Sep 11, 2011
1 parent 8fd406e commit f877cd5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/dd_types.h
Expand Up @@ -30,7 +30,7 @@
#ifndef __DOOMSDAY_TYPES_H__
#define __DOOMSDAY_TYPES_H__

#ifdef __x86_64__
#if defined(__x86_64__) || defined(__x86_64) || defined(_LP64)
# define __64BIT__
#endif

Expand Down
16 changes: 14 additions & 2 deletions doomsday/engine/portable/src/dd_main.c
Expand Up @@ -384,6 +384,18 @@ int DD_Main(void)
return -1;
}

#ifdef _DEBUG
// 64-bit sanity check.
{
void* ptr = 0;
#ifdef __64BIT__
ASSERT_64BIT(ptr);
#else
ASSERT_NOT_64BIT(ptr);
#endif
}
#endif

/**
* \note This must be called from the main thread due to issues with
* the devices we use via the WINAPI, MCI (cdaudio, mixer etc).
Expand Down Expand Up @@ -1241,14 +1253,14 @@ char *strlwr(char *string)
*/
int dd_vsnprintf(char* str, size_t size, const char* format, va_list ap)
{
int result = vsnprintf(str, size, format, ap);
int result = vsnprintf(str, size, format, ap);

#ifdef WIN32
// Always terminate.
str[size - 1] = 0;
return result;
#else
return result >= size? -1 : size;
return result >= (int)size? -1 : (int)size;
#endif
}

Expand Down

0 comments on commit f877cd5

Please sign in to comment.