Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • machinmachines/sandbox
1 result
Show changes
Commits on Source (2)
...@@ -47,6 +47,6 @@ PointerAlignment: Left ...@@ -47,6 +47,6 @@ PointerAlignment: Left
SortIncludes: false SortIncludes: false
SpaceBeforeCaseColon: false SpaceBeforeCaseColon: false
SpacesInAngles: false SpacesInAngles: false
Standard: Cpp11 Standard: Auto
TabWidth: 2 TabWidth: 2
UseTab: Never UseTab: Never
/// @file implementation/main.cc
/// @brief Implementation main entry point
/// @author gm
/// @copyright gm
///
/// This file is part of SandBox /// This file is part of SandBox
/// ///
/// SandBox is free software: you can redistribute it and/or modify /// SandBox is free software: you can redistribute it and/or modify
......
/// @file common.h
/// @brief SandBox common utilities header
/// @author gm
/// @copyright gm
///
/// This file is part of SandBox /// This file is part of SandBox
/// ///
/// SandBox is free software: you can redistribute it and/or modify /// SandBox is free software: you can redistribute it and/or modify
...@@ -24,24 +19,37 @@ ...@@ -24,24 +19,37 @@
#include "sandbox/configuration.h" #include "sandbox/configuration.h"
namespace sandbox { namespace sandbox
{
/// @brief Assume that the following condition is always true /// @brief Assume that the following condition is always true
/// (on some compilers, allows optimization) /// (on some compilers, allows optimization)
#if(COMPILER_MSVC) #if (COMPILER_MSVC)
static inline void ASSUME(const bool condition) {_assume(condition);} static inline void ASSUME(const bool condition)
#elif(COMPILER_GCC) || (COMPILER_CLANG) {
static inline void ASSUME(const bool condition) {if (!(condition)) { __builtin_unreachable(); }} _assume(condition);
}
#elif (COMPILER_GCC) || (COMPILER_CLANG)
static inline void ASSUME(const bool condition)
{
if (!(condition))
{
__builtin_unreachable();
}
}
#else #else
#define ASSUME(_condition_) #define ASSUME(_condition_)
#endif // _COMPILER_ ? #endif // _COMPILER_ ?
/// @brief Asserts condition == true /// @brief Asserts condition == true
#if(BUILD_CONFIGURATION_DEBUG) #if (BUILD_CONFIGURATION_DEBUG)
#define SANDBOX_ASSERT(_condition_) (assert((_condition_))) #define SANDBOX_ASSERT(_condition_) (assert((_condition_)))
#else #else
// Maps to "assume" in release configuration for better optimization // Maps to "assume" in release configuration for better optimization
#define SANDBOX_ASSERT(_condition_) {::sandbox::ASSUME((_condition_));} #define SANDBOX_ASSERT(_condition_) \
{ \
::sandbox::ASSUME((_condition_)); \
}
#endif #endif
} // namespace sandbox } // namespace sandbox
/// @file configuration.h
/// @brief SandBox configuration file
///
/// Provides basic preprocessor macros in order to detect /// Provides basic preprocessor macros in order to detect
/// user variables/hardware/OS/compiler... /// user variables/hardware/OS/compiler...
/// ///
/// @author gm
/// @copyright gm
///
/// This file is part of SandBox /// This file is part of SandBox
/// ///
/// SandBox is free software: you can redistribute it and/or modify /// SandBox is free software: you can redistribute it and/or modify
...@@ -38,15 +32,15 @@ ...@@ -38,15 +32,15 @@
/// @brief Build configuration detection /// @brief Build configuration detection
/// Since there are no easy cross-platform way to do this, /// Since there are no easy cross-platform way to do this,
/// we assume that "no asserts" means release /// we assume that "no asserts" means release
#if(defined(_NDEBUG) || defined(NDEBUG)) #if (defined(_NDEBUG) || defined(NDEBUG))
#define BUILD_CONFIGURATION_DEBUG 0 #define BUILD_CONFIGURATION_DEBUG 0
#else // defined(NDEBUG) ? #else // defined(NDEBUG) ?
#define BUILD_CONFIGURATION_DEBUG 1 #define BUILD_CONFIGURATION_DEBUG 1
#endif // defined(NDEBUG) ? #endif // defined(NDEBUG) ?
/// @brief Architecture detection - compiler specific preprocessor macros /// @brief Architecture detection - compiler specific preprocessor macros
#if COMPILER_MSVC #if COMPILER_MSVC
#if defined(_M_X64) #if defined(_M_X64)
#define ARCH_X86_64 1 #define ARCH_X86_64 1
#elif defined(_M_IX86) #elif defined(_M_IX86)
#define ARCH_X86_32 1 #define ARCH_X86_32 1
......
/// @file dummygroup.h
/// @author gm
/// @copyright gm
///
/// This file is part of SandBox /// This file is part of SandBox
/// ///
/// SandBox is free software: you can redistribute it and/or modify /// SandBox is free software: you can redistribute it and/or modify
...@@ -29,23 +25,23 @@ namespace dummygroup ...@@ -29,23 +25,23 @@ namespace dummygroup
/// @brief Base class for dummies /// @brief Base class for dummies
class DummyClassBase class DummyClassBase
{ {
public: public:
DummyClassBase() = default; DummyClassBase() = default;
virtual ~DummyClassBase() = default; virtual ~DummyClassBase() = default;
DummyClassBase(const DummyClassBase&) = delete; DummyClassBase(const DummyClassBase&) = delete;
DummyClassBase(DummyClassBase&&) = delete; DummyClassBase(DummyClassBase&&) = delete;
DummyClassBase& operator=(const DummyClassBase&) = delete; DummyClassBase& operator=(const DummyClassBase&) = delete;
DummyClassBase& operator=(DummyClassBase&&) = delete; DummyClassBase& operator=(DummyClassBase&&) = delete;
/// @brief Outputs a C-style string /// @brief Outputs a C-style string
virtual const char* GetSomething(void) = 0; virtual const char* GetSomething(void) = 0;
}; };
/// @brief Dummy group module, main entry point /// @brief Dummy group module, main entry point
class DummyGroup class DummyGroup
{ {
public: public:
static std::unique_ptr<DummyClassBase> Make(); static std::unique_ptr<DummyClassBase> Make();
}; };
} // namespace dummygroup } // namespace dummygroup
......
/// @file dummyclass.cc
/// @brief Dummy class definition
/// @author gm
/// @copyright gm
///
/// This file is part of SandBox /// This file is part of SandBox
/// ///
/// SandBox is free software: you can redistribute it and/or modify /// SandBox is free software: you can redistribute it and/or modify
...@@ -34,13 +29,13 @@ static const char static_data[] = "Hello, World!"; ...@@ -34,13 +29,13 @@ static const char static_data[] = "Hello, World!";
DummyClass::DummyClass() : data_(new char[sizeof(static_data)]) DummyClass::DummyClass() : data_(new char[sizeof(static_data)])
{ {
std::memcpy(data_.get(), &static_data[0], sizeof(static_data)); std::memcpy(data_.get(), &static_data[0], sizeof(static_data));
} }
const char* DummyClass::GetSomething(void) const char* DummyClass::GetSomething(void)
{ {
SANDBOX_ASSERT(data_); SANDBOX_ASSERT(data_);
return data_.get(); return data_.get();
} }
} // namespace dummygroup } // namespace dummygroup
......
/// @file dummyclass.h
/// @brief Dummy class declaration
/// @author gm
/// @copyright gm
///
/// This file is part of SandBox /// This file is part of SandBox
/// ///
/// SandBox is free software: you can redistribute it and/or modify /// SandBox is free software: you can redistribute it and/or modify
......
/// @file dummygroup.cc
/// @brief Dummy class definition
/// @author gm
/// @copyright gm
///
/// This file is part of SandBox /// This file is part of SandBox
/// ///
/// SandBox is free software: you can redistribute it and/or modify /// SandBox is free software: you can redistribute it and/or modify
...@@ -31,7 +26,7 @@ namespace dummygroup ...@@ -31,7 +26,7 @@ namespace dummygroup
std::unique_ptr<DummyClassBase> DummyGroup::Make() std::unique_ptr<DummyClassBase> DummyGroup::Make()
{ {
return std::make_unique<DummyClass>(); return std::make_unique<DummyClass>();
} }
} // namespace dummygroup } // namespace dummygroup
......