RTEMS: cpukit/include/rtems/rtl/rtl-indirect-ptr.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
rtl-indirect-ptr.h
Go to the documentation of this file.
1/*
2 * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
3 *
4 * The license and distribution terms for this file may be
5 * found in the file LICENSE in this distribution or at
6 * http://www.rtems.org/license/LICENSE.
7 */
17#if !defined (_RTEMS_RTL_INDIRECT_PTR_H_)
18#define _RTEMS_RTL_INDIRECT_PTR_H_
19
20#ifdef __cplusplus
21extern "C" {
22#endif /* __cplusplus */
23
24#include <rtems/chain.h>
25
29 struct rtems_rtl_ptr {
30 rtems_chain_node node;
31 void* pointer;
32};
33
34typedef struct rtems_rtl_ptr rtems_rtl_ptr;
35
39 struct rtems_rtl_sptr {
40 rtems_rtl_ptr ptr;
41 size_t size;
42};
43
44typedef struct rtems_rtl_sptr rtems_rtl_sptr;
45
52 struct rtems_rtl_ptr_chain {
53 rtems_chain_node node;
54 rtems_rtl_ptr ptr;
55};
56
57typedef struct rtems_rtl_ptr_chain rtems_rtl_ptr_chain;
58
65 struct rtems_rtl_sptr_chain {
66 rtems_chain_node node;
67 rtems_rtl_sptr ptr;
68};
69
70typedef struct rtems_rtl_sptr_chain rtems_rtl_sptr_chain;
71
78static inline void* rtems_rtl_ptr_get (rtems_rtl_ptr* handle)
79{
80 return handle->pointer;
81}
82
89static inline void rtems_rtl_ptr_set (rtems_rtl_ptr* handle, void* pointer)
90{
91 handle->pointer = pointer;
92}
93
99static inline void rtems_rtl_ptr_init (rtems_rtl_ptr* handle)
100{
101 rtems_chain_set_off_chain (&handle->node);
102 handle->pointer = NULL;
103}
104
111static inline bool rtems_rtl_ptr_null (rtems_rtl_ptr* handle)
112{
113 return handle->pointer == NULL;
114}
115
123static inline void rtems_rtl_ptr_move (rtems_rtl_ptr* dst, rtems_rtl_ptr* src)
124{
125 /*
126 * We do not know which chain the src handle resides on so insert the dst
127 * handle after the src handle then extract the src handle.
128 */
129 rtems_chain_insert_unprotected (&src->node, &dst->node);
130 rtems_chain_extract_unprotected (&src->node);
131 dst->pointer = src->pointer;
132 rtems_rtl_ptr_init (src);
133}
134
141#define rtems_rtl_ptr_type_get(_h, _t) ((_t*) rtems_rtl_ptr_get (_h))
142
149static inline void* rtems_rtl_sptr_get (rtems_rtl_sptr* handle)
150{
151 return rtems_rtl_ptr_get (&handle->ptr);
152}
153
160static inline void rtems_rtl_sptr_set (rtems_rtl_sptr* handle, void* pointer)
161{
162 rtems_rtl_ptr_set (&handle->ptr, pointer);
163}
164
170static inline void rtems_rtl_sptr_init (rtems_rtl_sptr* handle)
171{
172 rtems_rtl_ptr_init (&handle->ptr);
173 handle->size = 0;
174}
175
182static inline bool rtems_rtl_sptr_null (rtems_rtl_sptr* handle)
183{
184 return rtems_rtl_ptr_null (&handle->ptr);
185}
186
194static inline void rtems_rtl_sptr_move (rtems_rtl_sptr* dst, rtems_rtl_sptr* src)
195{
196 rtems_rtl_ptr_move (&dst->ptr, &src->ptr);
197 dst->size = src->size;
198 src->size = 0;
199}
200
207static inline size_t rtems_rtl_sptr_get_size (rtems_rtl_sptr* handle)
208{
209 return handle->size;
210}
211
218static inline void rtems_rtl_sptr_set_size (rtems_rtl_sptr* handle, size_t size)
219{
220 handle->size = size;
221}
222
229#define rtems_rtl_sptr_type_get(_h, _t) ((_t*) rtems_rtl_sptr_get (_h))
230
231#ifdef __cplusplus
232}
233#endif /* __cplusplus */
234
235#endif
NULL
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
chain.h
Chain API.
rtems_chain_insert_unprotected
RTEMS_INLINE_ROUTINE void rtems_chain_insert_unprotected(rtems_chain_node *after_node, rtems_chain_node *the_node)
See _Chain_Insert_unprotected().
Definition: chain.h:650
rtems_chain_extract_unprotected
RTEMS_INLINE_ROUTINE void rtems_chain_extract_unprotected(rtems_chain_node *the_node)
Extract the specified node from a chain (unprotected).
Definition: chain.h:590
rtems_chain_set_off_chain
RTEMS_INLINE_ROUTINE void rtems_chain_set_off_chain(rtems_chain_node *node)
Set off chain.
Definition: chain.h:183
Chain_Node_struct
Definition: chain.h:68
rtems_rtl_ptr_chain
Definition: rtl-indirect-ptr.h:52
rtems_rtl_ptr_chain::ptr
rtems_rtl_ptr ptr
Definition: rtl-indirect-ptr.h:54
rtems_rtl_ptr_chain::node
rtems_chain_node node
Definition: rtl-indirect-ptr.h:53
rtems_rtl_ptr
Definition: rtl-indirect-ptr.h:29
rtems_rtl_ptr::node
rtems_chain_node node
Definition: rtl-indirect-ptr.h:30
rtems_rtl_ptr::pointer
void * pointer
Definition: rtl-indirect-ptr.h:31
rtems_rtl_sptr_chain
Definition: rtl-indirect-ptr.h:65
rtems_rtl_sptr_chain::ptr
rtems_rtl_sptr ptr
Definition: rtl-indirect-ptr.h:67
rtems_rtl_sptr_chain::node
rtems_chain_node node
Definition: rtl-indirect-ptr.h:66
rtems_rtl_sptr
Definition: rtl-indirect-ptr.h:39
rtems_rtl_sptr::ptr
rtems_rtl_ptr ptr
Definition: rtl-indirect-ptr.h:40
rtems_rtl_sptr::size
size_t size
Definition: rtl-indirect-ptr.h:41