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 | #else
|
---|
10 | #include <stddef.h>
|
---|
11 | #endif
|
---|
12 |
|
---|
13 | #include <stdint.h>
|
---|
14 | #include "umock_c/umock_c_prod.h"
|
---|
15 |
|
---|
16 | #ifdef __cplusplus
|
---|
17 | extern "C"
|
---|
18 | {
|
---|
19 | #endif
|
---|
20 |
|
---|
21 | typedef struct DLIST_ENTRY_TAG
|
---|
22 | {
|
---|
23 | struct DLIST_ENTRY_TAG *Flink;
|
---|
24 | struct DLIST_ENTRY_TAG *Blink;
|
---|
25 | } DLIST_ENTRY, *PDLIST_ENTRY;
|
---|
26 |
|
---|
27 | MOCKABLE_FUNCTION(, void, DList_InitializeListHead, PDLIST_ENTRY, listHead);
|
---|
28 | MOCKABLE_FUNCTION(, int, DList_IsListEmpty, const PDLIST_ENTRY, listHead);
|
---|
29 | MOCKABLE_FUNCTION(, void, DList_InsertTailList, PDLIST_ENTRY, listHead, PDLIST_ENTRY, listEntry);
|
---|
30 | MOCKABLE_FUNCTION(, void, DList_InsertHeadList, PDLIST_ENTRY, listHead, PDLIST_ENTRY, listEntry);
|
---|
31 | MOCKABLE_FUNCTION(, void, DList_AppendTailList, PDLIST_ENTRY, listHead, PDLIST_ENTRY, ListToAppend);
|
---|
32 | MOCKABLE_FUNCTION(, int, DList_RemoveEntryList, PDLIST_ENTRY, listEntry);
|
---|
33 | MOCKABLE_FUNCTION(, PDLIST_ENTRY, DList_RemoveHeadList, PDLIST_ENTRY, listHead);
|
---|
34 |
|
---|
35 | //
|
---|
36 | // Calculate the address of the base of the structure given its type, and an
|
---|
37 | // address of a field within the structure.
|
---|
38 | //
|
---|
39 | #define containingRecord(address, type, field) ((type *)((uintptr_t)(address) - offsetof(type,field)))
|
---|
40 |
|
---|
41 | #ifdef __cplusplus
|
---|
42 | }
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | #endif /* DOUBLYLINKEDLIST_H */
|
---|