diff --git a/docs/doxygen/groups.dox b/docs/doxygen/groups.dox index 4da1ff4d..6e1a92f1 100644 --- a/docs/doxygen/groups.dox +++ b/docs/doxygen/groups.dox @@ -12,5 +12,6 @@ @defgroup types @defgroup string @defgroup bitutils + @defgroup stdversion @defgroup trap Interrupt and exception handling */ diff --git a/docs/source/pages/api/libs/stdbigos/version.rst b/docs/source/pages/api/libs/stdbigos/version.rst new file mode 100644 index 00000000..68d816db --- /dev/null +++ b/docs/source/pages/api/libs/stdbigos/version.rst @@ -0,0 +1,5 @@ +======= +Version +======= + +.. doxygengroup:: stdversion diff --git a/docs/source/pages/bigos/general/versioning.rst b/docs/source/pages/bigos/general/versioning.rst index 3874c2dd..94267d18 100644 --- a/docs/source/pages/bigos/general/versioning.rst +++ b/docs/source/pages/bigos/general/versioning.rst @@ -2,13 +2,66 @@ Versioning ========== :Author: Oskar Meler -:Date: 24-02-2026 -:Revision: 1 +:Date: 19-05-2026 +:Revision: 2 -All version numbers in BigOS follow the `Major.Minor.Patch` format. -* **Major** – Increment this when changes are made to existing interfaces that break backward compatibility. +Versioning Scheme +----------------- -* **Minor** – Increment this when additions or backward-compatible changes are made to the interface. +All BigOS version numbers follow the ``generation.feature.patch`` format. -* **Patch** – Increment this for bug fixes or other non-breaking corrections. +Generation +^^^^^^^^^^ +Incremented when breaking changes are made to existing interfaces or formats. +A change in Generation indicates **backward-incompatible modifications**. + +Feature +^^^^^^^ +Incremented when new functionality is added in a backward-compatible manner. +Feature updates do not break compatibility with older versions within the same Generation. + +Patch +^^^^^ +Incremented for bug fixes, internal improvements, and other non-breaking changes that do not affect interface behavior or compatibility. + + +Data Format vs Software Version +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +BigOS distinguishes between: + +Client version + The version of the running BigOS implementation (the consumer). + +Interface version + The version of the interface contract being consumed. + +The compatibility rules define whether a given client version can correctly interact with a given interface version. + + +Compatibility Rule +~~~~~~~~~~~~~~~~~~ + +A client version ``C`` is compatible with an interface version ``I`` if and only if the following conditions are met: + +- C.generation == I.generation +- C.feature ≥ I.feature + +Patch versions do not affect compatibility. + + +Version Limits +~~~~~~~~~~~~~~ + +Version components are constrained as follows: + +- Generation ≤ 65535 +- Feature ≤ 65535 +- Patch ≤ 65535 + + +Implementation Notes +~~~~~~~~~~~~~~~~~~~~ + +stdbigos provides a :doc:`utility library ` for working with version values. diff --git a/include/stdbigos/version.h b/include/stdbigos/version.h new file mode 100644 index 00000000..5a377c33 --- /dev/null +++ b/include/stdbigos/version.h @@ -0,0 +1,30 @@ +#ifndef STDBIGOS_VERSION +#define STDBIGOS_VERSION + +/// @addtogroup stdbigos +/// @{ +/// @addtogroup stdversion +/// @{ + +#include "stdbigos/types.h" + +typedef struct { + u16 generation; + u16 feature; + u16 patch; +} version_t; + +typedef u64 version_packed_t; + +version_t version_make(u16 generation, u16 feature, u16 patch); + +version_packed_t version_pack(version_t v); +version_t version_unpack(version_packed_t v); + +bool version_is_compatible(version_t current, version_t required); +bool version_packed_is_compatible(version_packed_t current, version_packed_t required); + +/// @} +/// @} + +#endif // !STDBIGOS_VERSION diff --git a/src/lib/stdbigos/version.c b/src/lib/stdbigos/version.c new file mode 100644 index 00000000..5de7f708 --- /dev/null +++ b/src/lib/stdbigos/version.c @@ -0,0 +1,29 @@ +#include "stdbigos/version.h" + +version_t version_make(u16 generation, u16 feature, u16 patch) { + return (version_t){.generation = generation, .feature = feature, .patch = patch}; +} + +version_packed_t version_pack(version_t v) { + version_packed_t generation_packed = ((version_packed_t)v.generation) << 32; + version_packed_t feature_packed = ((version_packed_t)v.feature) << 16; + version_packed_t patch_packed = ((version_packed_t)v.patch); + return generation_packed | feature_packed | patch_packed; +} + +version_t version_unpack(version_packed_t v) { + u16 generation = v >> 32; + u16 feature = (v >> 16); + u16 patch = v; + return (version_t){.generation = generation, .feature = feature, .patch = patch}; +} + +bool version_is_compatible(version_t current, version_t required) { + return current.generation == required.generation && current.feature >= required.feature; +} + +bool version_packed_is_compatible(version_packed_t current, version_packed_t required) { + version_t currentu = version_unpack(current); + version_t requiredu = version_unpack(required); + return currentu.generation == requiredu.generation && currentu.feature >= requiredu.feature; +}