From: Danny Smith Date: Fri, 15 Oct 2004 01:18:11 +0000 (+0000) Subject: 2004-10-15 Robert Wruck X-Git-Tag: reparent-point~65 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=12a638f990d6bb2456097cc303f3ace6cfb5ec3b;p=newlib-cygwin.git 2004-10-15 Robert Wruck Danny Smith = include/winbase.h (InitializeSListHead, Interlocked*): Guard with !__USE_NTOSKRNL__. * include/ddk/ntddk.h (__USE_NTOSKRNL__): Define. * include/ddk/winddk.h (InitializeSListHead, Interlocked*): Guard with __USE_NTOSKRNL__. (ExInterlockedPopEntrySList, ExInterlockedPushEntrySList): Add prototypes. Guard macro definition with __USE_NTOSKRNL__ && _WIN32_WINNT >= 0x0501 (ExAllocateFromNPagedLookasideList, ExAllocateFromPagedLookasideList, ExFreeToNPagedLookasideList, ExFreeToPagedLookasideList): Replace calts to InterlockedPopEntrySList, InterlockedPushEntrySList with ExInterlockedPopEntrySList, ExInterlockedPushEntrySList. * lib/ddk/ntosknl.def (ExInterlockedPopEntrySList, ExInterlockedPushEntrySList) Add stubs with fastcall decoration. (ExDesktopObjectType, ExEventObjectType, ExSemaphoreObjectType, ExWindowStationObjectType, IoAdapterObjectType, IoDeviceHandlerObjectSize, IoDeviceHandlerObjectType, IoDeviceObjectType, IoDriverObjectType, IoFileObjectType, LpcPortObjectType, MmSectionObjectType, SeTokenObjectType): Uncomment stubs. --- diff --git a/winsup/w32api/ChangeLog b/winsup/w32api/ChangeLog index 321f23ec8..a8afaf14c 100644 --- a/winsup/w32api/ChangeLog +++ b/winsup/w32api/ChangeLog @@ -1,3 +1,29 @@ +2004-10-15 Robert Wruck + Danny Smith + + = include/winbase.h (InitializeSListHead, Interlocked*): + Guard with !__USE_NTOSKRNL__. + + * include/ddk/ntddk.h (__USE_NTOSKRNL__): Define. + * include/ddk/winddk.h (InitializeSListHead, Interlocked*): + Guard with __USE_NTOSKRNL__. + (ExInterlockedPopEntrySList, ExInterlockedPushEntrySList): + Add prototypes. Guard macro definition with __USE_NTOSKRNL__ + && _WIN32_WINNT >= 0x0501 + (ExAllocateFromNPagedLookasideList, ExAllocateFromPagedLookasideList, + ExFreeToNPagedLookasideList, ExFreeToPagedLookasideList): + Replace calts to InterlockedPopEntrySList, InterlockedPushEntrySList + with ExInterlockedPopEntrySList, ExInterlockedPushEntrySList. + + * lib/ddk/ntosknl.def (ExInterlockedPopEntrySList, + ExInterlockedPushEntrySList) Add stubs with fastcall decoration. + (ExDesktopObjectType, ExEventObjectType, ExSemaphoreObjectType, + ExWindowStationObjectType, IoAdapterObjectType, + IoDeviceHandlerObjectSize, IoDeviceHandlerObjectType, + IoDeviceObjectType, IoDriverObjectType, IoFileObjectType, + LpcPortObjectType, MmSectionObjectType, SeTokenObjectType): + Uncomment stubs. + 2004-10-11 Robert Wruck * include/ddk/winddk.h (IoReleaseRemoveLockAndWait): Fix diff --git a/winsup/w32api/include/ddk/ntddk.h b/winsup/w32api/include/ddk/ntddk.h index d227fe98e..fd78905fd 100644 --- a/winsup/w32api/include/ddk/ntddk.h +++ b/winsup/w32api/include/ddk/ntddk.h @@ -19,9 +19,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * DEFINES: - * DBG - Debugging enabled/disabled (0/1) - * POOL_TAGGING - Enable pool tagging - * _X86_ - X86 environment + * DBG - Debugging enabled/disabled (0/1) + * POOL_TAGGING - Enable pool tagging + * _X86_ - X86 environment + * __USE_NTOSKRNL__ - Use ntoskrnl.exe exports instead of kernel32.dll */ #ifndef __NTDDK_H @@ -31,6 +32,10 @@ #pragma GCC system_header #endif +#ifndef __USE_NTOSKRNL__ +#define __USE_NTOSKRNL__ 1 +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/winsup/w32api/include/ddk/winddk.h b/winsup/w32api/include/ddk/winddk.h index a183efd80..771f57418 100644 --- a/winsup/w32api/include/ddk/winddk.h +++ b/winsup/w32api/include/ddk/winddk.h @@ -3809,6 +3809,11 @@ KeGetCurrentIrql( #define KeGetCurrentProcessorNumber() \ ((ULONG)KeGetCurrentKPCR()->ProcessorNumber) + +#if __USE_NTOSKRNL__ +/* CAREFUL: These are exported from ntoskrnl.exe as __fastcall functions, + but are also exported from kernel32.dll and declared in winbase.h as + __stdcall */ #if !defined(__INTERLOCKED_DECLARED) #define __INTERLOCKED_DECLARED @@ -3865,7 +3870,22 @@ InterlockedExchangeAdd( #define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) \ ((PVOID) InterlockedCompareExchange((PLONG) Destination, (LONG) Exchange, (LONG) Comparand)) +#if (_WIN32_WINNT >= 0x0501) +PSLIST_ENTRY +DDKFASTAPI +InterlockedPopEntrySList( + IN PSLIST_HEADER ListHead); + +NTOSAPI +PSLIST_ENTRY +DDKFASTAPI +InterlockedPushEntrySList( + IN PSLIST_HEADER ListHead, + IN PSLIST_ENTRY ListEntry); +#endif /* _WIN32_WINNT >= 0x0501 */ + #endif /* !__INTERLOCKED_DECLARED */ +#endif /* __USE_NTOSKRNL__ */ NTOSAPI VOID @@ -4150,23 +4170,6 @@ RemoveTailList( return Entry; } -#if !defined(_WINBASE_H) || _WIN32_WINNT < 0x0501 - -NTOSAPI -PSLIST_ENTRY -DDKFASTAPI -InterlockedPopEntrySList( - IN PSLIST_HEADER ListHead); - -NTOSAPI -PSLIST_ENTRY -DDKFASTAPI -InterlockedPushEntrySList( - IN PSLIST_HEADER ListHead, - IN PSLIST_ENTRY ListEntry); - -#endif - /* * USHORT * QueryDepthSList( @@ -5063,18 +5066,52 @@ ExAcquireSharedWaitForExclusive( IN PERESOURCE Resource, IN BOOLEAN Wait); + +NTOSAPI +PSINGLE_LIST_ENTRY +DDKFASTAPI +ExInterlockedPopEntrySList( + IN PSLIST_HEADER ListHead, + IN PKSPIN_LOCK Lock); + + +NTOSAPI +PSINGLE_LIST_ENTRY +DDKFASTAPI +ExInterlockedPushEntrySList( + IN PSLIST_HEADER ListHead, + IN PSINGLE_LIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); + + +#if (__USE_NTOSKRNL__) && (_WIN32_WINNT >= 0x0501) +#define ExInterlockedPopEntrySList(_ListHead, \ + _Lock) \ + InterlockedPopEntrySList(_ListHead) + +#define ExInterlockedPushEntrySList(_ListHead, \ + _ListEntry, \ + _Lock) \ + InterlockedPushEntrySList(_ListHead, _ListEntry) +#endif /* __USE_NTOSKRNL__ */ + +#define ExQueryDepthSList(ListHead) QueryDepthSList(ListHead) + static __inline PVOID ExAllocateFromNPagedLookasideList( IN PNPAGED_LOOKASIDE_LIST Lookaside) { - PVOID Entry; + PVOID Entry; - Lookaside->TotalAllocates++; - Entry = InterlockedPopEntrySList(&Lookaside->ListHead); - if (Entry == NULL) { - Lookaside->_DDK_DUMMYUNION_MEMBER(AllocateMisses)++; - Entry = (Lookaside->Allocate)(Lookaside->Type, Lookaside->Size, Lookaside->Tag); - } + Lookaside->TotalAllocates++; + Entry = ExInterlockedPopEntrySList(&Lookaside->ListHead, + &Lookaside->Obsoleted); + if (Entry == NULL) { + Lookaside->_DDK_DUMMYUNION_MEMBER(AllocateMisses)++; + Entry = (Lookaside->Allocate)(Lookaside->Type, + Lookaside->Size, + Lookaside->Tag); + } return Entry; } @@ -5085,15 +5122,49 @@ ExAllocateFromPagedLookasideList( PVOID Entry; Lookaside->TotalAllocates++; - Entry = InterlockedPopEntrySList(&Lookaside->ListHead); + Entry = ExInterlockedPopEntrySList(&Lookaside->ListHead, + &Lookaside->Obsoleted); if (Entry == NULL) { Lookaside->_DDK_DUMMYUNION_MEMBER(AllocateMisses)++; Entry = (Lookaside->Allocate)(Lookaside->Type, - Lookaside->Size, Lookaside->Tag); + Lookaside->Size, + Lookaside->Tag); } return Entry; } +static __inline VOID +ExFreeToNPagedLookasideList( + IN PNPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) +{ + Lookaside->TotalFrees++; + if (ExQueryDepthSList(&Lookaside->ListHead) >= Lookaside->Depth) { + Lookaside->_DDK_DUMMYUNION_N_MEMBER(2,FreeMisses)++; + (Lookaside->Free)(Entry); + } else { + ExInterlockedPushEntrySList(&Lookaside->ListHead, + (PSLIST_ENTRY)Entry, + &Lookaside->Obsoleted); + } +} + +static __inline VOID +ExFreeToPagedLookasideList( + IN PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) +{ + Lookaside->TotalFrees++; + if (ExQueryDepthSList(&Lookaside->ListHead) >= Lookaside->Depth) { + Lookaside->_DDK_DUMMYUNION_N_MEMBER(2,FreeMisses)++; + (Lookaside->Free)(Entry); + } else { + ExInterlockedPushEntrySList(&Lookaside->ListHead, + (PSLIST_ENTRY)Entry, + &Lookaside->Obsoleted); + } +} + NTOSAPI PVOID DDKAPI @@ -5194,37 +5265,6 @@ ExFreePoolWithTag( IN PVOID P, IN ULONG Tag); -#define ExQueryDepthSList(ListHead) QueryDepthSList(ListHead) - -static __inline VOID -ExFreeToNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) -{ - Lookaside->TotalFrees++; - if (ExQueryDepthSList(&Lookaside->ListHead) >= Lookaside->Depth) { - Lookaside->_DDK_DUMMYUNION_N_MEMBER(2,FreeMisses)++; - (Lookaside->Free)(Entry); - } else { - InterlockedPushEntrySList(&Lookaside->ListHead, - (PSLIST_ENTRY)Entry); - } -} - -static __inline VOID -ExFreeToPagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) -{ - Lookaside->TotalFrees++; - if (ExQueryDepthSList(&Lookaside->ListHead) >= Lookaside->Depth) { - Lookaside->_DDK_DUMMYUNION_N_MEMBER(2,FreeMisses)++; - (Lookaside->Free)(Entry); - } else { - InterlockedPushEntrySList(&Lookaside->ListHead, (PSLIST_ENTRY)Entry); - } -} - /* * ERESOURCE_THREAD * ExGetCurrentResourceThread( @@ -5404,15 +5444,6 @@ ExfInterlockedPopEntryList( IN PSINGLE_LIST_ENTRY ListHead, IN PKSPIN_LOCK Lock); -/* - * PSINGLE_LIST_ENTRY - * ExInterlockedPopEntrySList( - * IN PSLIST_HEADER ListHead, - * IN PKSPIN_LOCK Lock) - */ -#define ExInterlockedPopEntrySList(_ListHead, \ - _Lock) \ - InterlockedPopEntrySList(_ListHead) NTOSAPI PSINGLE_LIST_ENTRY @@ -5430,17 +5461,6 @@ ExfInterlockedPushEntryList( IN PSINGLE_LIST_ENTRY ListEntry, IN PKSPIN_LOCK Lock); -/* - * PSINGLE_LIST_ENTRY FASTCALL - * ExInterlockedPushEntrySList( - * IN PSLIST_HEADER ListHead, - * IN PSINGLE_LIST_ENTRY ListEntry, - * IN PKSPIN_LOCK Lock) - */ -#define ExInterlockedPushEntrySList(_ListHead, \ - _ListEntry, \ - _Lock) \ - InterlockedPushEntrySList(_ListHead, _ListEntry) NTOSAPI PLIST_ENTRY diff --git a/winsup/w32api/include/winbase.h b/winsup/w32api/include/winbase.h index ad82353e7..eb31442ca 100644 --- a/winsup/w32api/include/winbase.h +++ b/winsup/w32api/include/winbase.h @@ -1574,7 +1574,11 @@ WINBASEAPI BOOL WINAPI InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION, WINBASEAPI DWORD WINAPI SetCriticalSectionSpinCount(LPCRITICAL_SECTION,DWORD); WINBASEAPI BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR,DWORD); WINBASEAPI BOOL WINAPI InitializeSid (PSID,PSID_IDENTIFIER_AUTHORITY,BYTE); -#if !defined(__WINDDK_H) && _WIN32_WINNT >= 0x0501 + +#if !(__USE_NTOSKRNL__) +/* CAREFUL: These are exported from ntoskrnl.exe and declared in winddk.h + as __fastcall functions, but are exported from kernel32.dll as __stdcall */ +#if (_WIN32_WINNT >= 0x0501) WINBASEAPI VOID WINAPI InitializeSListHead(PSLIST_HEADER); #endif #ifndef __INTERLOCKED_DECLARED @@ -1598,6 +1602,8 @@ PSLIST_ENTRY WINAPI InterlockedPopEntrySList(PSLIST_HEADER); PSLIST_ENTRY WINAPI InterlockedPushEntrySList(PSLIST_HEADER,PSLIST_ENTRY); #endif #endif /* __INTERLOCKED_DECLARED */ +#endif /* __USE_NTOSKRNL__ */ + WINBASEAPI BOOL WINAPI IsBadCodePtr(FARPROC); WINBASEAPI BOOL WINAPI IsBadHugeReadPtr(PCVOID,UINT); WINBASEAPI BOOL WINAPI IsBadHugeWritePtr(PVOID,UINT); diff --git a/winsup/w32api/lib/ddk/ntoskrnl.def b/winsup/w32api/lib/ddk/ntoskrnl.def index 467f49413..99e3280c1 100644 --- a/winsup/w32api/lib/ddk/ntoskrnl.def +++ b/winsup/w32api/lib/ddk/ntoskrnl.def @@ -71,10 +71,10 @@ ExCreateCallback@16 ExDeleteNPagedLookasideList@4 ExDeletePagedLookasideList@4 ExDeleteResourceLite@4 -;ExDesktopObjectType DATA +ExDesktopObjectType DATA ;ExDisableResourceBoostLite ;ExEnumHandleTable -;ExEventObjectType DATA +ExEventObjectType DATA ExExtendZone@12 @Exfi386InterlockedDecrementLong@4 @Exfi386InterlockedExchangeUlong@8 @@ -113,9 +113,9 @@ ExInterlockedExtendZone@16 ExInterlockedInsertHeadList@12 ExInterlockedInsertTailList@12 ExInterlockedPopEntryList@8 -;ExInterlockedPopEntrySList +@ExInterlockedPopEntrySList@8 ExInterlockedPushEntryList@12 -;ExInterlockedPushEntrySList +@ExInterlockedPushEntrySList@12 ExInterlockedRemoveHeadList@8 ExIsProcessorFeaturePresent@4 ExIsResourceAcquiredExclusiveLite@4 @@ -137,7 +137,7 @@ ExReleaseResourceForThreadLite@8 @ExReleaseResourceLite@4 ;ExReleaseRundownProtection ;ExRundownCompleted -;ExSemaphoreObjectType DATA +ExSemaphoreObjectType DATA ExSetResourceOwnerPointer@8 ExSetTimerResolution@8 ;ExSystemExceptionFilter @@ -146,7 +146,7 @@ ExUnregisterCallback@4 ExUuidCreate@4 ExVerifySuite@4 ;ExWaitForRundownProtectionRelease -;ExWindowStationObjectType DATA +ExWindowStationObjectType DATA ;FsRtlAcquireFileExclusive ;FsRtlAddLargeMcbEntry ;FsRtlAddMcbEntry @@ -280,7 +280,7 @@ FsRtlIsTotalDeviceFailure@4 IoAcquireCancelSpinLock@4 IoAcquireRemoveLockEx@20 ;IoAcquireVpbSpinLock -;IoAdapterObjectType DATA +IoAdapterObjectType DATA IoAllocateAdapterChannel@20 IoAllocateController@16 IoAllocateDriverObjectExtension@16 @@ -332,15 +332,15 @@ IoDeleteDevice@4 ;IoDeleteDriver IoDeleteSymbolicLink@4 IoDetachDevice@4 -;IoDeviceHandlerObjectSize DATA -;IoDeviceHandlerObjectType DATA -;IoDeviceObjectType DATA +IoDeviceHandlerObjectSize DATA +IoDeviceHandlerObjectType DATA +IoDeviceObjectType DATA IoDisconnectInterrupt@4 -;IoDriverObjectType DATA +IoDriverObjectType DATA ;IoEnqueueIrp ;IoEnumerateDeviceObjectList ;IoFastQueryNetworkAttributes -;IoFileObjectType DATA +IoFileObjectType DATA ;IoForwardAndCatchIrp IoForwardIrpSynchronously@8 IoFreeController@4 @@ -625,7 +625,7 @@ KeWaitForSingleObject@20 ;LdrEnumResources ;LdrFindResourceDirectory_U ;LdrFindResource_U -;LpcPortObjectType DATA +LpcPortObjectType DATA ;LpcRequestPort ;LpcRequestWaitReplyPort ;LsaCallAuthenticationPackage @@ -692,7 +692,7 @@ MmProtectMdlSystemAddress@8 MmQuerySystemSize@0 MmRemovePhysicalMemory@8 MmResetDriverPaging@4 -;MmSectionObjectType DATA +MmSectionObjectType DATA MmSecureVirtualMemory@12 ;MmSetAddressRangeModified ;MmSetBankedSection @@ -1226,7 +1226,7 @@ SeSinglePrivilegeCheck@8 ;SeTokenImpersonationLevel ;SeTokenIsAdmin ;SeTokenIsRestricted -;SeTokenObjectType DATA +SeTokenObjectType DATA ;SeTokenType ;SeUnlockSubjectContext ;SeUnregisterLogonSessionTerminatedRoutine