source: rtems/cpukit/include/rtems/score/freechain.h @ 21275b58

5
Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on 11/22/18 at 18:14:51

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreFreechain
5 *
6 * @brief Freechain Handler API
7 */
8/*
9 * Copyright (c) 2013 Gedare Bloom.
10 *
11 * The license and distribution terms for this file may be
12 * found in the file LICENSE in this distribution or at
13 * http://www.rtems.org/license/LICENSE.
14 */
15
16#ifndef _RTEMS_SCORE_FREECHAIN_H
17#define _RTEMS_SCORE_FREECHAIN_H
18
19#include <rtems/score/basedefs.h>
20#include <rtems/score/chainimpl.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/**
27 * @defgroup ScoreFreechain Freechain Handler
28 *
29 * @ingroup Score
30 *
31 * The Freechain Handler is used to manage a chain of nodes, of which size can
32 * automatically increase when there is no free node left. This handler
33 * provides one data structure: Freechain_Control.
34 *
35 * @{
36 */
37
38/**
39 * @brief Allocator function.
40 */
41typedef void *( *Freechain_Allocator )( size_t size );
42
43/**
44 * @brief The freechain control.
45 */
46typedef struct {
47  /**
48   * @brief Chain of free nodes.
49   */
50  Chain_Control Free;
51} Freechain_Control;
52
53/**
54 * @brief Initializes a freechain.
55 *
56 * This routine initializes the freechain control structure to manage a chain
57 * of nodes.  In case the freechain is empty the extend handler is called to
58 * get more nodes.
59 *
60 * @param[in] freechain The freechain control to initialize.
61 * @param[in] initial_nodes Array with the initial nodes.
62 * @param[in] number_nodes The initial number of nodes.
63 * @param[in] node_size The node size.
64 */
65RTEMS_INLINE_ROUTINE void _Freechain_Initialize(
66  Freechain_Control   *freechain,
67  void                *initial_nodes,
68  size_t               number_nodes,
69  size_t               node_size
70)
71{
72  _Chain_Initialize(
73    &freechain->Free,
74    initial_nodes,
75    number_nodes,
76    node_size
77  );
78}
79
80/**
81 * @brief Gets a node from the freechain.
82 *
83 * @param[in] freechain The freechain control.
84 * @param[in] allocator The allocator function.
85 * @param[in] number_nodes_to_extend The number of nodes in case an extend is
86 *   necessary due to an empty freechain.
87 * @param[in] node_size The node size.
88 *
89 * @retval NULL The freechain is empty and the extend operation failed.
90 * @retval otherwise Pointer to a node.  The node ownership passes to the
91 * caller.
92 */
93void *_Freechain_Get(
94  Freechain_Control   *freechain,
95  Freechain_Allocator  allocator,
96  size_t               number_nodes_to_extend,
97  size_t               node_size
98);
99
100/**
101 * @brief Puts a node back onto the freechain.
102 *
103 * @param[in] freechain The freechain control.
104 * @param[in] node The node to put back.  The node may be @c NULL, in this case
105 *   the function does nothing.
106 */
107void _Freechain_Put(
108  Freechain_Control *freechain,
109  void              *node
110);
111
112/**@}*/
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif
119/* end of include file */
Note: See TracBrowser for help on using the repository browser.