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
Commit 0f203f1b authored by g4m4's avatar g4m4
Browse files

WIP

parent 837d9012
No related branches found
No related tags found
No related merge requests found
...@@ -191,8 +191,13 @@ if(COMPILER_IS_GCC OR COMPILER_IS_CLANG) ...@@ -191,8 +191,13 @@ if(COMPILER_IS_GCC OR COMPILER_IS_CLANG)
add_definitions(-Wpointer-arith) add_definitions(-Wpointer-arith)
add_definitions(-Wcast-qual) add_definitions(-Wcast-qual)
elseif(COMPILER_IS_MSVC) elseif(COMPILER_IS_MSVC)
# Warnings configuration
add_definitions(/W4) add_definitions(/W4)
add_definitions(/WX) add_definitions(/WX)
# Disable Run-Time Type Information
add_definitions(/GR-)
# Strict conformance mode
add_definitions(/permissive-)
# This disable useless msvc warnings about checked iterators # This disable useless msvc warnings about checked iterators
add_definitions(-D_SCL_SECURE_NO_WARNINGS) add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif(COMPILER_IS_GCC OR COMPILER_IS_CLANG) endif(COMPILER_IS_GCC OR COMPILER_IS_CLANG)
......
...@@ -32,5 +32,3 @@ add_executable(sandbox ...@@ -32,5 +32,3 @@ add_executable(sandbox
target_link_libraries(sandbox target_link_libraries(sandbox
sandbox_lib sandbox_lib
) )
set_target_mt(sandbox)
...@@ -20,14 +20,65 @@ ...@@ -20,14 +20,65 @@
#include <cstdio> #include <cstdio>
#include "immintrin.h"
#include "sandbox/src/common.h" #include "sandbox/src/common.h"
#include "sandbox/src/dummygroup/dummyclass.h" #include "sandbox/src/dummygroup/dummyclass.h"
struct Toto {
bool B;
__m128 Vec;
bool C;
};
/// @brief Main function, of course. /// @brief Main function, of course.
int main(int /*argc*/, char ** /*argv*/) { int main(int /*argc*/, char ** /*argv*/) {
const char* kText(sandbox::dummygroup::DummyClass().DoSomething()); const char *kText(sandbox::dummygroup::DummyClass().DoSomething());
printf("Done: %s", kText); printf("Done: %s", kText);
{
int a = 1;
short j;
float f = 1.f; // Originally not initialized but tis-kernel caught
// it was being accessed w/ an indeterminate value below
printf("%i\n", j = *(reinterpret_cast<short *>(&a)));
printf("%i\n", *(reinterpret_cast<int *>(&f)));
char arr[4] = {0x0F, 0x0, 0x0, 0x00};
std::printf("%i\n", *reinterpret_cast<int *>(arr));
}
{
int *x = new int[2]; // 8 bytes: [0,7].
int *u =
(int *)((char *)x + 6); // regardless of alignment of x this will not
// be an aligned address
*u = 1; // Access to range [6-9]
printf("%d\n", *u); // Access to range [6-9]
}
{
short a[2];
a[0] = 0x1111;
a[1] = 0x1111;
*(int *)a = 0x22222222; /* violation of aliasing rules */
printf("%x %x\n", a[0], a[1]);
}
{
int value[4] = {56, 57, 58, 59};
__m128 toto = _mm_loadu_ps(reinterpret_cast<float *>(&value[0]));
const float *ptr = reinterpret_cast<float *>(&toto);
float tata = *ptr;
float tata1 = *(ptr + 1);
float tata2 = *(ptr + 2);
float tata3 = *(ptr + 3);
printf("%f %f %f %f", tata, tata1, tata2, tata3);
printf("%d", value[0]);
}
return 0; return 0;
} }
...@@ -29,33 +29,26 @@ namespace sandbox { ...@@ -29,33 +29,26 @@ 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) { __assume(condition); }
#elif(_COMPILER_GCC) #elif (_COMPILER_GCC)
static inline void ASSUME(const bool condition) {if (!(condition)) __builtin_unreachable();} 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
/// @brief Attribute for structures alignment } // namespace sandbox
#if (_USE_SSE)
#if (_COMPILER_MSVC)
#define ALIGN __declspec(align(16))
#else
#define ALIGN __attribute__((aligned(16)))
#endif
#else
#define ALIGN
#endif // (_USE_SSE)
} // namespace sandbox
#endif // SANDBOX_SRC_COMMON_H_ #endif // SANDBOX_SRC_COMMON_H_
...@@ -54,13 +54,4 @@ ...@@ -54,13 +54,4 @@
#endif #endif
#endif #endif
/// @brief SIMD enabling, based on platform
#if defined(_DISABLE_SIMD)
#define _USE_SSE 0
#else
#if (_ARCH_X86)
#define _USE_SSE 1
#endif
#endif
#endif // SANDBOX_SRC_CONFIGURATION_H_ #endif // SANDBOX_SRC_CONFIGURATION_H_
...@@ -34,11 +34,7 @@ DummyClass::~DummyClass() { ...@@ -34,11 +34,7 @@ DummyClass::~DummyClass() {
// Nothing to do here for now // Nothing to do here for now
} }
const char *DummyClass::DoSomething(void) { return &data_[0]; }
const char* DummyClass::DoSomething(void) { } // namespace dummygroup
SANDBOX_ASSERT(data_ != nullptr); } // namespace sandbox
return &data_[0];
}
} // namespace dummygroup
} // namespace sandbox
...@@ -65,8 +65,7 @@ def ScanFileAndRename(filepath, name, name_lower, name_upper): ...@@ -65,8 +65,7 @@ def ScanFileAndRename(filepath, name, name_lower, name_upper):
''' '''
name_short = name_upper[:4] name_short = name_upper[:4]
current_file = open(filepath, 'r+') current_file = open(filepath, 'r+')
temp_renamed = string.replace(current_file.read(), temp_renamed = current_file.read().replace("SandBox", name).replace("sandbox", name_lower).replace("SANDBOX", name_upper).replace("SAND", name_short)
"SandBox", name).replace("sandbox", name_lower).replace("SANDBOX", name_upper).replace("SAND", name_short)
# Empty current file content and replace it # Empty current file content and replace it
current_file.seek(0) current_file.seek(0)
current_file.truncate() current_file.truncate()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment