mdbx: rework version info (stub for now).

This commit is contained in:
Leo Yuriev 2017-05-24 01:07:15 +03:00
parent 88ea2768f5
commit 62ebc59330
18 changed files with 103 additions and 93 deletions

View File

@ -1,5 +1,5 @@
Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>. Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>.
Copyright 2011-2017 Howard Chu, Symas Corp. Copyright 2011-2015 Howard Chu, Symas Corp.
Copyright 2015,2016 Peter-Service R&D LLC. Copyright 2015,2016 Peter-Service R&D LLC.
All rights reserved. All rights reserved.

View File

@ -42,8 +42,6 @@ HEADERS := mdbx.h
LIBRARIES := libmdbx.a libmdbx.so LIBRARIES := libmdbx.a libmdbx.so
TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk
MANPAGES := mdbx_stat.1 mdbx_copy.1 mdbx_dump.1 mdbx_load.1 MANPAGES := mdbx_stat.1 mdbx_copy.1 mdbx_dump.1 mdbx_load.1
MDBX_SRC := mdbx.h mdbx_osal.h $(addprefix src/, mdbx.c osal.c lck-posix.c defs.h bits.h osal.h midl.h)
SHELL := /bin/bash SHELL := /bin/bash
.PHONY: mdbx all install clean check coverage .PHONY: mdbx all install clean check coverage
@ -70,19 +68,13 @@ clean:
check: test/test check: test/test
rm -f $(TESTDB) && (set -o pipefail; test/test --pathname=$(TESTDB) --dont-cleanup-after basic | tee test.log | tail -n 42) && ./mdbx_chk -vn $(TESTDB) rm -f $(TESTDB) && (set -o pipefail; test/test --pathname=$(TESTDB) --dont-cleanup-after basic | tee test.log | tail -n 42) && ./mdbx_chk -vn $(TESTDB)
mdbx.o: $(MDBX_SRC) Makefile src/%.o: src/%.c mdbx.h mdbx_osal.h $(addprefix src/, defs.h bits.h osal.h midl.h) Makefile
$(CC) $(CFLAGS) -c src/mdbx.c -o $@ $(CC) $(CFLAGS) -c $(filter %.c, $^) -o $@
osal.o: $(MDBX_SRC) Makefile libmdbx.a: $(addprefix src/, mdbx.o osal.o lck-posix.o version.o)
$(CC) $(CFLAGS) -c src/osal.c -o $@
lck-posix.o: $(MDBX_SRC) Makefile
$(CC) $(CFLAGS) -c src/lck-posix.c -o $@
libmdbx.a: mdbx.o osal.o lck-posix.o
$(AR) rs $@ $? $(AR) rs $@ $?
libmdbx.so: mdbx.o osal.o lck-posix.o libmdbx.so: libmdbx.a
$(CC) $(CFLAGS) -save-temps $^ -pthread -shared $(LDFLAGS) -o $@ $(CC) $(CFLAGS) -save-temps $^ -pthread -shared $(LDFLAGS) -o $@
mdbx_%: src/tools/mdbx_%.c libmdbx.a mdbx_%: src/tools/mdbx_%.c libmdbx.a

View File

@ -21,6 +21,7 @@ src/tools/mdbx_load.1
src/tools/mdbx_load.c src/tools/mdbx_load.c
src/tools/mdbx_stat.1 src/tools/mdbx_stat.1
src/tools/mdbx_stat.c src/tools/mdbx_stat.c
src/version.c
test/actor.cc test/actor.cc
test/base.h test/base.h
test/chrono.cc test/chrono.cc

75
mdbx.h
View File

@ -19,7 +19,7 @@
* *
* --- * ---
* *
* Portions Copyright 2011-2017 Howard Chu, Symas Corp. All rights reserved. * Portions Copyright 2011-2015 Howard Chu, Symas Corp. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP * modification, are permitted only as authorized by the OpenLDAP
@ -46,53 +46,45 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#pragma once #pragma once
/* *INDENT-OFF* */ #ifndef LIBMDBX_H
/* clang-format off */ #define LIBMDBX_H
#ifndef _MDBX_H_ #define MDBX_VERSION_MAJOR 0
#define _MDBX_H_ #define MDBX_VERSION_MINOR 0
#include "mdbx_osal.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(push)
#endif #endif
/* *INDENT-ON* */ #include "mdbx_osal.h"
/* clang-format on */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Library major version */ typedef struct mdbx_version_info {
#define MDBX_VERSION_MAJOR 0 uint8_t major;
/* Library minor version */ uint8_t minor;
#define MDBX_VERSION_MINOR 2 uint16_t release;
/* Library patch version */ uint32_t revision;
#define MDBX_VERSION_PATCH 0 struct {
const char *datetime;
const char *tree;
const char *commit;
const char *describe;
} git;
} mdbx_version_info;
/* Combine args a,b,c into a single integer for easy version comparisons */ typedef struct mdbx_build_info {
#define MDB_VERINT(a, b, c) (((a) << 24) | ((b) << 16) | (c)) const char *datetime;
const char *target;
const char *options;
const char *compiler;
const char *flags;
} mdbx_build_info;
/* The full library version as a single integer */ extern LIBMDBX_API const struct mdbx_version_info mdbx_version;
#define MDBX_VERSION_FULL \ extern LIBMDBX_API const struct mdbx_build_info mdbx_build;
MDB_VERINT(MDBX_VERSION_MAJOR, MDBX_VERSION_MINOR, MDBX_VERSION_PATCH)
/* The release date of this library version */
#define MDBX_VERSION_DATE "DEVEL"
/* A stringifier for the version info */
#define MDBX_VERSTR(a, b, c, d) \
"MDBX " #a "." #b "." #c ": (" d ", https://github.com/ReOpen/libmdbx)"
/* A helper for the stringifier macro */
#define MDBX_VERFOO(a, b, c, d) MDBX_VERSTR(a, b, c, d)
/* The full library version as a C string */
#define MDBX_VERSION_STRING \
MDBX_VERFOO(MDBX_VERSION_MAJOR, MDBX_VERSION_MINOR, MDBX_VERSION_PATCH, \
MDBX_VERSION_DATE)
/* The name of the lock file in the DB environment */ /* The name of the lock file in the DB environment */
#define MDBX_LOCKNAME "/mdbx.lck" #define MDBX_LOCKNAME "/mdbx.lck"
@ -352,15 +344,6 @@ typedef struct MDBX_envinfo {
uint64_t me_meta2_txnid, me_meta2_sign; uint64_t me_meta2_txnid, me_meta2_sign;
} MDBX_envinfo; } MDBX_envinfo;
/* Return the LMDB library version information.
*
* [out] major if non-NULL, the library major version number is copied here
* [out] minor if non-NULL, the library minor version number is copied here
* [out] patch if non-NULL, the library patch version number is copied here
*
* Returns "version string" The library version as a string */
LIBMDBX_API const char *mdbx_version(int *major, int *minor, int *patch);
/* Return a string describing a given error code. /* Return a string describing a given error code.
* *
* This function is a superset of the ANSI C X3.159-1989 (ANSI C) strerror(3) * This function is a superset of the ANSI C X3.159-1989 (ANSI C) strerror(3)
@ -1532,4 +1515,4 @@ LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDB_dbi dbi, uint64_t *result,
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif /* _MDBX_H_ */ #endif /* LIBMDBX_H */

View File

@ -50,13 +50,7 @@
#endif #endif
#endif /* __dll_import */ #endif /* __dll_import */
#if defined(LIBMDBX_EXPORTS) /*--------------------------------------------------------------------------*/
#define LIBMDBX_API __dll_export
#elif defined(LIBMDBX_IMPORTS)
#define LIBMDBX_API __dll_import
#else
#define LIBMDBX_API
#endif /* LIBMDBX_API */
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
@ -122,4 +116,16 @@ typedef pthread_t mdbx_tid_t;
#define MDBX_EIO EIO #define MDBX_EIO EIO
#endif #endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
#if defined(LIBMDBX_EXPORTS)
#define LIBMDBX_API __dll_export
#elif defined(LIBMDBX_IMPORTS)
#define LIBMDBX_API __dll_import
#else
#define LIBMDBX_API
#endif /* LIBMDBX_API */

View File

@ -9,7 +9,7 @@
* *
* --- * ---
* *
* Portions Copyright 2011-2017 Howard Chu, Symas Corp. All rights reserved. * Portions Copyright 2011-2015 Howard Chu, Symas Corp. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP * modification, are permitted only as authorized by the OpenLDAP
@ -677,17 +677,6 @@ static int mdbx_drop0(MDB_cursor *mc, int subs);
static MDB_cmp_func mdbx_cmp_memn, mdbx_cmp_memnr, mdbx_cmp_int_ai, static MDB_cmp_func mdbx_cmp_memn, mdbx_cmp_memnr, mdbx_cmp_int_ai,
mdbx_cmp_int_a2, mdbx_cmp_int_ua; mdbx_cmp_int_a2, mdbx_cmp_int_ua;
/* Return the library version info. */
const char *mdbx_version(int *major, int *minor, int *patch) {
if (major)
*major = MDBX_VERSION_MAJOR;
if (minor)
*minor = MDBX_VERSION_MINOR;
if (patch)
*patch = MDBX_VERSION_PATCH;
return MDBX_VERSION_STRING;
}
static const char *__mdbx_strerr(int errnum) { static const char *__mdbx_strerr(int errnum) {
/* Table of descriptions for LMDB errors */ /* Table of descriptions for LMDB errors */
static const char *const tbl[] = { static const char *const tbl[] = {

View File

@ -633,7 +633,8 @@ int main(int argc, char *argv[]) {
while ((i = getopt(argc, argv, "Vvqnwcds:")) != EOF) { while ((i = getopt(argc, argv, "Vvqnwcds:")) != EOF) {
switch (i) { switch (i) {
case 'V': case 'V':
printf("%s\n", MDBX_VERSION_STRING); printf("%s (%s, build %s)\n", mdbx_version.git.describe,
mdbx_version.git.datetime, mdbx_build.datetime);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
case 'v': case 'v':

View File

@ -1,5 +1,5 @@
.\" Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>. .\" Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>.
.\" Copyright 2012-2017 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2012-2015 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>. .\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDB_COPY 1 "2014/06/20" "LMDB 0.9.14" .TH MDB_COPY 1 "2014/06/20" "LMDB 0.9.14"

View File

@ -34,8 +34,9 @@ int main(int argc, char *argv[]) {
else if (argv[1][1] == 'c' && argv[1][2] == '\0') else if (argv[1][1] == 'c' && argv[1][2] == '\0')
cpflags |= MDB_CP_COMPACT; cpflags |= MDB_CP_COMPACT;
else if (argv[1][1] == 'V' && argv[1][2] == '\0') { else if (argv[1][1] == 'V' && argv[1][2] == '\0') {
printf("%s\n", MDBX_VERSION_STRING); printf("%s (%s, build %s)\n", mdbx_version.git.describe,
exit(0); mdbx_version.git.datetime, mdbx_build.datetime);
exit(EXIT_SUCCESS);
} else } else
argc = 0; argc = 0;
} }

View File

@ -1,5 +1,5 @@
.\" Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>. .\" Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>.
.\" Copyright 2014-2017 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2014-2015 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>. .\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDB_DUMP 1 "2014/06/20" "LMDB 0.9.14" .TH MDB_DUMP 1 "2014/06/20" "LMDB 0.9.14"

View File

@ -177,8 +177,9 @@ int main(int argc, char *argv[]) {
while ((i = getopt(argc, argv, "af:lnps:V")) != EOF) { while ((i = getopt(argc, argv, "af:lnps:V")) != EOF) {
switch (i) { switch (i) {
case 'V': case 'V':
printf("%s\n", MDBX_VERSION_STRING); printf("%s (%s, build %s)\n", mdbx_version.git.describe,
exit(0); mdbx_version.git.datetime, mdbx_build.datetime);
exit(EXIT_SUCCESS);
break; break;
case 'l': case 'l':
list = 1; list = 1;

View File

@ -1,5 +1,5 @@
.\" Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>. .\" Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>.
.\" Copyright 2014-2017 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2014-2015 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>. .\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDB_LOAD 1 "2014/06/20" "LMDB 0.9.14" .TH MDB_LOAD 1 "2014/06/20" "LMDB 0.9.14"

View File

@ -317,8 +317,9 @@ int main(int argc, char *argv[]) {
while ((i = getopt(argc, argv, "f:ns:NTV")) != EOF) { while ((i = getopt(argc, argv, "f:ns:NTV")) != EOF) {
switch (i) { switch (i) {
case 'V': case 'V':
printf("%s\n", MDBX_VERSION_STRING); printf("%s (%s, build %s)\n", mdbx_version.git.describe,
exit(0); mdbx_version.git.datetime, mdbx_build.datetime);
exit(EXIT_SUCCESS);
break; break;
case 'f': case 'f':
if (freopen(optarg, "r", stdin) == NULL) { if (freopen(optarg, "r", stdin) == NULL) {

View File

@ -1,5 +1,5 @@
.\" Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>. .\" Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>.
.\" Copyright 2012-2017 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2012-2015 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>. .\" Copyright 2015,2016 Peter-Service R&D LLC <http://billing.ru/>.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDB_STAT 1 "2014/06/20" "LMDB 0.9.14" .TH MDB_STAT 1 "2014/06/20" "LMDB 0.9.14"

View File

@ -64,8 +64,9 @@ int main(int argc, char *argv[]) {
while ((i = getopt(argc, argv, "Vaefnrs:")) != EOF) { while ((i = getopt(argc, argv, "Vaefnrs:")) != EOF) {
switch (i) { switch (i) {
case 'V': case 'V':
printf("%s\n", MDBX_VERSION_STRING); printf("%s (%s, build %s)\n", mdbx_version.git.describe,
exit(0); mdbx_version.git.datetime, mdbx_build.datetime);
exit(EXIT_SUCCESS);
break; break;
case 'a': case 'a':
if (subname) if (subname)

34
src/version.c Normal file
View File

@ -0,0 +1,34 @@
/*
* Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>
* and other libmdbx authors: please see AUTHORS file.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
#include "./bits.h"
#if MDBX_VERSION_MAJOR != 0 || MDBX_VERSION_MINOR != 0
#error "API version mismatch!"
#endif
#define MDBX_VERSION_RELEASE 0
#define MDBX_VERSION_REVISION 0
const struct mdbx_version_info mdbx_version = {
MDBX_VERSION_MAJOR,
MDBX_VERSION_MINOR,
MDBX_VERSION_RELEASE,
MDBX_VERSION_REVISION,
{"@MDBX_GIT_TIMESTAMP@", "@MDBX_GIT_TREE@", "@MDBX_GIT_COMMIT@",
"@MDBX_GIT_DESCRIBE@"}};
const struct mdbx_build_info mdbx_build = {
"@MDBX_BUILD_TIMESTAMP@", "@MDBX_BUILD_TAGRET@", "@MDBX_BUILD_OPTIONS@",
"@MDBX_BUILD_COMPILER@", "@MDBX_BUILD_FLAGS@"};

View File

@ -5,7 +5,7 @@
/* /*
* Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>. * Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>.
* Copyright 2012-2017 Howard Chu, Symas Corp. * Copyright 2012-2015 Howard Chu, Symas Corp.
* Copyright 2015,2016 Peter-Service R&D LLC. * Copyright 2015,2016 Peter-Service R&D LLC.
* All rights reserved. * All rights reserved.
* *

View File

@ -5,7 +5,7 @@
/* /*
* Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>. * Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>.
* Copyright 2012-2017 Howard Chu, Symas Corp. * Copyright 2012-2015 Howard Chu, Symas Corp.
* Copyright 2015,2016 Peter-Service R&D LLC. * Copyright 2015,2016 Peter-Service R&D LLC.
* All rights reserved. * All rights reserved.
* *