1 #ifndef GIM_MEMORY_H_INCLUDED
2 #define GIM_MEMORY_H_INCLUDED
40 #include <xmmintrin.h>
43 #define pf(_x,_i) _mm_prefetch((void *)(_x + _i + pfval), 0)
45 #define pf2(_x,_i) _mm_prefetch((void *)(_x + _i + pfval2), 0)
56 #define GIM_COPY_ARRAYS(dest_array,source_array,element_count)\
58 for (GUINT _i_=0;_i_<element_count ;++_i_)\
60 dest_array[_i_] = source_array[_i_];\
64 #define GIM_COPY_ARRAYS_1(dest_array,source_array,element_count,copy_macro)\
66 for (GUINT _i_=0;_i_<element_count ;++_i_)\
68 copy_macro(dest_array[_i_],source_array[_i_]);\
73 #define GIM_ZERO_ARRAY(array,element_count)\
75 for (GUINT _i_=0;_i_<element_count ;++_i_)\
81 #define GIM_CONSTANT_ARRAY(array,element_count,constant)\
83 for (GUINT _i_=0;_i_<element_count ;++_i_)\
85 array[_i_] = constant;\
115 void *
gim_realloc(
void *ptr,
size_t oldsize,
size_t newsize);
120 #if defined (_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
121 #define GIM_SIMD_MEMORY 1
125 #define SIMD_T GUINT64
126 #define SIMD_T_SIZE sizeof(SIMD_T)
132 #ifdef GIM_SIMD_MEMORY
146 char * c_src_ptr = (
char *)src;
147 char * c_dst_ptr = (
char *)dst;
150 *(c_dst_ptr++) = *(c_src_ptr++);
155 memcpy(dst,src,copysize);
164 T _e_tmp_ = _array[_i];
165 _array[_i] = _array[_j];
166 _array[_j] = _e_tmp_;
173 char _e_tmp_[
sizeof(T)];
190 #endif // GIM_MEMORY_H_INCLUDED
void gim_simd_memcpy(void *dst, const void *src, size_t copysize)
void * gim_alloc(size_t size)
Standar Memory functions.
gim_alloca_function * gim_get_alloca_handler(void)
void * gim_realloc_function(void *ptr, size_t oldsize, size_t newsize)
void * gim_realloc(void *ptr, size_t oldsize, size_t newsize)
void gim_set_alloca_handler(gim_alloca_function *fn)
gim_free_function * gim_get_free_handler(void)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void gim_free_function(void *ptr)
gim_realloc_function * gim_get_realloc_handler(void)
void * gim_alloca_function(size_t size)
void * gim_alloca(size_t size)
void gim_set_alloc_handler(gim_alloc_function *fn)
Memory Function Handlers set new memory management functions.
void gim_swap_elements_memcpy(T *_array, size_t _i, size_t _j)
gim_alloc_function * gim_get_alloc_handler(void)
get current memory management functions.
void gim_set_free_handler(gim_free_function *fn)
void gim_swap_elements_ptr(char *_array, size_t _i, size_t _j)
void gim_set_realloc_handler(gim_realloc_function *fn)
void gim_swap_elements(T *_array, size_t _i, size_t _j)
void * gim_alloc_function(size_t size)
Function prototypes to allocate and free memory.