summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-09 10:39:48 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-09 10:39:48 +0100
commit11810e05e40e24de14a3f0213f978853ba632e9f (patch)
treec478b4c6fd42bb9cd838ced889d27a6c1c16fb8c
parentAdded NBT example dumps for reference (diff)
downloadcuberite-11810e05e40e24de14a3f0213f978853ba632e9f.tar
cuberite-11810e05e40e24de14a3f0213f978853ba632e9f.tar.gz
cuberite-11810e05e40e24de14a3f0213f978853ba632e9f.tar.bz2
cuberite-11810e05e40e24de14a3f0213f978853ba632e9f.tar.lz
cuberite-11810e05e40e24de14a3f0213f978853ba632e9f.tar.xz
cuberite-11810e05e40e24de14a3f0213f978853ba632e9f.tar.zst
cuberite-11810e05e40e24de14a3f0213f978853ba632e9f.zip
Diffstat (limited to '')
-rw-r--r--GNUmakefile4
-rw-r--r--WebServer/Globals.h96
-rw-r--r--makefile.debug4
-rw-r--r--source/Globals.h65
-rw-r--r--source/NBT.cpp4
-rw-r--r--source/NBT.h4
-rw-r--r--source/WorldStorage.h2
-rw-r--r--source/cCriticalSection.h6
-rw-r--r--source/main.cpp4
9 files changed, 62 insertions, 127 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 5353f19a0..25dd2b1b3 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -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
diff --git a/WebServer/Globals.h b/WebServer/Globals.h
index 2ef0b70ac..fd31ba703 100644
--- a/WebServer/Globals.h
+++ b/WebServer/Globals.h
@@ -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"
diff --git a/makefile.debug b/makefile.debug
index e7d8b90d3..898c23c5d 100644
--- a/makefile.debug
+++ b/makefile.debug
@@ -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
diff --git a/source/Globals.h b/source/Globals.h
index 0d6694e11..6291c51e8 100644
--- a/source/Globals.h
+++ b/source/Globals.h
@@ -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) )
diff --git a/source/NBT.cpp b/source/NBT.cpp
index c600a1868..928ef8080 100644
--- a/source/NBT.cpp
+++ b/source/NBT.cpp
@@ -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)
diff --git a/source/NBT.h b/source/NBT.h
index a05e574de..75ff6e361 100644
--- a/source/NBT.h
+++ b/source/NBT.h
@@ -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)
diff --git a/source/WorldStorage.h b/source/WorldStorage.h
index 689d5f1ef..0845a7ce7 100644
--- a/source/WorldStorage.h
+++ b/source/WorldStorage.h
@@ -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) {}
diff --git a/source/cCriticalSection.h b/source/cCriticalSection.h
index 414c970f7..0a149a95a 100644
--- a/source/cCriticalSection.h
+++ b/source/cCriticalSection.h
@@ -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;
diff --git a/source/main.cpp b/source/main.cpp
index f19a88210..1d245ae0b 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -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);