mdbx: resolve all warnings from MinGW.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2022-03-30 18:13:08 +03:00
parent 21da42d23d
commit 6f37c8e57f
9 changed files with 47 additions and 4 deletions

11
mdbx.h
View File

@ -324,7 +324,8 @@ typedef mode_t mdbx_mode_t;
#endif /* MDBX_DEPRECATED */
#ifndef __dll_export
#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || \
defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
#if defined(__GNUC__) || __has_attribute(__dllexport__)
#define __dll_export __attribute__((__dllexport__))
#elif defined(_MSC_VER)
@ -340,7 +341,8 @@ typedef mode_t mdbx_mode_t;
#endif /* __dll_export */
#ifndef __dll_import
#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || \
defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
#if defined(__GNUC__) || __has_attribute(__dllimport__)
#define __dll_import __attribute__((__dllimport__))
#elif defined(_MSC_VER)
@ -457,8 +459,13 @@ typedef mode_t mdbx_mode_t;
#ifndef MDBX_PRINTF_ARGS
#if defined(__GNUC__) || __has_attribute(__format__)
#if defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
#define MDBX_PRINTF_ARGS(format_index, first_arg) \
__attribute__((__format__(__gnu_printf__, format_index, first_arg)))
#else
#define MDBX_PRINTF_ARGS(format_index, first_arg) \
__attribute__((__format__(__printf__, format_index, first_arg)))
#endif /* __MINGW_PRINTF_FORMAT */
#else
#define MDBX_PRINTF_ARGS(format_index, first_arg)
#endif

View File

@ -5463,6 +5463,7 @@ inline size_t txn::put_multiple(map_handle map, const slice &key,
if (allow_partial)
break;
mdbx_txn_break(handle_);
MDBX_CXX17_FALLTHROUGH /* fallthrough */;
default:
MDBX_CXX20_UNLIKELY error::throw_exception(err);
}

View File

@ -107,6 +107,11 @@
# define __noop(...) do {} while(0)
#endif /* __noop */
#if defined(__fallthrough) && \
(defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__))
#undef __fallthrough
#endif /* __fallthrough workaround for MinGW */
#ifndef __fallthrough
# if defined(__cplusplus) && (__has_cpp_attribute(fallthrough) && \
(!defined(__clang__) || __clang__ > 4)) || __cplusplus >= 201703L

View File

@ -122,6 +122,11 @@
#pragma GCC diagnostic ignored "-Wattributes"
#endif /* GCC < 9 */
#if (defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)) && \
!defined(__USE_MINGW_ANSI_STDIO)
#define __USE_MINGW_ANSI_STDIO 1
#endif /* __USE_MINGW_ANSI_STDIO */
#include "../mdbx.h"
#include "defs.h"

View File

@ -754,6 +754,11 @@ MDBX_GetTickCount64 mdbx_GetTickCount64;
MDBX_RegGetValueA mdbx_RegGetValueA;
#endif /* xMDBX_ALLOY */
#if __GNUC_PREREQ(8, 0)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif /* GCC/MINGW */
static void mdbx_winnt_import(void) {
const HINSTANCE hNtdll = GetModuleHandleA("ntdll.dll");
@ -805,4 +810,8 @@ static void mdbx_winnt_import(void) {
}
}
#if __GNUC_PREREQ(8, 0)
#pragma GCC diagnostic pop
#endif /* GCC/MINGW */
#endif /* Windows LCK-implementation */

View File

@ -9,6 +9,11 @@
#define _CRT_SECURE_NO_WARNINGS
#endif /* _CRT_SECURE_NO_WARNINGS */
#if (defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)) && \
!defined(__USE_MINGW_ANSI_STDIO)
#define __USE_MINGW_ANSI_STDIO 1
#endif /* __USE_MINGW_ANSI_STDIO */
#include "../mdbx.h++"
#include "defs.h"

View File

@ -474,7 +474,7 @@ typedef union bin128 {
#if defined(_WIN32) || defined(_WIN64)
typedef union MDBX_srwlock {
struct {
__anonymous_struct_extension__ struct {
long volatile readerCount;
long volatile writerCount;
};

View File

@ -78,6 +78,12 @@ time from_ms(uint64_t ms) {
return result;
}
#if __GNUC_PREREQ(8, 0) && \
(defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif /* GCC/MINGW */
time now_realtime() {
#if defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS)
static void(WINAPI * query_time)(LPFILETIME);
@ -133,4 +139,9 @@ time now_monotonic() {
#endif
}
#if __GNUC_PREREQ(8, 0) && \
(defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__))
#pragma GCC diagnostic pop
#endif /* GCC/MINGW */
} /* namespace chrono */

View File

@ -75,7 +75,7 @@ void osal_setup(const std::vector<actor_config> &actors) {
if (!hEvent)
failure_perror("CreateEvent()", GetLastError());
hEvent = make_inheritable(hEvent);
log_trace("osal_setup: event %" PRIuPTR " -> %p", i, hEvent);
log_trace("osal_setup: event %u -> %p", i, hEvent);
events[i] = hEvent;
}