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

5
Last change on this file since e67929c was e67929c, checked in by Sebastian Huber <sebastian.huber@…>, on 09/21/17 at 12:13:16

posix: Implement self-contained POSIX barriers

POSIX barriers are now available in all configurations and no longer
depend on --enable-posix.

Update #2514.
Update #3114.

  • Property mode set to 100644
File size: 4.4 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_condition_variables;
115  uint32_t active_message_queues;
116  uint32_t active_mutexes;
117  uint32_t active_rwlocks;
118  uint32_t active_semaphores;
119  uint32_t active_threads;
120  uint32_t active_timers;
121} rtems_resource_posix_api;
122
123typedef struct {
124  Heap_Information_block workspace_info;
125  Heap_Information_block heap_info;
126  uint32_t active_posix_key_value_pairs;
127  uint32_t active_posix_keys;
128  rtems_resource_rtems_api rtems_api;
129  rtems_resource_posix_api posix_api;
130  int open_files;
131} rtems_resource_snapshot;
132
133/**
134 * @brief Tasks a snapshot of the resource usage of the system.
135 *
136 * @param[out] snapshot The snapshot of used resources.
137 *
138 * @see rtems_resource_snapshot_equal() and rtems_resource_snapshot_check().
139 *
140 * @code
141 * #include <assert.h>
142 *
143 * #include <rtems/libcsupport.h>
144 *
145 * void example(void)
146 * {
147 *   rtems_resource_snapshot before;
148 *
149 *   test_setup();
150 *   rtems_resource_snapshot_take(&before);
151 *   test();
152 *   assert(rtems_resource_snapshot_check(&before));
153 *   test_cleanup();
154 * }
155 * @endcode
156 */
157void rtems_resource_snapshot_take(rtems_resource_snapshot *snapshot);
158
159/**
160 * @brief Compares two resource snapshots for equality.
161 *
162 * @param[in] a One resource snapshot.
163 * @param[in] b Another resource snapshot.
164 *
165 * @retval true The resource snapshots are equal.
166 * @retval false Otherwise.
167 *
168 * @see rtems_resource_snapshot_take().
169 */
170bool rtems_resource_snapshot_equal(
171  const rtems_resource_snapshot *a,
172  const rtems_resource_snapshot *b
173);
174
175/**
176 * @brief Takes a new resource snapshot and checks that it is equal to the
177 * given resource snapshot.
178 *
179 * @param[in] snapshot The resource snapshot used for comparison with the new
180 * resource snapshot.
181 *
182 * @retval true The resource snapshots are equal.
183 * @retval false Otherwise.
184 *
185 * @see rtems_resource_snapshot_take().
186 */
187bool rtems_resource_snapshot_check(const rtems_resource_snapshot *snapshot);
188
189/** @} */
190
191#ifdef __cplusplus
192}
193#endif
194
195#endif
196/* end of include file */
Note: See TracBrowser for help on using the repository browser.