SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk_version.h
Go to the documentation of this file.
1/*
2 * SuperTinyKernel(TM) RTOS: Lightweight High-Performance Deterministic C++ RTOS for Embedded Systems.
3 *
4 * Source: https://github.com/SuperTinyKernel-RTOS
5 *
6 * Copyright (c) 2022-2026 Neutron Code Limited <stk@neutroncode.com>. All Rights Reserved.
7 * License: MIT License, see LICENSE for a full text.
8 */
9
10#ifndef STK_VERSION_H_
11#define STK_VERSION_H_
12
19
20// Version numbers are not overridable: a stray -D or an earlier #define must not change the version.
21// Checked with defined() rather than by value, so a 0 (e.g. patch) is caught as well.
22#if defined(STK_VERSION_MAJOR) || defined(STK_VERSION_MINOR) || defined(STK_VERSION_PATCH)
23 #error "STK_VERSION_MAJOR, STK_VERSION_MINOR and STK_VERSION_PATCH must not be defined outside of stk_version.h."
24#endif
25
32#define STK_VERSION_MAJOR 1
33
40#define STK_VERSION_MINOR 8
41
48#define STK_VERSION_PATCH 0
49
55#ifndef STK_VERSION_PRERELEASE
56 #define STK_VERSION_PRERELEASE ""
57#endif
58
64#ifdef STK_REVISION_HEADER
65 #include "stk_revision.h"
66#endif
67
74#ifndef STK_VERSION_REVISION
75 #define STK_VERSION_REVISION 0
76#endif
77
84#ifndef STK_VERSION_GIT_HASH
85 #define STK_VERSION_GIT_HASH "unknown"
86#endif
87
93#define STK_VERSION_STR_(x) #x
94
99#define STK_VERSION_STR(x) STK_VERSION_STR_(x)
100
106#if (STK_VERSION_MINOR < 10)
107 #define STK_MINOR_STR "0" STK_VERSION_STR(STK_VERSION_MINOR)
108#else
109 #define STK_MINOR_STR STK_VERSION_STR(STK_VERSION_MINOR)
110#endif
111
117#define STK_VERSION_STRING STK_VERSION_STR(STK_VERSION_MAJOR) "." \
118 STK_MINOR_STR "." \
119 STK_VERSION_STR(STK_VERSION_PATCH) \
120 STK_VERSION_PRERELEASE
121
130#define STK_VERSION_ENCODE(MAJ, MIN, PAT) \
131 ((((MAJ) & 0xFFUL) << 16) | (((MIN) & 0xFFUL) << 8) | ((PAT) & 0xFFUL))
132
138#define STK_VERSION_CODE \
139 STK_VERSION_ENCODE(STK_VERSION_MAJOR, STK_VERSION_MINOR, STK_VERSION_PATCH)
140
144#define STK_VERSION_CMSIS_RTOS2 \
145 ((STK_VERSION_MAJOR * 10000000UL) + (STK_VERSION_MINOR * 10000UL) + STK_VERSION_PATCH)
146
155#define STK_VERSION_AT_LEAST(MAJ, MIN, PAT) \
156 (STK_VERSION_CODE >= STK_VERSION_ENCODE(MAJ, MIN, PAT))
157
158// Each field must fit its byte of the packed code.
159#if (STK_VERSION_MAJOR > 255) || (STK_VERSION_MINOR > 255) || (STK_VERSION_PATCH > 255)
160 #error "STK version fields must be in the range 0..255."
161#endif
162
166#define STK_PACKAGE_NAME "SuperTinyKernel RTOS (STK)"
167
168#ifdef __cplusplus
169
173namespace stk {
174
179{
180 uint8_t major;
181 uint8_t minor;
182 uint8_t patch;
183 uint32_t code;
184 uint32_t revision;
185 const char *string;
186 const char *git_hash;
187};
188
193{
194 return VersionInfo {
195 .major = STK_VERSION_MAJOR,
196 .minor = STK_VERSION_MINOR,
197 .patch = STK_VERSION_PATCH,
198 .code = STK_VERSION_CODE,
199 .revision = STK_VERSION_REVISION,
200 .string = STK_VERSION_STRING,
201 .git_hash = STK_VERSION_GIT_HASH
202 };
203}
204
205} // namespace stk
206
207#endif // __cplusplus
208
209#endif /* STK_VERSION_H_ */
#define STK_VERSION_STRING
Version string literal: "1.08.0" or "1.08.0-rc1" (the minor number is zero-padded to two digits).
#define STK_VERSION_GIT_HASH
Build metadata: short git hash string.
Definition stk_version.h:85
#define STK_VERSION_MINOR
Minor version number.
Definition stk_version.h:40
#define STK_VERSION_PATCH
Patch version number.
Definition stk_version.h:48
#define STK_VERSION_MAJOR
Major version number.
Definition stk_version.h:32
#define STK_VERSION_CODE
Packed version, CMSIS-Core style (major in the upper halfword): 0x00MMmmpp.
#define STK_VERSION_REVISION
Build metadata: git commit count.
Definition stk_version.h:75
Namespace of STK package.
constexpr VersionInfo GetVersion()
Get version information.
Version information descriptor.
uint8_t minor
Minor version number.
const char * string
Version string: "1.08.0" or "1.08.0-rc1" (see STK_VERSION_STRING).
uint8_t major
Major version number.
const char * git_hash
Build metadata: short git hash, "<hash>-dirty" if modified, "unknown" if unavailable.
uint8_t patch
Patch version number.
uint32_t code
Packed version, STK_VERSION_CODE (0x00MMmmpp).
uint32_t revision
Build metadata: git commit count, 0 if unknown.