Vitalie Vrabie
2010-11-10 10:17:23 UTC
i need a function that returns a "double" representing the current
timestamp in days since 12/30/1899 (delphi/cbuilder's TDateTime
format) in my NDIS IM driver.
it's a 109205 days difference between the kernel's epoch and the one
of TDateTime.
given that there's no c runtime in a driver (thus no cast from uint64
to double), i come with this routine:
double SysUtilsNow()
{
UINT64 SystemTime, b;
double st, db;
NdisGetCurrentSystemTime((PLARGE_INTEGER)&SystemTime);
SystemTime -= ((UINT64)109205 * (UINT64)86400 * (UINT64)10000000);
// cast SystemTime to "double" in st
st = 0.0;
for (b=1, db=1.0; b!=0; b+=b, db+=db)
{
if ((SystemTime&b) != 0)
{
st += db;
}
}
return st / (86400.0 * 10000000.0);
}
and i get:
error LNK2001: unresolved external symbol __fltused
(same as i got when i tried to simply cast)
any insight where the problem is?
timestamp in days since 12/30/1899 (delphi/cbuilder's TDateTime
format) in my NDIS IM driver.
it's a 109205 days difference between the kernel's epoch and the one
of TDateTime.
given that there's no c runtime in a driver (thus no cast from uint64
to double), i come with this routine:
double SysUtilsNow()
{
UINT64 SystemTime, b;
double st, db;
NdisGetCurrentSystemTime((PLARGE_INTEGER)&SystemTime);
SystemTime -= ((UINT64)109205 * (UINT64)86400 * (UINT64)10000000);
// cast SystemTime to "double" in st
st = 0.0;
for (b=1, db=1.0; b!=0; b+=b, db+=db)
{
if ((SystemTime&b) != 0)
{
st += db;
}
}
return st / (86400.0 * 10000000.0);
}
and i get:
error LNK2001: unresolved external symbol __fltused
(same as i got when i tried to simply cast)
any insight where the problem is?