diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-02-08 17:54:00 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-03-26 01:22:17 +0100 |
commit | c39ac36e669e3dd5350761c29e774a8329604ad1 (patch) | |
tree | 6c7748326a8ab237440202eafa431b1845244771 /src | |
parent | 2898b001ea7ed85c15fc978b2fde446398a1e7b8 (diff) | |
download | slirp-c39ac36e669e3dd5350761c29e774a8329604ad1.zip slirp-c39ac36e669e3dd5350761c29e774a8329604ad1.tar.gz slirp-c39ac36e669e3dd5350761c29e774a8329604ad1.tar.bz2 |
build-sys: add version tooling
Add SLIRP_CHECK_VERSION() macro, and slirp_version_string() helpers.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libslirp-version.h.in | 23 | ||||
-rw-r--r-- | src/libslirp.h | 4 | ||||
-rw-r--r-- | src/util.h | 3 | ||||
-rw-r--r-- | src/version.c | 11 |
4 files changed, 41 insertions, 0 deletions
diff --git a/src/libslirp-version.h.in b/src/libslirp-version.h.in new file mode 100644 index 0000000..59f7a46 --- /dev/null +++ b/src/libslirp-version.h.in @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +#ifndef LIBSLIRP_VERSION_H_ +#define LIBSLIRP_VERSION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define SLIRP_MAJOR_VERSION @SLIRP_MAJOR_VERSION@ +#define SLIRP_MINOR_VERSION @SLIRP_MINOR_VERSION@ +#define SLIRP_MICRO_VERSION @SLIRP_MICRO_VERSION@ + +#define SLIRP_CHECK_VERSION(major,minor,micro) \ + (SLIRP_MAJOR_VERSION > (major) || \ + (SLIRP_MAJOR_VERSION == (major) && SLIRP_MINOR_VERSION > (minor)) || \ + (SLIRP_MAJOR_VERSION == (major) && SLIRP_MINOR_VERSION == (minor) && \ + SLIRP_MICRO_VERSION >= (micro))) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* LIBSLIRP_VERSION_H_ */ diff --git a/src/libslirp.h b/src/libslirp.h index bcd2974..9b2f611 100644 --- a/src/libslirp.h +++ b/src/libslirp.h @@ -14,6 +14,8 @@ #include <arpa/inet.h> #endif +#include "libslirp-version.h" + #ifdef __cplusplus extern "C" { #endif @@ -108,6 +110,8 @@ int slirp_state_load(Slirp *s, int version_id, SlirpReadCb read_cb, int slirp_state_version(void); +const char *slirp_version_string(void); + #ifdef __cplusplus } /* extern "C" */ #endif @@ -72,6 +72,9 @@ struct iovec { #include <sys/uio.h> #endif +#define stringify(s) tostring(s) +#define tostring(s) #s + #define SCALE_MS 1000000 #define ETH_ALEN 6 diff --git a/src/version.c b/src/version.c new file mode 100644 index 0000000..a837323 --- /dev/null +++ b/src/version.c @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +#include "libslirp.h" +#include "util.h" + +const char * +slirp_version_string(void) +{ + return stringify(SLIRP_MAJOR_VERSION) "." + stringify(SLIRP_MINOR_VERSION) "." + stringify(SLIRP_MICRO_VERSION); +} |