Skip to content

Commit a275c6f

Browse files
committed
added a utility library for version and updated docs
1 parent 7814761 commit a275c6f

5 files changed

Lines changed: 124 additions & 6 deletions

File tree

docs/doxygen/groups.dox

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
@defgroup types
1313
@defgroup string
1414
@defgroup bitutils
15+
@defgroup stdversion
1516
@defgroup trap Interrupt and exception handling
1617
*/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=======
2+
Version
3+
=======
4+
5+
.. doxygengroup:: stdversion

docs/source/pages/bigos/general/versioning.rst

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,66 @@ Versioning
22
==========
33

44
:Author: Oskar Meler
5-
:Date: 24-02-2026
6-
:Revision: 1
5+
:Date: 19-05-2026
6+
:Revision: 2
77

8-
All version numbers in BigOS follow the `Major.Minor.Patch` format.
98

10-
* **Major** – Increment this when changes are made to existing interfaces that break backward compatibility.
9+
Versioning Scheme
10+
-----------------
1111

12-
* **Minor** – Increment this when additions or backward-compatible changes are made to the interface.
12+
All BigOS version numbers follow the ``generation.feature.patch`` format.
1313

14-
* **Patch** – Increment this for bug fixes or other non-breaking corrections.
14+
Generation
15+
^^^^^^^^^^
16+
Incremented when breaking changes are made to existing interfaces or formats.
17+
A change in Generation indicates **backward-incompatible modifications**.
18+
19+
Feature
20+
^^^^^^^
21+
Incremented when new functionality is added in a backward-compatible manner.
22+
Feature updates do not break compatibility with older versions within the same Generation.
23+
24+
Patch
25+
^^^^^
26+
Incremented for bug fixes, internal improvements, and other non-breaking changes that do not affect interface behavior or compatibility.
27+
28+
29+
Data Format vs Software Version
30+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31+
32+
BigOS distinguishes between:
33+
34+
Software version (S)
35+
The version of the running BigOS implementation (the reader/consumer).
36+
37+
Data format version (F)
38+
The version of the serialized or on-disk data being interpreted.
39+
40+
The compatibility rules define whether a given software version can correctly read a given data format version.
41+
42+
43+
Compatibility Rule
44+
~~~~~~~~~~~~~~~~~~
45+
46+
A software version ``S`` is compatible with a data format version ``F`` if and only if the following conditions are met:
47+
48+
- S.generation == F.generation
49+
- S.feature ≥ F.feature
50+
51+
Patch versions do not affect compatibility.
52+
53+
54+
Version Limits
55+
~~~~~~~~~~~~~~
56+
57+
Version components are constrained as follows:
58+
59+
- Generation ≤ 1024
60+
- Feature ≤ 1024
61+
- Patch ≤ 4096
62+
63+
64+
Implementation Notes
65+
~~~~~~~~~~~~~~~~~~~~
66+
67+
stdbigos provides a :doc:`utility library </pages/api/libs/stdbigos/version>` for working with version values.

include/stdbigos/version.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef STDBIGOS_VERSION
2+
#define STDBIGOS_VERSION
3+
4+
/// @addtogroup stdbigos
5+
/// @{
6+
/// @addtogroup stdversion
7+
/// @{
8+
9+
#include "stdbigos/types.h"
10+
11+
typedef struct {
12+
u16 generation;
13+
u16 feature;
14+
u16 patch;
15+
} version_t;
16+
17+
typedef u32 version_packed_t;
18+
19+
version_t version_make(u16 generation, u16 feature, u16 patch);
20+
21+
version_packed_t version_pack(version_t v);
22+
version_t version_unpack(version_packed_t v);
23+
24+
bool version_is_compatible(version_t current, version_t required);
25+
bool version_packed_is_compatible(version_packed_t current, version_packed_t required);
26+
27+
/// @}
28+
/// @}
29+
30+
#endif // !STDBIGOS_VERSION

src/lib/stdbigos/version.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "stdbigos/version.h"
2+
3+
version_t version_make(u16 generation, u16 feature, u16 patch) {
4+
return (version_t){.generation = generation, .feature = feature, .patch = patch};
5+
}
6+
7+
version_packed_t version_pack(version_t v) {
8+
version_packed_t generation_packed = ((version_packed_t)v.generation & 0x3ffull) << 22;
9+
version_packed_t feature_packed = ((version_packed_t)v.feature & 0x3ffull) << 12;
10+
version_packed_t patch_packed = ((version_packed_t)v.patch & 0xfffull);
11+
return generation_packed | feature_packed | patch_packed;
12+
}
13+
14+
version_t version_unpack(version_packed_t v) {
15+
version_packed_t generation = v >> 22;
16+
version_packed_t feature = (v >> 12) & 0x3ffull;
17+
version_packed_t patch = v & 0xfffull;
18+
return (version_t){.generation = generation, .feature = feature, .patch = patch};
19+
}
20+
21+
bool version_is_compatible(version_t current, version_t required) {
22+
return current.generation == required.generation && current.feature >= required.feature;
23+
}
24+
25+
bool version_packed_is_compatible(version_packed_t current, version_packed_t required) {
26+
version_t currentu = version_unpack(current);
27+
version_t requiredu = version_unpack(required);
28+
return currentu.generation == requiredu.generation && currentu.feature >= requiredu.feature;
29+
}

0 commit comments

Comments
 (0)