1
0

Using the _DEBUG macro for *nix debug builds as well; trying to force 8-byte alignment on critical sections ( http://forum.mc-server.org/showthread.php?tid=384 )

git-svn-id: http://mc-server.googlecode.com/svn/trunk@387 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-03-09 09:39:48 +00:00
parent effe9647cc
commit 11810e05e4
9 changed files with 62 additions and 127 deletions

View File

@ -30,8 +30,8 @@ CCE_OPTIONS = -s -x c -O3
LNK_OPTIONS = -lstdc++ -pthread -O3
BUILDDIR = build/release/
else
CC_OPTIONS = -s -ggdb
CCE_OPTIONS = -s -x c -ggdb
CC_OPTIONS = -s -ggdb -D_DEBUG
CCE_OPTIONS = -s -x c -ggdb -D_DEBUG
LNK_OPTIONS = -lstdc++ -pthread -ggdb
BUILDDIR = build/debug/
endif

View File

@ -8,101 +8,7 @@
// Compiler-dependent stuff:
#ifndef _MSC_VER
// Non-MS compilers don't know the override keyword
#define override
#else
// MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
#pragma warning(disable:4481)
#endif // _MSC_VER
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for any class that shouldn't allow copying itself
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName &); \
void operator=(const TypeName &)
// OS-dependent stuff:
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <Winsock2.h>
#else
#include <sys/types.h>
#include <sys/stat.h> // for mkdir
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <time.h>
#include <dirent.h>
#include <errno.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <pthread.h>
#include <semaphore.h>
#include <errno.h>
#include <fcntl.h>
#include <tr1/memory>
#endif
// CRT stuff:
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
// STL stuff:
#include <vector>
#include <list>
#include <string>
#include <map>
#include <algorithm>
#include <memory>
// Common headers:
#include "../source/StringUtils.h"
#include "../source/cCriticalSection.h"
#include "../source/cMCLogger.h"
// Common definitions:
/// Evaluates to the number of elements in an array (compile-time!)
#define ARRAYCOUNT(X) (sizeof(X) / sizeof(*(X)))
// sprintf_s is the preferred call in MSVC ("secure"); make it *nix-compatible:
#ifndef _WIN32
#define sprintf_s(dst, size, format, ...) sprintf(dst, format, __VA_ARGS__ )
#define vsnprintf_s(buffer, buffer_size, maxcount, stringbuffer, ...) (vsnprintf(buffer, maxcount, stringbuffer, __VA_ARGS__))
#endif // _WIN32
#include "../source/Globals.h"

View File

@ -10,8 +10,8 @@
# _X: These settings produce a debug build, with gdb symbols:
CC_OPTIONS = -s -ggdb
CCE_OPTIONS = -s -x c -ggdb
CC_OPTIONS = -s -ggdb -D_DEBUG
CCE_OPTIONS = -s -x c -ggdb -D_DEBUG
LNK_OPTIONS = -lstdc++ -pthread -ggdb

View File

@ -9,18 +9,57 @@
// Compiler-dependent stuff:
#ifndef _MSC_VER
// Non-MS compilers don't know the override keyword
#define override
#define abstract
#define stricmp strcasecmp
#else
#if defined(_MSC_VER)
// MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
#pragma warning(disable:4481)
// Disable some warnings that we don't care about:
#pragma warning(disable:4100)
#endif // _MSC_VER
#define OBSOLETE __declspec(deprecated)
// No alignment needed in MSVC
#define ALIGN_8
#define ALIGN_16
#elif defined(__GNUC__)
// TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
#define abstract
// TODO: Can GCC mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
#define override
#define OBSOLETE __attribute__((deprecated))
#define ALIGN_8 __attribute__((aligned(8)))
#define ALIGN_16 __attribute__((aligned(16)))
// Some portability macros :)
#define stricmp strcasecmp
#else
#error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
/*
// Copy and uncomment this into another #elif section based on your compiler identification
// Explicitly mark classes as abstract (no instances can be created)
#define abstract
// Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
#define override
// Mark functions as obsolete, so that their usage results in a compile-time warning
#define OBSOLETE
// Mark types / variables for alignment. Do the platforms need it?
#define ALIGN_8
#define ALIGN_16
*/
#endif
@ -40,7 +79,7 @@
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <winsock.h>
#include <winsock2.h>
#else
#include <sys/types.h>
#include <sys/stat.h> // for mkdir
@ -112,16 +151,6 @@
/// Allows arithmetic expressions like "32 KiB" (but consider using parenthesis around it, "(32 KiB)" )
#define KiB * 1024
#ifdef _MSC_VER
#define OBSOLETE __declspec(deprecated)
#define ABSTRACT abstract
#else
// TODO: how do other compilers mark functions as obsolete, so that their usage results in a compile-time warning?
#define OBSOLETE
// TODO: Can other compilers explicitly mark classes as abstract (no instances can be created)?
#define ABSTRACT
#endif
/// Faster than (int)floorf((float)x / (float)div)
#define FAST_FLOOR_DIV( x, div ) ( (x) < 0 ? (((int)x / div) - 1) : ((int)x / div) )

View File

@ -622,7 +622,7 @@ cNBTTree * cNBTParser::Parse(const char * a_Data, int a_Length)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Dumping the NBT tree (debug-only)
#ifdef _DEBUG
#if (defined(_DEBUG) && defined(_WIN32))
#define CASE_SIMPLE_TAG(TYPE,FMT) \
case cNBTTag::TAG_##TYPE: \
@ -696,7 +696,7 @@ void DumpTree(const cNBTTree * a_Tree, int a_Level)
#undef CASE_SIMPLE_TAG
#endif // _DEBUG
#endif // (_DEBUG && _WIN32)

View File

@ -203,9 +203,9 @@ public:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Dumping the tree (DEBUG-only)
#ifdef _DEBUG
#if (defined(_DEBUG) && defined(_WIN32))
void DumpTree(const cNBTTree * a_Tree, int a_Level = 0);
#endif // _DEBUG
#endif // (_DEBUG && _WIN32)

View File

@ -31,7 +31,7 @@ class cBlockEntity;
/// Interface that all the world storage schemas need to implement
class cWSSchema ABSTRACT
class cWSSchema abstract
{
public:
cWSSchema(cWorld * a_World) : m_World(a_World) {}

View File

@ -19,10 +19,10 @@ private:
#ifdef _WIN32
CRITICAL_SECTION m_CriticalSection;
#else // _WIN32
void* m_CriticalSectionPtr; // Pointer to a CRITICAL_SECTION object
void* m_Attributes;
void* m_CriticalSectionPtr ALIGN_8; // Pointer to a CRITICAL_SECTION object
void* m_Attributes ALIGN_8;
#endif // else _WIN32
};
} ALIGN_8;

View File

@ -158,14 +158,14 @@ int main( int argc, char **argv )
#endif // _WIN32 && !_WIN64
// End of dump-file magic
#ifdef _DEBUG
#if defined(_DEBUG) && defined(_MSC_VER)
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
// _X: The simple built-in CRT leak finder - simply break when allocating the Nth block ({N} is listed in the leak output)
// Only useful when the leak is in the same sequence all the time
// _CrtSetBreakAlloc(85950);
#endif
#endif // _DEBUG && _MSC_VER
#ifndef _DEBUG
std::signal(SIGSEGV, ShowCrashReport);