KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
Utilities

Utilities for creating version info and checks. More...

Version Encoding

Utilities for encoding a version from its components.

#define KOS_VERSION_MAKE(major, minor, patch)
 Creates a version identifier from its constituents.
 
#define KOS_VERSION_MAKE_STRING(major, minor, patch)
 Creates a version string from its constituents.
 

Version Checking

Utilities for creating version checks.

#define KOS_VERSION_MAKE_COMPARISON(major, minor, patch, op, version)
 Creates a generic check against a given version.
 
#define KOS_VERSION_MAKE_ABOVE(major, minor, patch, version)
 Creates a check for being above a given version.
 
#define KOS_VERSION_MAKE_MIN(major, minor, patch, version)
 Creates a minimum version check.
 
#define KOS_VERSION_MAKE_IS(major, minor, patch, version)
 Creates an exact version check.
 
#define KOS_VERSION_MAKE_MAX(major, minor, patch, version)
 Creates a maximum version check.
 
#define KOS_VERSION_MAKE_BELOW(major, minor, patch, version)
 Creates a check for being below a given version.
 

Detailed Description

Utilities for creating version info and checks.

These are generalized utilities for construction of version info at compile-time. They are what KOS uses internally, but they can also be used externally to generate version info and version check utilities for your application.

Note
The ranges for the components of a version ID are as follows:
Component Bits Range
Major 8 0-255
Minor 8 0-255
Patch 8 0-255

Macro Definition Documentation

◆ KOS_VERSION_MAKE

#define KOS_VERSION_MAKE ( major,
minor,
patch )
Value:
(((major) << 16) | ((minor) << 8) | (patch))

Creates a version identifier from its constituents.

Used to create a version identifier at compile-time from its components.

Parameters
majorMajor version component.
minorMinor version component.
patchPatch version component.
Returns
Packed version identifier.

◆ KOS_VERSION_MAKE_ABOVE

#define KOS_VERSION_MAKE_ABOVE ( major,
minor,
patch,
version )
Value:
(KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <, version))
#define KOS_VERSION_MAKE_COMPARISON(major, minor, patch, op, version)
Creates a generic check against a given version.
Definition version.h:289

Creates a check for being above a given version.

Used to create a compile-time greater-than check against another version.

Note
Simply wrap this in a function to implement a runtime check.
Parameters
majorMajor version component.
minorMinor version component.
patchPatch version component.
versionThe reference version ID.
Return values
trueThe given version is above version.
falseThe given version is at or below version.

◆ KOS_VERSION_MAKE_BELOW

#define KOS_VERSION_MAKE_BELOW ( major,
minor,
patch,
version )
Value:
(KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >, version))

Creates a check for being below a given version.

Used to create a compile-time less-than check against another version.

Note
Simply wrap this in a function to implement a runtime check.
Parameters
majorMajor version component.
minorMinor version component.
patchPatch version component.
versionThe reference version ID.
Return values
trueThe given version is below version.
falseThe given version is at or above version.

◆ KOS_VERSION_MAKE_COMPARISON

#define KOS_VERSION_MAKE_COMPARISON ( major,
minor,
patch,
op,
version )
Value:
(KOS_VERSION_MAKE(major, minor, patch) op (version & 0xffffff))
#define KOS_VERSION_MAKE(major, minor, patch)
Creates a version identifier from its constituents.
Definition version.h:251

Creates a generic check against a given version.

Bottom-level macro used to create all compile-time comparison checks against other versions.

Parameters
majorMajor version component.
minorMinor version component.
patchPatch version component.
opInteger comparison operator (<=, >=, !=, ==, etc)/
versionEncoded version to compare against.
Returns
Boolean value for the given version compared against version using op.

◆ KOS_VERSION_MAKE_IS

#define KOS_VERSION_MAKE_IS ( major,
minor,
patch,
version )
Value:
(KOS_VERSION_MAKE_COMPARISON(major, minor, patch, ==, version))

Creates an exact version check.

Used to create a compile-time exact version check.

Note
Simply wrap this in a function to implement a runtime check.
Parameters
majorMajor version component.
minorMinor version component.
patchPatch version component.
versionThe exact version ID to match.
Return values
trueThe given version matches version exactly.
falseThe given version does not match version.

◆ KOS_VERSION_MAKE_MAX

#define KOS_VERSION_MAKE_MAX ( major,
minor,
patch,
version )
Value:
(KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >=, version))

Creates a maximum version check.

Used to create a compile-time maximum version check.

Note
Simply wrap this in a function to implement a runtime check.
Parameters
majorMajor version component.
minorMinor version component.
patchPatch version component.
versionThe maximum version ID.
Return values
trueThe given version is at or below version.
falseThe given version is above version.

◆ KOS_VERSION_MAKE_MIN

#define KOS_VERSION_MAKE_MIN ( major,
minor,
patch,
version )
Value:
(KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <=, version))

Creates a minimum version check.

Used to create a compile-time minimum version check.

Note
Simply wrap this in a function to implement a runtime check.
Parameters
majorMajor version component.
minorMinor version component.
patchPatch version component.
versionThe minimum version ID.
Return values
trueThe given version is at or above version.
falseThe given version is below version.

◆ KOS_VERSION_MAKE_STRING

#define KOS_VERSION_MAKE_STRING ( major,
minor,
patch )
Value:
KOS_STRINGIFY(major) "." \
KOS_STRINGIFY(minor) "." \
KOS_STRINGIFY(patch)

Creates a version string from its constituents.

Used to create a compile-time string literal from version components.

Parameters
majorMajor version component.
minorMinor version component.
patchpatch versoin component.
Returns
NULL-terminated C string literal in the format major.minor.patch