• R/O
  • HTTP
  • SSH
  • HTTPS

mingw-org-wsl: Commit

The MinGW.OSDN Windows System Libraries. Formerly designated as "MinGW.org Windows System Libraries", this encapsulates the "mingwrt" C runtime library extensions, and the "w32api" 32-bit MS-Windows API libraries.

Please note that this project no longer owns the "MinGW.org" domain name; any software which may be distributed from that domain is NOT supported by this project.


Commit MetaInfo

Revisione6a7d2485cad66c3daaf9c91e8b4d87c9210b2e0 (tree)
Time2022-11-02 23:46:12
AuthorKeith Marshall <keith@user...>
CommiterKeith Marshall

Log Message

Clean up interlocked memory access API declarations.

Change Summary

Incremental Difference

--- a/w32api/ChangeLog
+++ b/w32api/ChangeLog
@@ -1,3 +1,70 @@
1+2022-11-02 Keith Marshall <keith@users.osdn.me>
2+
3+ Clean up interlocked memory access API declarations.
4+
5+ * include/ddk/ntddk.h [_DDK_NTDDK_H]: Always defined, implying...
6+ [__USE_NTOSKRNL__]: ...this, never defined elsewhere, and always true
7+ when defined here; hence, macro is redundant; delete its definition,
8+ together with its enclosing (redundant) repeat definition guard.
9+
10+ * include/winbase.h include/ddk/winddk.h
11+ [__USE_NTOSKRNL__, __INTERLOCKED_DECLARED]: Delete references.
12+ (InterlockedDecrement, InterlockedIncrement, InterlockedExchange)
13+ (InterlockedCompareExchange, InterlockedCompareExchangePointer)
14+ (InterlockedExchangePointer, InterlockedExchangeAdd): Factor out;
15+ relocate declarations, and implementations as appropriate, to...
16+ * include/winnt.h: ...here, per Microsoft's current documentation.
17+ (__kernel_api): New local macro; define it conditionally...
18+ [_DDK_NTDDK_H defined]: ...to match DDKFASTAPI usage, else...
19+ [_DDK_NTDDK_H ! defined]: ...to match WINAPI usage.
20+
21+ * include/winbase.h (InterlockedPushEntrySList)
22+ (InterlockedPopEntrySlist): Declare them, only if...
23+ [_DDK_WINDDK_H ! defined]: ...not previously declared...
24+ * include/ddk/winddk.h: ...thence.
25+
26+ * include/winnt.h (_WIN32_INTRINSIC): New macro; define, and...
27+ (InterlockedCompareExchangePointer, InterlockedExchangePointer):
28+ ...use it.
29+
30+ * include/ddk/winddk.h (InterlockedPushEntrySList)
31+ (InterlockedPopEntrySlist): Declare them, only if...
32+ [_WINBASE_H ! defined]: ...not previously declared...
33+ * include/winbase.h: ...thence.
34+
35+ * include/ddk/winddk.h (FILE_LIST_DIRECTORY, FILE_READ_DATA)
36+ (FILE_ADD_FILE, FILE_WRITE_DATA, FILE_ADD_SUBDIRECTORY)
37+ (FILE_APPEND_DATA, FILE_CREATE_PIPE_INSTANCE, FILE_READ_EA)
38+ (FILE_WRITE_EA, FILE_EXECUTE, FILE_TRAVERSE, FILE_DELETE_CHILD)
39+ (FILE_READ_ATTRIBUTES, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ)
40+ (FILE_SHARE_WRITE, FILE_SHARE_DELETE, FILE_SHARE_VALID_FLAGS)
41+ (FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_HIDDEN)
42+ (FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_DIRECTORY)
43+ (FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_DEVICE, FILE_ATTRIBUTE_NORMAL)
44+ (FILE_ATTRIBUTE_TEMPORARY, FILE_ATTRIBUTE_SPARSE_FILE)
45+ (FILE_ATTRIBUTE_REPARSE_POINT, FILE_ATTRIBUTE_COMPRESSED)
46+ (FILE_ATTRIBUTE_OFFLINE, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)
47+ (FILE_ATTRIBUTE_ENCRYPTED, FILE_ATTRIBUTE_VIRTUAL)
48+ (FILE_ATTRIBUTE_VALID_FLAGS, FILE_ATTRIBUTE_VALID_SET_FLAGS)
49+ (FILE_COPY_STRUCTURED_STORAGE, FILE_STRUCTURED_STORAGE)
50+ (FILE_VALID_OPTION_FLAGS, FILE_VALID_PIPE_OPTION_FLAGS)
51+ (FILE_VALID_MAILSLOT_OPTION_FLAGS, FILE_VALID_SET_FLAGS)
52+ (FILE_SUPERSEDE, FILE_OPEN, FILE_CREATE, FILE_OPEN_IF, FILE_OVERWRITE)
53+ (FILE_OVERWRITE_IF, FILE_MAXIMUM_DISPOSITION, FILE_DIRECTORY_FILE)
54+ (FILE_WRITE_THROUGH, FILE_SEQUENTIAL_ONLY)
55+ (FILE_NO_INTERMEDIATE_BUFFERING, FILE_SYNCHRONOUS_IO_ALERT)
56+ (FILE_SYNCHRONOUS_IO_NONALERT, FILE_NON_DIRECTORY_FILE)
57+ (FILE_CREATE_TREE_CONNECTION, FILE_COMPLETE_IF_OPLOCKED)
58+ (FILE_NO_EA_KNOWLEDGE, FILE_OPEN_FOR_RECOVERY, FILE_RANDOM_ACCESS)
59+ (FILE_DELETE_ON_CLOSE, FILE_OPEN_BY_FILE_ID)
60+ (FILE_OPEN_FOR_BACKUP_INTENT, FILE_NO_COMPRESSION)
61+ (FILE_RESERVE_OPFILTER, FILE_OPEN_REPARSE_POINT, FILE_OPEN_NO_RECALL)
62+ (FILE_OPEN_FOR_FREE_SPACE_QUERY, FILE_ALL_ACCESS)
63+ (FILE_GENERIC_EXECUTE, FILE_GENERIC_READ, FILE_GENERIC_WRITE)
64+ (DUPLICATE_CLOSE_SOURCE, DUPLICATE_SAME_ACCESS)
65+ (DUPLICATE_SAME_ATTRIBUTES): Delete redundant definitions; all are...
66+ * include/winnt.h: ...already defined thence.
67+
168 2022-10-15 Keith Marshall <keith@users.osdn.me>
269
370 Do not define public symbols in <wspiapi.h>
--- a/w32api/include/ddk/ntddk.h
+++ b/w32api/include/ddk/ntddk.h
@@ -5,7 +5,6 @@
55 * DBG - Debugging enabled/disabled (0/1)
66 * POOL_TAGGING - Enable pool tagging
77 * _X86_ - X86 environment
8- * __USE_NTOSKRNL__ - Use ntoskrnl.exe instead of kernel32.dll
98 *
109 * $Id$
1110 *
@@ -34,12 +33,8 @@
3433 *
3534 */
3635 #ifndef _DDK_NTDDK_H
37-#define _DDK_NTDDK_H
3836 #pragma GCC system_header
39-
40-#ifndef __USE_NTOSKRNL__
41-#define __USE_NTOSKRNL__ 1
42-#endif
37+#define _DDK_NTDDK_H
4338
4439 #include <stdarg.h>
4540 #include <windef.h>
--- a/w32api/include/ddk/winddk.h
+++ b/w32api/include/ddk/winddk.h
@@ -360,100 +360,6 @@ typedef struct _DRIVE_LAYOUT_INFORMATION_EX *PDRIVE_LAYOUT_INFORMATION_EX;
360360 #define FILE_EXISTS 0x00000004
361361 #define FILE_DOES_NOT_EXIST 0x00000005
362362
363-#if 1
364-/* FIXME: also in winnt.h; hence, already defined?
365- */
366-#define FILE_LIST_DIRECTORY 0x00000001
367-#define FILE_READ_DATA 0x00000001
368-#define FILE_ADD_FILE 0x00000002
369-#define FILE_WRITE_DATA 0x00000002
370-#define FILE_ADD_SUBDIRECTORY 0x00000004
371-#define FILE_APPEND_DATA 0x00000004
372-#define FILE_CREATE_PIPE_INSTANCE 0x00000004
373-#define FILE_READ_EA 0x00000008
374-#define FILE_WRITE_EA 0x00000010
375-#define FILE_EXECUTE 0x00000020
376-#define FILE_TRAVERSE 0x00000020
377-#define FILE_DELETE_CHILD 0x00000040
378-#define FILE_READ_ATTRIBUTES 0x00000080
379-#define FILE_WRITE_ATTRIBUTES 0x00000100
380-
381-#define FILE_SHARE_READ 0x00000001
382-#define FILE_SHARE_WRITE 0x00000002
383-#define FILE_SHARE_DELETE 0x00000004
384-#define FILE_SHARE_VALID_FLAGS 0x00000007
385-
386-#define FILE_ATTRIBUTE_READONLY 0x00000001
387-#define FILE_ATTRIBUTE_HIDDEN 0x00000002
388-#define FILE_ATTRIBUTE_SYSTEM 0x00000004
389-#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
390-#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
391-#define FILE_ATTRIBUTE_DEVICE 0x00000040
392-#define FILE_ATTRIBUTE_NORMAL 0x00000080
393-#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
394-#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
395-#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
396-#define FILE_ATTRIBUTE_COMPRESSED 0x00000800
397-#define FILE_ATTRIBUTE_OFFLINE 0x00001000
398-#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
399-#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
400-#define FILE_ATTRIBUTE_VIRTUAL 0x00010000
401-
402-#define FILE_ATTRIBUTE_VALID_FLAGS 0x00017fb7
403-#define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7
404-
405-#define FILE_COPY_STRUCTURED_STORAGE 0x00000041
406-#define FILE_STRUCTURED_STORAGE 0x00000441
407-
408-#define FILE_VALID_OPTION_FLAGS 0x00ffffff
409-#define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
410-#define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
411-#define FILE_VALID_SET_FLAGS 0x00000036
412-
413-#define FILE_SUPERSEDE 0x00000000
414-#define FILE_OPEN 0x00000001
415-#define FILE_CREATE 0x00000002
416-#define FILE_OPEN_IF 0x00000003
417-#define FILE_OVERWRITE 0x00000004
418-#define FILE_OVERWRITE_IF 0x00000005
419-#define FILE_MAXIMUM_DISPOSITION 0x00000005
420-
421-#define FILE_DIRECTORY_FILE 0x00000001
422-#define FILE_WRITE_THROUGH 0x00000002
423-#define FILE_SEQUENTIAL_ONLY 0x00000004
424-#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
425-#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
426-#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
427-#define FILE_NON_DIRECTORY_FILE 0x00000040
428-#define FILE_CREATE_TREE_CONNECTION 0x00000080
429-#define FILE_COMPLETE_IF_OPLOCKED 0x00000100
430-#define FILE_NO_EA_KNOWLEDGE 0x00000200
431-#define FILE_OPEN_FOR_RECOVERY 0x00000400
432-#define FILE_RANDOM_ACCESS 0x00000800
433-#define FILE_DELETE_ON_CLOSE 0x00001000
434-#define FILE_OPEN_BY_FILE_ID 0x00002000
435-#define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
436-#define FILE_NO_COMPRESSION 0x00008000
437-#define FILE_RESERVE_OPFILTER 0x00100000
438-#define FILE_OPEN_REPARSE_POINT 0x00200000
439-#define FILE_OPEN_NO_RECALL 0x00400000
440-#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
441-
442-#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
443-
444-#define FILE_GENERIC_EXECUTE \
445- (STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE)
446-
447-#define FILE_GENERIC_READ \
448- (STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES \
449- | FILE_READ_EA | SYNCHRONIZE)
450-
451-#define FILE_GENERIC_WRITE \
452- (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES \
453- | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE)
454-
455-#endif /* winnt.h */
456-
457363 #define DIRECTORY_QUERY (0x0001)
458364 #define DIRECTORY_TRAVERSE (0x0002)
459365 #define DIRECTORY_CREATE_OBJECT (0x0004)
@@ -946,15 +852,6 @@ typedef VOID DDKAPI
946852 #define SYMBOLIC_LINK_QUERY 0x0001
947853 #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
948854
949-#if 1
950-/* FIXME: also in winnt.h; hence already defined?
951- */
952-#define DUPLICATE_CLOSE_SOURCE 0x00000001
953-#define DUPLICATE_SAME_ACCESS 0x00000002
954-#define DUPLICATE_SAME_ATTRIBUTES 0x00000004
955-
956-#endif /* winnt.h */
957-
958855 typedef
959856 struct _OBJECT_NAME_INFORMATION
960857 { UNICODE_STRING Name;
@@ -4062,56 +3959,38 @@ KeGetCurrentIrql( VOID );
40623959 ((ULONG)KeGetCurrentKPCR()->Number)
40633960
40643961
4065-#if __USE_NTOSKRNL__
4066-/* CAREFUL: These are exported from ntoskrnl.exe as __fastcall functions,
4067- but are also exported from kernel32.dll and declared in winbase.h as
4068- __stdcall */
4069-#if !defined(__INTERLOCKED_DECLARED)
4070-#define __INTERLOCKED_DECLARED
4071-
4072-NTOSAPI LONG DDKFASTAPI
4073-InterlockedIncrement( /*IN*/ LONG VOLATILE *Addend );
4074-
4075-NTOSAPI LONG DDKFASTAPI
4076-InterlockedDecrement( /*IN*/ LONG VOLATILE *Addend );
4077-
4078-NTOSAPI LONG DDKFASTAPI
4079-InterlockedCompareExchange(
4080- /*IN OUT*/ PLONG VOLATILE Destination,
4081- /*IN*/ LONG Exchange,
4082- /*IN*/ LONG Comparand
4083-);
4084-
4085-NTOSAPI LONG DDKFASTAPI
4086-InterlockedExchange(
4087- /*IN OUT*/ PLONG VOLATILE Target,
4088- /*IN*/ LONG Value
4089-);
4090-
4091-NTOSAPI LONG DDKFASTAPI
4092-InterlockedExchangeAdd(
4093- /*IN OUT*/ PLONG VOLATILE Addend,
4094- /*IN*/ LONG Value
4095-);
4096-
4097-/* PVOID
4098- * InterlockedExchangePointer(
4099- * IN OUT PVOID VOLATILE *Target,
4100- * IN PVOID Value)
3962+/* Formerly declared here, on the assumption that we are building
3963+ * a Windows device driver, and thus exported by ntoskrnl.exe, with
3964+ * __fastcall calling convention, (as opposed to exports of the same
3965+ * functions from kernel32.dll, whence the __stdcall convention is
3966+ * applicable), the following:
3967+ *
3968+ * long InterlockedDecrement (long volatile *);
3969+ * long InterlockedIncrement (long volatile *);
3970+ *
3971+ * long InterlockedExchange (long volatile *, long);
3972+ * long InterlockedCompareExchange (long volatile *, long, long);
3973+ * long InterlockedExchangeAdd (long volatile *, long);
3974+ *
3975+ * together with intrinsic implementations of:
3976+ *
3977+ * void *InterlockedCompareExchangePointer (void *volatile *, void *, void *);
3978+ * void *InterlockedExchangePointer (void *volatile *, void *);
3979+ *
3980+ * are now declared in <winnt.h>, which is guaranteed to have been
3981+ * included already, with logic to determine the appropriate calling
3982+ * convention; thus, we may simply adopt the appropriately qualified
3983+ * <winnt.h> declarations, without repetition here.
3984+ *
3985+ * Similarly, (but without the guarantee of prior inclusion),
3986+ * introduced by WinXP...
41013987 */
4102-#define InterlockedExchangePointer(Target, Value) \
4103- ((PVOID) InterlockedExchange((PLONG) Target, (LONG) Value))
4104-
4105-/* PVOID InterlockedCompareExchangePointer(
4106- * IN OUT PVOID *Destination,
4107- * IN PVOID Exchange,
4108- * IN PVOID Comparand
4109- * )
3988+#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP) && ! defined _WINBASE_H
3989+/* ...the following MAY have been declared already, if <winbase.h>
3990+ * has been included before we get to here; if it has, we simply adopt
3991+ * its declarations, but if it has not, we provide declarations here,
3992+ * (assuming use of the __fastcall exports from ntoskrnl.exe).
41103993 */
4111-#define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) \
4112- ((PVOID) InterlockedCompareExchange((PLONG) Destination, (LONG) Exchange, (LONG) Comparand))
4113-
4114-#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
41153994 PSLIST_ENTRY DDKFASTAPI
41163995 InterlockedPopEntrySList( /*IN*/ PSLIST_HEADER ListHead );
41173996
@@ -4120,10 +3999,7 @@ InterlockedPushEntrySList(
41203999 /*IN*/ PSLIST_HEADER ListHead,
41214000 /*IN*/ PSLIST_ENTRY ListEntry
41224001 );
4123-#endif /* _WIN32_WINNT >= _WIN32_WINNT_WINXP */
4124-
4125-#endif /* !__INTERLOCKED_DECLARED */
4126-#endif /* __USE_NTOSKRNL__ */
4002+#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WINXP) && !_WINBASE_H */
41274003
41284004 NTOSAPI VOID DDKFASTAPI
41294005 KefAcquireSpinLockAtDpcLevel( /*IN*/ PKSPIN_LOCK SpinLock );
@@ -4138,7 +4014,7 @@ KefReleaseSpinLockFromDpcLevel( /*IN*/ PKSPIN_LOCK SpinLock );
41384014
41394015 #define KeGetDcacheFillSize() 1L
41404016
4141-#endif /* _X86_ */
4017+#endif /* _X86_ */
41424018
41434019 /* Utility functions
41444020 */
@@ -4218,7 +4094,7 @@ RtlAssert(
42184094 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
42194095 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
42204096
4221-#else /* !DBG */
4097+#else /* !DBG */
42224098
42234099 #define ASSERT(exp) ((VOID) 0)
42244100 #define ASSERTMSG(msg, exp) ((VOID) 0)
@@ -4232,7 +4108,7 @@ RtlAssert(
42324108 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
42334109 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
42344110
4235-#endif /* DBG */
4111+#endif /* DBG */
42364112
42374113
42384114 /* Driver support routines
@@ -5072,13 +4948,13 @@ ExInterlockedPushEntrySList(
50724948 /*IN*/ PKSPIN_LOCK Lock
50734949 );
50744950
5075-#if (__USE_NTOSKRNL__) && (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
4951+#if _WIN32_WINNT >= _WIN32_WINNT_WINXP
50764952 #define ExInterlockedPopEntrySList(_ListHead, _Lock) \
50774953 InterlockedPopEntrySList(_ListHead)
50784954
50794955 #define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \
50804956 InterlockedPushEntrySList(_ListHead, _ListEntry)
5081-#endif /* __USE_NTOSKRNL__ */
4957+#endif /* _WIN32_WINNT >= _WIN32_WINNT_WINXP */
50824958
50834959 #define ExQueryDepthSList(ListHead) QueryDepthSList(ListHead)
50844960
@@ -5113,7 +4989,7 @@ ExFreeToNPagedLookasideList(
51134989 }
51144990 }
51154991
5116-#if (__USE_NTOSKRNL__) && (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
4992+#if _WIN32_WINNT >= _WIN32_WINNT_WINXP
51174993
51184994 static __inline__ PVOID
51194995 ExAllocateFromPagedLookasideList(
@@ -5145,7 +5021,7 @@ ExFreeToPagedLookasideList(
51455021 }
51465022 }
51475023
5148-#else /* (__USE_NTOSKRNL__) && (_WIN32_WINNT >= _WIN32_WINNT_WINXP) */
5024+#else /* _WIN32_WINNT >= _WIN32_WINNT_WINXP */
51495025
51505026 NTOSAPI PVOID DDKAPI
51515027 ExAllocateFromPagedLookasideList( /*IN*/ PPAGED_LOOKASIDE_LIST Lookaside );
@@ -5156,7 +5032,7 @@ ExFreeToPagedLookasideList(
51565032 /*IN*/ PVOID Entry
51575033 );
51585034
5159-#endif /* (__USE_NTOSKRNL__) && (_WIN32_WINNT >= _WIN32_WINNT_WINXP) */
5035+#endif /* _WIN32_WINNT >= _WIN32_WINNT_WINXP */
51605036
51615037 NTOSAPI PVOID DDKAPI
51625038 ExAllocatePoolWithQuotaTag(
@@ -5177,7 +5053,7 @@ ExAllocatePoolWithTag(
51775053 #define ExAllocatePoolWithQuota(p,n) ExAllocatePoolWithQuotaTag(p,n,' kdD')
51785054 #define ExAllocatePool(p,n) ExAllocatePoolWithTag(p,n,' kdD')
51795055
5180-#else /* !POOL_TAGGING */
5056+#else /* !POOL_TAGGING */
51815057
51825058 NTOSAPI PVOID DDKAPI
51835059 ExAllocatePool( /*IN*/ POOL_TYPE PoolType, /*IN*/ SIZE_T NumberOfBytes );
@@ -5185,7 +5061,7 @@ ExAllocatePool( /*IN*/ POOL_TYPE PoolType, /*IN*/ SIZE_T NumberOfBytes );
51855061 NTOSAPI PVOID DDKAPI
51865062 ExAllocatePoolWithQuota( /*IN*/ POOL_TYPE PoolType, /*IN*/ SIZE_T NumberOfBytes );
51875063
5188-#endif /* POOL_TAGGING */
5064+#endif /* POOL_TAGGING */
51895065
51905066 NTOSAPI PVOID DDKAPI
51915067 ExAllocatePoolWithTagPriority(
@@ -8328,14 +8204,14 @@ DbgSetDebugFilterState(
83288204 #define KdBreakPoint() DbgBreakPoint()
83298205 #define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s)
83308206
8331-#else /* !DBG */
8207+#else /* !DBG */
83328208
83338209 #define KdPrint(_x_)
83348210 #define KdPrintEx(_x_)
83358211 #define KdBreakPoint()
83368212 #define KdBreakPointWithStatus(s)
83378213
8338-#endif /* !DBG */
8214+#endif /* !DBG */
83398215
83408216 extern NTOSAPI PBOOLEAN KdDebuggerNotPresent;
83418217 extern NTOSAPI PBOOLEAN KdDebuggerEnabled;
--- a/w32api/include/winbase.h
+++ b/w32api/include/winbase.h
@@ -2099,41 +2099,52 @@ WINBASEAPI BOOL WINAPI InitializeSecurityDescriptor
20992099 (PSECURITY_DESCRIPTOR, DWORD);
21002100 WINBASEAPI BOOL WINAPI InitializeSid (PSID, PSID_IDENTIFIER_AUTHORITY, BYTE);
21012101
2102-#if !(__USE_NTOSKRNL__)
2103-/* CAREFUL: These are exported from ntoskrnl.exe and declared in winddk.h
2104- as __fastcall functions, but are exported from kernel32.dll as __stdcall */
2105-#if (_WIN32_WINNT >= 0x0501)
2102+/* Formerly declared here, but now documented by Microsoft as being
2103+ * declared in <winnt.h>, (which has been automatically included by
2104+ * the time we get here), declarations of the following interlocked
2105+ * memory access functions:
2106+ *
2107+ * long InterlockedDecrement (long volatile *);
2108+ * long InterlockedIncrement (long volatile *);
2109+ *
2110+ * long InterlockedExchange (long volatile *, long);
2111+ * long InterlockedCompareExchange (long volatile *, long, long);
2112+ * long InterlockedExchangeAdd (long volatile *, long);
2113+ *
2114+ * together with the associated intrinsic implementations of:
2115+ *
2116+ * void *InterlockedCompareExchangePointer (void *volatile *, void *, void *);
2117+ * void *InterlockedExchangePointer (void *volatile *, void *);
2118+ *
2119+ * have been relocated accordingly.
2120+ */
2121+#if _WIN32_WINNT >= _WIN32_WINNT_WINXP
2122+/* FIXME: Microsoft's current documentation says that the following
2123+ * should be declared in <interlockedapi.h>, (which MinGW.OSDN doesn't
2124+ * provide at present); leave them here for the time being, but maybe
2125+ * consider a future relocation.
2126+ */
21062127 WINBASEAPI VOID WINAPI InitializeSListHead (PSLIST_HEADER);
2107-#endif
2128+WINBASEAPI PSLIST_ENTRY WINAPI InterlockedFlushSList (PSLIST_HEADER);
21082129
2109-#ifndef __INTERLOCKED_DECLARED
2110-/* FIXME: Is this another invitation for inconsistent definition?
2111- * Where else is this declared?
2130+#ifndef _DDK_WINDDK_H
2131+/*
2132+ * ** CAUTION **
2133+ *
2134+ * This pair is exported by both ntoskrnl.exe and kernel32.exe, but with
2135+ * incompatible calling conventions; intent to link with ntoskrnl.exe may
2136+ * have been indicated already, by prior inclusion of <ddk/winddk.h>, in
2137+ * which case these will have been declared already, with the appropriate
2138+ * __fastcall semantics, but if not, declare them here, with the choice
2139+ * between __stdcall and __fastcall determined appropriately by prior
2140+ * definition of __kernel_api, inherited from <winnt.h>, (which has
2141+ * been included previously).
21122142 */
2113-#define __INTERLOCKED_DECLARED
2114-LONG WINAPI InterlockedCompareExchange (LONG volatile *, LONG, LONG);
2115-/* PVOID WINAPI InterlockedCompareExchangePointer (PVOID *, PVOID, PVOID); */
2116-#define InterlockedCompareExchangePointer(d, e, c) \
2117- (PVOID)InterlockedCompareExchange((LONG volatile *)(d),(LONG)(e),(LONG)(c))
2118-LONG WINAPI InterlockedDecrement (LONG volatile *);
2119-LONG WINAPI InterlockedExchange (LONG volatile *, LONG);
2120-/* PVOID WINAPI InterlockedExchangePointer (PVOID *, PVOID); */
2121-#define InterlockedExchangePointer(t, v) \
2122- (PVOID)InterlockedExchange((LONG volatile *)(t),(LONG)(v))
2123-LONG WINAPI InterlockedExchangeAdd (LONG volatile *, LONG);
2124-
2125-#if (_WIN32_WINNT >= 0x0501)
2126-PSLIST_ENTRY WINAPI InterlockedFlushSList (PSLIST_HEADER);
2127-#endif
2128-
2129-LONG WINAPI InterlockedIncrement (LONG volatile *);
2143+PSLIST_ENTRY __kernel_api InterlockedPushEntrySList (PSLIST_HEADER, PSLIST_ENTRY);
2144+PSLIST_ENTRY __kernel_api InterlockedPopEntrySList (PSLIST_HEADER);
21302145
2131-#if (_WIN32_WINNT >= 0x0501)
2132-PSLIST_ENTRY WINAPI InterlockedPopEntrySList (PSLIST_HEADER);
2133-PSLIST_ENTRY WINAPI InterlockedPushEntrySList (PSLIST_HEADER, PSLIST_ENTRY);
2134-#endif
2135-#endif /* __INTERLOCKED_DECLARED */
2136-#endif /* __USE_NTOSKRNL__ */
2146+#endif /* !_DDK_WINDDK_H */
2147+#endif /* _WIN32_WINNT >= _WIN32_WINNT_WINXP */
21372148
21382149 WINBASEAPI BOOL WINAPI IsBadCodePtr (FARPROC);
21392150 WINBASEAPI BOOL WINAPI IsBadHugeReadPtr (PCVOID, UINT);
--- a/w32api/include/winnt.h
+++ b/w32api/include/winnt.h
@@ -4333,6 +4333,58 @@ static FORCEINLINE void MemoryBarrier (void)
43334333 #undef __mingw_thread_fence
43344334 #undef __mingw_fence_insn__
43354335
4336+#ifndef _DDK_NTDDK_H
4337+/* Several of the interlocked memory access API functions, which are
4338+ * declared below, are exported by both kernel32.dll, and ntoskrnl.exe,
4339+ * but with different (incompatible) calling conventions in each case.
4340+ *
4341+ * In the case where _DDK_NTDDL_H is NOT defined, it is assumed that
4342+ * the intent is to link with kernel32.dll, and the __stdcall calling
4343+ * convention is applicable...
4344+ */
4345+#define __kernel_api __stdcall
4346+#else
4347+/* ...whereas, when the _DDK_NTDDK_H guard IS defined, (as it will
4348+ * be when <ddk/ntddk.h> has been included beforehand), it is assumed
4349+ * that the intent is to build a Windows device driver, which will be
4350+ * linked with ntoskrnl.exe, and the __fastcall calling convention
4351+ * becomes applicable.
4352+ */
4353+#define __kernel_api __fastcall
4354+#endif
4355+/* Formerly declared within <winbase.h>, and relocated here, to
4356+ * conform with Microsoft's current documentation, the following,
4357+ * conforming to the __stdcall calling convention, are exported by
4358+ * kernel32.dll; alternative implementations of each, but conforming
4359+ * to the __fastcall calling convention, are exported by ntoskrnl.exe,
4360+ * so these are declared with the appropriate __kernel_api calling
4361+ * convention, as determined immediately above.
4362+ */
4363+LONG __kernel_api InterlockedDecrement (LONG volatile *);
4364+LONG __kernel_api InterlockedIncrement (LONG volatile *);
4365+
4366+LONG __kernel_api InterlockedExchange (LONG volatile *, LONG);
4367+LONG __kernel_api InterlockedCompareExchange (LONG volatile *, LONG, LONG);
4368+LONG __kernel_api InterlockedExchangeAdd (LONG volatile *, LONG);
4369+
4370+/* The interlocked pointer exchange functions are ALWAYS implemented
4371+ * as intrinsics, in terms of corresponding long int exchange functions.
4372+ */
4373+#define _WIN32_INTRINSIC extern __inline__ __attribute__((gnu_inline))
4374+
4375+_WIN32_INTRINSIC
4376+PVOID InterlockedCompareExchangePointer (PVOID volatile *D, PVOID X, PVOID C)
4377+{ return (PVOID)(
4378+ InterlockedCompareExchange ((LONG volatile *)(D), (LONG)(X), (LONG)(C))
4379+ );
4380+}
4381+_WIN32_INTRINSIC
4382+PVOID InterlockedExchangePointer (PVOID volatile *D, PVOID X)
4383+{ return (PVOID)(
4384+ InterlockedExchange ((LONG volatile *)(D), (LONG)(X))
4385+ );
4386+}
4387+
43364388 _END_C_DECLS
43374389
43384390 #endif /* ! RC_INVOKED */
Show on old repository browser