ChibiOS/RT  6.0.3
chdynamic.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio.
3 
4  This file is part of ChibiOS.
5 
6  ChibiOS is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  ChibiOS is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 /**
21  * @file chdynamic.h
22  * @brief Dynamic threads macros and structures.
23  *
24  * @addtogroup dynamic_threads
25  * @{
26  */
27 
28 #ifndef CHDYNAMIC_H
29 #define CHDYNAMIC_H
30 
31 #if (CH_CFG_USE_DYNAMIC == TRUE) || defined(__DOXYGEN__)
32 
33 /*===========================================================================*/
34 /* Module constants. */
35 /*===========================================================================*/
36 
37 /*===========================================================================*/
38 /* Module pre-compile time settings. */
39 /*===========================================================================*/
40 
41 /*===========================================================================*/
42 /* Derived constants and error checks. */
43 /*===========================================================================*/
44 
45 /*
46  * Module dependencies check.
47  */
48 #if CH_CFG_USE_WAITEXIT == FALSE
49 #error "CH_CFG_USE_DYNAMIC requires CH_CFG_USE_WAITEXIT"
50 #endif
51 
52 #if CH_CFG_USE_REGISTRY == FALSE
53 #error "CH_CFG_USE_DYNAMIC requires CH_CFG_USE_REGISTRY"
54 #endif
55 
56 #if (CH_CFG_USE_HEAP == FALSE) && (CH_CFG_USE_MEMPOOLS == FALSE)
57 #error "CH_CFG_USE_DYNAMIC requires CH_CFG_USE_HEAP and/or CH_CFG_USE_MEMPOOLS"
58 #endif
59 
60 /*===========================================================================*/
61 /* Module data structures and types. */
62 /*===========================================================================*/
63 
64 /*===========================================================================*/
65 /* Module macros. */
66 /*===========================================================================*/
67 
68 /*===========================================================================*/
69 /* External declarations. */
70 /*===========================================================================*/
71 
72 /*
73  * Dynamic threads APIs.
74  */
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 #if CH_CFG_USE_HEAP == TRUE
79  thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
80  const char *name, tprio_t prio,
81  tfunc_t pf, void *arg);
82 #endif
83 #if CH_CFG_USE_MEMPOOLS == TRUE
84  thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, const char *name,
85  tprio_t prio, tfunc_t pf, void *arg);
86 #endif
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 /*===========================================================================*/
92 /* Module inline functions. */
93 /*===========================================================================*/
94 
95 #endif /* CH_CFG_USE_DYNAMIC == TRUE */
96 
97 #endif /* CHDYNAMIC_H */
98 
99 /** @} */
Memory pool descriptor.
Definition: chmempools.h:64
thread_t * chThdCreateFromHeap(memory_heap_t *heapp, size_t size, const char *name, tprio_t prio, tfunc_t pf, void *arg)
Creates a new thread allocating the memory from the heap.
Definition: chdynamic.c:82
void(* tfunc_t)(void *p)
Thread function.
Definition: chthreads.h:52
thread_t * chThdCreateFromMemoryPool(memory_pool_t *mp, const char *name, tprio_t prio, tfunc_t pf, void *arg)
Creates a new thread allocating the memory from the specified memory pool.
Definition: chdynamic.c:145
Structure describing a memory heap.
Definition: chmemheaps.h:96
Structure representing a thread.
Definition: chschd.h:153