2000-10-01 03:40:42 +02:00
|
|
|
/*
|
|
|
|
* Large integer functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Alexandre Julliard
|
2003-02-19 04:39:46 +01:00
|
|
|
* Copyright 2003 Thomas Mertes
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
|
2010-02-05 12:23:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "ntstatus.h"
|
2005-11-28 17:32:54 +01:00
|
|
|
#define WIN32_NO_STATUS
|
2002-12-10 23:56:43 +01:00
|
|
|
#include "windef.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
2019-05-14 12:30:46 +02:00
|
|
|
#include "wine/asm.h"
|
2000-10-01 03:40:42 +02:00
|
|
|
|
2009-08-24 12:50:11 +02:00
|
|
|
#ifndef _WIN64
|
|
|
|
|
2000-10-01 03:40:42 +02:00
|
|
|
/*
|
|
|
|
* Note: we use LONGLONG instead of LARGE_INTEGER, because
|
|
|
|
* the latter is a structure and the calling convention for
|
|
|
|
* returning a structure would not be binary-compatible.
|
|
|
|
*
|
|
|
|
* FIXME: for platforms that don't have a native LONGLONG type,
|
|
|
|
* we should define LONGLONG as a structure similar to LARGE_INTEGER
|
|
|
|
* and do everything by hand. You are welcome to do it...
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlLargeIntegerAdd (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Add two 64 bit integers.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to add to a.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The sum of a and b.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlLargeIntegerAdd( LONGLONG a, LONGLONG b )
|
|
|
|
{
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlLargeIntegerSubtract (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Subtract two 64 bit integers.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to subtract from a.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The difference of a and b.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlLargeIntegerSubtract( LONGLONG a, LONGLONG b )
|
|
|
|
{
|
|
|
|
return a - b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlLargeIntegerNegate (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Negate a 64 bit integer.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The value of a negated.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlLargeIntegerNegate( LONGLONG a )
|
|
|
|
{
|
|
|
|
return -a;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlLargeIntegerShiftLeft (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Perform a shift left on a 64 bit integer.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* count [I] Number of bits to shift by
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The value of a following the shift.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlLargeIntegerShiftLeft( LONGLONG a, INT count )
|
|
|
|
{
|
|
|
|
return a << count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlLargeIntegerShiftRight (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Perform a shift right on a 64 bit integer.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* count [I] Number of bits to shift by
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The value of a following the shift.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlLargeIntegerShiftRight( LONGLONG a, INT count )
|
|
|
|
{
|
|
|
|
return (ULONGLONG)a >> count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlLargeIntegerArithmeticShift (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Perform an arithmetic shift right on a 64 bit integer.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* count [I] Number of bits to shift by
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The value of a following the shift.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlLargeIntegerArithmeticShift( LONGLONG a, INT count )
|
|
|
|
{
|
|
|
|
/* FIXME: gcc does arithmetic shift here, but it may not be true on all platforms */
|
|
|
|
return a >> count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlLargeIntegerDivide (NTDLL.@)
|
|
|
|
*
|
2003-10-01 05:20:21 +02:00
|
|
|
* Divide one 64 bit unsigned integer by another, with remainder.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to divide a by
|
|
|
|
* rem [O] Destination for remainder
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The dividend of a and b. If rem is non-NULL it is set to the remainder.
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* Should it be signed division instead?
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
ULONGLONG WINAPI RtlLargeIntegerDivide( ULONGLONG a, ULONGLONG b, ULONGLONG *rem )
|
|
|
|
{
|
|
|
|
ULONGLONG ret = a / b;
|
|
|
|
if (rem) *rem = a - ret * b;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlConvertLongToLargeInteger (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Convert a 32 bit integer into 64 bits.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Number to convert
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* a.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlConvertLongToLargeInteger( LONG a )
|
|
|
|
{
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlConvertUlongToLargeInteger (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Convert a 32 bit unsigned integer into 64 bits.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Number to convert
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* a.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
ULONGLONG WINAPI RtlConvertUlongToLargeInteger( ULONG a )
|
|
|
|
{
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlEnlargedIntegerMultiply (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Multiply two integers giving a 64 bit integer result.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to multiply a by.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The product of a and b.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlEnlargedIntegerMultiply( INT a, INT b )
|
|
|
|
{
|
|
|
|
return (LONGLONG)a * b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlEnlargedUnsignedMultiply (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Multiply two unsigned integers giving a 64 bit unsigned integer result.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to multiply a by.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The product of a and b.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
2000-10-13 22:26:03 +02:00
|
|
|
ULONGLONG WINAPI RtlEnlargedUnsignedMultiply( UINT a, UINT b )
|
2000-10-01 03:40:42 +02:00
|
|
|
{
|
|
|
|
return (ULONGLONG)a * b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlEnlargedUnsignedDivide (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Divide one 64 bit unsigned integer by a 32 bit unsigned integer, with remainder.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to divide a by
|
|
|
|
* remptr [O] Destination for remainder
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The dividend of a and b. If remptr is non-NULL it is set to the remainder.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
UINT WINAPI RtlEnlargedUnsignedDivide( ULONGLONG a, UINT b, UINT *remptr )
|
|
|
|
{
|
|
|
|
#if defined(__i386__) && defined(__GNUC__)
|
2011-07-29 19:18:41 +02:00
|
|
|
UINT ret, rem;
|
2002-11-18 20:49:18 +01:00
|
|
|
|
2011-07-29 19:18:41 +02:00
|
|
|
__asm__("divl %4"
|
2000-10-01 03:40:42 +02:00
|
|
|
: "=a" (ret), "=d" (rem)
|
2011-07-29 19:18:41 +02:00
|
|
|
: "0" ((UINT)a), "1" ((UINT)(a >> 32)), "g" (b) );
|
2000-10-01 03:40:42 +02:00
|
|
|
if (remptr) *remptr = rem;
|
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
UINT ret = a / b;
|
|
|
|
if (remptr) *remptr = a % b;
|
|
|
|
return ret;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlExtendedLargeIntegerDivide (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Divide one 64 bit integer by a 32 bit integer, with remainder.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to divide a by
|
|
|
|
* rem [O] Destination for remainder
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The dividend of a and b. If rem is non-NULL it is set to the remainder.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlExtendedLargeIntegerDivide( LONGLONG a, INT b, INT *rem )
|
|
|
|
{
|
|
|
|
LONGLONG ret = a / b;
|
|
|
|
if (rem) *rem = a - b * ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlExtendedIntegerMultiply (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Multiply one 64 bit integer by another 32 bit integer.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to multiply a by.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The product of a and b.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlExtendedIntegerMultiply( LONGLONG a, INT b )
|
|
|
|
{
|
|
|
|
return a * b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlExtendedMagicDivide (NTDLL.@)
|
|
|
|
*
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
* Allows replacing a division by a longlong constant with a multiplication by
|
|
|
|
* the inverse constant.
|
2000-10-01 03:40:42 +02:00
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* RETURNS
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
* (dividend * inverse_divisor) >> (64 + shift)
|
2000-10-01 03:40:42 +02:00
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* NOTES
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
* If the divisor of a division is constant, the constants inverse_divisor and
|
|
|
|
* shift must be chosen such that inverse_divisor = 2^(64 + shift) / divisor.
|
|
|
|
* Then we have RtlExtendedMagicDivide(dividend,inverse_divisor,shift) ==
|
|
|
|
* dividend * inverse_divisor / 2^(64 + shift) == dividend / divisor.
|
2000-10-01 03:40:42 +02:00
|
|
|
*
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
* The Parameter inverse_divisor although defined as LONGLONG is used as
|
|
|
|
* ULONGLONG.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
2003-02-19 04:39:46 +01:00
|
|
|
#define LOWER_32(A) ((A) & 0xffffffff)
|
|
|
|
#define UPPER_32(A) ((A) >> 32)
|
|
|
|
LONGLONG WINAPI RtlExtendedMagicDivide(
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
LONGLONG dividend, /* [I] Dividend to be divided by the constant divisor */
|
|
|
|
LONGLONG inverse_divisor, /* [I] Constant computed manually as 2^(64+shift) / divisor */
|
|
|
|
INT shift) /* [I] Constant shift chosen to make inverse_divisor as big as possible for 64 bits */
|
2003-02-19 04:39:46 +01:00
|
|
|
{
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
ULONGLONG dividend_high;
|
|
|
|
ULONGLONG dividend_low;
|
|
|
|
ULONGLONG inverse_divisor_high;
|
|
|
|
ULONGLONG inverse_divisor_low;
|
2003-02-19 04:39:46 +01:00
|
|
|
ULONGLONG ah_bl;
|
|
|
|
ULONGLONG al_bh;
|
|
|
|
LONGLONG result;
|
|
|
|
int positive;
|
|
|
|
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
if (dividend < 0) {
|
|
|
|
dividend_high = UPPER_32((ULONGLONG) -dividend);
|
|
|
|
dividend_low = LOWER_32((ULONGLONG) -dividend);
|
2003-02-19 04:39:46 +01:00
|
|
|
positive = 0;
|
|
|
|
} else {
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
dividend_high = UPPER_32((ULONGLONG) dividend);
|
|
|
|
dividend_low = LOWER_32((ULONGLONG) dividend);
|
2003-02-19 04:39:46 +01:00
|
|
|
positive = 1;
|
|
|
|
} /* if */
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
inverse_divisor_high = UPPER_32((ULONGLONG) inverse_divisor);
|
|
|
|
inverse_divisor_low = LOWER_32((ULONGLONG) inverse_divisor);
|
2003-02-19 04:39:46 +01:00
|
|
|
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
ah_bl = dividend_high * inverse_divisor_low;
|
|
|
|
al_bh = dividend_low * inverse_divisor_high;
|
2003-02-19 04:39:46 +01:00
|
|
|
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
result = (LONGLONG) ((dividend_high * inverse_divisor_high +
|
2003-02-19 04:39:46 +01:00
|
|
|
UPPER_32(ah_bl) +
|
|
|
|
UPPER_32(al_bh) +
|
Implemented RtlRandom, RtlAreAllAccessesGranted,
RtlAreAnyAccessesGranted, RtlCopyLuid, RtlEqualLuid, RtlMapGenericMask
and RtlCopyLuidAndAttributesArray.
Documentation updates for RtlExtendedMagicDivide, RtlUniform,
RtlUnicodeStringToAnsiString, RtlAppendAsciizToString,
RtlAppendStringToString, RtlAppendUnicodeToString and
RtlAppendUnicodeStringToString.
2003-04-08 02:55:36 +02:00
|
|
|
UPPER_32(LOWER_32(ah_bl) + LOWER_32(al_bh) +
|
|
|
|
UPPER_32(dividend_low * inverse_divisor_low))) >> shift);
|
2003-02-19 04:39:46 +01:00
|
|
|
|
|
|
|
if (positive) {
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
return -result;
|
|
|
|
} /* if */
|
|
|
|
}
|
|
|
|
|
2010-02-05 12:23:48 +01:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* RtlInterlockedCompareExchange64 (NTDLL.@)
|
|
|
|
*/
|
|
|
|
LONGLONG WINAPI RtlInterlockedCompareExchange64( LONGLONG *dest, LONGLONG xchg, LONGLONG compare )
|
|
|
|
{
|
|
|
|
return interlocked_cmpxchg64( dest, xchg, compare );
|
|
|
|
}
|
|
|
|
|
2009-08-24 12:50:11 +02:00
|
|
|
#endif /* _WIN64 */
|
2003-02-19 04:39:46 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RtlLargeIntegerToChar [NTDLL.@]
|
|
|
|
*
|
|
|
|
* Convert an unsigned large integer to a character string.
|
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: STATUS_SUCCESS. str contains the converted number
|
|
|
|
* Failure: STATUS_INVALID_PARAMETER, if base is not 0, 2, 8, 10 or 16.
|
|
|
|
* STATUS_BUFFER_OVERFLOW, if str would be larger than length.
|
|
|
|
* STATUS_ACCESS_VIOLATION, if str is NULL.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Instead of base 0 it uses 10 as base.
|
|
|
|
* Writes at most length characters to the string str.
|
2005-02-25 15:07:56 +01:00
|
|
|
* Str is '\0' terminated when length allows it.
|
|
|
|
* When str fits exactly in length characters the '\0' is omitted.
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* If value_ptr is NULL it crashes, as the native function does.
|
2003-02-19 04:39:46 +01:00
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* DIFFERENCES
|
|
|
|
* - Accept base 0 as 10 instead of crashing as native function does.
|
|
|
|
* - The native function does produce garbage or STATUS_BUFFER_OVERFLOW for
|
2003-10-01 05:20:21 +02:00
|
|
|
* base 2, 8 and 16 when the value is larger than 0xFFFFFFFF.
|
2003-02-19 04:39:46 +01:00
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlLargeIntegerToChar(
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
const ULONGLONG *value_ptr, /* [I] Pointer to the value to be converted */
|
|
|
|
ULONG base, /* [I] Number base for conversion (allowed 0, 2, 8, 10 or 16) */
|
|
|
|
ULONG length, /* [I] Length of the str buffer in bytes */
|
|
|
|
PCHAR str) /* [O] Destination for the converted value */
|
2003-02-19 04:39:46 +01:00
|
|
|
{
|
|
|
|
ULONGLONG value = *value_ptr;
|
|
|
|
CHAR buffer[65];
|
|
|
|
PCHAR pos;
|
|
|
|
CHAR digit;
|
|
|
|
ULONG len;
|
|
|
|
|
|
|
|
if (base == 0) {
|
|
|
|
base = 10;
|
|
|
|
} else if (base != 2 && base != 8 && base != 10 && base != 16) {
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
pos = &buffer[64];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
|
|
|
pos--;
|
|
|
|
digit = value % base;
|
|
|
|
value = value / base;
|
|
|
|
if (digit < 10) {
|
|
|
|
*pos = '0' + digit;
|
|
|
|
} else {
|
|
|
|
*pos = 'A' + digit - 10;
|
|
|
|
} /* if */
|
|
|
|
} while (value != 0L);
|
|
|
|
|
|
|
|
len = &buffer[64] - pos;
|
|
|
|
if (len > length) {
|
|
|
|
return STATUS_BUFFER_OVERFLOW;
|
|
|
|
} else if (str == NULL) {
|
|
|
|
return STATUS_ACCESS_VIOLATION;
|
|
|
|
} else if (len == length) {
|
|
|
|
memcpy(str, pos, len);
|
|
|
|
} else {
|
|
|
|
memcpy(str, pos, len + 1);
|
|
|
|
} /* if */
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* RtlInt64ToUnicodeString (NTDLL.@)
|
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* Convert a large unsigned integer to a '\0' terminated unicode string.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: STATUS_SUCCESS. str contains the converted number
|
|
|
|
* Failure: STATUS_INVALID_PARAMETER, if base is not 0, 2, 8, 10 or 16.
|
|
|
|
* STATUS_BUFFER_OVERFLOW, if str is too small to hold the string
|
|
|
|
* (with the '\0' termination). In this case str->Length
|
|
|
|
* is set to the length, the string would have (which can
|
|
|
|
* be larger than the MaximumLength).
|
2003-02-19 04:39:46 +01:00
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* NOTES
|
|
|
|
* Instead of base 0 it uses 10 as base.
|
|
|
|
* If str is NULL it crashes, as the native function does.
|
2003-02-19 04:39:46 +01:00
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* DIFFERENCES
|
|
|
|
* - Accept base 0 as 10 instead of crashing as native function does.
|
2003-02-19 04:39:46 +01:00
|
|
|
* - Do not return STATUS_BUFFER_OVERFLOW when the string is long enough.
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* The native function does this when the string would be longer than 31
|
2003-02-19 04:39:46 +01:00
|
|
|
* characters even when the string parameter is long enough.
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* - The native function does produce garbage or STATUS_BUFFER_OVERFLOW for
|
2003-02-19 04:39:46 +01:00
|
|
|
* base 2, 8 and 16 when the value is larger than 0xFFFFFFFF.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
2003-02-19 04:39:46 +01:00
|
|
|
NTSTATUS WINAPI RtlInt64ToUnicodeString(
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
ULONGLONG value, /* [I] Value to be converted */
|
|
|
|
ULONG base, /* [I] Number base for conversion (allowed 0, 2, 8, 10 or 16) */
|
|
|
|
UNICODE_STRING *str) /* [O] Destination for the converted value */
|
2003-02-19 04:39:46 +01:00
|
|
|
{
|
|
|
|
WCHAR buffer[65];
|
|
|
|
PWCHAR pos;
|
|
|
|
WCHAR digit;
|
|
|
|
|
|
|
|
if (base == 0) {
|
|
|
|
base = 10;
|
|
|
|
} else if (base != 2 && base != 8 && base != 10 && base != 16) {
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
pos = &buffer[64];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
|
|
|
pos--;
|
|
|
|
digit = value % base;
|
|
|
|
value = value / base;
|
|
|
|
if (digit < 10) {
|
|
|
|
*pos = '0' + digit;
|
|
|
|
} else {
|
|
|
|
*pos = 'A' + digit - 10;
|
|
|
|
} /* if */
|
|
|
|
} while (value != 0L);
|
|
|
|
|
|
|
|
str->Length = (&buffer[64] - pos) * sizeof(WCHAR);
|
|
|
|
if (str->Length >= str->MaximumLength) {
|
|
|
|
return STATUS_BUFFER_OVERFLOW;
|
|
|
|
} else {
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
memcpy(str->Buffer, pos, str->Length + sizeof(WCHAR));
|
2003-02-19 04:39:46 +01:00
|
|
|
} /* if */
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2000-10-13 22:26:03 +02:00
|
|
|
|
|
|
|
|
2009-08-24 12:50:11 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
|
2000-10-13 22:26:03 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* _alldiv (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Divide two 64 bit unsigned integers.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
2011-02-03 19:43:21 +01:00
|
|
|
* b [I] Number to divide a by.
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The dividend of a and b.
|
2000-10-13 22:26:03 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI _alldiv( LONGLONG a, LONGLONG b )
|
|
|
|
{
|
|
|
|
return a / b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* _allmul (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Multiply two 64 bit integers.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to multiply a by.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The product of a and b.
|
2000-10-13 22:26:03 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI _allmul( LONGLONG a, LONGLONG b )
|
|
|
|
{
|
|
|
|
return a * b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* _allrem (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Calculate the remainder after dividing two 64 bit integers.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to divide a by.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The remainder of a divided by b.
|
2000-10-13 22:26:03 +02:00
|
|
|
*/
|
|
|
|
LONGLONG WINAPI _allrem( LONGLONG a, LONGLONG b )
|
|
|
|
{
|
|
|
|
return a % b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* _aulldiv (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Divide two 64 bit unsigned integers.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
2011-02-03 19:43:21 +01:00
|
|
|
* b [I] Number to divide a by.
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The dividend of a and b.
|
2000-10-13 22:26:03 +02:00
|
|
|
*/
|
|
|
|
ULONGLONG WINAPI _aulldiv( ULONGLONG a, ULONGLONG b )
|
|
|
|
{
|
|
|
|
return a / b;
|
|
|
|
}
|
|
|
|
|
2016-08-04 22:04:29 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* _allshl (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Shift a 64 bit integer to the left.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to shift a by to the left.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The left-shifted value.
|
|
|
|
*/
|
|
|
|
LONGLONG WINAPI _allshl( LONGLONG a, LONG b )
|
|
|
|
{
|
|
|
|
return a << b;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* _allshr (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Shift a 64 bit integer to the right.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to shift a by to the right.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The right-shifted value.
|
|
|
|
*/
|
|
|
|
LONGLONG WINAPI _allshr( LONGLONG a, LONG b )
|
|
|
|
{
|
|
|
|
return a >> b;
|
|
|
|
}
|
2000-10-13 22:26:03 +02:00
|
|
|
|
2018-04-03 17:10:27 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* _alldvrm (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Divide two 64 bit integers.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to divide a by.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Returns the quotient of a and b in edx:eax.
|
|
|
|
* Returns the remainder of a and b in ebx:ecx.
|
|
|
|
*/
|
|
|
|
__ASM_STDCALL_FUNC( _alldvrm, 16,
|
|
|
|
"pushl %ebp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
|
|
|
|
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
|
|
|
|
"movl %esp,%ebp\n\t"
|
|
|
|
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
|
|
|
|
"pushl 20(%ebp)\n\t"
|
|
|
|
"pushl 16(%ebp)\n\t"
|
|
|
|
"pushl 12(%ebp)\n\t"
|
|
|
|
"pushl 8(%ebp)\n\t"
|
|
|
|
"call " __ASM_NAME("_allrem") "\n\t"
|
|
|
|
"movl %edx,%ebx\n\t"
|
|
|
|
"pushl %eax\n\t"
|
|
|
|
"pushl 20(%ebp)\n\t"
|
|
|
|
"pushl 16(%ebp)\n\t"
|
|
|
|
"pushl 12(%ebp)\n\t"
|
|
|
|
"pushl 8(%ebp)\n\t"
|
|
|
|
"call " __ASM_NAME("_alldiv") "\n\t"
|
|
|
|
"popl %ecx\n\t"
|
|
|
|
"leave\n\t"
|
|
|
|
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
|
|
|
|
__ASM_CFI(".cfi_same_value %ebp\n\t")
|
|
|
|
"ret $16" )
|
|
|
|
|
2000-10-13 22:26:03 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* _aullrem (NTDLL.@)
|
2003-10-01 05:20:21 +02:00
|
|
|
*
|
|
|
|
* Calculate the remainder after dividing two 64 bit unsigned integers.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to divide a by.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The remainder of a divided by b.
|
2000-10-13 22:26:03 +02:00
|
|
|
*/
|
|
|
|
ULONGLONG WINAPI _aullrem( ULONGLONG a, ULONGLONG b )
|
|
|
|
{
|
|
|
|
return a % b;
|
|
|
|
}
|
2009-08-24 12:50:11 +02:00
|
|
|
|
2016-08-04 22:04:29 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* _aullshr (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Shift a 64 bit unsigned integer to the right.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to shift a by to the right.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The right-shifted value.
|
|
|
|
*/
|
|
|
|
ULONGLONG WINAPI _aullshr( ULONGLONG a, LONG b )
|
|
|
|
{
|
|
|
|
return a >> b;
|
|
|
|
}
|
|
|
|
|
2018-04-03 17:10:27 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* _aulldvrm (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Divide two 64 bit unsigned integers.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* a [I] Initial number.
|
|
|
|
* b [I] Number to divide a by.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Returns the quotient of a and b in edx:eax.
|
|
|
|
* Returns the remainder of a and b in ebx:ecx.
|
|
|
|
*/
|
|
|
|
__ASM_STDCALL_FUNC( _aulldvrm, 16,
|
|
|
|
"pushl %ebp\n\t"
|
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
|
|
|
|
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
|
|
|
|
"movl %esp,%ebp\n\t"
|
|
|
|
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
|
|
|
|
"pushl 20(%ebp)\n\t"
|
|
|
|
"pushl 16(%ebp)\n\t"
|
|
|
|
"pushl 12(%ebp)\n\t"
|
|
|
|
"pushl 8(%ebp)\n\t"
|
|
|
|
"call " __ASM_NAME("_aullrem") "\n\t"
|
|
|
|
"movl %edx,%ebx\n\t"
|
|
|
|
"pushl %eax\n\t"
|
|
|
|
"pushl 20(%ebp)\n\t"
|
|
|
|
"pushl 16(%ebp)\n\t"
|
|
|
|
"pushl 12(%ebp)\n\t"
|
|
|
|
"pushl 8(%ebp)\n\t"
|
|
|
|
"call " __ASM_NAME("_aulldiv") "\n\t"
|
|
|
|
"popl %ecx\n\t"
|
|
|
|
"leave\n\t"
|
|
|
|
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
|
|
|
|
__ASM_CFI(".cfi_same_value %ebp\n\t")
|
|
|
|
"ret $16" )
|
|
|
|
|
2009-08-24 12:50:11 +02:00
|
|
|
#endif /* __i386__ */
|