RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
31 void* pointer;
32};
33
34typedef struct rtems_rtl_ptr rtems_rtl_ptr;
35
41 size_t size;
42};
43
44typedef struct rtems_rtl_sptr rtems_rtl_sptr;
45
55};
56
58
68};
69
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{
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 */
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
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
Chain API.
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_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_INLINE_ROUTINE void rtems_chain_set_off_chain(rtems_chain_node *node)
Set off chain.
Definition: chain.h:183
Definition: chain.h:68
Definition: rtl-indirect-ptr.h:52
rtems_rtl_ptr ptr
Definition: rtl-indirect-ptr.h:54
rtems_chain_node node
Definition: rtl-indirect-ptr.h:53
Definition: rtl-indirect-ptr.h:29
rtems_chain_node node
Definition: rtl-indirect-ptr.h:30
void * pointer
Definition: rtl-indirect-ptr.h:31
Definition: rtl-indirect-ptr.h:65
rtems_rtl_sptr ptr
Definition: rtl-indirect-ptr.h:67
rtems_chain_node node
Definition: rtl-indirect-ptr.h:66
Definition: rtl-indirect-ptr.h:39
rtems_rtl_ptr ptr
Definition: rtl-indirect-ptr.h:40
size_t size
Definition: rtl-indirect-ptr.h:41
unsigned size
Definition: tte.h:1