I am trying to use a “double” data type in kernel driver while collecting time stamps using KeQueryPerformanceCounter.
Basically i am calculating the elapsed time for an activity and convert the elapsed time data into a double. Below is the code.
DOUBLE lfTemp = 0;
ullCurrentTimeStamp = KeQueryPerformanceCounter(NULL);
////KeQueryPerformanceFrequency(
ullElapsedMicroseconds.QuadPart = (ullCurrentTimeStamp.QuadPart) - (pstDeviceContext->stPortTimeLog.ullStartUpTimeStamp.QuadPart);
ullElapsedMicroseconds.QuadPart *= 1000;
lfTemp = (double)(ullElapsedMicroseconds.QuadPart / pstDeviceContext->stPortTimeLog.ullFrequency.QuadPart);
I am seeing the below error:
“timer.obj : error LNK2001: unresolved external symbol __fltused”
I don’t see this symbol “__fltused” anywhere in the code.
From a couple of suggestions i found googling for this issue, i tried changing the option of “Ignore all default libraries” in “Linker” tab in the project properties to “No”. But that gave another error.
“LIBCMT.lib(fpinit.obj) : warning LNK4257: object file was not compiled for kernel mode; the image might not run”
I tried addding /kernal option in the “command line options” filed in project properties -> c/c++ sections but it didn’t help.
is there any other additional step that i need to take while using floating data types in kernel mode?
From a couple of articles i found on internet, they suggested not to use double data type at all in kernel mode. But i do need to use it for my requirement.
Don’t use floating point. Why do you think you need it?
d
Bent from my phone
From: xxxxx@gmail.commailto:xxxxx
Sent: ?12/?4/?2014 8:23 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: [ntdev] Getting linking error while Using DOUBLE data type in kernel mode
I am trying to use a “double” data type in kernel driver while collecting time stamps using KeQueryPerformanceCounter.
Basically i am calculating the elapsed time for an activity and convert the elapsed time data into a double. Below is the code.
DOUBLE lfTemp = 0;
ullCurrentTimeStamp = KeQueryPerformanceCounter(NULL);
////KeQueryPerformanceFrequency(
ullElapsedMicroseconds.QuadPart = (ullCurrentTimeStamp.QuadPart) - (pstDeviceContext->stPortTimeLog.ullStartUpTimeStamp.QuadPart);
ullElapsedMicroseconds.QuadPart *= 1000;
lfTemp = (double)(ullElapsedMicroseconds.QuadPart / pstDeviceContext->stPortTimeLog.ullFrequency.QuadPart);
I am seeing the below error:
“timer.obj : error LNK2001: unresolved external symbol fltused"
I don’t see this symbol " fltused” anywhere in the code.
From a couple of suggestions i found googling for this issue, i tried changing the option of “Ignore all default libraries” in “Linker” tab in the project properties to “No”. But that gave another error.
“LIBCMT.lib(fpinit.obj) : warning LNK4257: object file was not compiled for kernel mode; the image might not run”
I tried addding /kernal option in the “command line options” filed in project properties -> c/c++ sections but it didn’t help.
is there any other additional step that i need to take while using floating data types in kernel mode?
From a couple of articles i found on internet, they suggested not to use double data type at all in kernel mode. But i do need to use it for my requirement.
—
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>
You’re not doing float point calculations anyway (just storing it as FP). Why not just use 64 bit integer?
On Dec 4, 2014, at 8:23 AM, xxxxx@gmail.com wrote:
I am trying to use a “double” data type in kernel driver while collecting time stamps using KeQueryPerformanceCounter.
The problem with floating point in kernel code is that the floating point registers are not saved and restored in all circumstances. You can use KeSaveFloatingPointState and KeRestoreFloatingPointState to manage that yourself, but it’s a rather expensive operation.
Basically i am calculating the elapsed time for an activity and convert the elapsed time data into a double. Below is the code.
DOUBLE lfTemp = 0;
ullCurrentTimeStamp = KeQueryPerformanceCounter(NULL);
////KeQueryPerformanceFrequency(
ullElapsedMicroseconds.QuadPart = (ullCurrentTimeStamp.QuadPart) - (pstDeviceContext->stPortTimeLog.ullStartUpTimeStamp.QuadPart);
ullElapsedMicroseconds.QuadPart *= 1000;
Those aren’t microseconds. That’s in units of 100 nanoseconds.
lfTemp = (double)(ullElapsedMicroseconds.QuadPart / pstDeviceContext->stPortTimeLog.ullFrequency.QuadPart);
As was pointed out, you are actually doing integer division here, and then casting the result to a double. You might as well just store it as an integer. The result you get will be in milliseconds, since you multiplied the elapsed count by 1000.
I am seeing the below error:
“timer.obj : error LNK2001: unresolved external symbol __fltused”
I don’t see this symbol “__fltused” anywhere in the code.
No. The compiler automatically inserts a reference to that symbol in any object file that uses floating point, specifically to allow things like this to be caught.
From a couple of articles i found on internet, they suggested not to use double data type at all in kernel mode. But i do need to use it for my requirement.
No, you don’t.
—
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.