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
00031
00032
00033 #pragma once
00034
00035
00036 #include "../api_core.h"
00037 #include "../Text/string_types.h"
00038 #include <vector>
00039
00042 struct CL_API_CORE CL_PreallocatedMemory
00043 {
00044 int dummy;
00045 };
00046
00047 class CL_Mutex;
00048
00052 class CL_API_CORE CL_System
00053 {
00056
00057 public:
00059 static unsigned int get_time();
00060
00062 static bool detect_mmx();
00063
00065 static bool detect_3dnow();
00066
00068 static bool detect_ext_3dnow();
00069
00071 static CL_Mutex *get_sharedptr_mutex();
00072
00074 static int get_num_cores();
00075
00076
00080
00081 public:
00083 static int capture_stack_trace(int frames_to_skip, int max_frames, void **out_frames, unsigned int *out_hash = 0);
00084
00086
00087 static std::vector<CL_String> get_stack_frames_text(void **frames, int num_frames);
00088
00090 static void sleep(int millis);
00091
00094
00100 static CL_String get_exe_path();
00101
00103 template<typename T>
00104 static void call_constructor(T *memory)
00105 {
00106 new ((CL_PreallocatedMemory *) memory) T;
00107 }
00108
00109 template<typename T, typename P1>
00110 static void call_constructor(T *memory, P1 p1)
00111 {
00112 new ((CL_PreallocatedMemory *) memory) T(p1);
00113 }
00114
00115 template<typename T, typename P1, typename P2>
00116 static void call_constructor(T *memory, P1 p1, P2 p2)
00117 {
00118 new ((CL_PreallocatedMemory *) memory) T(p1, p2);
00119 }
00120
00121 template<typename T, typename P1, typename P2, typename P3>
00122 static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3)
00123 {
00124 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3);
00125 }
00126
00127 template<typename T, typename P1, typename P2, typename P3, typename P4>
00128 static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4)
00129 {
00130 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4);
00131 }
00132
00133 template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5>
00134 static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
00135 {
00136 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4, p5);
00137 }
00138
00139 template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00140 static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
00141 {
00142 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4, p5, p6);
00143 }
00144
00145 template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
00146 static void call_constructor(T *memory, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7)
00147 {
00148 new ((CL_PreallocatedMemory *) memory) T(p1, p2, p3, p4, p5, p6, p7);
00149 }
00150
00152 template<typename T>
00153 static void call_destructor(T *memory)
00154 {
00155 memory->~T();
00156 }
00157
00158 static void alloc_thread_temp_pool();
00159
00160 static void free_thread_temp_pool();
00161
00162
00166
00167 private:
00169 };
00170
00171