7#include <ascii-chat/version.h>
18#if defined(__GNUC__) || defined(__clang__)
22__attribute__((used, section(
"__TEXT,__ascii_chat"))) const
char ascii_chat_custom_section[] =
23 ASCII_CHAT_DOT_ASCII_CHAT_STRING;
24__attribute__((used, section("__TEXT,__comment"))) const
char ascii_chat_comment_string[] =
25 ASCII_CHAT_DOT_COMMENT_STRING;
26__attribute__((used, section("__TEXT,__version"))) const
char ascii_chat_version_string[] = ASCII_CHAT_VERSION_FULL;
27#define ASCII_CHAT_VERSION_GETTERS
29#elif defined(__linux__)
31__attribute__((used, section(
".ascii_chat"))) const
char ascii_chat_custom_section[] = ASCII_CHAT_DOT_ASCII_CHAT_STRING;
32__attribute__((used, section(".comment"))) const
char ascii_chat_comment_string[] = ASCII_CHAT_DOT_COMMENT_STRING;
33__attribute__((used, section(".version"))) const
char ascii_chat_version_string[] = ASCII_CHAT_VERSION_FULL;
34#define ASCII_CHAT_VERSION_GETTERS
37#ifdef ASCII_CHAT_VERSION_GETTERS
39const char *ascii_chat_get_version(
void) {
40 return ascii_chat_version_string;
42const char *ascii_chat_get_comment(
void) {
43 return ascii_chat_comment_string;
50 semantic_version_t result = {0, 0, 0,
false};
52 if (!version_string || version_string[0] ==
'\0') {
56 const char *p = version_string;
59 if (p[0] ==
'v' || p[0] ==
'V') {
66 long major = strtol(p, &endptr, 10);
67 if (errno == ERANGE || endptr == p || major < 0 || major > INT_MAX) {
70 result.major = (int)major;
81 long minor = strtol(p, &endptr, 10);
82 if (errno == ERANGE || endptr == p || minor < 0 || minor > INT_MAX) {
85 result.minor = (int)minor;
96 long patch = strtol(p, &endptr, 10);
97 if (errno == ERANGE || endptr == p || patch < 0 || patch > INT_MAX) {
100 result.patch = (int)patch;
114 if (a.major < b.major) {
117 if (a.major > b.major) {
122 if (a.minor < b.minor) {
125 if (a.minor > b.minor) {
130 if (a.patch < b.patch) {
133 if (a.patch > b.patch) {
__attribute__((constructor))
Register fork handlers for common module.
int version_compare(semantic_version_t a, semantic_version_t b)
semantic_version_t version_parse(const char *version_string)