123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966 |
- /*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <[email protected]>
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
- */
- #include "../SDL_internal.h"
- /* This file contains portable stdlib functions for SDL */
- #include "SDL_stdinc.h"
- #include "../libm/math_libm.h"
- double
- SDL_atan(double x)
- {
- #ifdef HAVE_ATAN
- return atan(x);
- #else
- return SDL_uclibc_atan(x);
- #endif /* HAVE_ATAN */
- }
- double
- SDL_atan2(double x, double y)
- {
- #if defined(HAVE_ATAN2)
- return atan2(x, y);
- #else
- return SDL_uclibc_atan2(x, y);
- #endif /* HAVE_ATAN2 */
- }
- double
- SDL_acos(double val)
- {
- #if defined(HAVE_ACOS)
- return acos(val);
- #else
- double result;
- if (val == -1.0) {
- result = M_PI;
- } else {
- result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
- if (result < 0.0)
- {
- result += M_PI;
- }
- }
- return result;
- #endif
- }
- double
- SDL_asin(double val)
- {
- #if defined(HAVE_ASIN)
- return asin(val);
- #else
- double result;
- if (val == -1.0) {
- result = -(M_PI / 2.0);
- } else {
- result = (M_PI / 2.0) - SDL_acos(val);
- }
- return result;
- #endif
- }
- double
- SDL_ceil(double x)
- {
- #ifdef HAVE_CEIL
- return ceil(x);
- #else
- double integer = SDL_floor(x);
- double fraction = x - integer;
- if (fraction > 0.0) {
- integer += 1.0;
- }
- return integer;
- #endif /* HAVE_CEIL */
- }
- double
- SDL_copysign(double x, double y)
- {
- #if defined(HAVE_COPYSIGN)
- return copysign(x, y);
- #elif defined(HAVE__COPYSIGN)
- return _copysign(x, y);
- #else
- return SDL_uclibc_copysign(x, y);
- #endif /* HAVE_COPYSIGN */
- }
- double
- SDL_cos(double x)
- {
- #if defined(HAVE_COS)
- return cos(x);
- #else
- return SDL_uclibc_cos(x);
- #endif /* HAVE_COS */
- }
- float
- SDL_cosf(float x)
- {
- #ifdef HAVE_COSF
- return cosf(x);
- #else
- return (float)SDL_cos((double)x);
- #endif
- }
- double
- SDL_fabs(double x)
- {
- #if defined(HAVE_FABS)
- return fabs(x);
- #else
- return SDL_uclibc_fabs(x);
- #endif /* HAVE_FABS */
- }
- double
- SDL_floor(double x)
- {
- #if defined(HAVE_FLOOR)
- return floor(x);
- #else
- return SDL_uclibc_floor(x);
- #endif /* HAVE_FLOOR */
- }
- double
- SDL_log(double x)
- {
- #if defined(HAVE_LOG)
- return log(x);
- #else
- return SDL_uclibc_log(x);
- #endif /* HAVE_LOG */
- }
- double
- SDL_pow(double x, double y)
- {
- #if defined(HAVE_POW)
- return pow(x, y);
- #else
- return SDL_uclibc_pow(x, y);
- #endif /* HAVE_POW */
- }
- double
- SDL_scalbn(double x, int n)
- {
- #if defined(HAVE_SCALBN)
- return scalbn(x, n);
- #elif defined(HAVE__SCALB)
- return _scalb(x, n);
- #else
- return SDL_uclibc_scalbn(x, n);
- #endif /* HAVE_SCALBN */
- }
- double
- SDL_sin(double x)
- {
- #if defined(HAVE_SIN)
- return sin(x);
- #else
- return SDL_uclibc_sin(x);
- #endif /* HAVE_SIN */
- }
- float
- SDL_sinf(float x)
- {
- #ifdef HAVE_SINF
- return sinf(x);
- #else
- return (float)SDL_sin((double)x);
- #endif /* HAVE_SINF */
- }
- double
- SDL_sqrt(double x)
- {
- #if defined(HAVE_SQRT)
- return sqrt(x);
- #else
- return SDL_uclibc_sqrt(x);
- #endif
- }
- float
- SDL_sqrtf(float x)
- {
- #if defined(HAVE_SQRTF)
- return sqrtf(x);
- #else
- return (float)SDL_sqrt((double)x);
- #endif
- }
- double
- SDL_tan(double x)
- {
- #if defined(HAVE_TAN)
- return tan(x);
- #else
- return SDL_uclibc_tan(x);
- #endif
- }
- float
- SDL_tanf(float x)
- {
- #if defined(HAVE_TANF)
- return tanf(x);
- #else
- return (float)SDL_tan((double)x);
- #endif
- }
- int SDL_abs(int x)
- {
- #ifdef HAVE_ABS
- return abs(x);
- #else
- return ((x) < 0 ? -(x) : (x));
- #endif
- }
- #ifdef HAVE_CTYPE_H
- int SDL_isdigit(int x) { return isdigit(x); }
- int SDL_isspace(int x) { return isspace(x); }
- int SDL_toupper(int x) { return toupper(x); }
- int SDL_tolower(int x) { return tolower(x); }
- #else
- int SDL_isdigit(int x) { return ((x) >= '0') && ((x) <= '9'); }
- int SDL_isspace(int x) { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
- int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
- int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
- #endif
- #ifndef HAVE_LIBC
- /* These are some C runtime intrinsics that need to be defined */
- #if defined(_MSC_VER)
- #ifndef __FLTUSED__
- #define __FLTUSED__
- __declspec(selectany) int _fltused = 1;
- #endif
- /* The optimizer on Visual Studio 2010/2012 generates memcpy() calls */
- #if _MSC_VER >= 1600 && defined(_WIN64) && !defined(_DEBUG)
- #include <intrin.h>
- #pragma function(memcpy)
- void * memcpy ( void * destination, const void * source, size_t num )
- {
- const Uint8 *src = (const Uint8 *)source;
- Uint8 *dst = (Uint8 *)destination;
- size_t i;
-
- /* All WIN64 architectures have SSE, right? */
- if (!((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
- __m128 values[4];
- for (i = num / 64; i--;) {
- _mm_prefetch(src, _MM_HINT_NTA);
- values[0] = *(__m128 *) (src + 0);
- values[1] = *(__m128 *) (src + 16);
- values[2] = *(__m128 *) (src + 32);
- values[3] = *(__m128 *) (src + 48);
- _mm_stream_ps((float *) (dst + 0), values[0]);
- _mm_stream_ps((float *) (dst + 16), values[1]);
- _mm_stream_ps((float *) (dst + 32), values[2]);
- _mm_stream_ps((float *) (dst + 48), values[3]);
- src += 64;
- dst += 64;
- }
- num &= 63;
- }
- while (num--) {
- *dst++ = *src++;
- }
- return destination;
- }
- #endif /* _MSC_VER == 1600 && defined(_WIN64) && !defined(_DEBUG) */
- #ifdef _M_IX86
- /* Float to long */
- void
- __declspec(naked)
- _ftol()
- {
- /* *INDENT-OFF* */
- __asm {
- push ebp
- mov ebp,esp
- sub esp,20h
- and esp,0FFFFFFF0h
- fld st(0)
- fst dword ptr [esp+18h]
- fistp qword ptr [esp+10h]
- fild qword ptr [esp+10h]
- mov edx,dword ptr [esp+18h]
- mov eax,dword ptr [esp+10h]
- test eax,eax
- je integer_QnaN_or_zero
- arg_is_not_integer_QnaN:
- fsubp st(1),st
- test edx,edx
- jns positive
- fstp dword ptr [esp]
- mov ecx,dword ptr [esp]
- xor ecx,80000000h
- add ecx,7FFFFFFFh
- adc eax,0
- mov edx,dword ptr [esp+14h]
- adc edx,0
- jmp localexit
- positive:
- fstp dword ptr [esp]
- mov ecx,dword ptr [esp]
- add ecx,7FFFFFFFh
- sbb eax,0
- mov edx,dword ptr [esp+14h]
- sbb edx,0
- jmp localexit
- integer_QnaN_or_zero:
- mov edx,dword ptr [esp+14h]
- test edx,7FFFFFFFh
- jne arg_is_not_integer_QnaN
- fstp dword ptr [esp+18h]
- fstp dword ptr [esp+18h]
- localexit:
- leave
- ret
- }
- /* *INDENT-ON* */
- }
- void
- _ftol2_sse()
- {
- _ftol();
- }
- /* 64-bit math operators for 32-bit systems */
- void
- __declspec(naked)
- _allmul()
- {
- /* *INDENT-OFF* */
- __asm {
- mov eax, dword ptr[esp+8]
- mov ecx, dword ptr[esp+10h]
- or ecx, eax
- mov ecx, dword ptr[esp+0Ch]
- jne hard
- mov eax, dword ptr[esp+4]
- mul ecx
- ret 10h
- hard:
- push ebx
- mul ecx
- mov ebx, eax
- mov eax, dword ptr[esp+8]
- mul dword ptr[esp+14h]
- add ebx, eax
- mov eax, dword ptr[esp+8]
- mul ecx
- add edx, ebx
- pop ebx
- ret 10h
- }
- /* *INDENT-ON* */
- }
- void
- __declspec(naked)
- _alldiv()
- {
- /* *INDENT-OFF* */
- __asm {
- push edi
- push esi
- push ebx
- xor edi,edi
- mov eax,dword ptr [esp+14h]
- or eax,eax
- jge L1
- inc edi
- mov edx,dword ptr [esp+10h]
- neg eax
- neg edx
- sbb eax,0
- mov dword ptr [esp+14h],eax
- mov dword ptr [esp+10h],edx
- L1:
- mov eax,dword ptr [esp+1Ch]
- or eax,eax
- jge L2
- inc edi
- mov edx,dword ptr [esp+18h]
- neg eax
- neg edx
- sbb eax,0
- mov dword ptr [esp+1Ch],eax
- mov dword ptr [esp+18h],edx
- L2:
- or eax,eax
- jne L3
- mov ecx,dword ptr [esp+18h]
- mov eax,dword ptr [esp+14h]
- xor edx,edx
- div ecx
- mov ebx,eax
- mov eax,dword ptr [esp+10h]
- div ecx
- mov edx,ebx
- jmp L4
- L3:
- mov ebx,eax
- mov ecx,dword ptr [esp+18h]
- mov edx,dword ptr [esp+14h]
- mov eax,dword ptr [esp+10h]
- L5:
- shr ebx,1
- rcr ecx,1
- shr edx,1
- rcr eax,1
- or ebx,ebx
- jne L5
- div ecx
- mov esi,eax
- mul dword ptr [esp+1Ch]
- mov ecx,eax
- mov eax,dword ptr [esp+18h]
- mul esi
- add edx,ecx
- jb L6
- cmp edx,dword ptr [esp+14h]
- ja L6
- jb L7
- cmp eax,dword ptr [esp+10h]
- jbe L7
- L6:
- dec esi
- L7:
- xor edx,edx
- mov eax,esi
- L4:
- dec edi
- jne L8
- neg edx
- neg eax
- sbb edx,0
- L8:
- pop ebx
- pop esi
- pop edi
- ret 10h
- }
- /* *INDENT-ON* */
- }
- void
- __declspec(naked)
- _aulldiv()
- {
- /* *INDENT-OFF* */
- __asm {
- push ebx
- push esi
- mov eax,dword ptr [esp+18h]
- or eax,eax
- jne L1
- mov ecx,dword ptr [esp+14h]
- mov eax,dword ptr [esp+10h]
- xor edx,edx
- div ecx
- mov ebx,eax
- mov eax,dword ptr [esp+0Ch]
- div ecx
- mov edx,ebx
- jmp L2
- L1:
- mov ecx,eax
- mov ebx,dword ptr [esp+14h]
- mov edx,dword ptr [esp+10h]
- mov eax,dword ptr [esp+0Ch]
- L3:
- shr ecx,1
- rcr ebx,1
- shr edx,1
- rcr eax,1
- or ecx,ecx
- jne L3
- div ebx
- mov esi,eax
- mul dword ptr [esp+18h]
- mov ecx,eax
- mov eax,dword ptr [esp+14h]
- mul esi
- add edx,ecx
- jb L4
- cmp edx,dword ptr [esp+10h]
- ja L4
- jb L5
- cmp eax,dword ptr [esp+0Ch]
- jbe L5
- L4:
- dec esi
- L5:
- xor edx,edx
- mov eax,esi
- L2:
- pop esi
- pop ebx
- ret 10h
- }
- /* *INDENT-ON* */
- }
- void
- __declspec(naked)
- _allrem()
- {
- /* *INDENT-OFF* */
- __asm {
- push ebx
- push edi
- xor edi,edi
- mov eax,dword ptr [esp+10h]
- or eax,eax
- jge L1
- inc edi
- mov edx,dword ptr [esp+0Ch]
- neg eax
- neg edx
- sbb eax,0
- mov dword ptr [esp+10h],eax
- mov dword ptr [esp+0Ch],edx
- L1:
- mov eax,dword ptr [esp+18h]
- or eax,eax
- jge L2
- mov edx,dword ptr [esp+14h]
- neg eax
- neg edx
- sbb eax,0
- mov dword ptr [esp+18h],eax
- mov dword ptr [esp+14h],edx
- L2:
- or eax,eax
- jne L3
- mov ecx,dword ptr [esp+14h]
- mov eax,dword ptr [esp+10h]
- xor edx,edx
- div ecx
- mov eax,dword ptr [esp+0Ch]
- div ecx
- mov eax,edx
- xor edx,edx
- dec edi
- jns L4
- jmp L8
- L3:
- mov ebx,eax
- mov ecx,dword ptr [esp+14h]
- mov edx,dword ptr [esp+10h]
- mov eax,dword ptr [esp+0Ch]
- L5:
- shr ebx,1
- rcr ecx,1
- shr edx,1
- rcr eax,1
- or ebx,ebx
- jne L5
- div ecx
- mov ecx,eax
- mul dword ptr [esp+18h]
- xchg eax,ecx
- mul dword ptr [esp+14h]
- add edx,ecx
- jb L6
- cmp edx,dword ptr [esp+10h]
- ja L6
- jb L7
- cmp eax,dword ptr [esp+0Ch]
- jbe L7
- L6:
- sub eax,dword ptr [esp+14h]
- sbb edx,dword ptr [esp+18h]
- L7:
- sub eax,dword ptr [esp+0Ch]
- sbb edx,dword ptr [esp+10h]
- dec edi
- jns L8
- L4:
- neg edx
- neg eax
- sbb edx,0
- L8:
- pop edi
- pop ebx
- ret 10h
- }
- /* *INDENT-ON* */
- }
- void
- __declspec(naked)
- _aullrem()
- {
- /* *INDENT-OFF* */
- __asm {
- push ebx
- mov eax,dword ptr [esp+14h]
- or eax,eax
- jne L1
- mov ecx,dword ptr [esp+10h]
- mov eax,dword ptr [esp+0Ch]
- xor edx,edx
- div ecx
- mov eax,dword ptr [esp+8]
- div ecx
- mov eax,edx
- xor edx,edx
- jmp L2
- L1:
- mov ecx,eax
- mov ebx,dword ptr [esp+10h]
- mov edx,dword ptr [esp+0Ch]
- mov eax,dword ptr [esp+8]
- L3:
- shr ecx,1
- rcr ebx,1
- shr edx,1
- rcr eax,1
- or ecx,ecx
- jne L3
- div ebx
- mov ecx,eax
- mul dword ptr [esp+14h]
- xchg eax,ecx
- mul dword ptr [esp+10h]
- add edx,ecx
- jb L4
- cmp edx,dword ptr [esp+0Ch]
- ja L4
- jb L5
- cmp eax,dword ptr [esp+8]
- jbe L5
- L4:
- sub eax,dword ptr [esp+10h]
- sbb edx,dword ptr [esp+14h]
- L5:
- sub eax,dword ptr [esp+8]
- sbb edx,dword ptr [esp+0Ch]
- neg edx
- neg eax
- sbb edx,0
- L2:
- pop ebx
- ret 10h
- }
- /* *INDENT-ON* */
- }
- void
- __declspec(naked)
- _alldvrm()
- {
- /* *INDENT-OFF* */
- __asm {
- push edi
- push esi
- push ebp
- xor edi,edi
- xor ebp,ebp
- mov eax,dword ptr [esp+14h]
- or eax,eax
- jge L1
- inc edi
- inc ebp
- mov edx,dword ptr [esp+10h]
- neg eax
- neg edx
- sbb eax,0
- mov dword ptr [esp+14h],eax
- mov dword ptr [esp+10h],edx
- L1:
- mov eax,dword ptr [esp+1Ch]
- or eax,eax
- jge L2
- inc edi
- mov edx,dword ptr [esp+18h]
- neg eax
- neg edx
- sbb eax,0
- mov dword ptr [esp+1Ch],eax
- mov dword ptr [esp+18h],edx
- L2:
- or eax,eax
- jne L3
- mov ecx,dword ptr [esp+18h]
- mov eax,dword ptr [esp+14h]
- xor edx,edx
- div ecx
- mov ebx,eax
- mov eax,dword ptr [esp+10h]
- div ecx
- mov esi,eax
- mov eax,ebx
- mul dword ptr [esp+18h]
- mov ecx,eax
- mov eax,esi
- mul dword ptr [esp+18h]
- add edx,ecx
- jmp L4
- L3:
- mov ebx,eax
- mov ecx,dword ptr [esp+18h]
- mov edx,dword ptr [esp+14h]
- mov eax,dword ptr [esp+10h]
- L5:
- shr ebx,1
- rcr ecx,1
- shr edx,1
- rcr eax,1
- or ebx,ebx
- jne L5
- div ecx
- mov esi,eax
- mul dword ptr [esp+1Ch]
- mov ecx,eax
- mov eax,dword ptr [esp+18h]
- mul esi
- add edx,ecx
- jb L6
- cmp edx,dword ptr [esp+14h]
- ja L6
- jb L7
- cmp eax,dword ptr [esp+10h]
- jbe L7
- L6:
- dec esi
- sub eax,dword ptr [esp+18h]
- sbb edx,dword ptr [esp+1Ch]
- L7:
- xor ebx,ebx
- L4:
- sub eax,dword ptr [esp+10h]
- sbb edx,dword ptr [esp+14h]
- dec ebp
- jns L9
- neg edx
- neg eax
- sbb edx,0
- L9:
- mov ecx,edx
- mov edx,ebx
- mov ebx,ecx
- mov ecx,eax
- mov eax,esi
- dec edi
- jne L8
- neg edx
- neg eax
- sbb edx,0
- L8:
- pop ebp
- pop esi
- pop edi
- ret 10h
- }
- /* *INDENT-ON* */
- }
- void
- __declspec(naked)
- _aulldvrm()
- {
- /* *INDENT-OFF* */
- __asm {
- push esi
- mov eax,dword ptr [esp+14h]
- or eax,eax
- jne L1
- mov ecx,dword ptr [esp+10h]
- mov eax,dword ptr [esp+0Ch]
- xor edx,edx
- div ecx
- mov ebx,eax
- mov eax,dword ptr [esp+8]
- div ecx
- mov esi,eax
- mov eax,ebx
- mul dword ptr [esp+10h]
- mov ecx,eax
- mov eax,esi
- mul dword ptr [esp+10h]
- add edx,ecx
- jmp L2
- L1:
- mov ecx,eax
- mov ebx,dword ptr [esp+10h]
- mov edx,dword ptr [esp+0Ch]
- mov eax,dword ptr [esp+8]
- L3:
- shr ecx,1
- rcr ebx,1
- shr edx,1
- rcr eax,1
- or ecx,ecx
- jne L3
- div ebx
- mov esi,eax
- mul dword ptr [esp+14h]
- mov ecx,eax
- mov eax,dword ptr [esp+10h]
- mul esi
- add edx,ecx
- jb L4
- cmp edx,dword ptr [esp+0Ch]
- ja L4
- jb L5
- cmp eax,dword ptr [esp+8]
- jbe L5
- L4:
- dec esi
- sub eax,dword ptr [esp+10h]
- sbb edx,dword ptr [esp+14h]
- L5:
- xor ebx,ebx
- L2:
- sub eax,dword ptr [esp+8]
- sbb edx,dword ptr [esp+0Ch]
- neg edx
- neg eax
- sbb edx,0
- mov ecx,edx
- mov edx,ebx
- mov ebx,ecx
- mov ecx,eax
- mov eax,esi
- pop esi
- ret 10h
- }
- /* *INDENT-ON* */
- }
- void
- __declspec(naked)
- _allshl()
- {
- /* *INDENT-OFF* */
- __asm {
- cmp cl,40h
- jae RETZERO
- cmp cl,20h
- jae MORE32
- shld edx,eax,cl
- shl eax,cl
- ret
- MORE32:
- mov edx,eax
- xor eax,eax
- and cl,1Fh
- shl edx,cl
- ret
- RETZERO:
- xor eax,eax
- xor edx,edx
- ret
- }
- /* *INDENT-ON* */
- }
- void
- __declspec(naked)
- _allshr()
- {
- /* *INDENT-OFF* */
- __asm {
- cmp cl,40h
- jae RETZERO
- cmp cl,20h
- jae MORE32
- shrd eax,edx,cl
- sar edx,cl
- ret
- MORE32:
- mov eax,edx
- xor edx,edx
- and cl,1Fh
- sar eax,cl
- ret
- RETZERO:
- xor eax,eax
- xor edx,edx
- ret
- }
- /* *INDENT-ON* */
- }
- void
- __declspec(naked)
- _aullshr()
- {
- /* *INDENT-OFF* */
- __asm {
- cmp cl,40h
- jae RETZERO
- cmp cl,20h
- jae MORE32
- shrd eax,edx,cl
- shr edx,cl
- ret
- MORE32:
- mov eax,edx
- xor edx,edx
- and cl,1Fh
- shr eax,cl
- ret
- RETZERO:
- xor eax,eax
- xor edx,edx
- ret
- }
- /* *INDENT-ON* */
- }
- #endif /* _M_IX86 */
- #endif /* MSC_VER */
- #endif /* !HAVE_LIBC */
- /* vi: set ts=4 sw=4 expandtab: */
|