Big config/debug update

Added config checkers
Macro no longer use suffixes
Moved MemoryManager to upper directory
Renamed *_MEMORYMANAGER to *_MANAGE_MEMORY
Renamed AUDIO_STREAMEDBUFFERCOUNT to AUDIO_STREAMED_BUFFER_COUNT
Renamed CORE_REAL_PRECISION to CORE_DECIMAL_DIGITS
Renamed DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION to
DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
Renamed GRAPHICS_MAX_LIGHTPERPASS to GRAPHICS_MAX_LIGHT_PER_PASS
Renamed UTILITY_FORCE_DECLARATION_STRIDE_MULTIPLE_OF_32 to
UTILITY_VERTEX_DECLARATION_FORCE_STRIDE_MULTIPLE_OF_32


Former-commit-id: 81ef836ac9f092ac471f60e544bb7c7c6370593c
This commit is contained in:
Lynix
2014-07-08 10:56:37 +02:00
parent f819beb747
commit c4b10dddda
64 changed files with 471 additions and 206 deletions

View File

@@ -29,6 +29,9 @@
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
// Précision des réels lors de la transformation en chaîne de caractère (Max. chiffres après la virgule)
#define NAZARA_CORE_DECIMAL_DIGITS 6
// Duplique la sortie du log sur le flux de sortie standard (cout)
#define NAZARA_CORE_DUPLICATE_LOG_TO_COUT 0
@@ -44,11 +47,8 @@
// Incorpore la table Unicode Character Data (Nécessaires pour faire fonctionner le flag NzString::HandleUTF8)
#define NAZARA_CORE_INCLUDE_UNICODEDATA 0
// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks, ralenti l'exécution)
#define NAZARA_CORE_MEMORYMANAGER 0
// Précision des réels lors de la transformation en texte (Max. chiffres après la virgule)
#define NAZARA_CORE_REAL_PRECISION 6
// Utilise le MemoryManager pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes)
#define NAZARA_CORE_MANAGE_MEMORY 0
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
#define NAZARA_CORE_SAFE 1
@@ -64,7 +64,7 @@
#define NAZARA_THREADSAFETY_LOG 1 // NzLog
#define NAZARA_THREADSAFETY_RESOURCE 1 // NzResource
// Le nombre de spinlocks à utiliser avec les critical sections de Windows (0 pour désactiver)
// Le nombre de spinlocks à utiliser avec les sections critiques de Windows (0 pour désactiver)
#define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096
// Optimise l'implémentation Windows avec certaines avancées de Windows vista (Casse la compatibilité XP)
@@ -75,4 +75,7 @@
#define NAZARA_CORE_TIMER_WAKEUPTIME 10
*/
/// Vérification des valeurs et types de certaines constantes
#include <Nazara/Core/ConfigCheck.hpp>
#endif // NAZARA_CONFIG_CORE_HPP

View File

@@ -0,0 +1,25 @@
// Copyright (C) 2014 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_CONFIG_CHECK_CORE_HPP
#define NAZARA_CONFIG_CHECK_CORE_HPP
/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp
#include <type_traits>
#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type <decltype(name)>::value && name op val, #type err)
// On force la valeur de MANAGE_MEMORY en mode debug
#if defined(NAZARA_DEBUG) && !NAZARA_CORE_MANAGE_MEMORY
#undef NAZARA_CORE_MANAGE_MEMORY
#define NAZARA_CORE_MANAGE_MEMORY 1
#endif
CheckTypeAndVal(NAZARA_CORE_DECIMAL_DIGITS, integral, >, 0, " shall be a strictly positive integer");
CheckTypeAndVal(NAZARA_CORE_FILE_BUFFERSIZE, integral, >, 0, " shall be a strictly positive integer");
CheckTypeAndVal(NAZARA_CORE_WINDOWS_CS_SPINLOCKS, integral, >=, 0, " shall be a positive integer");
#endif // NAZARA_CONFIG_CHECK_CORE_HPP

View File

@@ -3,6 +3,6 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Config.hpp>
#if NAZARA_CORE_MEMORYMANAGER || defined(NAZARA_DEBUG)
#include <Nazara/Core/Debug/MemoryManager.hpp>
#if NAZARA_CORE_MANAGE_MEMORY
#include <Nazara/Core/Debug/NewRedefinition.hpp>
#endif

View File

@@ -1,44 +0,0 @@
// Copyright (C) 2014 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#ifndef NAZARA_DEBUG_MEMORYMANAGER_HPP
#define NAZARA_DEBUG_MEMORYMANAGER_HPP
#include <Nazara/Prerequesites.hpp>
#include <cstdio>
#include <cstring>
class NAZARA_API NzMemoryManager
{
public:
static void* Allocate(std::size_t size, bool multi, const char* file = nullptr, unsigned int line = 0);
static void Free(void* pointer, bool multi);
static unsigned int GetAllocatedBlockCount();
static std::size_t GetAllocatedSize();
static unsigned int GetAllocationCount();
static void NextFree(const char* file, unsigned int line);
private:
NzMemoryManager();
~NzMemoryManager();
static void Initialize();
static void TimeInfo(char buffer[23]);
static void Uninitialize();
};
NAZARA_API void* operator new(std::size_t size, const char* file, unsigned int line);
NAZARA_API void* operator new[](std::size_t size, const char* file, unsigned int line);
NAZARA_API void operator delete(void* ptr, const char* file, unsigned int line) noexcept;
NAZARA_API void operator delete[](void* ptr, const char* file, unsigned int line) noexcept;
#endif // NAZARA_DEBUG_MEMORYMANAGER_HPP
#ifndef NAZARA_DEBUG_MEMORYMANAGER_DISABLE_REDEFINITION
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
#define new new(__FILE__, __LINE__)
#endif

View File

@@ -0,0 +1,28 @@
// Copyright (C) 2014 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// Pas de #pragma once car ce fichier est prévu pour être inclus plusieurs fois
#include <Nazara/Core/Config.hpp>
#if NAZARA_CORE_MANAGE_MEMORY
#ifndef NAZARA_DEBUG_NEWREDEFINITION_HPP
#define NAZARA_DEBUG_NEWREDEFINITION_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/MemoryManager.hpp>
NAZARA_API void* operator new(std::size_t size, const char* file, unsigned int line);
NAZARA_API void* operator new[](std::size_t size, const char* file, unsigned int line);
NAZARA_API void operator delete(void* ptr, const char* file, unsigned int line) noexcept;
NAZARA_API void operator delete[](void* ptr, const char* file, unsigned int line) noexcept;
#endif // NAZARA_DEBUG_NEWREDEFINITION_HPP
#ifndef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
#define new new(__FILE__, __LINE__)
#endif
#endif // NAZARA_CORE_MANAGE_MEMORY

View File

@@ -2,7 +2,8 @@
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#if NAZARA_CORE_MEMORYMANAGER || defined(NAZARA_DEBUG)
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
#if NAZARA_CORE_MANAGE_MEMORY
#undef delete
#undef new
#endif

View File

@@ -0,0 +1,36 @@
// Copyright (C) 2014 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_MEMORYMANAGER_HPP
#define NAZARA_MEMORYMANAGER_HPP
#include <Nazara/Prerequesites.hpp>
#include <cstdio>
#include <cstring>
class NAZARA_API NzMemoryManager
{
public:
static void* Allocate(std::size_t size, bool multi = false, const char* file = nullptr, unsigned int line = 0);
static void Free(void* pointer, bool multi = false);
static unsigned int GetAllocatedBlockCount();
static std::size_t GetAllocatedSize();
static unsigned int GetAllocationCount();
static void NextFree(const char* file, unsigned int line);
private:
NzMemoryManager();
~NzMemoryManager();
static void Initialize();
static void TimeInfo(char buffer[23]);
static void Uninitialize();
};
#endif // NAZARA_MEMORYMANAGER_HPP