00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00032
00033
00034 #pragma once
00035
00036
00037 #include "../api_core.h"
00038 #include "../Text/string_types.h"
00039 #include "../System/cl_platform.h"
00040 #include <vector>
00041
00044 struct CL_API_CORE CL_PreallocatedMemory
00045 {
00046 int dummy;
00047 };
00048
00049 class CL_Mutex;
00050
00054 class CL_API_CORE CL_System
00055 {
00058
00059 public:
00061 static unsigned int get_time();
00062
00064 static cl_ubyte64 get_microseconds();
00065
00066 enum CL_CPU_ExtensionX86 { mmx, mmx_ex, _3d_now, _3d_now_ex, sse, sse2, sse3, ssse3, sse4_a, sse4_1, sse4_2, xop, avx, aes, fma3, fma4 };
00067 enum CL_CPU_ExtensionPPC { altivec };
00068
00069 static bool detect_cpu_extension(CL_CPU_ExtensionX86 ext);
00070 static bool detect_cpu_extension(CL_CPU_ExtensionPPC ext);
00071
00073 static CL_Mutex *get_sharedptr_mutex();
00074
00076 static int get_num_cores();
00077
00078
00082
00083 public:
00085 static void *aligned_alloc(size_t size, size_t alignment = 16);
00086
00088 static void aligned_free(void *ptr);
00089
00091 static int capture_stack_trace(int frames_to_skip, int max_frames, void **out_frames, unsigned int *out_hash = 0);
00092
00094
00095 static std::vector<CL_String> get_stack_frames_text(void **frames, int num_frames);
00096
00101 static void sleep(int millis);
00102
00108 static void pause(int millis);
00109
00112
00118 static CL_String get_exe_path();
00119
00121 template<typename T>
00122 static void call_constructor(T *memory)
00123 {
00124 new ((CL_PreallocatedMemory *) memory) T;
00125 }
00126
00127 template<typename T, typename P1>
00128 static void call_constructor(T *memory, P1 p1)
00129 {
00130 new ((CL_PreallocatedMemory *) memory) T(p1);
00131 }
00132
00133 template<typename T, typename P1, typename P2>
00134 static void call_constructor(T *memory, P1 p1, P2 p2)
00135 {
00136 new ((CL_PreallocatedMemory *) memory) T(p1, p2);
00137 }
00138
00139 template<typename T, typename P1, typename P2, typename P3>
00140 static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3)
00141 {
00142 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3);
00143 }
00144
00145 template<typename T, typename P1, typename P2, typename P3, typename P4>
00146 static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4)
00147 {
00148 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4);
00149 }
00150
00151 template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5>
00152 static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
00153 {
00154 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4, p5);
00155 }
00156
00157 template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00158 static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
00159 {
00160 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4, p5, p6);
00161 }
00162
00163 template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
00164 static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7)
00165 {
00166 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4, p5, p6, p7);
00167 }
00168
00170 template<typename T>
00171 static void call_destructor(T *memory)
00172 {
00173 memory->~T();
00174 }
00175
00176
00180
00181 private:
00183 };
00184
00185