source: rtems/cpukit/libcsupport/include/rtems/libcsupport.h @ 25ba0cd

4.115
Last change on this file since 25ba0cd was 25ba0cd, checked in by Sebastian Huber <sebastian.huber@…>, on 01/09/13 at 19:39:26

libcsupport: Documentation

  • Property mode set to 100644
File size: 4.6 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.com/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 );
60extern void libc_init(void);
61extern int  host_errno(void);
62extern void fix_syscall_errno(void);
63
64/**
65 * @brief Get free malloc information.
66 *
67 * Find amount of free heap remaining
68 */
69extern size_t malloc_free_space(void);
70extern void open_dev_console(void);
71
72/**
73 * @brief Get malloc status information.
74 *
75 * Find amount of free heap remaining.
76 */
77extern int malloc_info(Heap_Information_block *the_info);
78
79/*
80 *  Prototypes required to install newlib reentrancy user extension
81 */
82bool newlib_create_hook(
83  rtems_tcb *current_task,
84  rtems_tcb *creating_task
85);
86
87#define __RTEMS_NEWLIB_BEGIN 0
88
89void newlib_delete_hook(
90  rtems_tcb *current_task,
91  rtems_tcb *deleted_task
92);
93
94#define RTEMS_NEWLIB_EXTENSION \
95{ \
96  newlib_create_hook,     /* rtems_task_create  */ \
97  0,                      /* rtems_task_start   */ \
98  0,                      /* rtems_task_restart */ \
99  newlib_delete_hook,     /* rtems_task_delete  */ \
100  0,                      /* task_switch  */ \
101  __RTEMS_NEWLIB_BEGIN,   /* task_begin   */ \
102  0,                      /* task_exitted */ \
103  0                       /* fatal        */ \
104}
105
106typedef struct {
107  uint32_t active_barriers;
108  uint32_t active_extensions;
109  uint32_t active_message_queues;
110  uint32_t active_partitions;
111  uint32_t active_periods;
112  uint32_t active_ports;
113  uint32_t active_regions;
114  uint32_t active_semaphores;
115  uint32_t active_tasks;
116  uint32_t active_timers;
117} rtems_resource_rtems_api;
118
119typedef struct {
120  uint32_t active_barriers;
121  uint32_t active_condition_variables;
122  uint32_t active_keys;
123  uint32_t active_message_queues;
124  uint32_t active_message_queue_descriptors;
125  uint32_t active_mutexes;
126  uint32_t active_rwlocks;
127  uint32_t active_semaphores;
128  uint32_t active_spinlocks;
129  uint32_t active_threads;
130  uint32_t active_timers;
131} rtems_resource_posix_api;
132
133typedef struct {
134  Heap_Information_block workspace_info;
135  Heap_Information_block heap_info;
136  rtems_resource_rtems_api rtems_api;
137  rtems_resource_posix_api posix_api;
138  int open_files;
139} rtems_resource_snapshot;
140
141/**
142 * @brief Tasks a snapshot of the resource usage of the system.
143 *
144 * @param[out] snapshot The snapshot of used resources.
145 *
146 * @see rtems_resource_snapshot_equal() and rtems_resource_snapshot_check().
147 *
148 * @code
149 * #include <assert.h>
150 *
151 * #include <rtems/libcsupport.h>
152 *
153 * void example(void)
154 * {
155 *   rtems_resource_snapshot before;
156 *
157 *   test_setup();
158 *   rtems_resource_snapshot_take(&before);
159 *   test();
160 *   assert(rtems_resource_snapshot_check(&before));
161 *   test_cleanup();
162 * }
163 * @endcode
164 */
165void rtems_resource_snapshot_take(rtems_resource_snapshot *snapshot);
166
167/**
168 * @brief Compares two resource snapshots for equality.
169 *
170 * @param[in] a One resource snapshot.
171 * @param[in] b Another resource snapshot.
172 *
173 * @retval true The resource snapshots are equal.
174 * @retval false Otherwise.
175 *
176 * @see rtems_resource_snapshot_take().
177 */
178bool rtems_resource_snapshot_equal(
179  const rtems_resource_snapshot *a,
180  const rtems_resource_snapshot *b
181);
182
183/**
184 * @brief Takes a new resource snapshot and checks that it is equal to the
185 * given resource snapshot.
186 *
187 * @param[in] snapshot The resource snapshot used for comparison with the new
188 * resource snapshot.
189 *
190 * @retval true The resource snapshots are equal.
191 * @retval false Otherwise.
192 *
193 * @see rtems_resource_snapshot_take().
194 */
195bool rtems_resource_snapshot_check(const rtems_resource_snapshot *snapshot);
196
197/** @} */
198
199#ifdef __cplusplus
200}
201#endif
202
203#endif
204/* end of include file */
Note: See TracBrowser for help on using the repository browser.