5 aclib - advanced C library ;)
6 This file contains functions which improve and expand standard C-library
7 see aclib_template.c ... this file only contains runtime cpu detection and config options stuff
8 runtime cpu detection by michael niedermayer (michaelni@gmx.at) is under GPL
11 #include "../cpudetect.h"
12 #include "fastmemcpy.h"
14 #define BLOCK_SIZE 4096
15 #define CONFUSION_FACTOR 0
16 //Feel free to fine-tune the above 2, it might be possible to get some speedup with them :)
20 #define CAN_COMPILE_X86_ASM
23 //Note: we have MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one
25 //#if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT)
29 #ifdef CAN_COMPILE_X86_ASM
31 #if (defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)
35 #if (defined (HAVE_MMX2) && !defined (HAVE_SSE2)) || defined (RUNTIME_CPUDETECT)
39 #if (defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)
43 #if defined (HAVE_SSE2) || defined (RUNTIME_CPUDETECT)
59 #define RENAME(a) a ## _C
60 #include "aclib_template.c"
72 #define RENAME(a) a ## _MMX
73 #include "aclib_template.c"
85 #define RENAME(a) a ## _MMX2
86 #include "aclib_template.c"
98 #define RENAME(a) a ## _3DNow
99 #include "aclib_template.c"
102 //SSE versions (only used on SSE2 cpus)
111 #define RENAME(a) a ## _SSE
112 #include "aclib_template.c"
115 #endif // CAN_COMPILE_X86_ASM
118 void * fast_memcpy(void * to
, const void * from
, size_t len
)
120 #ifdef RUNTIME_CPUDETECT
121 #ifdef CAN_COMPILE_X86_ASM
122 // ordered per speed fasterst first
124 fast_memcpy_SSE(to
, from
, len
);
125 else if(gCpuCaps
.hasMMX2
)
126 fast_memcpy_MMX2(to
, from
, len
);
127 else if(gCpuCaps
.has3DNow
)
128 fast_memcpy_3DNow(to
, from
, len
);
129 else if(gCpuCaps
.hasMMX
)
130 fast_memcpy_MMX(to
, from
, len
);
132 #endif //CAN_COMPILE_X86_ASM
133 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
136 fast_memcpy_SSE(to
, from
, len
);
137 #elif defined (HAVE_MMX2)
138 fast_memcpy_MMX2(to
, from
, len
);
139 #elif defined (HAVE_3DNOW)
140 fast_memcpy_3DNow(to
, from
, len
);
141 #elif defined (HAVE_MMX)
142 fast_memcpy_MMX(to
, from
, len
);
144 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
147 #endif //!RUNTIME_CPUDETECT
152 void * mem2agpcpy(void * to
, const void * from
, size_t len
)
154 #ifdef RUNTIME_CPUDETECT
155 #ifdef CAN_COMPILE_X86_ASM
156 // ordered per speed fasterst first
158 mem2agpcpy_SSE(to
, from
, len
);
159 else if(gCpuCaps
.hasMMX2
)
160 mem2agpcpy_MMX2(to
, from
, len
);
161 else if(gCpuCaps
.has3DNow
)
162 mem2agpcpy_3DNow(to
, from
, len
);
163 else if(gCpuCaps
.hasMMX
)
164 mem2agpcpy_MMX(to
, from
, len
);
166 #endif //CAN_COMPILE_X86_ASM
167 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
170 mem2agpcpy_SSE(to
, from
, len
);
171 #elif defined (HAVE_MMX2)
172 mem2agpcpy_MMX2(to
, from
, len
);
173 #elif defined (HAVE_3DNOW)
174 mem2agpcpy_3DNow(to
, from
, len
);
175 #elif defined (HAVE_MMX)
176 mem2agpcpy_MMX(to
, from
, len
);
178 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
181 #endif //!RUNTIME_CPUDETECT
185 #endif /* use fastmemcpy */