[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-smartcardddk
Subject:    Re: NT, 9X: LARGE_INTEGER's mystery
From:       Vladimir Beker <bwz () ARX ! COM>
Date:       1999-10-27 17:25:07
[Download RAW message or body]


Hello, Klaus

Please, find the compilation options below. Note that I don't play with
them, just use BUILD utility as is.
I work with VC++ 5.0

The check build (produces the correct result):
cl -nologo -Ii386\ -I. -Id:\ddk98\inc -Id:\ddk98\src\smartcrd\inc
-Id:\ddk98\inc\win98 -Id:\ddk98\inc\win98 -Id:\ddk98\inc\win98 -D_X86_=1
-Di386=1  -DSTD_CALL -DCONDITION_HANDLING=1 -DNT_UP=1  -DNT_INST=0
-DWIN32=100 -D_NT1X_=100 -DWINNT=1 -D_WIN32_WINNT=0x0400
-DWIN32_LEAN_AND_MEAN=1 -DDBG=1 -DDEVL=1 -DFPO=0    -DNDEBUG -D_DLL=1
-DDRIVER    /c /Zel /Zp8 /Gy -cbstring /W3 /Gz  /QIfdiv- /QIf  /Gi- /Gm-
/GX- /GR- /GF  -Z7 /Od /Oi /Oy-   -FId:\ddk98\inc\win98\warning.h
.\port98.c

The free build (that one that fails):
cl -nologo -Ii386\ -I. -Id:\ddk98\inc -Id:\ddk98\src\smartcrd\inc
-Id:\ddk98\inc\win98 -Id:\ddk98\inc\win98 -Id:\ddk98\inc\win98 -D_X86_=1
-Di386=1  -DSTD_CALL -DCONDITION_HANDLING=1 -DNT_UP=1  -DNT_INST=0
-DWIN32=100 -D_NT1X_=100 -DWINNT=1 -D_WIN32_WINNT=0x0400
-DWIN32_LEAN_AND_MEAN=1 -DDEVL=1 -DFPO=1    -DNDEBUG -D_DLL=1 -DDRIVER    /c
/Zel /Zp8 /Gy -cbstring /W3 /Gz  /QIfdiv- /QIf  /Gi- /Gm- /GX- /GR- /GF
/Oxs /Oy   -FId:\ddk98\inc\win98\warning.h  .\port98.c

Vladimir Beker
Project Leader
Algorithmic Research Ltd
[mailto:bwz@arx.com]
http://www.arx.com
Tel. +972-3-9279519
Fax. +972-3-9230864


-----Original Message-----
From: Klaus Schutz (Exchange) [mailto:kschutz@EXCHANGE.MICROSOFT.COM]
Sent: Wednesday, October 27, 1999 7:17 PM
To: SmartCardDDK@DISCUSS.MICROSOFT.COM
Subject: Re: NT, 9X: LARGE_INTEGER's mystery


Vladimir,

so, you're getting different code when you do a checked compile versus a
free compile, but your source code is the same?
What are the compiler options used in your checked and free environment?

Klaus U Schutz
Microsoft

-----Original Message-----
From: Vladimir Beker [mailto:bwz@ARX.COM]
Sent: Tuesday, October 26, 1999 9:41 AM
To: SmartCardDDK@DISCUSS.MICROSOFT.COM
Subject: Re: NT, 9X: LARGE_INTEGER's mystery


Sorry, change it to

a.QuadPart = - (LONG)(10000 * x);

To get into details, the entire code looks as follows:
(all fields belong to the same structure)

some_struct->Timeout.QuadPart = - (LONG) (10 * 10000 *
some_struct->TimeoutInMs);
switch (some_struct->some_other_field) {
..
}

The assembler in my case looks like (free build):

mov   EAX, [ESI+0ACH] ; contains TimeoutInMs
mov   ECX, [ESI+0a4H]; contains some_other_field used in switch
imul EAX,EAX,0FFFFD8F0; EAX now 0FA0A1F00, EBX = 0
mov EDX, ECX ; belongs to switch
mov [ESI+148H], EAX; stores the low part of Timeout, which is right
dec EDX ; belongs to switch
mov [ESI + 14CH], EBX ; stores the high part of Timeout. OOPS, IT IS ZERO
jz xxx; belongs to switch - the rest of code is not relevant

As you can see, CDQ does not appear here.

According to C-rules, it seems to be incorrect, since there is no ambiguty
in type conversion rules
(which is wrong, for instance for >> operator).
I have no prblem to work around this bug and write more reliable code (I
did). The point is bug in compiler, not the possibility
to find better way to write code

I use VC++ 5.0.

Vladimir Beker
Project Leader
Algorithmic Research Ltd
[mailto:bwz@arx.com]
http://www.arx.com
Tel. +972-3-9279519
Fax. +972-3-9230864


-----Original Message-----
From: Doug Barlow (Exchange) [mailto:dbarlow@MICROSOFT.COM]
Sent: Tuesday, October 26, 1999 6:36 PM
To: SmartCardDDK@DISCUSS.MICROSOFT.COM
Subject: Re: NT, 9X: LARGE_INTEGER's mystery


What compiler are you using?  I just get errors claiming "Incompatible
Types".

Doug Barlow
Microsoft Corporation

-----Original Message-----
From: Vladimir Beker [mailto:bwz@ARX.COM]
Sent: Tuesday, October 26, 1999 5:52 AM
To: SmartCardDDK@DISCUSS.MICROSOFT.COM
Subject: NT, 9X: LARGE_INTEGER's mystery

Hello, all

I think I found nice bug in Microsoft code:

How, in your opinion, should work the following code:

ULONG x = 10000;
LARGE_INTEGER a;
a = - (LONG)(10000 * x);

Let's not discuss how good is this code. The question is: whether the higher
ULONG of
'a' is filled with zeros or with ones.
When I wrote this code, I wanted ones. Maybe I was wrong - it is a point for
other
discussion.
The interesting point is, however, that it is filled by ones when I do the
Checked Build of
the driver, and with zeros in the case of Free Build

Any comments?
Thanks

Vladimir Beker
Project Leader
Algorithmic Research Ltd
[mailto:bwz@arx.com]
http://www.arx.com
Tel. +972-3-9279519
Fax. +972-3-9230864

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic