1 | // Copyright (c) Microsoft. All rights reserved.
|
---|
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
---|
3 |
|
---|
4 | #ifndef DOUBLYLINKEDLIST_H
|
---|
5 | #define DOUBLYLINKEDLIST_H
|
---|
6 |
|
---|
7 | #ifdef __cplusplus
|
---|
8 | #include <cstddef>
|
---|
9 | extern "C"
|
---|
10 | {
|
---|
11 | #else
|
---|
12 | #include <stddef.h>
|
---|
13 | #endif
|
---|
14 |
|
---|
15 | #include <stdint.h>
|
---|
16 | #include "azure_c_shared_utility/umock_c_prod.h"
|
---|
17 |
|
---|
18 | typedef struct DLIST_ENTRY_TAG
|
---|
19 | {
|
---|
20 | struct DLIST_ENTRY_TAG *Flink;
|
---|
21 | struct DLIST_ENTRY_TAG *Blink;
|
---|
22 | } DLIST_ENTRY, *PDLIST_ENTRY;
|
---|
23 |
|
---|
24 | MOCKABLE_FUNCTION(, void, DList_InitializeListHead, PDLIST_ENTRY, listHead);
|
---|
25 | MOCKABLE_FUNCTION(, int, DList_IsListEmpty, const PDLIST_ENTRY, listHead);
|
---|
26 | MOCKABLE_FUNCTION(, void, DList_InsertTailList, PDLIST_ENTRY, listHead, PDLIST_ENTRY, listEntry);
|
---|
27 | MOCKABLE_FUNCTION(, void, DList_InsertHeadList, PDLIST_ENTRY, listHead, PDLIST_ENTRY, listEntry);
|
---|
28 | MOCKABLE_FUNCTION(, void, DList_AppendTailList, PDLIST_ENTRY, listHead, PDLIST_ENTRY, ListToAppend);
|
---|
29 | MOCKABLE_FUNCTION(, int, DList_RemoveEntryList, PDLIST_ENTRY, listEntry);
|
---|
30 | MOCKABLE_FUNCTION(, PDLIST_ENTRY, DList_RemoveHeadList, PDLIST_ENTRY, listHead);
|
---|
31 |
|
---|
32 | //
|
---|
33 | // Calculate the address of the base of the structure given its type, and an
|
---|
34 | // address of a field within the structure.
|
---|
35 | //
|
---|
36 | #define containingRecord(address, type, field) ((type *)((uintptr_t)(address) - offsetof(type,field)))
|
---|
37 |
|
---|
38 | #ifdef __cplusplus
|
---|
39 | }
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #endif /* DOUBLYLINKEDLIST_H */
|
---|