SDL  2.0
SDL_stdlib.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS)
23 #define SDL_DISABLE_ANALYZE_MACROS 1
24 #endif
25 
26 #include "../SDL_internal.h"
27 
28 /* This file contains portable stdlib functions for SDL */
29 
30 #include "SDL_stdinc.h"
31 #include "../libm/math_libm.h"
32 
33 
34 double
35 SDL_atan(double x)
36 {
37 #if defined(HAVE_ATAN)
38  return atan(x);
39 #else
40  return SDL_uclibc_atan(x);
41 #endif
42 }
43 
44 float
45 SDL_atanf(float x)
46 {
47 #if defined(HAVE_ATANF)
48  return atanf(x);
49 #else
50  return (float)SDL_atan((double)x);
51 #endif
52 }
53 
54 double
55 SDL_atan2(double x, double y)
56 {
57 #if defined(HAVE_ATAN2)
58  return atan2(x, y);
59 #else
60  return SDL_uclibc_atan2(x, y);
61 #endif
62 }
63 
64 float
65 SDL_atan2f(float x, float y)
66 {
67 #if defined(HAVE_ATAN2F)
68  return atan2f(x, y);
69 #else
70  return (float)SDL_atan2((double)x, (double)y);
71 #endif
72 }
73 
74 double
75 SDL_acos(double val)
76 {
77 #if defined(HAVE_ACOS)
78  return acos(val);
79 #else
80  double result;
81  if (val == -1.0) {
82  result = M_PI;
83  } else {
84  result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
85  if (result < 0.0)
86  {
87  result += M_PI;
88  }
89  }
90  return result;
91 #endif
92 }
93 
94 float
95 SDL_acosf(float val)
96 {
97 #if defined(HAVE_ACOSF)
98  return acosf(val);
99 #else
100  return (float)SDL_acos((double)val);
101 #endif
102 }
103 
104 double
105 SDL_asin(double val)
106 {
107 #if defined(HAVE_ASIN)
108  return asin(val);
109 #else
110  double result;
111  if (val == -1.0) {
112  result = -(M_PI / 2.0);
113  } else {
114  result = (M_PI / 2.0) - SDL_acos(val);
115  }
116  return result;
117 #endif
118 }
119 
120 float
122 {
123 #if defined(HAVE_ASINF)
124  return asinf(val);
125 #else
126  return (float)SDL_asin((double)val);
127 #endif
128 }
129 
130 double
131 SDL_ceil(double x)
132 {
133 #if defined(HAVE_CEIL)
134  return ceil(x);
135 #else
136  double integer = SDL_floor(x);
137  double fraction = x - integer;
138  if (fraction > 0.0) {
139  integer += 1.0;
140  }
141  return integer;
142 #endif /* HAVE_CEIL */
143 }
144 
145 float
146 SDL_ceilf(float x)
147 {
148 #if defined(HAVE_CEILF)
149  return ceilf(x);
150 #else
151  return (float)SDL_ceil((float)x);
152 #endif
153 }
154 
155 double
156 SDL_copysign(double x, double y)
157 {
158 #if defined(HAVE_COPYSIGN)
159  return copysign(x, y);
160 #elif defined(HAVE__COPYSIGN)
161  return _copysign(x, y);
162 #elif defined(__WATCOMC__) && defined(__386__)
163  /* this is nasty as hell, but it works.. */
164  unsigned int *xi = (unsigned int *) &x,
165  *yi = (unsigned int *) &y;
166  xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
167  return x;
168 #else
169  return SDL_uclibc_copysign(x, y);
170 #endif /* HAVE_COPYSIGN */
171 }
172 
173 float
174 SDL_copysignf(float x, float y)
175 {
176 #if defined(HAVE_COPYSIGNF)
177  return copysignf(x, y);
178 #else
179  return (float)SDL_copysign((double)x, (double)y);
180 #endif
181 }
182 
183 double
184 SDL_cos(double x)
185 {
186 #if defined(HAVE_COS)
187  return cos(x);
188 #else
189  return SDL_uclibc_cos(x);
190 #endif
191 }
192 
193 float
194 SDL_cosf(float x)
195 {
196 #if defined(HAVE_COSF)
197  return cosf(x);
198 #else
199  return (float)SDL_cos((double)x);
200 #endif
201 }
202 
203 double
204 SDL_exp(double x)
205 {
206 #if defined(HAVE_EXP)
207  return exp(x);
208 #else
209  return SDL_uclibc_exp(x);
210 #endif
211 }
212 
213 float
214 SDL_expf(float x)
215 {
216 #if defined(HAVE_EXPF)
217  return expf(x);
218 #else
219  return (float)SDL_exp((double)x);
220 #endif
221 }
222 
223 double
224 SDL_fabs(double x)
225 {
226 #if defined(HAVE_FABS)
227  return fabs(x);
228 #else
229  return SDL_uclibc_fabs(x);
230 #endif
231 }
232 
233 float
234 SDL_fabsf(float x)
235 {
236 #if defined(HAVE_FABSF)
237  return fabsf(x);
238 #else
239  return (float)SDL_fabs((double)x);
240 #endif
241 }
242 
243 double
244 SDL_floor(double x)
245 {
246 #if defined(HAVE_FLOOR)
247  return floor(x);
248 #else
249  return SDL_uclibc_floor(x);
250 #endif
251 }
252 
253 float
254 SDL_floorf(float x)
255 {
256 #if defined(HAVE_FLOORF)
257  return floorf(x);
258 #else
259  return (float)SDL_floor((double)x);
260 #endif
261 }
262 
263 double
264 SDL_fmod(double x, double y)
265 {
266 #if defined(HAVE_FMOD)
267  return fmod(x, y);
268 #else
269  return SDL_uclibc_fmod(x, y);
270 #endif
271 }
272 
273 float
274 SDL_fmodf(float x, float y)
275 {
276 #if defined(HAVE_FMODF)
277  return fmodf(x, y);
278 #else
279  return (float)SDL_fmod((double)x, (double)y);
280 #endif
281 }
282 
283 double
284 SDL_log(double x)
285 {
286 #if defined(HAVE_LOG)
287  return log(x);
288 #else
289  return SDL_uclibc_log(x);
290 #endif
291 }
292 
293 float
294 SDL_logf(float x)
295 {
296 #if defined(HAVE_LOGF)
297  return logf(x);
298 #else
299  return (float)SDL_log((double)x);
300 #endif
301 }
302 
303 double
304 SDL_log10(double x)
305 {
306 #if defined(HAVE_LOG10)
307  return log10(x);
308 #else
309  return SDL_uclibc_log10(x);
310 #endif
311 }
312 
313 float
314 SDL_log10f(float x)
315 {
316 #if defined(HAVE_LOG10F)
317  return log10f(x);
318 #else
319  return (float)SDL_log10((double)x);
320 #endif
321 }
322 
323 double
324 SDL_pow(double x, double y)
325 {
326 #if defined(HAVE_POW)
327  return pow(x, y);
328 #else
329  return SDL_uclibc_pow(x, y);
330 #endif
331 }
332 
333 float
334 SDL_powf(float x, float y)
335 {
336 #if defined(HAVE_POWF)
337  return powf(x, y);
338 #else
339  return (float)SDL_pow((double)x, (double)y);
340 #endif
341 }
342 
343 double
344 SDL_scalbn(double x, int n)
345 {
346 #if defined(HAVE_SCALBN)
347  return scalbn(x, n);
348 #elif defined(HAVE__SCALB)
349  return _scalb(x, n);
350 #elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2)
351 /* from scalbn(3): If FLT_RADIX equals 2 (which is
352  * usual), then scalbn() is equivalent to ldexp(3). */
353  return ldexp(x, n);
354 #else
355  return SDL_uclibc_scalbn(x, n);
356 #endif
357 }
358 
359 float
360 SDL_scalbnf(float x, int n)
361 {
362 #if defined(HAVE_SCALBNF)
363  return scalbnf(x, n);
364 #else
365  return (float)SDL_scalbn((double)x, n);
366 #endif
367 }
368 
369 double
370 SDL_sin(double x)
371 {
372 #if defined(HAVE_SIN)
373  return sin(x);
374 #else
375  return SDL_uclibc_sin(x);
376 #endif
377 }
378 
379 float
380 SDL_sinf(float x)
381 {
382 #if defined(HAVE_SINF)
383  return sinf(x);
384 #else
385  return (float)SDL_sin((double)x);
386 #endif
387 }
388 
389 double
390 SDL_sqrt(double x)
391 {
392 #if defined(HAVE_SQRT)
393  return sqrt(x);
394 #else
395  return SDL_uclibc_sqrt(x);
396 #endif
397 }
398 
399 float
400 SDL_sqrtf(float x)
401 {
402 #if defined(HAVE_SQRTF)
403  return sqrtf(x);
404 #else
405  return (float)SDL_sqrt((double)x);
406 #endif
407 }
408 
409 double
410 SDL_tan(double x)
411 {
412 #if defined(HAVE_TAN)
413  return tan(x);
414 #else
415  return SDL_uclibc_tan(x);
416 #endif
417 }
418 
419 float
420 SDL_tanf(float x)
421 {
422 #if defined(HAVE_TANF)
423  return tanf(x);
424 #else
425  return (float)SDL_tan((double)x);
426 #endif
427 }
428 
429 int SDL_abs(int x)
430 {
431 #if defined(HAVE_ABS)
432  return abs(x);
433 #else
434  return ((x) < 0 ? -(x) : (x));
435 #endif
436 }
437 
438 #if defined(HAVE_CTYPE_H)
439 int SDL_isdigit(int x) { return isdigit(x); }
440 int SDL_isspace(int x) { return isspace(x); }
441 int SDL_isupper(int x) { return isupper(x); }
442 int SDL_islower(int x) { return islower(x); }
443 int SDL_toupper(int x) { return toupper(x); }
444 int SDL_tolower(int x) { return tolower(x); }
445 #else
446 int SDL_isdigit(int x) { return ((x) >= '0') && ((x) <= '9'); }
447 int SDL_isspace(int x) { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
448 int SDL_isupper(int x) { return ((x) >= 'A') && ((x) <= 'Z'); }
449 int SDL_islower(int x) { return ((x) >= 'a') && ((x) <= 'z'); }
450 int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
451 int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
452 #endif
453 
454 
455 #ifndef HAVE_LIBC
456 /* These are some C runtime intrinsics that need to be defined */
457 
458 #if defined(_MSC_VER)
459 
460 #ifndef __FLTUSED__
461 #define __FLTUSED__
462 __declspec(selectany) int _fltused = 1;
463 #endif
464 
465 /* The optimizer on Visual Studio 2005 and later generates memcpy() calls */
466 #if (_MSC_VER >= 1400) && defined(_WIN64) && !defined(_DEBUG) && !(_MSC_VER >= 1900 && defined(_MT))
467 #include <intrin.h>
468 
469 #pragma function(memcpy)
470 void * memcpy ( void * destination, const void * source, size_t num )
471 {
472  const Uint8 *src = (const Uint8 *)source;
473  Uint8 *dst = (Uint8 *)destination;
474  size_t i;
475 
476  /* All WIN64 architectures have SSE, right? */
477  if (!((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
478  __m128 values[4];
479  for (i = num / 64; i--;) {
480  _mm_prefetch(src, _MM_HINT_NTA);
481  values[0] = *(__m128 *) (src + 0);
482  values[1] = *(__m128 *) (src + 16);
483  values[2] = *(__m128 *) (src + 32);
484  values[3] = *(__m128 *) (src + 48);
485  _mm_stream_ps((float *) (dst + 0), values[0]);
486  _mm_stream_ps((float *) (dst + 16), values[1]);
487  _mm_stream_ps((float *) (dst + 32), values[2]);
488  _mm_stream_ps((float *) (dst + 48), values[3]);
489  src += 64;
490  dst += 64;
491  }
492  num &= 63;
493  }
494 
495  while (num--) {
496  *dst++ = *src++;
497  }
498  return destination;
499 }
500 #endif /* _MSC_VER == 1600 && defined(_WIN64) && !defined(_DEBUG) */
501 
502 #ifdef _M_IX86
503 
504 /* Float to long */
505 void
506 __declspec(naked)
507 _ftol()
508 {
509  /* *INDENT-OFF* */
510  __asm {
511  push ebp
512  mov ebp,esp
513  sub esp,20h
514  and esp,0FFFFFFF0h
515  fld st(0)
516  fst dword ptr [esp+18h]
517  fistp qword ptr [esp+10h]
518  fild qword ptr [esp+10h]
519  mov edx,dword ptr [esp+18h]
520  mov eax,dword ptr [esp+10h]
521  test eax,eax
522  je integer_QnaN_or_zero
523 arg_is_not_integer_QnaN:
524  fsubp st(1),st
525  test edx,edx
526  jns positive
527  fstp dword ptr [esp]
528  mov ecx,dword ptr [esp]
529  xor ecx,80000000h
530  add ecx,7FFFFFFFh
531  adc eax,0
532  mov edx,dword ptr [esp+14h]
533  adc edx,0
534  jmp localexit
535 positive:
536  fstp dword ptr [esp]
537  mov ecx,dword ptr [esp]
538  add ecx,7FFFFFFFh
539  sbb eax,0
540  mov edx,dword ptr [esp+14h]
541  sbb edx,0
542  jmp localexit
543 integer_QnaN_or_zero:
544  mov edx,dword ptr [esp+14h]
545  test edx,7FFFFFFFh
546  jne arg_is_not_integer_QnaN
547  fstp dword ptr [esp+18h]
548  fstp dword ptr [esp+18h]
549 localexit:
550  leave
551  ret
552  }
553  /* *INDENT-ON* */
554 }
555 
556 void
557 _ftol2_sse()
558 {
559  _ftol();
560 }
561 
562 /* 64-bit math operators for 32-bit systems */
563 void
564 __declspec(naked)
565 _allmul()
566 {
567  /* *INDENT-OFF* */
568  __asm {
569  mov eax, dword ptr[esp+8]
570  mov ecx, dword ptr[esp+10h]
571  or ecx, eax
572  mov ecx, dword ptr[esp+0Ch]
573  jne hard
574  mov eax, dword ptr[esp+4]
575  mul ecx
576  ret 10h
577 hard:
578  push ebx
579  mul ecx
580  mov ebx, eax
581  mov eax, dword ptr[esp+8]
582  mul dword ptr[esp+14h]
583  add ebx, eax
584  mov eax, dword ptr[esp+8]
585  mul ecx
586  add edx, ebx
587  pop ebx
588  ret 10h
589  }
590  /* *INDENT-ON* */
591 }
592 
593 void
594 __declspec(naked)
595 _alldiv()
596 {
597  /* *INDENT-OFF* */
598  __asm {
599  push edi
600  push esi
601  push ebx
602  xor edi,edi
603  mov eax,dword ptr [esp+14h]
604  or eax,eax
605  jge L1
606  inc edi
607  mov edx,dword ptr [esp+10h]
608  neg eax
609  neg edx
610  sbb eax,0
611  mov dword ptr [esp+14h],eax
612  mov dword ptr [esp+10h],edx
613 L1:
614  mov eax,dword ptr [esp+1Ch]
615  or eax,eax
616  jge L2
617  inc edi
618  mov edx,dword ptr [esp+18h]
619  neg eax
620  neg edx
621  sbb eax,0
622  mov dword ptr [esp+1Ch],eax
623  mov dword ptr [esp+18h],edx
624 L2:
625  or eax,eax
626  jne L3
627  mov ecx,dword ptr [esp+18h]
628  mov eax,dword ptr [esp+14h]
629  xor edx,edx
630  div ecx
631  mov ebx,eax
632  mov eax,dword ptr [esp+10h]
633  div ecx
634  mov edx,ebx
635  jmp L4
636 L3:
637  mov ebx,eax
638  mov ecx,dword ptr [esp+18h]
639  mov edx,dword ptr [esp+14h]
640  mov eax,dword ptr [esp+10h]
641 L5:
642  shr ebx,1
643  rcr ecx,1
644  shr edx,1
645  rcr eax,1
646  or ebx,ebx
647  jne L5
648  div ecx
649  mov esi,eax
650  mul dword ptr [esp+1Ch]
651  mov ecx,eax
652  mov eax,dword ptr [esp+18h]
653  mul esi
654  add edx,ecx
655  jb L6
656  cmp edx,dword ptr [esp+14h]
657  ja L6
658  jb L7
659  cmp eax,dword ptr [esp+10h]
660  jbe L7
661 L6:
662  dec esi
663 L7:
664  xor edx,edx
665  mov eax,esi
666 L4:
667  dec edi
668  jne L8
669  neg edx
670  neg eax
671  sbb edx,0
672 L8:
673  pop ebx
674  pop esi
675  pop edi
676  ret 10h
677  }
678  /* *INDENT-ON* */
679 }
680 
681 void
682 __declspec(naked)
683 _aulldiv()
684 {
685  /* *INDENT-OFF* */
686  __asm {
687  push ebx
688  push esi
689  mov eax,dword ptr [esp+18h]
690  or eax,eax
691  jne L1
692  mov ecx,dword ptr [esp+14h]
693  mov eax,dword ptr [esp+10h]
694  xor edx,edx
695  div ecx
696  mov ebx,eax
697  mov eax,dword ptr [esp+0Ch]
698  div ecx
699  mov edx,ebx
700  jmp L2
701 L1:
702  mov ecx,eax
703  mov ebx,dword ptr [esp+14h]
704  mov edx,dword ptr [esp+10h]
705  mov eax,dword ptr [esp+0Ch]
706 L3:
707  shr ecx,1
708  rcr ebx,1
709  shr edx,1
710  rcr eax,1
711  or ecx,ecx
712  jne L3
713  div ebx
714  mov esi,eax
715  mul dword ptr [esp+18h]
716  mov ecx,eax
717  mov eax,dword ptr [esp+14h]
718  mul esi
719  add edx,ecx
720  jb L4
721  cmp edx,dword ptr [esp+10h]
722  ja L4
723  jb L5
724  cmp eax,dword ptr [esp+0Ch]
725  jbe L5
726 L4:
727  dec esi
728 L5:
729  xor edx,edx
730  mov eax,esi
731 L2:
732  pop esi
733  pop ebx
734  ret 10h
735  }
736  /* *INDENT-ON* */
737 }
738 
739 void
740 __declspec(naked)
741 _allrem()
742 {
743  /* *INDENT-OFF* */
744  __asm {
745  push ebx
746  push edi
747  xor edi,edi
748  mov eax,dword ptr [esp+10h]
749  or eax,eax
750  jge L1
751  inc edi
752  mov edx,dword ptr [esp+0Ch]
753  neg eax
754  neg edx
755  sbb eax,0
756  mov dword ptr [esp+10h],eax
757  mov dword ptr [esp+0Ch],edx
758 L1:
759  mov eax,dword ptr [esp+18h]
760  or eax,eax
761  jge L2
762  mov edx,dword ptr [esp+14h]
763  neg eax
764  neg edx
765  sbb eax,0
766  mov dword ptr [esp+18h],eax
767  mov dword ptr [esp+14h],edx
768 L2:
769  or eax,eax
770  jne L3
771  mov ecx,dword ptr [esp+14h]
772  mov eax,dword ptr [esp+10h]
773  xor edx,edx
774  div ecx
775  mov eax,dword ptr [esp+0Ch]
776  div ecx
777  mov eax,edx
778  xor edx,edx
779  dec edi
780  jns L4
781  jmp L8
782 L3:
783  mov ebx,eax
784  mov ecx,dword ptr [esp+14h]
785  mov edx,dword ptr [esp+10h]
786  mov eax,dword ptr [esp+0Ch]
787 L5:
788  shr ebx,1
789  rcr ecx,1
790  shr edx,1
791  rcr eax,1
792  or ebx,ebx
793  jne L5
794  div ecx
795  mov ecx,eax
796  mul dword ptr [esp+18h]
797  xchg eax,ecx
798  mul dword ptr [esp+14h]
799  add edx,ecx
800  jb L6
801  cmp edx,dword ptr [esp+10h]
802  ja L6
803  jb L7
804  cmp eax,dword ptr [esp+0Ch]
805  jbe L7
806 L6:
807  sub eax,dword ptr [esp+14h]
808  sbb edx,dword ptr [esp+18h]
809 L7:
810  sub eax,dword ptr [esp+0Ch]
811  sbb edx,dword ptr [esp+10h]
812  dec edi
813  jns L8
814 L4:
815  neg edx
816  neg eax
817  sbb edx,0
818 L8:
819  pop edi
820  pop ebx
821  ret 10h
822  }
823  /* *INDENT-ON* */
824 }
825 
826 void
827 __declspec(naked)
828 _aullrem()
829 {
830  /* *INDENT-OFF* */
831  __asm {
832  push ebx
833  mov eax,dword ptr [esp+14h]
834  or eax,eax
835  jne L1
836  mov ecx,dword ptr [esp+10h]
837  mov eax,dword ptr [esp+0Ch]
838  xor edx,edx
839  div ecx
840  mov eax,dword ptr [esp+8]
841  div ecx
842  mov eax,edx
843  xor edx,edx
844  jmp L2
845 L1:
846  mov ecx,eax
847  mov ebx,dword ptr [esp+10h]
848  mov edx,dword ptr [esp+0Ch]
849  mov eax,dword ptr [esp+8]
850 L3:
851  shr ecx,1
852  rcr ebx,1
853  shr edx,1
854  rcr eax,1
855  or ecx,ecx
856  jne L3
857  div ebx
858  mov ecx,eax
859  mul dword ptr [esp+14h]
860  xchg eax,ecx
861  mul dword ptr [esp+10h]
862  add edx,ecx
863  jb L4
864  cmp edx,dword ptr [esp+0Ch]
865  ja L4
866  jb L5
867  cmp eax,dword ptr [esp+8]
868  jbe L5
869 L4:
870  sub eax,dword ptr [esp+10h]
871  sbb edx,dword ptr [esp+14h]
872 L5:
873  sub eax,dword ptr [esp+8]
874  sbb edx,dword ptr [esp+0Ch]
875  neg edx
876  neg eax
877  sbb edx,0
878 L2:
879  pop ebx
880  ret 10h
881  }
882  /* *INDENT-ON* */
883 }
884 
885 void
886 __declspec(naked)
887 _alldvrm()
888 {
889  /* *INDENT-OFF* */
890  __asm {
891  push edi
892  push esi
893  push ebp
894  xor edi,edi
895  xor ebp,ebp
896  mov eax,dword ptr [esp+14h]
897  or eax,eax
898  jge L1
899  inc edi
900  inc ebp
901  mov edx,dword ptr [esp+10h]
902  neg eax
903  neg edx
904  sbb eax,0
905  mov dword ptr [esp+14h],eax
906  mov dword ptr [esp+10h],edx
907 L1:
908  mov eax,dword ptr [esp+1Ch]
909  or eax,eax
910  jge L2
911  inc edi
912  mov edx,dword ptr [esp+18h]
913  neg eax
914  neg edx
915  sbb eax,0
916  mov dword ptr [esp+1Ch],eax
917  mov dword ptr [esp+18h],edx
918 L2:
919  or eax,eax
920  jne L3
921  mov ecx,dword ptr [esp+18h]
922  mov eax,dword ptr [esp+14h]
923  xor edx,edx
924  div ecx
925  mov ebx,eax
926  mov eax,dword ptr [esp+10h]
927  div ecx
928  mov esi,eax
929  mov eax,ebx
930  mul dword ptr [esp+18h]
931  mov ecx,eax
932  mov eax,esi
933  mul dword ptr [esp+18h]
934  add edx,ecx
935  jmp L4
936 L3:
937  mov ebx,eax
938  mov ecx,dword ptr [esp+18h]
939  mov edx,dword ptr [esp+14h]
940  mov eax,dword ptr [esp+10h]
941 L5:
942  shr ebx,1
943  rcr ecx,1
944  shr edx,1
945  rcr eax,1
946  or ebx,ebx
947  jne L5
948  div ecx
949  mov esi,eax
950  mul dword ptr [esp+1Ch]
951  mov ecx,eax
952  mov eax,dword ptr [esp+18h]
953  mul esi
954  add edx,ecx
955  jb L6
956  cmp edx,dword ptr [esp+14h]
957  ja L6
958  jb L7
959  cmp eax,dword ptr [esp+10h]
960  jbe L7
961 L6:
962  dec esi
963  sub eax,dword ptr [esp+18h]
964  sbb edx,dword ptr [esp+1Ch]
965 L7:
966  xor ebx,ebx
967 L4:
968  sub eax,dword ptr [esp+10h]
969  sbb edx,dword ptr [esp+14h]
970  dec ebp
971  jns L9
972  neg edx
973  neg eax
974  sbb edx,0
975 L9:
976  mov ecx,edx
977  mov edx,ebx
978  mov ebx,ecx
979  mov ecx,eax
980  mov eax,esi
981  dec edi
982  jne L8
983  neg edx
984  neg eax
985  sbb edx,0
986 L8:
987  pop ebp
988  pop esi
989  pop edi
990  ret 10h
991  }
992  /* *INDENT-ON* */
993 }
994 
995 void
996 __declspec(naked)
997 _aulldvrm()
998 {
999  /* *INDENT-OFF* */
1000  __asm {
1001  push esi
1002  mov eax,dword ptr [esp+14h]
1003  or eax,eax
1004  jne L1
1005  mov ecx,dword ptr [esp+10h]
1006  mov eax,dword ptr [esp+0Ch]
1007  xor edx,edx
1008  div ecx
1009  mov ebx,eax
1010  mov eax,dword ptr [esp+8]
1011  div ecx
1012  mov esi,eax
1013  mov eax,ebx
1014  mul dword ptr [esp+10h]
1015  mov ecx,eax
1016  mov eax,esi
1017  mul dword ptr [esp+10h]
1018  add edx,ecx
1019  jmp L2
1020 L1:
1021  mov ecx,eax
1022  mov ebx,dword ptr [esp+10h]
1023  mov edx,dword ptr [esp+0Ch]
1024  mov eax,dword ptr [esp+8]
1025 L3:
1026  shr ecx,1
1027  rcr ebx,1
1028  shr edx,1
1029  rcr eax,1
1030  or ecx,ecx
1031  jne L3
1032  div ebx
1033  mov esi,eax
1034  mul dword ptr [esp+14h]
1035  mov ecx,eax
1036  mov eax,dword ptr [esp+10h]
1037  mul esi
1038  add edx,ecx
1039  jb L4
1040  cmp edx,dword ptr [esp+0Ch]
1041  ja L4
1042  jb L5
1043  cmp eax,dword ptr [esp+8]
1044  jbe L5
1045 L4:
1046  dec esi
1047  sub eax,dword ptr [esp+10h]
1048  sbb edx,dword ptr [esp+14h]
1049 L5:
1050  xor ebx,ebx
1051 L2:
1052  sub eax,dword ptr [esp+8]
1053  sbb edx,dword ptr [esp+0Ch]
1054  neg edx
1055  neg eax
1056  sbb edx,0
1057  mov ecx,edx
1058  mov edx,ebx
1059  mov ebx,ecx
1060  mov ecx,eax
1061  mov eax,esi
1062  pop esi
1063  ret 10h
1064  }
1065  /* *INDENT-ON* */
1066 }
1067 
1068 void
1069 __declspec(naked)
1070 _allshl()
1071 {
1072  /* *INDENT-OFF* */
1073  __asm {
1074  cmp cl,40h
1075  jae RETZERO
1076  cmp cl,20h
1077  jae MORE32
1078  shld edx,eax,cl
1079  shl eax,cl
1080  ret
1081 MORE32:
1082  mov edx,eax
1083  xor eax,eax
1084  and cl,1Fh
1085  shl edx,cl
1086  ret
1087 RETZERO:
1088  xor eax,eax
1089  xor edx,edx
1090  ret
1091  }
1092  /* *INDENT-ON* */
1093 }
1094 
1095 void
1096 __declspec(naked)
1097 _allshr()
1098 {
1099  /* *INDENT-OFF* */
1100  __asm {
1101  cmp cl,3Fh
1102  jae RETSIGN
1103  cmp cl,20h
1104  jae MORE32
1105  shrd eax,edx,cl
1106  sar edx,cl
1107  ret
1108 MORE32:
1109  mov eax,edx
1110  sar edx,1Fh
1111  and cl,1Fh
1112  sar eax,cl
1113  ret
1114 RETSIGN:
1115  sar edx,1Fh
1116  mov eax,edx
1117  ret
1118  }
1119  /* *INDENT-ON* */
1120 }
1121 
1122 void
1123 __declspec(naked)
1124 _aullshr()
1125 {
1126  /* *INDENT-OFF* */
1127  __asm {
1128  cmp cl,40h
1129  jae RETZERO
1130  cmp cl,20h
1131  jae MORE32
1132  shrd eax,edx,cl
1133  shr edx,cl
1134  ret
1135 MORE32:
1136  mov eax,edx
1137  xor edx,edx
1138  and cl,1Fh
1139  shr eax,cl
1140  ret
1141 RETZERO:
1142  xor eax,eax
1143  xor edx,edx
1144  ret
1145  }
1146  /* *INDENT-ON* */
1147 }
1148 
1149 #endif /* _M_IX86 */
1150 
1151 #endif /* MSC_VER */
1152 
1153 #endif /* !HAVE_LIBC */
1154 
1155 /* vi: set ts=4 sw=4 expandtab: */
SDL_floor
double SDL_floor(double x)
Definition: SDL_stdlib.c:244
SDL_logf
float SDL_logf(float x)
Definition: SDL_stdlib.c:294
fabs
double fabs(double x)
Definition: s_fabs.c:22
SDL_log10
double SDL_log10(double x)
Definition: SDL_stdlib.c:304
SDL_scalbn
double SDL_scalbn(double x, int n)
Definition: SDL_stdlib.c:344
source
GLsizei GLsizei GLchar * source
Definition: SDL_opengl_glext.h:680
cos
double cos(double x)
Definition: s_cos.c:46
SDL_abs
int SDL_abs(int x)
Definition: SDL_stdlib.c:429
L5
static const double L5
Definition: e_pow.c:85
SDL_fmodf
float SDL_fmodf(float x, float y)
Definition: SDL_stdlib.c:274
SDL_acosf
float SDL_acosf(float val)
Definition: SDL_stdlib.c:95
SDL_uclibc_floor
double SDL_uclibc_floor(double x)
SDL_floorf
float SDL_floorf(float x)
Definition: SDL_stdlib.c:254
SDL_fabsf
float SDL_fabsf(float x)
Definition: SDL_stdlib.c:234
SDL_uclibc_fmod
double SDL_uclibc_fmod(double x, double y)
SDL_cosf
float SDL_cosf(float x)
Definition: SDL_stdlib.c:194
num
GLuint num
Definition: SDL_opengl_glext.h:4959
SDL_sqrt
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:390
SDL_uclibc_sqrt
double SDL_uclibc_sqrt(double x)
SDL_uclibc_scalbn
double SDL_uclibc_scalbn(double x, int n)
memcpy
#define memcpy
Definition: SDL_malloc.c:630
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1949
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9435
SDL_uclibc_cos
double SDL_uclibc_cos(double x)
SDL_fmod
double SDL_fmod(double x, double y)
Definition: SDL_stdlib.c:264
SDL_expf
float SDL_expf(float x)
Definition: SDL_stdlib.c:214
n
GLdouble n
Definition: SDL_opengl_glext.h:1955
add
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF PF lsl PF PF PF else PF lsl PF add
Definition: pixman-arm-simd-asm.h:215
SDL_uclibc_exp
double SDL_uclibc_exp(double x)
L4
static const double L4
Definition: e_pow.c:84
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1740
L2
static const double L2
Definition: e_pow.c:82
SDL_sin
double SDL_sin(double x)
Definition: SDL_stdlib.c:370
values
GLenum GLsizei GLsizei GLint * values
Definition: SDL_opengl_glext.h:1489
SDL_tanf
float SDL_tanf(float x)
Definition: SDL_stdlib.c:420
scalbn
#define scalbn
Definition: math_private.h:46
SDL_sqrtf
float SDL_sqrtf(float x)
Definition: SDL_stdlib.c:400
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
SDL_uclibc_fabs
double SDL_uclibc_fabs(double x)
SDL_uclibc_atan2
double SDL_uclibc_atan2(double y, double x)
SDL_copysignf
float SDL_copysignf(float x, float y)
Definition: SDL_stdlib.c:174
SDL_copysign
double SDL_copysign(double x, double y)
Definition: SDL_stdlib.c:156
SDL_uclibc_copysign
double SDL_uclibc_copysign(double x, double y)
SDL_asin
double SDL_asin(double val)
Definition: SDL_stdlib.c:105
SDL_toupper
int SDL_toupper(int x)
Definition: SDL_stdlib.c:450
SDL_uclibc_pow
double SDL_uclibc_pow(double x, double y)
mov
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF PF lsl PF PF PF else PF mov
Definition: pixman-arm-simd-asm.h:214
tan
double tan(double x)
Definition: s_tan.c:45
SDL_atan
double SDL_atan(double x)
Definition: SDL_stdlib.c:35
SDL_isupper
int SDL_isupper(int x)
Definition: SDL_stdlib.c:448
copysign
double copysign(double x, double y)
Definition: s_copysign.c:21
sub
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF sub
Definition: pixman-arm-simd-asm.h:208
SDL_tan
double SDL_tan(double x)
Definition: SDL_stdlib.c:410
pop
#define pop
Definition: SDL_qsort.c:196
SDL_asinf
float SDL_asinf(float val)
Definition: SDL_stdlib.c:121
SDL_uclibc_atan
double SDL_uclibc_atan(double x)
SDL_log10f
float SDL_log10f(float x)
Definition: SDL_stdlib.c:314
SDL_islower
int SDL_islower(int x)
Definition: SDL_stdlib.c:449
SDL_isspace
int SDL_isspace(int x)
Definition: SDL_stdlib.c:447
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_tolower
int SDL_tolower(int x)
Definition: SDL_stdlib.c:451
SDL_sinf
float SDL_sinf(float x)
Definition: SDL_stdlib.c:380
SDL_pow
double SDL_pow(double x, double y)
Definition: SDL_stdlib.c:324
atan
double atan(double x)
Definition: s_atan.c:71
SDL_powf
float SDL_powf(float x, float y)
Definition: SDL_stdlib.c:334
SDL_scalbnf
float SDL_scalbnf(float x, int n)
Definition: SDL_stdlib.c:360
SDL_fabs
double SDL_fabs(double x)
Definition: SDL_stdlib.c:224
src
GLenum src
Definition: SDL_opengl_glext.h:1740
L3
static const double L3
Definition: e_pow.c:83
SDL_isdigit
int SDL_isdigit(int x)
Definition: SDL_stdlib.c:446
val
GLuint GLfloat * val
Definition: SDL_opengl_glext.h:1495
SDL_stdinc.h
SDL_atanf
float SDL_atanf(float x)
Definition: SDL_stdlib.c:45
L1
static const double L1
Definition: e_pow.c:81
SDL_ceil
double SDL_ceil(double x)
Definition: SDL_stdlib.c:131
L6
static const double L6
Definition: e_pow.c:86
SDL_acos
double SDL_acos(double val)
Definition: SDL_stdlib.c:75
SDL_uclibc_sin
double SDL_uclibc_sin(double x)
SDL_uclibc_log
double SDL_uclibc_log(double x)
SDL_atan2f
float SDL_atan2f(float x, float y)
Definition: SDL_stdlib.c:65
st
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst st
Definition: pixman-arm-simd-asm.h:160
floor
double floor(double x)
Definition: s_floor.c:33
SDL_ceilf
float SDL_ceilf(float x)
Definition: SDL_stdlib.c:146
SDL_uclibc_log10
double SDL_uclibc_log10(double x)
SDL_exp
double SDL_exp(double x)
Definition: SDL_stdlib.c:204
ptr
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
Definition: pixman-arm-simd-asm.h:171
sin
double sin(double x)
Definition: s_sin.c:46
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_atan2
double SDL_atan2(double x, double y)
Definition: SDL_stdlib.c:55
and
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF and
Definition: pixman-arm-simd-asm.h:206
uintptr_t
unsigned int uintptr_t
Definition: SDL_config_windows.h:70
SDL_cos
double SDL_cos(double x)
Definition: SDL_stdlib.c:184
SDL_log
double SDL_log(double x)
Definition: SDL_stdlib.c:284
SDL_uclibc_tan
double SDL_uclibc_tan(double x)
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179