diff options
author | Leonid Yuriev <leo@yuriev.ru> | 2020-10-08 02:02:18 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-10-09 16:50:37 +0300 |
commit | a519d4617ed83a2167a693ae87934e56889fef05 (patch) | |
tree | 85c3aea76fe15268fc0891cf18c328913c6d4347 /libs/libmdbx/src/test/chrono.cc | |
parent | bc58e7ec8ef67c37b6d302eaa2e76deedec03106 (diff) |
libmdbx: switch to original amalgamated source code (v0.9.1.18)
Amalgamated source code is the recommended form for
embedding libmdbx in non-CMake build systems. This amalgamated
version contains a minimum of files, is fully ready for use,
and make impossible a number of errors.
To upgrade or switch to a different version, just unpack
to the `src` subdirectory a corresponding `libmdbx-amalgamated-X_Y_Z.zip`
at the https://github.com/erthink/libmdbx/releases.
For instance, the https://github.com/erthink/libmdbx/releases/download/v0.9.2/libmdbx-amalgamated-0_9_2.zip
for the next release.
--
Minimal changes have been made to the build configuration:
1. For use the standard `DllMain()` entry of libmdbx:
- added the `MDBX_BUILD_SHARED_LIBRARY=1` option;
- removed the `MDBX_CONFIG_MANUAL_TLS_CALLBACK` option;
- deleted the `miranda.c` file containing only `DllMain()`
with the `mdbx_dll_handle()` call, now this is done by the library itself.
2. Removed refs to extra files (that missing in the amalgamated source code):
- for building `libmdbx.dll` only the `mdbx.h` and `mdbx.c` are used,
but not `mdbx.c++` for a C++ API;
- for building the `mdbx_chk`, `mdbx_load`, and `mdbx_dump` utilities
only it own sources are used.
--
Last libmdbx changes:
- Fixed missing installation of `mdbx.h++`.
- Fixed use of obsolete `__noreturn`.
- Fixed use of `yield` instruction on ARM if unsupported.
- Added pthread workaround for buggy toolchain/cmake/buildroot.
- Fixed use of `pthread_yield()` for non-GLIBC.
- Fixed use of `RegGetValueA()` on Windows 2000/XP.
- Fixed use of `GetTickCount64()` on Windows 2000/XP.
- Fixed opening DB on a network shares (in the exclusive mode).
- Fixed copy&paste typos.
- Fixed minor false-positive GCC warning.
Diffstat (limited to 'libs/libmdbx/src/test/chrono.cc')
-rw-r--r-- | libs/libmdbx/src/test/chrono.cc | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/libs/libmdbx/src/test/chrono.cc b/libs/libmdbx/src/test/chrono.cc deleted file mode 100644 index 43cd2a370c..0000000000 --- a/libs/libmdbx/src/test/chrono.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2017-2020 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 "test.h" - -namespace chrono { - -#ifndef NSEC_PER_SEC -#define NSEC_PER_SEC 1000000000u -#endif /* NSEC_PER_SEC */ - -uint32_t ns2fractional(uint32_t ns) { - assert(ns < NSEC_PER_SEC); - /* LY: здесь и далее используется "длинное деление", которое - * для ясности кода оставлено как есть (без ручной оптимизации). Так как - * GCC, Clang и даже MSVC сами давно умеют конвертировать деление на - * константу в быструю reciprocal-форму. */ - return ((uint64_t)ns << 32) / NSEC_PER_SEC; -} - -uint32_t fractional2ns(uint32_t fractional) { - return (fractional * (uint64_t)NSEC_PER_SEC) >> 32; -} - -#ifndef USEC_PER_SEC -#define USEC_PER_SEC 1000000u -#endif /* USEC_PER_SEC */ -uint32_t us2fractional(uint32_t us) { - assert(us < USEC_PER_SEC); - return ((uint64_t)us << 32) / USEC_PER_SEC; -} - -uint32_t fractional2us(uint32_t fractional) { - return (fractional * (uint64_t)USEC_PER_SEC) >> 32; -} - -#ifndef MSEC_PER_SEC -#define MSEC_PER_SEC 1000u -#endif /* MSEC_PER_SEC */ -uint32_t ms2fractional(uint32_t ms) { - assert(ms < MSEC_PER_SEC); - return ((uint64_t)ms << 32) / MSEC_PER_SEC; -} - -uint32_t fractional2ms(uint32_t fractional) { - return (fractional * (uint64_t)MSEC_PER_SEC) >> 32; -} - -time from_ns(uint64_t ns) { - time result; - result.fixedpoint = ((ns / NSEC_PER_SEC) << 32) | - ns2fractional((uint32_t)(ns % NSEC_PER_SEC)); - return result; -} - -time from_us(uint64_t us) { - time result; - result.fixedpoint = ((us / USEC_PER_SEC) << 32) | - us2fractional((uint32_t)(us % USEC_PER_SEC)); - return result; -} - -time from_ms(uint64_t ms) { - time result; - result.fixedpoint = ((ms / MSEC_PER_SEC) << 32) | - ms2fractional((uint32_t)(ms % MSEC_PER_SEC)); - return result; -} - -time now_realtime() { -#if defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS) - static void(WINAPI * query_time)(LPFILETIME); - if (!query_time) { - query_time = (void(WINAPI *)(LPFILETIME))GetProcAddress( - GetModuleHandle(TEXT("kernel32.dll")), - "GetSystemTimePreciseAsFileTime"); - if (!query_time) - query_time = GetSystemTimeAsFileTime; - } - - FILETIME filetime; - query_time(&filetime); - uint64_t ns100 = - (uint64_t)filetime.dwHighDateTime << 32 | filetime.dwLowDateTime; - return from_ns((ns100 - UINT64_C(116444736000000000)) * 100u); -#else - struct timespec ts; - if (unlikely(clock_gettime(CLOCK_REALTIME, &ts))) - failure_perror("clock_gettime(CLOCK_REALTIME", errno); - - return from_timespec(ts); -#endif -} - -time now_motonic() { -#if defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS) - static uint64_t reciprocal; - static LARGE_INTEGER Frequency; - if (reciprocal == 0) { - if (!QueryPerformanceFrequency(&Frequency)) - failure_perror("QueryPerformanceFrequency()", GetLastError()); - reciprocal = (((UINT64_C(1) << 48) + Frequency.QuadPart / 2 + 1) / - Frequency.QuadPart); - assert(reciprocal); - } - - LARGE_INTEGER Counter; - if (!QueryPerformanceCounter(&Counter)) - failure_perror("QueryPerformanceCounter()", GetLastError()); - - time result; - result.fixedpoint = (Counter.QuadPart / Frequency.QuadPart) << 32; - uint64_t mod = Counter.QuadPart % Frequency.QuadPart; - result.fixedpoint += (mod * reciprocal) >> 16; - return result; -#else - struct timespec ts; - if (unlikely(clock_gettime(CLOCK_MONOTONIC, &ts))) - failure_perror("clock_gettime(CLOCK_MONOTONIC)", errno); - - return from_timespec(ts); -#endif -} - -} /* namespace chrono */ |