Cordio Stack and Cordio Profiles  r2p3-02rel0
wsf_queue.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file wsf_queue.h
4  *
5  * \brief General purpose queue service.
6  *
7  * Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
8  * ARM Ltd. confidential and proprietary.
9  *
10  * IMPORTANT. Your use of this file is governed by a Software License Agreement
11  * ("Agreement") that must be accepted in order to download or otherwise receive a
12  * copy of this file. You may not use or copy this file for any purpose other than
13  * as described in the Agreement. If you do not agree to all of the terms of the
14  * Agreement do not use this file and delete all copies in your possession or control;
15  * if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
16  * to any use, copying or further distribution of this software.
17  */
18 /*************************************************************************************************/
19 #ifndef WSF_QUEUE_H
20 #define WSF_QUEUE_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /*! \addtogroup WSF_QUEUE_API
27  * \{ */
28 
29 /**************************************************************************************************
30  Macros
31 **************************************************************************************************/
32 
33 /*! \brief Initialize a queue */
34 #define WSF_QUEUE_INIT(pQueue) {(pQueue)->pHead = NULL; (pQueue)->pTail = NULL;}
35 
36 /**************************************************************************************************
37  Data Types
38 **************************************************************************************************/
39 
40 /*! \brief Queue structure */
41 typedef struct
42 {
43  void *pHead; /*!< \brief head of queue */
44  void *pTail; /*!< \brief tail of queue */
45 } wsfQueue_t;
46 
47 /**************************************************************************************************
48  Function Declarations
49 **************************************************************************************************/
50 
51 /*************************************************************************************************/
52 /*!
53  * \brief Enqueue an element to the tail of a queue.
54  *
55  * \param pQueue Pointer to queue.
56  * \param pElem Pointer to element.
57  *
58  * \return None.
59  */
60 /*************************************************************************************************/
61 void WsfQueueEnq(wsfQueue_t *pQueue, void *pElem);
62 
63 /*************************************************************************************************/
64 /*!
65  * \brief Dequeue an element from the head of a queue.
66  *
67  * \param pQueue Pointer to queue.
68  *
69  * \return Pointer to element that has been dequeued or NULL if queue is empty.
70  */
71 /*************************************************************************************************/
72 void *WsfQueueDeq(wsfQueue_t *pQueue);
73 
74 /*************************************************************************************************/
75 /*!
76  * \brief Push an element to the head of a queue.
77  *
78  * \param pQueue Pointer to queue.
79  * \param pElem Pointer to element.
80  *
81  * \return None.
82  */
83 /*************************************************************************************************/
84 void WsfQueuePush(wsfQueue_t *pQueue, void *pElem);
85 
86 /*************************************************************************************************/
87 /*!
88  * \brief Insert an element into a queue. This function is typically used when iterating
89  * over a queue.
90  *
91  * \param pQueue Pointer to queue.
92  * \param pElem Pointer to element to be inserted.
93  * \param pPrev Pointer to previous element in the queue before element to be inserted.
94  * Note: set pPrev to NULL if pElem is first element in queue.
95  * \return None.
96  */
97 /*************************************************************************************************/
98 void WsfQueueInsert(wsfQueue_t *pQueue, void *pElem, void *pPrev);
99 
100 /*************************************************************************************************/
101 /*!
102  * \brief Remove an element from a queue. This function is typically used when iterating
103  * over a queue.
104  *
105  * \param pQueue Pointer to queue.
106  * \param pElem Pointer to element to be removed.
107  * \param pPrev Pointer to previous element in the queue before element to be removed.
108  *
109  * \return None.
110  */
111 /*************************************************************************************************/
112 void WsfQueueRemove(wsfQueue_t *pQueue, void *pElem, void *pPrev);
113 
114 /*************************************************************************************************/
115 /*!
116  * \brief Count the number of elements in a queue.
117  *
118  * \param pQueue Pointer to queue.
119  *
120  * \return Number of elements in queue.
121  */
122 /*************************************************************************************************/
124 
125 /*************************************************************************************************/
126 /*!
127  * \brief Return TRUE if queue is empty.
128  *
129  * \param pQueue Pointer to queue.
130  *
131  * \return TRUE if queue is empty, FALSE otherwise.
132  */
133 /*************************************************************************************************/
135 
136 /*! \} */ /* WSF_QUEUE_API */
137 
138 #ifdef __cplusplus
139 };
140 #endif
141 
142 #endif /* WSF_QUEUE_H */
void * pHead
head of queue
Definition: wsf_queue.h:43
uint8_t bool_t
Boolean data type.
Definition: wsf_types.h:78
uint16_t WsfQueueCount(wsfQueue_t *pQueue)
Count the number of elements in a queue.
void * WsfQueueDeq(wsfQueue_t *pQueue)
Dequeue an element from the head of a queue.
bool_t WsfQueueEmpty(wsfQueue_t *pQueue)
Return TRUE if queue is empty.
void WsfQueuePush(wsfQueue_t *pQueue, void *pElem)
Push an element to the head of a queue.
Queue structure.
Definition: wsf_queue.h:41
void WsfQueueInsert(wsfQueue_t *pQueue, void *pElem, void *pPrev)
Insert an element into a queue. This function is typically used when iterating over a queue...
unsigned short uint16_t
Unsigned 16-bit value.
Definition: wsf_types.h:67
void * pTail
tail of queue
Definition: wsf_queue.h:44
void WsfQueueEnq(wsfQueue_t *pQueue, void *pElem)
Enqueue an element to the tail of a queue.
void WsfQueueRemove(wsfQueue_t *pQueue, void *pElem, void *pPrev)
Remove an element from a queue. This function is typically used when iterating over a queue...