Mercurial > sdl-ios-xcode
comparison src/stdlib/SDL_stdlib.c @ 1346:1b5fbaf1d2c6
Default to build SDL without MSVCRT
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 08 Feb 2006 08:55:33 +0000 |
parents | 7f32b9bede06 |
children | 22f39393668a |
comparison
equal
deleted
inserted
replaced
1345:7f32b9bede06 | 1346:1b5fbaf1d2c6 |
---|---|
28 #ifndef HAVE_LIBC | 28 #ifndef HAVE_LIBC |
29 /* These are some C runtime intrinsics that need to be defined */ | 29 /* These are some C runtime intrinsics that need to be defined */ |
30 | 30 |
31 #if defined(_MSC_VER) | 31 #if defined(_MSC_VER) |
32 | 32 |
33 /* Float to long (FIXME!) */ | 33 /* Float to long */ |
34 long _ftol() | 34 void __declspec(naked) _ftol() |
35 { | 35 { |
36 return 0; | 36 __asm { |
37 } | 37 push ebp |
38 long _ftol2_sse() | 38 mov ebp,esp |
39 { | 39 sub esp,20h |
40 return 0; | 40 and esp,0FFFFFFF0h |
41 } | 41 fld st(0) |
42 | 42 fst dword ptr [esp+18h] |
43 /* 64-bit math operators (FIXME!) */ | 43 fistp qword ptr [esp+10h] |
44 void _allmul() | 44 fild qword ptr [esp+10h] |
45 { | 45 mov edx,dword ptr [esp+18h] |
46 } | 46 mov eax,dword ptr [esp+10h] |
47 void _alldiv() | 47 test eax,eax |
48 { | 48 je integer_QnaN_or_zero |
49 } | 49 arg_is_not_integer_QnaN: |
50 void _aulldiv() | 50 fsubp st(1),st |
51 { | 51 test edx,edx |
52 } | 52 jns positive |
53 void _allrem() | 53 fstp dword ptr [esp] |
54 { | 54 mov ecx,dword ptr [esp] |
55 } | 55 xor ecx,80000000h |
56 void _aullrem() | 56 add ecx,7FFFFFFFh |
57 { | 57 adc eax,0 |
58 } | 58 mov edx,dword ptr [esp+14h] |
59 void _alldvrm() | 59 adc edx,0 |
60 { | 60 jmp localexit |
61 } | 61 positive: |
62 void _aulldvrm() | 62 fstp dword ptr [esp] |
63 { | 63 mov ecx,dword ptr [esp] |
64 } | 64 add ecx,7FFFFFFFh |
65 void _allshl() | 65 sbb eax,0 |
66 { | 66 mov edx,dword ptr [esp+14h] |
67 } | 67 sbb edx,0 |
68 void _aullshr() | 68 jmp localexit |
69 { | 69 integer_QnaN_or_zero: |
70 mov edx,dword ptr [esp+14h] | |
71 test edx,7FFFFFFFh | |
72 jne arg_is_not_integer_QnaN | |
73 fstp dword ptr [esp+18h] | |
74 fstp dword ptr [esp+18h] | |
75 localexit: | |
76 leave | |
77 ret | |
78 } | |
79 } | |
80 void __declspec(naked) _ftol2_sse() | |
81 { | |
82 _ftol(); | |
83 } | |
84 | |
85 /* 64-bit math operators for 32-bit systems */ | |
86 void __declspec(naked) _allmul() | |
87 { | |
88 __asm { | |
89 push ebp | |
90 mov ebp,esp | |
91 push edi | |
92 push esi | |
93 push ebx | |
94 sub esp,0Ch | |
95 mov eax,dword ptr [ebp+10h] | |
96 mov edi,dword ptr [ebp+8] | |
97 mov ebx,eax | |
98 mov esi,eax | |
99 sar esi,1Fh | |
100 mov eax,dword ptr [ebp+8] | |
101 mul ebx | |
102 imul edi,esi | |
103 mov ecx,edx | |
104 mov dword ptr [ebp-18h],eax | |
105 mov edx,dword ptr [ebp+0Ch] | |
106 add ecx,edi | |
107 imul ebx,edx | |
108 mov eax,dword ptr [ebp-18h] | |
109 lea ebx,[ebx+ecx] | |
110 mov dword ptr [ebp-14h],ebx | |
111 mov edx,dword ptr [ebp-14h] | |
112 add esp,0Ch | |
113 pop ebx | |
114 pop esi | |
115 pop edi | |
116 pop ebp | |
117 ret | |
118 } | |
119 } | |
120 void __declspec(naked) _alldiv() | |
121 { | |
122 __asm { | |
123 push edi | |
124 push esi | |
125 push ebx | |
126 xor edi,edi | |
127 mov eax,dword ptr [esp+14h] | |
128 or eax,eax | |
129 jge L1 | |
130 inc edi | |
131 mov edx,dword ptr [esp+10h] | |
132 neg eax | |
133 neg edx | |
134 sbb eax,0 | |
135 mov dword ptr [esp+14h],eax | |
136 mov dword ptr [esp+10h],edx | |
137 L1: | |
138 mov eax,dword ptr [esp+1Ch] | |
139 or eax,eax | |
140 jge L2 | |
141 inc edi | |
142 mov edx,dword ptr [esp+18h] | |
143 neg eax | |
144 neg edx | |
145 sbb eax,0 | |
146 mov dword ptr [esp+1Ch],eax | |
147 mov dword ptr [esp+18h],edx | |
148 L2: | |
149 or eax,eax | |
150 jne L3 | |
151 mov ecx,dword ptr [esp+18h] | |
152 mov eax,dword ptr [esp+14h] | |
153 xor edx,edx | |
154 div ecx | |
155 mov ebx,eax | |
156 mov eax,dword ptr [esp+10h] | |
157 div ecx | |
158 mov edx,ebx | |
159 jmp L4 | |
160 L3: | |
161 mov ebx,eax | |
162 mov ecx,dword ptr [esp+18h] | |
163 mov edx,dword ptr [esp+14h] | |
164 mov eax,dword ptr [esp+10h] | |
165 L5: | |
166 shr ebx,1 | |
167 rcr ecx,1 | |
168 shr edx,1 | |
169 rcr eax,1 | |
170 or ebx,ebx | |
171 jne L5 | |
172 div ecx | |
173 mov esi,eax | |
174 mul dword ptr [esp+1Ch] | |
175 mov ecx,eax | |
176 mov eax,dword ptr [esp+18h] | |
177 mul esi | |
178 add edx,ecx | |
179 jb L6 | |
180 cmp edx,dword ptr [esp+14h] | |
181 ja L6 | |
182 jb L7 | |
183 cmp eax,dword ptr [esp+10h] | |
184 jbe L7 | |
185 L6: | |
186 dec esi | |
187 L7: | |
188 xor edx,edx | |
189 mov eax,esi | |
190 L4: | |
191 dec edi | |
192 jne L8 | |
193 neg edx | |
194 neg eax | |
195 sbb edx,0 | |
196 L8: | |
197 pop ebx | |
198 pop esi | |
199 pop edi | |
200 ret 10h | |
201 } | |
202 } | |
203 void __declspec(naked) _aulldiv() | |
204 { | |
205 __asm { | |
206 push ebx | |
207 push esi | |
208 mov eax,dword ptr [esp+18h] | |
209 or eax,eax | |
210 jne L1 | |
211 mov ecx,dword ptr [esp+14h] | |
212 mov eax,dword ptr [esp+10h] | |
213 xor edx,edx | |
214 div ecx | |
215 mov ebx,eax | |
216 mov eax,dword ptr [esp+0Ch] | |
217 div ecx | |
218 mov edx,ebx | |
219 jmp L2 | |
220 L1: | |
221 mov ecx,eax | |
222 mov ebx,dword ptr [esp+14h] | |
223 mov edx,dword ptr [esp+10h] | |
224 mov eax,dword ptr [esp+0Ch] | |
225 L3: | |
226 shr ecx,1 | |
227 rcr ebx,1 | |
228 shr edx,1 | |
229 rcr eax,1 | |
230 or ecx,ecx | |
231 jne L3 | |
232 div ebx | |
233 mov esi,eax | |
234 mul dword ptr [esp+18h] | |
235 mov ecx,eax | |
236 mov eax,dword ptr [esp+14h] | |
237 mul esi | |
238 add edx,ecx | |
239 jb L4 | |
240 cmp edx,dword ptr [esp+10h] | |
241 ja L4 | |
242 jb L5 | |
243 cmp eax,dword ptr [esp+0Ch] | |
244 jbe L5 | |
245 L4: | |
246 dec esi | |
247 L5: | |
248 xor edx,edx | |
249 mov eax,esi | |
250 L2: | |
251 pop esi | |
252 pop ebx | |
253 ret 10h | |
254 } | |
255 } | |
256 void __declspec(naked) _allrem() | |
257 { | |
258 __asm { | |
259 push ebx | |
260 push edi | |
261 xor edi,edi | |
262 mov eax,dword ptr [esp+10h] | |
263 or eax,eax | |
264 jge L1 | |
265 inc edi | |
266 mov edx,dword ptr [esp+0Ch] | |
267 neg eax | |
268 neg edx | |
269 sbb eax,0 | |
270 mov dword ptr [esp+10h],eax | |
271 mov dword ptr [esp+0Ch],edx | |
272 L1: | |
273 mov eax,dword ptr [esp+18h] | |
274 or eax,eax | |
275 jge L2 | |
276 mov edx,dword ptr [esp+14h] | |
277 neg eax | |
278 neg edx | |
279 sbb eax,0 | |
280 mov dword ptr [esp+18h],eax | |
281 mov dword ptr [esp+14h],edx | |
282 L2: | |
283 or eax,eax | |
284 jne L3 | |
285 mov ecx,dword ptr [esp+14h] | |
286 mov eax,dword ptr [esp+10h] | |
287 xor edx,edx | |
288 div ecx | |
289 mov eax,dword ptr [esp+0Ch] | |
290 div ecx | |
291 mov eax,edx | |
292 xor edx,edx | |
293 dec edi | |
294 jns L4 | |
295 jmp L8 | |
296 L3: | |
297 mov ebx,eax | |
298 mov ecx,dword ptr [esp+14h] | |
299 mov edx,dword ptr [esp+10h] | |
300 mov eax,dword ptr [esp+0Ch] | |
301 L5: | |
302 shr ebx,1 | |
303 rcr ecx,1 | |
304 shr edx,1 | |
305 rcr eax,1 | |
306 or ebx,ebx | |
307 jne L5 | |
308 div ecx | |
309 mov ecx,eax | |
310 mul dword ptr [esp+18h] | |
311 xchg eax,ecx | |
312 mul dword ptr [esp+14h] | |
313 add edx,ecx | |
314 jb L6 | |
315 cmp edx,dword ptr [esp+10h] | |
316 ja L6 | |
317 jb L7 | |
318 cmp eax,dword ptr [esp+0Ch] | |
319 jbe L7 | |
320 L6: | |
321 sub eax,dword ptr [esp+14h] | |
322 sbb edx,dword ptr [esp+18h] | |
323 L7: | |
324 sub eax,dword ptr [esp+0Ch] | |
325 sbb edx,dword ptr [esp+10h] | |
326 dec edi | |
327 jns L8 | |
328 L4: | |
329 neg edx | |
330 neg eax | |
331 sbb edx,0 | |
332 L8: | |
333 pop edi | |
334 pop ebx | |
335 ret 10h | |
336 } | |
337 } | |
338 void __declspec(naked) _aullrem() | |
339 { | |
340 __asm { | |
341 push ebx | |
342 mov eax,dword ptr [esp+14h] | |
343 or eax,eax | |
344 jne L1 | |
345 mov ecx,dword ptr [esp+10h] | |
346 mov eax,dword ptr [esp+0Ch] | |
347 xor edx,edx | |
348 div ecx | |
349 mov eax,dword ptr [esp+8] | |
350 div ecx | |
351 mov eax,edx | |
352 xor edx,edx | |
353 jmp L2 | |
354 L1: | |
355 mov ecx,eax | |
356 mov ebx,dword ptr [esp+10h] | |
357 mov edx,dword ptr [esp+0Ch] | |
358 mov eax,dword ptr [esp+8] | |
359 L3: | |
360 shr ecx,1 | |
361 rcr ebx,1 | |
362 shr edx,1 | |
363 rcr eax,1 | |
364 or ecx,ecx | |
365 jne L3 | |
366 div ebx | |
367 mov ecx,eax | |
368 mul dword ptr [esp+14h] | |
369 xchg eax,ecx | |
370 mul dword ptr [esp+10h] | |
371 add edx,ecx | |
372 jb L4 | |
373 cmp edx,dword ptr [esp+0Ch] | |
374 ja L4 | |
375 jb L5 | |
376 cmp eax,dword ptr [esp+8] | |
377 jbe L5 | |
378 L4: | |
379 sub eax,dword ptr [esp+10h] | |
380 sbb edx,dword ptr [esp+14h] | |
381 L5: | |
382 sub eax,dword ptr [esp+8] | |
383 sbb edx,dword ptr [esp+0Ch] | |
384 neg edx | |
385 neg eax | |
386 sbb edx,0 | |
387 L2: | |
388 pop ebx | |
389 ret 10h | |
390 } | |
391 } | |
392 void __declspec(naked) _alldvrm() | |
393 { | |
394 __asm { | |
395 push edi | |
396 push esi | |
397 push ebp | |
398 xor edi,edi | |
399 xor ebp,ebp | |
400 mov eax,dword ptr [esp+14h] | |
401 or eax,eax | |
402 jge L1 | |
403 inc edi | |
404 inc ebp | |
405 mov edx,dword ptr [esp+10h] | |
406 neg eax | |
407 neg edx | |
408 sbb eax,0 | |
409 mov dword ptr [esp+14h],eax | |
410 mov dword ptr [esp+10h],edx | |
411 L1: | |
412 mov eax,dword ptr [esp+1Ch] | |
413 or eax,eax | |
414 jge L2 | |
415 inc edi | |
416 mov edx,dword ptr [esp+18h] | |
417 neg eax | |
418 neg edx | |
419 sbb eax,0 | |
420 mov dword ptr [esp+1Ch],eax | |
421 mov dword ptr [esp+18h],edx | |
422 L2: | |
423 or eax,eax | |
424 jne L3 | |
425 mov ecx,dword ptr [esp+18h] | |
426 mov eax,dword ptr [esp+14h] | |
427 xor edx,edx | |
428 div ecx | |
429 mov ebx,eax | |
430 mov eax,dword ptr [esp+10h] | |
431 div ecx | |
432 mov esi,eax | |
433 mov eax,ebx | |
434 mul dword ptr [esp+18h] | |
435 mov ecx,eax | |
436 mov eax,esi | |
437 mul dword ptr [esp+18h] | |
438 add edx,ecx | |
439 jmp L4 | |
440 L3: | |
441 mov ebx,eax | |
442 mov ecx,dword ptr [esp+18h] | |
443 mov edx,dword ptr [esp+14h] | |
444 mov eax,dword ptr [esp+10h] | |
445 L5: | |
446 shr ebx,1 | |
447 rcr ecx,1 | |
448 shr edx,1 | |
449 rcr eax,1 | |
450 or ebx,ebx | |
451 jne L5 | |
452 div ecx | |
453 mov esi,eax | |
454 mul dword ptr [esp+1Ch] | |
455 mov ecx,eax | |
456 mov eax,dword ptr [esp+18h] | |
457 mul esi | |
458 add edx,ecx | |
459 jb L6 | |
460 cmp edx,dword ptr [esp+14h] | |
461 ja L6 | |
462 jb L7 | |
463 cmp eax,dword ptr [esp+10h] | |
464 jbe L7 | |
465 L6: | |
466 dec esi | |
467 sub eax,dword ptr [esp+18h] | |
468 sbb edx,dword ptr [esp+1Ch] | |
469 L7: | |
470 xor ebx,ebx | |
471 L4: | |
472 sub eax,dword ptr [esp+10h] | |
473 sbb edx,dword ptr [esp+14h] | |
474 dec ebp | |
475 jns L9 | |
476 neg edx | |
477 neg eax | |
478 sbb edx,0 | |
479 L9: | |
480 mov ecx,edx | |
481 mov edx,ebx | |
482 mov ebx,ecx | |
483 mov ecx,eax | |
484 mov eax,esi | |
485 dec edi | |
486 jne L8 | |
487 neg edx | |
488 neg eax | |
489 sbb edx,0 | |
490 L8: | |
491 pop ebp | |
492 pop esi | |
493 pop edi | |
494 ret 10h | |
495 } | |
496 } | |
497 void __declspec(naked) _aulldvrm() | |
498 { | |
499 __asm { | |
500 push esi | |
501 mov eax,dword ptr [esp+14h] | |
502 or eax,eax | |
503 jne L1 | |
504 mov ecx,dword ptr [esp+10h] | |
505 mov eax,dword ptr [esp+0Ch] | |
506 xor edx,edx | |
507 div ecx | |
508 mov ebx,eax | |
509 mov eax,dword ptr [esp+8] | |
510 div ecx | |
511 mov esi,eax | |
512 mov eax,ebx | |
513 mul dword ptr [esp+10h] | |
514 mov ecx,eax | |
515 mov eax,esi | |
516 mul dword ptr [esp+10h] | |
517 add edx,ecx | |
518 jmp L2 | |
519 L1: | |
520 mov ecx,eax | |
521 mov ebx,dword ptr [esp+10h] | |
522 mov edx,dword ptr [esp+0Ch] | |
523 mov eax,dword ptr [esp+8] | |
524 L3: | |
525 shr ecx,1 | |
526 rcr ebx,1 | |
527 shr edx,1 | |
528 rcr eax,1 | |
529 or ecx,ecx | |
530 jne L3 | |
531 div ebx | |
532 mov esi,eax | |
533 mul dword ptr [esp+14h] | |
534 mov ecx,eax | |
535 mov eax,dword ptr [esp+10h] | |
536 mul esi | |
537 add edx,ecx | |
538 jb L4 | |
539 cmp edx,dword ptr [esp+0Ch] | |
540 ja L4 | |
541 jb L5 | |
542 cmp eax,dword ptr [esp+8] | |
543 jbe L5 | |
544 L4: | |
545 dec esi | |
546 sub eax,dword ptr [esp+10h] | |
547 sbb edx,dword ptr [esp+14h] | |
548 L5: | |
549 xor ebx,ebx | |
550 L2: | |
551 sub eax,dword ptr [esp+8] | |
552 sbb edx,dword ptr [esp+0Ch] | |
553 neg edx | |
554 neg eax | |
555 sbb edx,0 | |
556 mov ecx,edx | |
557 mov edx,ebx | |
558 mov ebx,ecx | |
559 mov ecx,eax | |
560 mov eax,esi | |
561 pop esi | |
562 ret 10h | |
563 } | |
564 } | |
565 void __declspec(naked) _allshl() | |
566 { | |
567 __asm { | |
568 cmp cl,40h | |
569 jae RETZERO | |
570 cmp cl,20h | |
571 jae MORE32 | |
572 shld edx,eax,cl | |
573 shl eax,cl | |
574 ret | |
575 MORE32: | |
576 mov edx,eax | |
577 xor eax,eax | |
578 and cl,1Fh | |
579 shl edx,cl | |
580 ret | |
581 RETZERO: | |
582 xor eax,eax | |
583 xor edx,edx | |
584 ret | |
585 } | |
586 } | |
587 void __declspec(naked) _aullshr() | |
588 { | |
589 __asm { | |
590 cmp cl,40h | |
591 jae RETZERO | |
592 cmp cl,20h | |
593 jae MORE32 | |
594 shrd eax,edx,cl | |
595 shr edx,cl | |
596 ret | |
597 MORE32: | |
598 mov eax,edx | |
599 xor edx,edx | |
600 and cl,1Fh | |
601 shr eax,cl | |
602 ret | |
603 RETZERO: | |
604 xor eax,eax | |
605 xor edx,edx | |
606 ret | |
607 } | |
70 } | 608 } |
71 | 609 |
72 #endif /* MSC_VER */ | 610 #endif /* MSC_VER */ |
73 | 611 |
74 #endif /* !HAVE_LIBC */ | 612 #endif /* !HAVE_LIBC */ |