Commit 27952ef0 authored by Alexandre Julliard's avatar Alexandre Julliard

Added a few more large integer functions.

parent 97827ead
......@@ -214,26 +214,11 @@ VOID WINAPI GetSystemTimeAsFileTime( LPFILETIME time )
* 1) Divided by CLK_TCK
* 2) Time is relative. There is no 'starting date', so there is
* no need in offset correction, like in UnixTimeToFileTime
* FIXME: This function should be moved to a more appropriate .c file
* FIXME: On floating point operations, it is assumed that
* floating values are truncated on conversion to integer.
*/
static void TIME_ClockTimeToFileTime(clock_t unix_time, LPFILETIME filetime)
{
double td = (unix_time*10000000.0)/CLK_TCK;
/* Yes, double, because long int might overflow here. */
#if SIZEOF_LONG_LONG >= 8
unsigned long long t = td;
filetime->dwLowDateTime = (UINT) t;
filetime->dwHighDateTime = (UINT) (t >> 32);
#else
double divider = 1. * (1 << 16) * (1 << 16);
filetime->dwHighDateTime = (UINT) (td / divider);
filetime->dwLowDateTime = (UINT) (td - filetime->dwHighDateTime*divider);
/* using floor() produces wierd results, better leave this as it is
* ( with (UINT32) convertion )
*/
#endif
LONGLONG secs = RtlEnlargedUnsignedMultiply( unix_time, 10000000 );
((LARGE_INTEGER *)filetime)->QuadPart = RtlExtendedLargeIntegerDivide( secs, CLK_TCK, NULL );
}
/*********************************************************************
......
......@@ -115,7 +115,7 @@ LONGLONG WINAPI RtlEnlargedIntegerMultiply( INT a, INT b )
/******************************************************************************
* RtlEnlargedUnsignedMultiply (NTDLL.@)
*/
LONGLONG WINAPI RtlEnlargedUnsignedMultiply( UINT a, UINT b )
ULONGLONG WINAPI RtlEnlargedUnsignedMultiply( UINT a, UINT b )
{
return (ULONGLONG)a * b;
}
......@@ -180,3 +180,48 @@ LONGLONG WINAPI RtlExtendedIntegerMultiply( LONGLONG a, INT b )
* return 0;
* }
*/
/******************************************************************************
* _alldiv (NTDLL.@)
*/
LONGLONG WINAPI _alldiv( LONGLONG a, LONGLONG b )
{
return a / b;
}
/******************************************************************************
* _allmul (NTDLL.@)
*/
LONGLONG WINAPI _allmul( LONGLONG a, LONGLONG b )
{
return a * b;
}
/******************************************************************************
* _allrem (NTDLL.@)
*/
LONGLONG WINAPI _allrem( LONGLONG a, LONGLONG b )
{
return a % b;
}
/******************************************************************************
* _aulldiv (NTDLL.@)
*/
ULONGLONG WINAPI _aulldiv( ULONGLONG a, ULONGLONG b )
{
return a / b;
}
/******************************************************************************
* _aullrem (NTDLL.@)
*/
ULONGLONG WINAPI _aullrem( ULONGLONG a, ULONGLONG b )
{
return a % b;
}
......@@ -598,35 +598,6 @@ NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
}
/******************************************************************************
* _alldiv [NTDLL.937]
*
*
*/
long long WINAPI _alldiv(LARGE_INTEGER a, LARGE_INTEGER b)
{
#if SIZEOF_LONG_LONG==8
return (*(long long*)&a / *(long long*)&b);
#else
FIXME("stub\n");
return 0;
#endif
}
/******************************************************************************
* _allmul [NTDLL.938]
*
*
*/
long long WINAPI _allmul(LARGE_INTEGER a, LARGE_INTEGER b)
{
#if SIZEOF_LONG_LONG==8
return (*(long long*)&a * *(long long*)&b);
#else
FIXME("stub\n");
return 0;
#endif
}
/******************************************************************************
* NtPowerInformation [NTDLL]
*
*/
......
......@@ -865,7 +865,12 @@ type win32
@ stub __eFYL2X
@ stub __eFYL2XP1
@ stub __eGetStatusWord
@ stdcall64 _alldiv(long long long long) _alldiv
@ stdcall64 _allmul(long long long long) _allmul
@ register _alloca_probe() NTDLL_alloca_probe
@ stdcall64 _allrem(long long long long) _allrem
@ stdcall64 _aulldiv(long long long long) _aulldiv
@ stdcall64 _aullrem(long long long long) _aullrem
@ register _chkstk() NTDLL_chkstk
@ stub _fltused
@ cdecl _ftol() NTDLL__ftol
......
......@@ -15,6 +15,7 @@
#include "winbase.h"
#include "winerror.h"
#include "ntddk.h"
#include "debugtools.h"
#include "storage32.h"
......@@ -534,52 +535,7 @@ HRESULT WINAPI StgStreamImpl_Seek(
return STG_E_INVALIDFUNCTION;
}
#if SIZEOF_LONG_LONG >= 8
plibNewPosition->QuadPart += dlibMove.QuadPart;
#else
/*
* do some multiword arithmetic:
* treat HighPart as a signed value
* treat LowPart as unsigned
* NOTE: this stuff is two's complement specific!
*/
if (dlibMove.s.HighPart < 0) { /* dlibMove is < 0 */
/* calculate the absolute value of dlibMove ... */
dlibMove.s.HighPart = -dlibMove.s.HighPart;
dlibMove.s.LowPart ^= -1;
/* ... and subtract with carry */
if (dlibMove.s.LowPart > plibNewPosition->s.LowPart) {
/* carry needed, This accounts for any underflows at [1]*/
plibNewPosition->s.HighPart -= 1;
}
plibNewPosition->s.LowPart -= dlibMove.s.LowPart; /* [1] */
plibNewPosition->s.HighPart -= dlibMove.s.HighPart;
} else {
/* add directly */
int initialLowPart = plibNewPosition->s.LowPart;
plibNewPosition->s.LowPart += dlibMove.s.LowPart;
if((plibNewPosition->s.LowPart < initialLowPart) ||
(plibNewPosition->s.LowPart < dlibMove.s.LowPart)) {
/* LowPart has rolled over => add the carry digit to HighPart */
plibNewPosition->s.HighPart++;
}
plibNewPosition->s.HighPart += dlibMove.s.HighPart;
}
/*
* Check if we end-up before the beginning of the file. That should
* trigger an error.
*/
if (plibNewPosition->s.HighPart < 0) {
return STG_E_INVALIDPOINTER;
}
/*
* We currently don't support files with offsets of >32 bits.
* Note that we have checked for a negative offset already
*/
assert(plibNewPosition->s.HighPart <= 0);
#endif
plibNewPosition->QuadPart = RtlLargeIntegerAdd( plibNewPosition->QuadPart, dlibMove.QuadPart );
/*
* tell the caller what we calculated
......
......@@ -39,6 +39,7 @@
#endif
#include "winbase.h"
#include "ntddk.h"
#include "wine/winbase16.h" /* for GetCurrentTask */
#include "wine/winestring.h" /* for lstrcpyAtoW */
#include "winerror.h"
......@@ -860,7 +861,6 @@ static int DRIVE_GetFreeSpace( int drive, PULARGE_INTEGER size,
PULARGE_INTEGER available )
{
struct statfs info;
unsigned long long bigsize,bigavail=0;
if (!DRIVE_IsValid(drive))
{
......@@ -880,30 +880,19 @@ static int DRIVE_GetFreeSpace( int drive, PULARGE_INTEGER size,
return 0;
}
bigsize = (unsigned long long)info.f_bsize
* (unsigned long long)info.f_blocks;
size->QuadPart = RtlEnlargedUnsignedMultiply( info.f_bsize, info.f_blocks );
#ifdef STATFS_HAS_BAVAIL
bigavail = (unsigned long long)info.f_bavail
* (unsigned long long)info.f_bsize;
available->QuadPart = RtlEnlargedUnsignedMultiply( info.f_bavail, info.f_bsize );
#else
# ifdef STATFS_HAS_BFREE
bigavail = (unsigned long long)info.f_bfree
* (unsigned long long)info.f_bsize;
available->QuadPart = RtlEnlargedUnsignedMultiply( info.f_bfree, info.f_bsize );
# else
# error "statfs has no bfree/bavail member!"
# endif
#endif
size->s.LowPart = (DWORD)bigsize;
size->s.HighPart = (DWORD)(bigsize>>32);
if (DRIVE_GetType(drive) == TYPE_CDROM)
{ /* ALWAYS 0, even if no real CD-ROM mounted there !! */
available->s.LowPart = 0;
available->s.HighPart = 0;
}
else
{
available->s.LowPart = (DWORD)bigavail;
available->s.HighPart = (DWORD)(bigavail>>32);
available->QuadPart = 0;
}
return 1;
}
......
......@@ -1943,11 +1943,11 @@ BOOL WINAPI SetFileTime( HANDLE hFile,
struct set_file_time_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
if (lpLastAccessTime)
req->access_time = DOSFS_FileTimeToUnixTime(lpLastAccessTime, NULL);
RtlTimeToSecondsSince1970( lpLastAccessTime, (DWORD *)&req->access_time );
else
req->access_time = 0; /* FIXME */
if (lpLastWriteTime)
req->write_time = DOSFS_FileTimeToUnixTime(lpLastWriteTime, NULL);
RtlTimeToSecondsSince1970( lpLastWriteTime, (DWORD *)&req->write_time );
else
req->write_time = 0; /* FIXME */
ret = !server_call( REQ_SET_FILE_TIME );
......
......@@ -754,7 +754,6 @@ VOID WINAPI RtlReleasePebLock(void);
/* mathematics */
LONGLONG WINAPI RtlConvertLongToLargeInteger( LONG a );
LONGLONG WINAPI RtlEnlargedIntegerMultiply( INT a, INT b );
LONGLONG WINAPI RtlEnlargedUnsignedMultiply( UINT a, UINT b );
LONGLONG WINAPI RtlExtendedMagicDivide( LONGLONG a, LONGLONG b, INT shift );
LONGLONG WINAPI RtlExtendedIntegerMultiply( LONGLONG a, INT b );
LONGLONG WINAPI RtlExtendedLargeIntegerDivide( LONGLONG a, INT b, INT *rem );
......@@ -764,6 +763,7 @@ LONGLONG WINAPI RtlLargeIntegerNegate( LONGLONG a );
LONGLONG WINAPI RtlLargeIntegerShiftLeft( LONGLONG a, INT count );
LONGLONG WINAPI RtlLargeIntegerShiftRight( LONGLONG a, INT count );
LONGLONG WINAPI RtlLargeIntegerSubtract( LONGLONG a, LONGLONG b );
ULONGLONG WINAPI RtlEnlargedUnsignedMultiply( UINT a, UINT b );
UINT WINAPI RtlEnlargedUnsignedDivide( ULONGLONG a, UINT b, UINT *remptr );
ULONGLONG WINAPI RtlConvertUlongToLargeInteger( ULONG a );
ULONGLONG WINAPI RtlLargeIntegerDivide( ULONGLONG a, ULONGLONG b, ULONGLONG *rem );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment