diff options
author | Alan Antonuk <alan.antonuk@gmail.com> | 2013-07-02 13:57:33 -0700 |
---|---|---|
committer | Alan Antonuk <alan.antonuk@gmail.com> | 2013-07-23 09:53:10 -0700 |
commit | 8efc95955770989b3d09c011bc3e311f84787f1d (patch) | |
tree | 165356fb50a17b5b657bacf60126c1f5ab882311 | |
parent | 866255fc608e4c562c1bad90f0afb0c391e6ce49 (diff) | |
download | rabbitmq-c-github-ask-8efc95955770989b3d09c011bc3e311f84787f1d.tar.gz |
Add compile and runtime library version functions
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | cmake/config.h.in | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | librabbitmq/amqp.h | 88 | ||||
-rw-r--r-- | librabbitmq/amqp_mem.c | 7 |
5 files changed, 95 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4db4e5c..9fd39a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,6 @@ project(rabbitmq-c "C") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -set(RMQ_VERSION_MAJOR 0) -set(RMQ_VERSION_MINOR 3) -set(RMQ_VERSION_PATCH 0) - # Follow all steps below in order to calculate new ABI version when updating the library # NOTE: THIS IS UNRELATED to the actual project version # @@ -27,8 +23,6 @@ math(EXPR RMQ_SOVERSION_PATCH "${RMQ_SOVERSION_REVISION}") set(RMQ_VERSION ${RMQ_SOVERSION_MAJOR}.${RMQ_SOVERSION_MINOR}.${RMQ_SOVERSION_PATCH}) set(RMQ_SOVERSION ${RMQ_SOVERSION_MAJOR}) -set(VERSION ${RMQ_VERSION_MAJOR}.${RMQ_VERSION_MINOR}.${RMQ_VERSION_PATCH}) - if (MSVC) set(CMAKE_C_FLAGS "/W4 /nologo ${CMAKE_C_FLAGS}") elseif (CMAKE_COMPILER_IS_GNUCC) diff --git a/cmake/config.h.in b/cmake/config.h.in index 9535d66..e7a83c4 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -2,8 +2,6 @@ #ifndef CONFIG_H #define CONFIG_H -#define VERSION "${VERSION}" - #ifndef __cplusplus # define inline ${C_INLINE_KEYWORD} #endif diff --git a/configure.ac b/configure.ac index 931a22b..c92af48 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ([2.59]) m4_define([major_version], [0]) -m4_define([minor_version], [3]) +m4_define([minor_version], [4]) m4_define([micro_version], [0]) # Follow all steps below in order to calculate new ABI version when updating the library diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h index 7da8ac3..b3a5aaa 100644 --- a/librabbitmq/amqp.h +++ b/librabbitmq/amqp.h @@ -157,6 +157,94 @@ struct timeval; AMQP_BEGIN_DECLS /** + * @def AMQP_VERSION_MAJOR major version number constant + * + * The major version is incremented when backwards incompatible API changes + * are made. + */ +/** + * @ def AMQP_VERSION_MINOR minor version number constant + * + * The minor version is incremented when new APIs are added. Existing APIs + * are left alone. + */ +/** + * @def AMQP_VERSION_PATCH patch version number constant + * + * The patch version is incremented when library code changes, but the API + * is not changed. + */ +/** + * @def AMQP_VERSION_IS_RELEASE constant set to 1 for tagged release, 0 otherwise + * + * NOTE: versions that are not tagged releases are not guaranteed to be API/ABI + * compatible with older releases, and may change commit-to-commit. + */ +/* + * Developer note: when changing these, be sure to update SOVERSION constants + * in CMakeLists.txt and configure.ac + */ +#define AMQP_VERSION_MAJOR 0 +#define AMQP_VERSION_MINOR 4 +#define AMQP_VERSION_PATCH 0 +#define AMQP_VERSION_IS_RELEASE 0 + +/** + * @def AMQP_VERSION is a packed version number + * + * AMQP_VERSION is a 4-byte unsigned integer with the high byte set to the + * major version, next byte set to the minor version, the next byte the patch + * version, and the lowest byte set to 1 for released versions, 0 otherwise. + * + * Version 2.3.4 which is released version would be encoded as 0x02030401 + */ +#define AMQP_VERSION ((AMQP_VERSION_MAJOR << 24) | \ + (AMQP_VERSION_MINOR << 16) | \ + (AMQP_VERSION_PATCH << 8) | \ + (AMQP_VERSION_IS_RELEASE)) + +#define AMQ_STRINGIFY(s) AMQ_STRINGIFY_HELPER(s) +#define AMQ_STRINGIFY_HELPER(s) #s + +#define AMQ_VERSION_STRING AMQ_STRINGIFY(AMQP_VERSION_MAJOR) "." \ + AMQ_STRINGIFY(AMQP_VERSION_MINOR) "." \ + AMQ_STRINGIFY(AMQP_VERSION_PATCH) + +/** + * @def AMQP_VERSION_STRING is a string representation of AMQP_VERSION. + * Non-released versions of the library will have "-pre" appended to the + * version string + */ +#if AMQP_VERSION_IS_RELEASE +# define AMQP_VERSION_STRING AMQ_VERSION_STRING +#else +# define AMQP_VERSION_STRING AMQ_VERSION_STRING "-pre" +#endif + + +/** + * Returns the rabbitmq-c version as a packed integer. + * + * See \ref AMQP_VERSION + * + * @return packed 32-bit integer representing version of library at runtime + */ +AMQP_PUBLIC_FUNCTION +uint32_t +AMQP_CALL amqp_version_number(void); + +/** + * Returns the rabbitmq-c version as a string. + * + * See \ref AMQP_VERSION_STRING + * + * @return a statically allocated string describing the version of rabbitmq-c. + */ +AMQP_PUBLIC_FUNCTION +char const * +AMQP_CALL amqp_version(void); + +/** * Default frame size */ #define AMQP_DEFAULT_FRAME_SIZE 131072 diff --git a/librabbitmq/amqp_mem.c b/librabbitmq/amqp_mem.c index 88b1e9f..586117e 100644 --- a/librabbitmq/amqp_mem.c +++ b/librabbitmq/amqp_mem.c @@ -48,7 +48,12 @@ char const *amqp_version(void) { - return VERSION; /* defined in config.h */ + return AMQP_VERSION_STRING; +} + +uint32_t amqp_version_number(void) +{ + return AMQP_VERSION; } void init_amqp_pool(amqp_pool_t *pool, size_t pagesize) |