mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 02:24:14 +08:00
mdbx: rework version info (stub for now).
This commit is contained in:
parent
88ea2768f5
commit
62ebc59330
@ -1,5 +1,5 @@
|
||||
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.
|
||||
All rights reserved.
|
||||
|
||||
|
16
Makefile
16
Makefile
@ -42,8 +42,6 @@ HEADERS := mdbx.h
|
||||
LIBRARIES := libmdbx.a libmdbx.so
|
||||
TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk
|
||||
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
|
||||
|
||||
.PHONY: mdbx all install clean check coverage
|
||||
@ -70,19 +68,13 @@ clean:
|
||||
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)
|
||||
|
||||
mdbx.o: $(MDBX_SRC) Makefile
|
||||
$(CC) $(CFLAGS) -c src/mdbx.c -o $@
|
||||
src/%.o: src/%.c mdbx.h mdbx_osal.h $(addprefix src/, defs.h bits.h osal.h midl.h) Makefile
|
||||
$(CC) $(CFLAGS) -c $(filter %.c, $^) -o $@
|
||||
|
||||
osal.o: $(MDBX_SRC) Makefile
|
||||
$(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
|
||||
libmdbx.a: $(addprefix src/, mdbx.o osal.o lck-posix.o version.o)
|
||||
$(AR) rs $@ $?
|
||||
|
||||
libmdbx.so: mdbx.o osal.o lck-posix.o
|
||||
libmdbx.so: libmdbx.a
|
||||
$(CC) $(CFLAGS) -save-temps $^ -pthread -shared $(LDFLAGS) -o $@
|
||||
|
||||
mdbx_%: src/tools/mdbx_%.c libmdbx.a
|
||||
|
@ -21,6 +21,7 @@ src/tools/mdbx_load.1
|
||||
src/tools/mdbx_load.c
|
||||
src/tools/mdbx_stat.1
|
||||
src/tools/mdbx_stat.c
|
||||
src/version.c
|
||||
test/actor.cc
|
||||
test/base.h
|
||||
test/chrono.cc
|
||||
|
75
mdbx.h
75
mdbx.h
@ -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
|
||||
* modification, are permitted only as authorized by the OpenLDAP
|
||||
@ -46,53 +46,45 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#pragma once
|
||||
/* *INDENT-OFF* */
|
||||
/* clang-format off */
|
||||
#ifndef LIBMDBX_H
|
||||
#define LIBMDBX_H
|
||||
|
||||
#ifndef _MDBX_H_
|
||||
#define _MDBX_H_
|
||||
|
||||
#include "mdbx_osal.h"
|
||||
#define MDBX_VERSION_MAJOR 0
|
||||
#define MDBX_VERSION_MINOR 0
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#pragma warning(push)
|
||||
#endif
|
||||
|
||||
/* *INDENT-ON* */
|
||||
/* clang-format on */
|
||||
#include "mdbx_osal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Library major version */
|
||||
#define MDBX_VERSION_MAJOR 0
|
||||
/* Library minor version */
|
||||
#define MDBX_VERSION_MINOR 2
|
||||
/* Library patch version */
|
||||
#define MDBX_VERSION_PATCH 0
|
||||
typedef struct mdbx_version_info {
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
uint16_t release;
|
||||
uint32_t revision;
|
||||
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 */
|
||||
#define MDB_VERINT(a, b, c) (((a) << 24) | ((b) << 16) | (c))
|
||||
typedef struct mdbx_build_info {
|
||||
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 */
|
||||
#define MDBX_VERSION_FULL \
|
||||
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)
|
||||
extern LIBMDBX_API const struct mdbx_version_info mdbx_version;
|
||||
extern LIBMDBX_API const struct mdbx_build_info mdbx_build;
|
||||
|
||||
/* The name of the lock file in the DB environment */
|
||||
#define MDBX_LOCKNAME "/mdbx.lck"
|
||||
@ -352,15 +344,6 @@ typedef struct MDBX_envinfo {
|
||||
uint64_t me_meta2_txnid, me_meta2_sign;
|
||||
} 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.
|
||||
*
|
||||
* 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)
|
||||
#endif
|
||||
|
||||
#endif /* _MDBX_H_ */
|
||||
#endif /* LIBMDBX_H */
|
||||
|
20
mdbx_osal.h
20
mdbx_osal.h
@ -50,13 +50,7 @@
|
||||
#endif
|
||||
#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
|
||||
#pragma warning(push)
|
||||
@ -122,4 +116,16 @@ typedef pthread_t mdbx_tid_t;
|
||||
#define MDBX_EIO EIO
|
||||
#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 */
|
||||
|
13
src/mdbx.c
13
src/mdbx.c
@ -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
|
||||
* 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,
|
||||
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) {
|
||||
/* Table of descriptions for LMDB errors */
|
||||
static const char *const tbl[] = {
|
||||
|
@ -633,7 +633,8 @@ int main(int argc, char *argv[]) {
|
||||
while ((i = getopt(argc, argv, "Vvqnwcds:")) != EOF) {
|
||||
switch (i) {
|
||||
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);
|
||||
break;
|
||||
case 'v':
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" 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/>.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.TH MDB_COPY 1 "2014/06/20" "LMDB 0.9.14"
|
||||
|
@ -34,8 +34,9 @@ int main(int argc, char *argv[]) {
|
||||
else if (argv[1][1] == 'c' && argv[1][2] == '\0')
|
||||
cpflags |= MDB_CP_COMPACT;
|
||||
else if (argv[1][1] == 'V' && argv[1][2] == '\0') {
|
||||
printf("%s\n", MDBX_VERSION_STRING);
|
||||
exit(0);
|
||||
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
||||
mdbx_version.git.datetime, mdbx_build.datetime);
|
||||
exit(EXIT_SUCCESS);
|
||||
} else
|
||||
argc = 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" 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/>.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.TH MDB_DUMP 1 "2014/06/20" "LMDB 0.9.14"
|
||||
|
@ -177,8 +177,9 @@ int main(int argc, char *argv[]) {
|
||||
while ((i = getopt(argc, argv, "af:lnps:V")) != EOF) {
|
||||
switch (i) {
|
||||
case 'V':
|
||||
printf("%s\n", MDBX_VERSION_STRING);
|
||||
exit(0);
|
||||
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
||||
mdbx_version.git.datetime, mdbx_build.datetime);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'l':
|
||||
list = 1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" 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/>.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.TH MDB_LOAD 1 "2014/06/20" "LMDB 0.9.14"
|
||||
|
@ -317,8 +317,9 @@ int main(int argc, char *argv[]) {
|
||||
while ((i = getopt(argc, argv, "f:ns:NTV")) != EOF) {
|
||||
switch (i) {
|
||||
case 'V':
|
||||
printf("%s\n", MDBX_VERSION_STRING);
|
||||
exit(0);
|
||||
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
||||
mdbx_version.git.datetime, mdbx_build.datetime);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'f':
|
||||
if (freopen(optarg, "r", stdin) == NULL) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" 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/>.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.TH MDB_STAT 1 "2014/06/20" "LMDB 0.9.14"
|
||||
|
@ -64,8 +64,9 @@ int main(int argc, char *argv[]) {
|
||||
while ((i = getopt(argc, argv, "Vaefnrs:")) != EOF) {
|
||||
switch (i) {
|
||||
case 'V':
|
||||
printf("%s\n", MDBX_VERSION_STRING);
|
||||
exit(0);
|
||||
printf("%s (%s, build %s)\n", mdbx_version.git.describe,
|
||||
mdbx_version.git.datetime, mdbx_build.datetime);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'a':
|
||||
if (subname)
|
||||
|
34
src/version.c
Normal file
34
src/version.c
Normal 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@"};
|
@ -5,7 +5,7 @@
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user