ChibiOS  19.1.4
chtypes.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 templates/chtypes.h
22  * @brief System types template.
23  *
24  * @addtogroup port_types
25  * @details The types defined in this file may change depending on the target
26  * architecture. You may also try to optimize the size of the various
27  * types in order to privilege size or performance, be careful in
28  * doing so.
29  * @{
30  */
31 
32 #ifndef CHTYPES_H
33 #define CHTYPES_H
34 
35 #include <stddef.h>
36 #include <stdint.h>
37 #include <stdbool.h>
38 
39 /**
40  * @name Kernel types
41  * @{
42  */
43 typedef uint32_t rtcnt_t; /**< Realtime counter. */
44 typedef uint64_t rttime_t; /**< Realtime accumulator. */
45 typedef uint32_t syssts_t; /**< System status word. */
46 typedef uint8_t tmode_t; /**< Thread flags. */
47 typedef uint8_t tstate_t; /**< Thread state. */
48 typedef uint8_t trefs_t; /**< Thread references counter. */
49 typedef uint8_t tslices_t; /**< Thread time slices counter.*/
50 typedef uint32_t tprio_t; /**< Thread priority. */
51 typedef int32_t msg_t; /**< Inter-thread message. */
52 typedef int32_t eventid_t; /**< Numeric event identifier. */
53 typedef uint32_t eventmask_t; /**< Mask of event identifiers. */
54 typedef uint32_t eventflags_t; /**< Mask of event flags. */
55 typedef int32_t cnt_t; /**< Generic signed counter. */
56 typedef uint32_t ucnt_t; /**< Generic unsigned counter. */
57 /** @} */
58 
59 /**
60  * @brief ROM constant modifier.
61  * @note It is set to use the "const" keyword in this port.
62  */
63 #define ROMCONST const
64 
65 /**
66  * @brief Makes functions not inlineable.
67  * @note If the compiler does not support such attribute then the
68  * realtime counter precision could be degraded.
69  */
70 #define NOINLINE __attribute__((noinline))
71 
72 /**
73  * @brief Optimized thread function declaration macro.
74  */
75 #define PORT_THD_FUNCTION(tname, arg) void tname(void *arg)
76 
77 /**
78  * @brief Packed variable specifier.
79  */
80 #define PACKED_VAR __attribute__((packed))
81 
82 /**
83  * @brief Memory alignment enforcement for variables.
84  */
85 #define ALIGNED_VAR(n) __attribute__((aligned(n)))
86 
87 /**
88  * @brief Size of a pointer.
89  * @note To be used where the sizeof operator cannot be used, preprocessor
90  * expressions for example.
91  */
92 #define SIZEOF_PTR 4
93 
94 /**
95  * @brief True if alignment is low-high in current architecture.
96  */
97 #define REVERSE_ORDER 1
98 
99 #endif /* CHTYPES_H */
100 
101 /** @} */
uint32_t tprio_t
Definition: chtypes.h:50
int32_t cnt_t
Definition: chtypes.h:55
uint64_t rttime_t
Definition: chtypes.h:44
uint8_t tmode_t
Definition: chtypes.h:46
uint32_t ucnt_t
Definition: chtypes.h:56
uint8_t tslices_t
Definition: chtypes.h:49
uint32_t rtcnt_t
Definition: chtypes.h:43
uint8_t tstate_t
Definition: chtypes.h:47
uint32_t eventmask_t
Definition: chtypes.h:53
int32_t eventid_t
Definition: chtypes.h:52
uint8_t trefs_t
Definition: chtypes.h:48
uint32_t syssts_t
Definition: chtypes.h:45
uint32_t eventflags_t
Definition: chtypes.h:54
int32_t msg_t
Definition: chtypes.h:51