Refactored interlocked typedefs, avoid namespace collisions.

This commit is contained in:
Armin Novak 2016-08-10 10:46:01 +02:00 committed by Armin Novak
parent 64c5d78b3f
commit 4f62d848ac
6 changed files with 88 additions and 88 deletions

View File

@ -61,7 +61,7 @@ struct _PRINTER_DEVICE
rdpPrinter* printer;
PSLIST_HEADER pIrpList;
WINPR_PSLIST_HEADER pIrpList;
HANDLE event;
HANDLE stopEvent;
@ -405,7 +405,7 @@ UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
free(DriverName);
free(PrintName);
printer_dev->pIrpList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
printer_dev->pIrpList = (WINPR_PSLIST_HEADER) _aligned_malloc(sizeof(WINPR_SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
if (!printer_dev->pIrpList)
{
WLog_ERR(TAG, "_aligned_malloc failed!");

View File

@ -337,7 +337,7 @@ typedef UINT (*pcIRPResponse)(IRP* irp);
struct _IRP
{
SLIST_ENTRY ItemEntry;
WINPR_SLIST_ENTRY ItemEntry;
DEVICE* device;
DEVMAN* devman;

View File

@ -43,56 +43,56 @@ extern "C" {
((type *)(((ULONG_PTR) address) - (ULONG_PTR)(&(((type *) 0)->field))))
#endif
typedef struct _LIST_ENTRY LIST_ENTRY;
typedef struct _LIST_ENTRY* PLIST_ENTRY;
typedef struct _WINPR_LIST_ENTRY WINPR_LIST_ENTRY;
typedef struct _WINPR_LIST_ENTRY* WINPR_PLIST_ENTRY;
struct _LIST_ENTRY
struct _WINPR_LIST_ENTRY
{
PLIST_ENTRY Flink;
PLIST_ENTRY Blink;
WINPR_PLIST_ENTRY Flink;
WINPR_PLIST_ENTRY Blink;
};
typedef struct _SINGLE_LIST_ENTRY SINGLE_LIST_ENTRY;
typedef struct _SINGLE_LIST_ENTRY* PSINGLE_LIST_ENTRY;
typedef struct _WINPR_SINGLE_LIST_ENTRY WINPR_SINGLE_LIST_ENTRY;
typedef struct _WINPR_SINGLE_LIST_ENTRY* WINPR_PSINGLE_LIST_ENTRY;
struct _SINGLE_LIST_ENTRY
struct _WINPR_SINGLE_LIST_ENTRY
{
PSINGLE_LIST_ENTRY Next;
WINPR_PSINGLE_LIST_ENTRY Next;
};
typedef struct LIST_ENTRY32
typedef struct WINPR_LIST_ENTRY32
{
DWORD Flink;
DWORD Blink;
} LIST_ENTRY32;
typedef LIST_ENTRY32 *PLIST_ENTRY32;
} WINPR_LIST_ENTRY32;
typedef WINPR_LIST_ENTRY32 *WINPR_PLIST_ENTRY32;
typedef struct LIST_ENTRY64
typedef struct WINPR_LIST_ENTRY64
{
ULONGLONG Flink;
ULONGLONG Blink;
} LIST_ENTRY64;
typedef LIST_ENTRY64 *PLIST_ENTRY64;
} WINPR_LIST_ENTRY64;
typedef WINPR_LIST_ENTRY64 *WINPR_PLIST_ENTRY64;
#ifdef _WIN64
typedef struct _SLIST_ENTRY *PSLIST_ENTRY;
typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY
typedef struct _WINPR_SLIST_ENTRY *WINPR_PSLIST_ENTRY;
typedef struct DECLSPEC_ALIGN(16) _WINPR_SLIST_ENTRY
{
PSLIST_ENTRY Next;
} SLIST_ENTRY;
WINPR_PSLIST_ENTRY Next;
} WINPR_SLIST_ENTRY;
#else /* _WIN64 */
#define SLIST_ENTRY SINGLE_LIST_ENTRY
#define _SLIST_ENTRY _SINGLE_LIST_ENTRY
#define PSLIST_ENTRY PSINGLE_LIST_ENTRY
#define WINPR_SLIST_ENTRY WINPR_SINGLE_LIST_ENTRY
#define _WINPR_SLIST_ENTRY _WINPR_SINGLE_LIST_ENTRY
#define PWINPR_SLIST_ENTRY WINPR_PSINGLE_LIST_ENTRY
#endif /* _WIN64 */
#ifdef _WIN64
typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER
typedef union DECLSPEC_ALIGN(16) _WINPR_SLIST_HEADER
{
struct
{
@ -119,34 +119,34 @@ typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER
ULONGLONG Reserved:3;
ULONGLONG NextEntry:60;
} HeaderX64;
} SLIST_HEADER, *PSLIST_HEADER;
} WINPR_SLIST_HEADER, *WINPR_PSLIST_HEADER;
#else /* _WIN64 */
typedef union _SLIST_HEADER
typedef union _WINPR_SLIST_HEADER
{
ULONGLONG Alignment;
struct
{
SLIST_ENTRY Next;
WINPR_SLIST_ENTRY Next;
WORD Depth;
WORD Sequence;
} DUMMYSTRUCTNAME;
} SLIST_HEADER, *PSLIST_HEADER;
} WINPR_SLIST_HEADER, *WINPR_PSLIST_HEADER;
#endif /* _WIN64 */
/* Singly-Linked List */
WINPR_API VOID InitializeSListHead(PSLIST_HEADER ListHead);
WINPR_API VOID InitializeSListHead(WINPR_PSLIST_HEADER ListHead);
WINPR_API PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry);
WINPR_API PSLIST_ENTRY InterlockedPushListSListEx(PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, ULONG Count);
WINPR_API PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead);
WINPR_API PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead);
WINPR_API PWINPR_SLIST_ENTRY InterlockedPushEntrySList(WINPR_PSLIST_HEADER ListHead, PWINPR_SLIST_ENTRY ListEntry);
WINPR_API PWINPR_SLIST_ENTRY InterlockedPushListSListEx(WINPR_PSLIST_HEADER ListHead, PWINPR_SLIST_ENTRY List, PWINPR_SLIST_ENTRY ListEnd, ULONG Count);
WINPR_API PWINPR_SLIST_ENTRY InterlockedPopEntrySList(WINPR_PSLIST_HEADER ListHead);
WINPR_API PWINPR_SLIST_ENTRY InterlockedFlushSList(WINPR_PSLIST_HEADER ListHead);
WINPR_API USHORT QueryDepthSList(PSLIST_HEADER ListHead);
WINPR_API USHORT QueryDepthSList(WINPR_PSLIST_HEADER ListHead);
WINPR_API LONG InterlockedIncrement(LONG volatile *Addend);
WINPR_API LONG InterlockedDecrement(LONG volatile *Addend);
@ -172,21 +172,21 @@ WINPR_API LONGLONG InterlockedCompareExchange64(LONGLONG volatile *Destination,
/* Doubly-Linked List */
WINPR_API VOID InitializeListHead(PLIST_ENTRY ListHead);
WINPR_API VOID InitializeListHead(WINPR_PLIST_ENTRY ListHead);
WINPR_API BOOL IsListEmpty(const LIST_ENTRY* ListHead);
WINPR_API BOOL IsListEmpty(const WINPR_LIST_ENTRY* ListHead);
WINPR_API BOOL RemoveEntryList(PLIST_ENTRY Entry);
WINPR_API BOOL RemoveEntryList(WINPR_PLIST_ENTRY Entry);
WINPR_API VOID InsertHeadList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
WINPR_API PLIST_ENTRY RemoveHeadList(PLIST_ENTRY ListHead);
WINPR_API VOID InsertHeadList(WINPR_PLIST_ENTRY ListHead, WINPR_PLIST_ENTRY Entry);
WINPR_API WINPR_PLIST_ENTRY RemoveHeadList(WINPR_PLIST_ENTRY ListHead);
WINPR_API VOID InsertTailList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry);
WINPR_API PLIST_ENTRY RemoveTailList(PLIST_ENTRY ListHead);
WINPR_API VOID AppendTailList(PLIST_ENTRY ListHead, PLIST_ENTRY ListToAppend);
WINPR_API VOID InsertTailList(WINPR_PLIST_ENTRY ListHead, WINPR_PLIST_ENTRY Entry);
WINPR_API WINPR_PLIST_ENTRY RemoveTailList(WINPR_PLIST_ENTRY ListHead);
WINPR_API VOID AppendTailList(WINPR_PLIST_ENTRY ListHead, WINPR_PLIST_ENTRY ListToAppend);
WINPR_API VOID PushEntryList(PSINGLE_LIST_ENTRY ListHead, PSINGLE_LIST_ENTRY Entry);
WINPR_API PSINGLE_LIST_ENTRY PopEntryList(PSINGLE_LIST_ENTRY ListHead);
WINPR_API VOID PushEntryList(WINPR_PSINGLE_LIST_ENTRY ListHead, WINPR_PSINGLE_LIST_ENTRY Entry);
WINPR_API WINPR_PSINGLE_LIST_ENTRY PopEntryList(WINPR_PSINGLE_LIST_ENTRY ListHead);
#ifdef __cplusplus
}

View File

@ -33,7 +33,7 @@
#include <stdio.h>
#include <stdlib.h>
VOID InitializeSListHead(PSLIST_HEADER ListHead)
VOID InitializeSListHead(WINPR_PSLIST_HEADER ListHead)
{
#ifdef _WIN64
ListHead->s.Alignment = 0;
@ -44,10 +44,10 @@ VOID InitializeSListHead(PSLIST_HEADER ListHead)
#endif
}
PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry)
PWINPR_SLIST_ENTRY InterlockedPushEntrySList(WINPR_PSLIST_HEADER ListHead, PWINPR_SLIST_ENTRY ListEntry)
{
SLIST_HEADER old;
SLIST_HEADER new;
WINPR_SLIST_HEADER old;
WINPR_SLIST_HEADER new;
#ifdef _WIN64
new.HeaderX64.NextEntry = (((ULONG_PTR) ListEntry) >> 4);
@ -85,7 +85,7 @@ PSLIST_ENTRY InterlockedPushEntrySList(PSLIST_HEADER ListHead, PSLIST_ENTRY List
#endif
}
PSLIST_ENTRY InterlockedPushListSListEx(PSLIST_HEADER ListHead, PSLIST_ENTRY List, PSLIST_ENTRY ListEnd, ULONG Count)
PWINPR_SLIST_ENTRY InterlockedPushListSListEx(WINPR_PSLIST_HEADER ListHead, PWINPR_SLIST_ENTRY List, PWINPR_SLIST_ENTRY ListEnd, ULONG Count)
{
#ifdef _WIN64
@ -95,11 +95,11 @@ PSLIST_ENTRY InterlockedPushListSListEx(PSLIST_HEADER ListHead, PSLIST_ENTRY Lis
return NULL;
}
PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead)
PWINPR_SLIST_ENTRY InterlockedPopEntrySList(WINPR_PSLIST_HEADER ListHead)
{
SLIST_HEADER old;
SLIST_HEADER new;
PSLIST_ENTRY entry;
WINPR_SLIST_HEADER old;
WINPR_SLIST_HEADER new;
PWINPR_SLIST_ENTRY entry;
#ifdef _WIN64
while (1)
@ -140,10 +140,10 @@ PSLIST_ENTRY InterlockedPopEntrySList(PSLIST_HEADER ListHead)
return entry;
}
PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead)
PWINPR_SLIST_ENTRY InterlockedFlushSList(WINPR_PSLIST_HEADER ListHead)
{
SLIST_HEADER old;
SLIST_HEADER new;
WINPR_SLIST_HEADER old;
WINPR_SLIST_HEADER new;
if (!QueryDepthSList(ListHead))
return NULL;
@ -180,7 +180,7 @@ PSLIST_ENTRY InterlockedFlushSList(PSLIST_HEADER ListHead)
#endif
}
USHORT QueryDepthSList(PSLIST_HEADER ListHead)
USHORT QueryDepthSList(WINPR_PSLIST_HEADER ListHead)
{
#ifdef _WIN64
return ListHead->HeaderX64.Depth;
@ -332,20 +332,20 @@ LONGLONG InterlockedCompareExchange64(LONGLONG volatile *Destination, LONGLONG E
* http://msdn.microsoft.com/en-us/library/windows/hardware/ff563802/
*/
VOID InitializeListHead(PLIST_ENTRY ListHead)
VOID InitializeListHead(WINPR_PLIST_ENTRY ListHead)
{
ListHead->Flink = ListHead->Blink = ListHead;
}
BOOL IsListEmpty(const LIST_ENTRY* ListHead)
BOOL IsListEmpty(const WINPR_LIST_ENTRY* ListHead)
{
return (BOOL) (ListHead->Flink == ListHead);
}
BOOL RemoveEntryList(PLIST_ENTRY Entry)
BOOL RemoveEntryList(WINPR_PLIST_ENTRY Entry)
{
PLIST_ENTRY OldFlink;
PLIST_ENTRY OldBlink;
WINPR_PLIST_ENTRY OldFlink;
WINPR_PLIST_ENTRY OldBlink;
OldFlink = Entry->Flink;
OldBlink = Entry->Blink;
@ -355,9 +355,9 @@ BOOL RemoveEntryList(PLIST_ENTRY Entry)
return (BOOL) (OldFlink == OldBlink);
}
VOID InsertHeadList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry)
VOID InsertHeadList(WINPR_PLIST_ENTRY ListHead, WINPR_PLIST_ENTRY Entry)
{
PLIST_ENTRY OldFlink;
WINPR_PLIST_ENTRY OldFlink;
OldFlink = ListHead->Flink;
Entry->Flink = OldFlink;
@ -366,10 +366,10 @@ VOID InsertHeadList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry)
ListHead->Flink = Entry;
}
PLIST_ENTRY RemoveHeadList(PLIST_ENTRY ListHead)
WINPR_PLIST_ENTRY RemoveHeadList(WINPR_PLIST_ENTRY ListHead)
{
PLIST_ENTRY Flink;
PLIST_ENTRY Entry;
WINPR_PLIST_ENTRY Flink;
WINPR_PLIST_ENTRY Entry;
Entry = ListHead->Flink;
Flink = Entry->Flink;
@ -379,9 +379,9 @@ PLIST_ENTRY RemoveHeadList(PLIST_ENTRY ListHead)
return Entry;
}
VOID InsertTailList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry)
VOID InsertTailList(WINPR_PLIST_ENTRY ListHead, WINPR_PLIST_ENTRY Entry)
{
PLIST_ENTRY OldBlink;
WINPR_PLIST_ENTRY OldBlink;
OldBlink = ListHead->Blink;
Entry->Flink = ListHead;
@ -390,10 +390,10 @@ VOID InsertTailList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry)
ListHead->Blink = Entry;
}
PLIST_ENTRY RemoveTailList(PLIST_ENTRY ListHead)
WINPR_PLIST_ENTRY RemoveTailList(WINPR_PLIST_ENTRY ListHead)
{
PLIST_ENTRY Blink;
PLIST_ENTRY Entry;
WINPR_PLIST_ENTRY Blink;
WINPR_PLIST_ENTRY Entry;
Entry = ListHead->Blink;
Blink = Entry->Blink;
@ -403,9 +403,9 @@ PLIST_ENTRY RemoveTailList(PLIST_ENTRY ListHead)
return Entry;
}
VOID AppendTailList(PLIST_ENTRY ListHead, PLIST_ENTRY ListToAppend)
VOID AppendTailList(WINPR_PLIST_ENTRY ListHead, WINPR_PLIST_ENTRY ListToAppend)
{
PLIST_ENTRY ListEnd = ListHead->Blink;
WINPR_PLIST_ENTRY ListEnd = ListHead->Blink;
ListHead->Blink->Flink = ListToAppend;
ListHead->Blink = ListToAppend->Blink;
@ -413,15 +413,15 @@ VOID AppendTailList(PLIST_ENTRY ListHead, PLIST_ENTRY ListToAppend)
ListToAppend->Blink = ListEnd;
}
VOID PushEntryList(PSINGLE_LIST_ENTRY ListHead, PSINGLE_LIST_ENTRY Entry)
VOID PushEntryList(WINPR_PSINGLE_LIST_ENTRY ListHead, WINPR_PSINGLE_LIST_ENTRY Entry)
{
Entry->Next = ListHead->Next;
ListHead->Next = Entry;
}
PSINGLE_LIST_ENTRY PopEntryList(PSINGLE_LIST_ENTRY ListHead)
WINPR_PSINGLE_LIST_ENTRY PopEntryList(WINPR_PSINGLE_LIST_ENTRY ListHead)
{
PSINGLE_LIST_ENTRY FirstEntry;
WINPR_PSINGLE_LIST_ENTRY FirstEntry;
FirstEntry = ListHead->Next;

View File

@ -6,7 +6,7 @@
typedef struct _LIST_ITEM
{
LIST_ENTRY ItemEntry;
WINPR_LIST_ENTRY ItemEntry;
ULONG Signature;
} LIST_ITEM, *PLIST_ITEM;
@ -14,10 +14,10 @@ int TestInterlockedDList(int argc, char* argv[])
{
ULONG Count;
PLIST_ITEM pListItem;
PLIST_ENTRY pListHead;
PLIST_ENTRY pListEntry;
WINPR_PLIST_ENTRY pListHead;
WINPR_PLIST_ENTRY pListEntry;
pListHead = (PLIST_ENTRY) _aligned_malloc(sizeof(LIST_ENTRY), MEMORY_ALLOCATION_ALIGNMENT);
pListHead = (WINPR_PLIST_ENTRY) _aligned_malloc(sizeof(WINPR_LIST_ENTRY), MEMORY_ALLOCATION_ALIGNMENT);
if (!pListHead)
{

View File

@ -6,20 +6,20 @@
typedef struct _PROGRAM_ITEM
{
SLIST_ENTRY ItemEntry;
WINPR_SLIST_ENTRY ItemEntry;
ULONG Signature;
} PROGRAM_ITEM, *PPROGRAM_ITEM;
int TestInterlockedSList(int argc, char* argv[])
{
ULONG Count;
PSLIST_ENTRY pFirstEntry;
PSLIST_ENTRY pListEntry;
PSLIST_HEADER pListHead;
PWINPR_SLIST_ENTRY pFirstEntry;
PWINPR_SLIST_ENTRY pListEntry;
WINPR_PSLIST_HEADER pListHead;
PPROGRAM_ITEM pProgramItem;
/* Initialize the list header to a MEMORY_ALLOCATION_ALIGNMENT boundary. */
pListHead = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
pListHead = (WINPR_PSLIST_HEADER) _aligned_malloc(sizeof(WINPR_SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
if (!pListHead)
{