source: rtems/cpukit/score/include/rtems/score/freechain.h @ 64939bc

4.115
Last change on this file since 64939bc was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.3 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 <stdbool.h>
20
21#include <rtems/score/chain.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/**
28 * @defgroup ScoreFreechain Freechain Handler
29 *
30 * @ingroup Score
31 *
32 * The Freechain Handler is used to manage a chain of nodes, of which size can
33 * automatically increase when there is no free node left. This handler
34 * provides one data structure: Freechain_Control.
35 *
36 * @{
37 */
38
39typedef struct Freechain_Control Freechain_Control;
40
41/**
42 * @brief Extends the freechain.
43 *
44 * @param[in] freechain The freechain control.
45 *
46 * @retval true The freechain contains now at least one node.
47 * @retval false Otherwise.
48 */
49typedef bool ( *Freechain_Extend )( Freechain_Control *freechain );
50
51/**
52 * @typedef Freechain_Control
53 *
54 * This is used to manage freechain's nodes.
55 */
56struct Freechain_Control {
57  Chain_Control     Freechain;
58  Freechain_Extend  extend;
59};
60
61/**
62 * @brief Initializes a freechain.
63 *
64 * This routine initializes the freechain control structure to manage a chain
65 * of nodes.  In case the freechain is empty the extend handler is called to
66 * get more nodes.
67 *
68 * @param[in,out] freechain The freechain control to initialize.
69 * @param[in] extend The extend handler.  It is called by _Freechain_Get() in
70 * case the freechain is empty.
71 */
72void _Freechain_Initialize(
73  Freechain_Control *freechain,
74  Freechain_Extend   extend
75);
76
77/**
78 * @brief Gets a node from the freechain.
79 *
80 * @param[in,out] freechain The freechain control.
81 *
82 * @retval NULL The freechain is empty and the extend operation failed.
83 * @retval otherwise Pointer to a node.  The node ownership passes to the
84 * caller.
85 */
86void *_Freechain_Get(
87  Freechain_Control *freechain
88);
89
90/**
91 * @brief Puts a node back onto the freechain.
92 *
93 * @param[in,out] freechain The freechain control.
94 * @param[in] node The node to put back.
95 */
96void _Freechain_Put(
97  Freechain_Control *freechain,
98  void              *node
99);
100
101/**@}*/
102
103#ifdef __cplusplus
104}
105#endif
106
107#endif
108/* end of include file */
Note: See TracBrowser for help on using the repository browser.