source: rtems/cpukit/libcsupport/include/rtems/libcsupport.h @ c8982e5

5
Last change on this file since c8982e5 was c8982e5, checked in by Sebastian Huber <sebastian.huber@…>, on 04/26/16 at 19:20:31

posix: Simplify message queues

The mq_open() function returns a descriptor to a POSIX message queue
object identified by a name. This is similar to sem_open(). In
contrast to the POSIX semaphore the POSIX message queues use a separate
object for the descriptor. This extra object is superfluous, since the
object identifier can be used directly for this purpose, just like for
the semaphores.

Update #2702.
Update #2555.

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief Standard C Library Support
5 *
6 * This include file contains the information regarding the
7 * RTEMS specific support for the standard C library.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2011.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_RTEMS_LIBCSUPPORT_H
20#define _RTEMS_RTEMS_LIBCSUPPORT_H
21
22#include <sys/types.h>
23#include <stdint.h>
24
25#include <rtems/score/heap.h>
26#include <rtems/rtems/tasks.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/**
33 * @defgroup libcsupport Standard C Library Support
34 *
35 * @brief RTEMS Specific Support for the Standard C Library
36 *
37 */
38/**@{**/
39
40extern void malloc_dump(void);
41
42/**
43 * @brief Malloc walk.
44 */
45extern bool malloc_walk(int source, bool printf_enabled);
46
47/**
48 * @brief Set malloc heap pointer.
49 *
50 * This routine is primarily used for debugging.
51 */
52void malloc_set_heap_pointer(Heap_Control *new_heap);
53
54/**
55 * @brief Get malloc heap pointer.
56 *
57 * This routine is primarily used for debugging.
58 */
59Heap_Control *malloc_get_heap_pointer( void );
60
61/**
62 * @brief Get free malloc information.
63 *
64 * Find amount of free heap remaining
65 */
66extern size_t malloc_free_space(void);
67
68/**
69 * @brief Get malloc status information.
70 *
71 * Find amount of free heap remaining.
72 */
73extern int malloc_info(Heap_Information_block *the_info);
74
75/*
76 *  Prototypes required to install newlib reentrancy user extension
77 */
78bool newlib_create_hook(
79  rtems_tcb *current_task,
80  rtems_tcb *creating_task
81);
82
83void newlib_terminate_hook(
84  rtems_tcb *current_task
85);
86
87#define RTEMS_NEWLIB_EXTENSION \
88{ \
89  newlib_create_hook,     /* rtems_task_create  */ \
90  0,                      /* rtems_task_start   */ \
91  0,                      /* rtems_task_restart */ \
92  0,                      /* rtems_task_delete  */ \
93  0,                      /* task_switch  */ \
94  0,                      /* task_begin   */ \
95  0,                      /* task_exitted */ \
96  0,                      /* fatal        */ \
97  newlib_terminate_hook   /* thread terminate */ \
98}
99
100typedef struct {
101  uint32_t active_barriers;
102  uint32_t active_extensions;
103  uint32_t active_message_queues;
104  uint32_t active_partitions;
105  uint32_t active_periods;
106  uint32_t active_ports;
107  uint32_t active_regions;
108  uint32_t active_semaphores;
109  uint32_t active_tasks;
110  uint32_t active_timers;
111} rtems_resource_rtems_api;
112
113typedef struct {
114  uint32_t active_barriers;
115  uint32_t active_condition_variables;
116  uint32_t active_message_queues;
117  uint32_t active_mutexes;
118  uint32_t active_rwlocks;
119  uint32_t active_semaphores;
120  uint32_t active_spinlocks;
121  uint32_t active_threads;
122  uint32_t active_timers;
123} rtems_resource_posix_api;
124
125typedef struct {
126  Heap_Information_block workspace_info;
127  Heap_Information_block heap_info;
128  uint32_t active_posix_key_value_pairs;
129  uint32_t active_posix_keys;
130  rtems_resource_rtems_api rtems_api;
131  rtems_resource_posix_api posix_api;
132  int open_files;
133} rtems_resource_snapshot;
134
135/**
136 * @brief Tasks a snapshot of the resource usage of the system.
137 *
138 * @param[out] snapshot The snapshot of used resources.
139 *
140 * @see rtems_resource_snapshot_equal() and rtems_resource_snapshot_check().
141 *
142 * @code
143 * #include <assert.h>
144 *
145 * #include <rtems/libcsupport.h>
146 *
147 * void example(void)
148 * {
149 *   rtems_resource_snapshot before;
150 *
151 *   test_setup();
152 *   rtems_resource_snapshot_take(&before);
153 *   test();
154 *   assert(rtems_resource_snapshot_check(&before));
155 *   test_cleanup();
156 * }
157 * @endcode
158 */
159void rtems_resource_snapshot_take(rtems_resource_snapshot *snapshot);
160
161/**
162 * @brief Compares two resource snapshots for equality.
163 *
164 * @param[in] a One resource snapshot.
165 * @param[in] b Another resource snapshot.
166 *
167 * @retval true The resource snapshots are equal.
168 * @retval false Otherwise.
169 *
170 * @see rtems_resource_snapshot_take().
171 */
172bool rtems_resource_snapshot_equal(
173  const rtems_resource_snapshot *a,
174  const rtems_resource_snapshot *b
175);
176
177/**
178 * @brief Takes a new resource snapshot and checks that it is equal to the
179 * given resource snapshot.
180 *
181 * @param[in] snapshot The resource snapshot used for comparison with the new
182 * resource snapshot.
183 *
184 * @retval true The resource snapshots are equal.
185 * @retval false Otherwise.
186 *
187 * @see rtems_resource_snapshot_take().
188 */
189bool rtems_resource_snapshot_check(const rtems_resource_snapshot *snapshot);
190
191/** @} */
192
193#ifdef __cplusplus
194}
195#endif
196
197#endif
198/* end of include file */
Note: See TracBrowser for help on using the repository browser.