Problem with InterlockedOr using XP build environment in W2003 DDK

Hello all,

I can’t believe I’m the first to notice this, (but I looked in the archives
for “InterlockedOr” and didn’t come up with anything pertinent).

I recently came across a problem where my driver (which compiles and works
fine using either the
W2K build environments or the W2003 environments) failed to compile when
using the XP environment.
Actually I got a warning, but I have it set to fail if warnings are
generated.

The problem appears to be caused by the different definitions of
_InterlockedOr.

WINDDK/3790/inc/ddk/wxp/ntddk.h says
LONG
_InterlockedOr (
IN OUT PLONG Target,
IN LONG Set
);

WINDDK/3790/inc/ddk/wnet/ntddk.h says
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

which, incidently, agrees with the documentation.

I “fixed” my XP problem by overriding the definition in one of my own
headers

#if (_WIN32_WINNT==0x0501)
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

#pragma intrinsic (_InterlockedOr)
#endif

Note the XP version of _InterlockedXor is differently broken (it has a “*”
missing)

Is this a “known error” in the DDK?

Don

Don Ward wrote:

The problem appears to be caused by the different definitions of
_InterlockedOr.

WINDDK/3790/inc/ddk/wxp/ntddk.h says
LONG
_InterlockedOr (
IN OUT PLONG Target,
IN LONG Set
);

WINDDK/3790/inc/ddk/wnet/ntddk.h says
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

which, incidently, agrees with the documentation.

OK… I’ll bite. The only difference I see is the use of “volatile”,
and I guess I don’t know why this would cause a compiler error.

Did I guess right at what you’re elluding to??

Can you perhaps be a bit more explicit…

Peter
OSR

FWIW, I have noticed that many interlocked operations in the Win2k headers
do not reference the pertinent argument as volatile in the Win2k headers,
unlike the WinXP headers(I don’t compile for server 2003 that often to
remember its case). The docs of course have pertinent arguments referenced
as volatile. Unless I cast away the volatile (very bad) in Win2k
environment, I cannot get many Win2k interlocked operations to compile. An
alternate (ugly) solution would be to edit the headers for Win2k and include
the volatile keyword.

e.g.

volatile LONG lCount = 0;

InterlockedIncrement(&lCount); // will not compile under Win2k
InterlockedIncrement((PLONG)&lCount); // compiles under Win2k, but not
desirable.

I’m using server 2003 DDK, build 1289. Is there something that I’m missing?

Philip Lukidis

-----Original Message-----
From: Don Ward [mailto:xxxxx@careful.co.uk]
Sent: Tuesday, January 25, 2005 11:58 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem with InterlockedOr using XP build environment
in W2003 DDK

Hello all,

I can’t believe I’m the first to notice this, (but I looked in the archives
for “InterlockedOr” and didn’t come up with anything pertinent).

I recently came across a problem where my driver (which compiles and works
fine using either the
W2K build environments or the W2003 environments) failed to compile when
using the XP environment.
Actually I got a warning, but I have it set to fail if warnings are
generated.

The problem appears to be caused by the different definitions of
_InterlockedOr.

WINDDK/3790/inc/ddk/wxp/ntddk.h says
LONG
_InterlockedOr (
IN OUT PLONG Target,
IN LONG Set
);

WINDDK/3790/inc/ddk/wnet/ntddk.h says
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

which, incidently, agrees with the documentation.

I “fixed” my XP problem by overriding the definition in one of my own
headers

#if (_WIN32_WINNT==0x0501)
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

#pragma intrinsic (_InterlockedOr)
#endif

Note the XP version of _InterlockedXor is differently broken (it has a “*”
missing)

Is this a “known error” in the DDK?

Don


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@guillemot.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Sorry, didn’t mean to be obscure.

My compiler generates the following without my ‘patch’

aspkpd\code\src\kpdioctl.c(536) : error C2220: warning treated as error - no
object file generated
aspkpd\code\src\kpdioctl.c(536) : error C4090: ‘function’ : different
‘volatile’ qualifiers

With my fix in, it’s quiet. Also the DDK docs for InterlockedOr have the
volatile qualifier whereas the XP definition doesn’t. I agree, the fact it
*failed* is my choice, but it still looks as though the definition is wrong
in the XP header files.

Don

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter
Viscarola (OSR)
Sent: 25 January 2005 18:51
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Problem with InterlockedOr using XP build
environment in W2003 DDK

Don Ward wrote:
>
> The problem appears to be caused by the different definitions of
> _InterlockedOr.
>
> WINDDK/3790/inc/ddk/wxp/ntddk.h says
> LONG
> _InterlockedOr (
> IN OUT PLONG Target,
> IN LONG Set
> );
>
> WINDDK/3790/inc/ddk/wnet/ntddk.h says
> LONG
> _InterlockedOr (
> IN OUT LONG volatile *Target,
> IN LONG Set
> );
>
> which, incidently, agrees with the documentation.
>

OK… I’ll bite. The only difference I see is the use of “volatile”,
and I guess I don’t know why this would cause a compiler error.

Did I guess right at what you’re elluding to??

Can you perhaps be a bit more explicit…

Peter
OSR


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

The XP version does not have a ‘*’ missing. “PLONG target” is the same as
“long * target”.

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of Don Ward
Sent: Tuesday, January 25, 2005 11:58 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem with InterlockedOr using XP build environment in
W2003 DDK

Hello all,

I can’t believe I’m the first to notice this, (but I looked in the archives
for “InterlockedOr” and didn’t come up with anything pertinent).

I recently came across a problem where my driver (which compiles and works
fine using either the W2K build environments or the W2003 environments)
failed to compile when using the XP environment.
Actually I got a warning, but I have it set to fail if warnings are
generated.

The problem appears to be caused by the different definitions of
_InterlockedOr.

WINDDK/3790/inc/ddk/wxp/ntddk.h says
LONG
_InterlockedOr (
IN OUT PLONG Target,
IN LONG Set
);

WINDDK/3790/inc/ddk/wnet/ntddk.h says
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

which, incidently, agrees with the documentation.

I “fixed” my XP problem by overriding the definition in one of my own
headers

#if (_WIN32_WINNT==0x0501)
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

#pragma intrinsic (_InterlockedOr)
#endif

Note the XP version of _InterlockedXor is differently broken (it has a “*”
missing)

Is this a “known error” in the DDK?

Don


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@bwandel.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Don Ward wrote:

Sorry, didn’t mean to be obscure.

My compiler generates the following without my ‘patch’

aspkpd\code\src\kpdioctl.c(536) : error C2220: warning treated as error - no
object file generated
aspkpd\code\src\kpdioctl.c(536) : error C4090: ‘function’ : different
‘volatile’ qualifiers

With my fix in, it’s quiet. Also the DDK docs for InterlockedOr have the
volatile qualifier whereas the XP definition doesn’t. I agree, the fact it
*failed* is my choice, but it still looks as though the definition is wrong
in the XP header files.

Yup… Looks to me like you’re onto a legitimate bug. Yuck!

Specifically:


A)

In the Windows Server 2003 PRERELEASE DDK, Server 03 Build Environment,
I see that the definition for _InterlockedOr is:

LONG
InterlockedOr (
IN OUT LONG volatile *Destination,
IN LONG Value
);

This is irrespective of the compiler version, which either satisfies the
defintion with a FORCEINLINE function (older compiler) or an intrinsic
via #pragma intrinsic (newer compiler).

Note that the header file has been significantly restructured, also,
from the XP version.

B)
In the same Windows Server 2003 PRERELEASE DDK, Windows XP Build
Environment, AND in the Windows XP Gold DDK, XP Build Environment, this
same function is declared without the “volatile” decoration:

LONG
_InterlockedOr (
IN OUT PLONG Target,
IN LONG Set
);

Though NOTE that the “volatile” decoration IS THERE for the other
_Interlocked function declarations.


I’ll make sure that the DDK Team folks know about this.

Thanks for taking the time to write… If I hear any sort of resolution,
I’ll let you know via this list.

Peter
OSR

But the volatile keyword is there or not depending on the OS environment
(like InterlockedIncrement in W2k vs Wxp). How does that make sense (OR:
what am I missing)? Isn’t that dangerous (to lack the volatile keyword) if
this operand is periodically polled by thread A, and modified by thread B?

Philip Lukidis

-----Original Message-----
From: Bill Wandel [mailto:xxxxx@bwandel.com]
Sent: Tuesday, January 25, 2005 4:00 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Problem with InterlockedOr using XP build
environment in W2003 DDK

The XP version does not have a ‘*’ missing. “PLONG target” is the same as
“long * target”.

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of Don Ward
Sent: Tuesday, January 25, 2005 11:58 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem with InterlockedOr using XP build environment in
W2003 DDK

Hello all,

I can’t believe I’m the first to notice this, (but I looked in the archives
for “InterlockedOr” and didn’t come up with anything pertinent).

I recently came across a problem where my driver (which compiles and works
fine using either the W2K build environments or the W2003 environments)
failed to compile when using the XP environment.
Actually I got a warning, but I have it set to fail if warnings are
generated.

The problem appears to be caused by the different definitions of
_InterlockedOr.

WINDDK/3790/inc/ddk/wxp/ntddk.h says
LONG
_InterlockedOr (
IN OUT PLONG Target,
IN LONG Set
);

WINDDK/3790/inc/ddk/wnet/ntddk.h says
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

which, incidently, agrees with the documentation.

I “fixed” my XP problem by overriding the definition in one of my own
headers

#if (_WIN32_WINNT==0x0501)
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

#pragma intrinsic (_InterlockedOr)
#endif

Note the XP version of _InterlockedXor is differently broken (it has a “*”
missing)

Is this a “known error” in the DDK?

Don


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@bwandel.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@guillemot.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The lack of a volatile keyword is not “dangerous.” Whether or not the
operand is declared as volatile will have no effect on the calling
function’s code generation. However it’s convenient to declare the
operand as volatile so that should the parameter passed be declared
volatile (not uncommon here) there will be no loss of qualifiers. Other
than that it’s up to you to declare your variables volatile
appropriately.

Chuck

----- Original Message -----
From: “Philip Lukidis”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, January 26, 2005 4:53 AM
Subject: RE: [ntdev] Problem with InterlockedOr using XP build
environment in W2003 DDK

> But the volatile keyword is there or not depending on the OS
> environment
> (like InterlockedIncrement in W2k vs Wxp). How does that make sense
> (OR:
> what am I missing)? Isn’t that dangerous (to lack the volatile
> keyword) if
> this operand is periodically polled by thread A, and modified by
> thread B?
>
> Philip Lukidis
>
> -----Original Message-----
> From: Bill Wandel [mailto:xxxxx@bwandel.com]
> Sent: Tuesday, January 25, 2005 4:00 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] Problem with InterlockedOr using XP build
> environment in W2003 DDK
>
>
> The XP version does not have a ‘*’ missing. “PLONG target” is the same
> as
> “long * target”.
>
> Bill Wandel
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]
> On Behalf Of Don Ward
> Sent: Tuesday, January 25, 2005 11:58 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Problem with InterlockedOr using XP build environment
> in
> W2003 DDK
>
> Hello all,
>
> I can’t believe I’m the first to notice this, (but I looked in the
> archives
> for “InterlockedOr” and didn’t come up with anything pertinent).
>
> I recently came across a problem where my driver (which compiles and
> works
> fine using either the W2K build environments or the W2003
> environments)
> failed to compile when using the XP environment.
> Actually I got a warning, but I have it set to fail if warnings are
> generated.
>
> The problem appears to be caused by the different definitions of
> _InterlockedOr.
>
> WINDDK/3790/inc/ddk/wxp/ntddk.h says
> LONG
> _InterlockedOr (
> IN OUT PLONG Target,
> IN LONG Set
> );
>
> WINDDK/3790/inc/ddk/wnet/ntddk.h says
> LONG
> _InterlockedOr (
> IN OUT LONG volatile *Target,
> IN LONG Set
> );
>
> which, incidently, agrees with the documentation.
>
> I “fixed” my XP problem by overriding the definition in one of my own
> headers
>
> #if (_WIN32_WINNT==0x0501)
> LONG
> _InterlockedOr (
> IN OUT LONG volatile Target,
> IN LONG Set
> );
>
> #pragma intrinsic (_InterlockedOr)
> #endif
>
> Note the XP version of _InterlockedXor is differently broken (it has a
> "
"
> missing)
>
> Is this a “known error” in the DDK?
>
> Don

The missing “*” is not in InterlockedOr. As my original post said, it’s
missing in interlockedXor.
Here is the relevant extract from WINDDK/3790/inc/ddk/wxp/ntddk.h

LONG
_InterlockedXor (
IN OUT LONG volatile Target,
IN LONG Set
);

#pragma intrinsic (_InterlockedXor)

#define InterlockedXor _InterlockedXor

Don

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bill Wandel
Sent: 25 January 2005 21:00
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Problem with InterlockedOr using XP
build environment in W2003 DDK

The XP version does not have a ‘*’ missing. “PLONG target” is
the same as “long * target”.

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]
On Behalf Of Don Ward
Sent: Tuesday, January 25, 2005 11:58 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem with InterlockedOr using XP build
environment in W2003 DDK

Hello all,

I can’t believe I’m the first to notice this, (but I looked
in the archives for “InterlockedOr” and didn’t come up with
anything pertinent).

I recently came across a problem where my driver (which
compiles and works fine using either the W2K build
environments or the W2003 environments) failed to compile
when using the XP environment. Actually I got a warning, but
I have it set to fail if warnings are generated.

The problem appears to be caused by the different definitions
of _InterlockedOr.

WINDDK/3790/inc/ddk/wxp/ntddk.h says
LONG
_InterlockedOr (
IN OUT PLONG Target,
IN LONG Set
);

WINDDK/3790/inc/ddk/wnet/ntddk.h says
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

which, incidently, agrees with the documentation.

I “fixed” my XP problem by overriding the definition in one
of my own headers

#if (_WIN32_WINNT==0x0501)
LONG
_InterlockedOr (
IN OUT LONG volatile *Target,
IN LONG Set
);

#pragma intrinsic (_InterlockedOr)
#endif

Note the XP version of _InterlockedXor is differently broken
(it has a “*”
missing)

Is this a “known error” in the DDK?

Don


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@bwandel.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@careful.co.uk
To unsubscribe send a blank email to xxxxx@lists.osr.com

This appears to be a recurrent issue. I recall a timer function in NT 4’s
ntddk.h didn’t work for exactly this reason.

Jack.

“Don Ward” wrote in message news:xxxxx@ntdev…
> Hello all,
>
> I can’t believe I’m the first to notice this, (but I looked in the
archives
> for “InterlockedOr” and didn’t come up with anything pertinent).
>
> I recently came across a problem where my driver (which compiles and works
> fine using either the
> W2K build environments or the W2003 environments) failed to compile when
> using the XP environment.
> Actually I got a warning, but I have it set to fail if warnings are
> generated.
>
> The problem appears to be caused by the different definitions of
> _InterlockedOr.
>
> WINDDK/3790/inc/ddk/wxp/ntddk.h says
> LONG
> _InterlockedOr (
> IN OUT PLONG Target,
> IN LONG Set
> );
>
> WINDDK/3790/inc/ddk/wnet/ntddk.h says
> LONG
> _InterlockedOr (
> IN OUT LONG volatile *Target,
> IN LONG Set
> );
>
> which, incidently, agrees with the documentation.
>
> I “fixed” my XP problem by overriding the definition in one of my own
> headers
>
> #if (_WIN32_WINNT==0x0501)
> LONG
> _InterlockedOr (
> IN OUT LONG volatile Target,
> IN LONG Set
> );
>
> #pragma intrinsic (_InterlockedOr)
> #endif
>
> Note the XP version of _InterlockedXor is differently broken (it has a "
"
> missing)
>
> Is this a “known error” in the DDK?
>
> Don
>
>

Peter Viscarola (OSR) wrote:

>

Yup… Looks to me like you’re onto a legitimate bug. Yuck!

I’ll make sure that the DDK Team folks know about this.

Thanks for taking the time to write… If I hear any sort of resolution,
I’ll let you know via this list.

To close the loop on this issue: The relevant folks at MS agree that
this is a bug. And you caught it just in time!

Word has it that the bug’s been filed, and the fix is scheduled for the
S03 SP1 DDK.

Thanks again to Don, for raising this problem to the rest of the community.

Peter
OSR