RTEMS  5.1
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
21 extern "C" {
22 #endif /* __cplusplus */
23 
24 #include <rtems/chain.h>
25 
29 struct rtems_rtl_ptr {
31  void* pointer;
32 };
33 
34 typedef struct rtems_rtl_ptr rtems_rtl_ptr;
35 
41  size_t size;
42 };
43 
44 typedef struct rtems_rtl_sptr rtems_rtl_sptr;
45 
55 };
56 
58 
68 };
69 
71 
78 static inline void* rtems_rtl_ptr_get (rtems_rtl_ptr* handle)
79 {
80  return handle->pointer;
81 }
82 
89 static inline void rtems_rtl_ptr_set (rtems_rtl_ptr* handle, void* pointer)
90 {
91  handle->pointer = pointer;
92 }
93 
99 static 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 
111 static inline bool rtems_rtl_ptr_null (rtems_rtl_ptr* handle)
112 {
113  return handle->pointer == NULL;
114 }
115 
123 static 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  */
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 
149 static inline void* rtems_rtl_sptr_get (rtems_rtl_sptr* handle)
150 {
151  return rtems_rtl_ptr_get (&handle->ptr);
152 }
153 
160 static inline void rtems_rtl_sptr_set (rtems_rtl_sptr* handle, void* pointer)
161 {
162  rtems_rtl_ptr_set (&handle->ptr, pointer);
163 }
164 
170 static inline void rtems_rtl_sptr_init (rtems_rtl_sptr* handle)
171 {
172  rtems_rtl_ptr_init (&handle->ptr);
173  handle->size = 0;
174 }
175 
182 static inline bool rtems_rtl_sptr_null (rtems_rtl_sptr* handle)
183 {
184  return rtems_rtl_ptr_null (&handle->ptr);
185 }
186 
194 static 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 
207 static inline size_t rtems_rtl_sptr_get_size (rtems_rtl_sptr* handle)
208 {
209  return handle->size;
210 }
211 
218 static 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
void * pointer
Definition: rtl-indirect-ptr.h:31
Definition: chain.h:68
rtems_rtl_ptr ptr
Definition: rtl-indirect-ptr.h:40
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
Definition: rtl-indirect-ptr.h:29
rtems_chain_node node
Definition: rtl-indirect-ptr.h:53
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_rtl_sptr ptr
Definition: rtl-indirect-ptr.h:67
size_t size
Definition: rtl-indirect-ptr.h:41
RTEMS_INLINE_ROUTINE void rtems_chain_set_off_chain(rtems_chain_node *node)
Set off chain.
Definition: chain.h:183
Chain API.
Definition: rtl-indirect-ptr.h:65
rtems_chain_node node
Definition: rtl-indirect-ptr.h:66
unsigned size
Definition: tte.h:74
rtems_rtl_ptr ptr
Definition: rtl-indirect-ptr.h:54
Definition: rtl-indirect-ptr.h:52
Definition: rtl-indirect-ptr.h:39
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
rtems_chain_node node
Definition: rtl-indirect-ptr.h:30