Add mechanism to disable temporary compiler warnings in a sequence of code.
This commit is contained in:
1 parent
a36752b8ce
commit
f2a06ede62
14 files changed
+149
-1
No files matched your search
@@ -135,6 +135,9 @@ using std::memory_order_seq_cst;
|
|||||||
We also assume that the call to the atomic_* interface is "clean".
|
We also assume that the call to the atomic_* interface is "clean".
|
||||||
*/
|
*/
|
||||||
#include "m-mutex.h"
|
#include "m-mutex.h"
|
||||||
|
#include "m-core.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* _Atomic qualifier for a type (emulation).
|
/* _Atomic qualifier for a type (emulation).
|
||||||
The structure is quite large:
|
The structure is quite large:
|
||||||
@@ -305,6 +308,8 @@ static inline long long atomic_fetch_unlock (m_mutex_t *lock, long long val)
|
|||||||
|
|
||||||
/* TODO: Missing atomic_flag. Problem: it is supposed to be lock free! */
|
/* TODO: Missing atomic_flag. Problem: it is supposed to be lock free! */
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
/********************************** INTERNAL ************************************/
|
/********************************** INTERNAL ************************************/
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
// Define the basic limb of a bitset
|
// Define the basic limb of a bitset
|
||||||
typedef uint64_t bitset_limb;
|
typedef uint64_t bitset_limb;
|
||||||
// And its size in bits
|
// And its size in bits
|
||||||
@@ -813,4 +815,6 @@ bitset_get_str(string_t str, const bitset_t set, bool append)
|
|||||||
string_push_back (str, ']');
|
string_push_back (str, ']');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -29,6 +29,8 @@
|
|||||||
#include "m-atomic.h"
|
#include "m-atomic.h"
|
||||||
#include "m-genint.h"
|
#include "m-genint.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* Minimum number of nodes per group of nodes */
|
/* Minimum number of nodes per group of nodes */
|
||||||
#define C_MEMPOOL_MIN_NODE_PER_GROUP 16
|
#define C_MEMPOOL_MIN_NODE_PER_GROUP 16
|
||||||
|
|
||||||
@@ -822,5 +824,6 @@ m_vlapool_del(m_vlapool_t mem, void *d, m_gc_tid_t id)
|
|||||||
m_vlapool_slist_push(mem->thread_data[id].to_be_reclaimed, snode);
|
m_vlapool_slist_push(mem->thread_data[id].to_be_reclaimed, snode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -103,6 +103,68 @@
|
|||||||
#define M_ATTR_EXTENSION
|
#define M_ATTR_EXTENSION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Ignore some warnings detected by some compilers in the library.
|
||||||
|
* Whatever we do, there is some warnings that cannot be fixed.
|
||||||
|
* So they are ignored in order to avoid polluting the user with
|
||||||
|
* theses warnings.
|
||||||
|
* They are:
|
||||||
|
* * If we build in C++ mode, they are warnings about using the C
|
||||||
|
* dialect. It is expected as M*LIB is a C library.
|
||||||
|
*
|
||||||
|
* * For clang, additional warnings are ignored since their detection are broken
|
||||||
|
* in the context of M*LIB:
|
||||||
|
* - unused generated inline functions
|
||||||
|
* https://bugs.llvm.org//show_bug.cgi?id=22712
|
||||||
|
*/
|
||||||
|
#if defined(__clang__) && defined(__cplusplus)
|
||||||
|
|
||||||
|
#if __clang_major__ >= 6
|
||||||
|
#define M_BEGIN_PROTECTED_CODE \
|
||||||
|
_Pragma("clang diagnostic push") \
|
||||||
|
_Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
|
||||||
|
_Pragma("clang diagnostic ignored \"-Wzero-as-null-pointer-constant\"") \
|
||||||
|
_Pragma("clang diagnostic ignored \"-Wunused-function\"")
|
||||||
|
#else
|
||||||
|
#define M_BEGIN_PROTECTED_CODE \
|
||||||
|
_Pragma("clang diagnostic push") \
|
||||||
|
_Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
|
||||||
|
_Pragma("clang diagnostic ignored \"-Wunused-function\"")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define M_END_PROTECTED_CODE \
|
||||||
|
_Pragma("clang diagnostic pop")
|
||||||
|
|
||||||
|
#elif defined(__GNUC__) && defined(__cplusplus)
|
||||||
|
|
||||||
|
/* G++ doesn't support well disabling temporary warnings.
|
||||||
|
* See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
|
||||||
|
*/
|
||||||
|
#define M_BEGIN_PROTECTED_CODE \
|
||||||
|
_Pragma("GCC diagnostic push") \
|
||||||
|
_Pragma("GCC diagnostic ignored \"-Wold-style-cast\"") \
|
||||||
|
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||||
|
|
||||||
|
#define M_END_PROTECTED_CODE \
|
||||||
|
_Pragma("GCC diagnostic pop")
|
||||||
|
|
||||||
|
#elif defined(__clang__)
|
||||||
|
|
||||||
|
#define M_BEGIN_PROTECTED_CODE \
|
||||||
|
_Pragma("clang diagnostic push") \
|
||||||
|
_Pragma("clang diagnostic ignored \"-Wunused-function\"")
|
||||||
|
|
||||||
|
#define M_END_PROTECTED_CODE \
|
||||||
|
_Pragma("clang diagnostic pop")
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define M_BEGIN_PROTECTED_CODE
|
||||||
|
#define M_END_PROTECTED_CODE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do not create the following symbols that are defined in GLIBC malloc.h
|
* Do not create the following symbols that are defined in GLIBC malloc.h
|
||||||
* M_MXFAST
|
* M_MXFAST
|
||||||
@@ -119,6 +181,8 @@
|
|||||||
* M_ARENA_MAX
|
* M_ARENA_MAX
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/****************** Preprocessing Times Macro ******************/
|
/****************** Preprocessing Times Macro ******************/
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -3310,4 +3374,6 @@ m_core_serial_fail(void)
|
|||||||
return M_SERIAL_FAIL;
|
return M_SERIAL_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -28,6 +28,8 @@
|
|||||||
#include "m-core.h"
|
#include "m-core.h"
|
||||||
#include "m-atomic.h"
|
#include "m-atomic.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* GENINT is a container providing unique integers.
|
/* GENINT is a container providing unique integers.
|
||||||
It has the following properties:
|
It has the following properties:
|
||||||
- it stores integer from [0..N) (N is fixed).
|
- it stores integer from [0..N) (N is fixed).
|
||||||
@@ -240,4 +242,6 @@ genint_push(genint_t s, unsigned int n)
|
|||||||
GENINT_CONTRACT(s);
|
GENINT_CONTRACT(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -28,6 +28,8 @@
|
|||||||
#include "m-core.h"
|
#include "m-core.h"
|
||||||
#include "m-atomic.h"
|
#include "m-atomic.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* Define the oplist of a intrusive shared pointer.
|
/* Define the oplist of a intrusive shared pointer.
|
||||||
USAGE: ISHARED_OPLIST(name [, oplist_of_the_type]) */
|
USAGE: ISHARED_OPLIST(name [, oplist_of_the_type]) */
|
||||||
#define ISHARED_PTR_OPLIST(...) \
|
#define ISHARED_PTR_OPLIST(...) \
|
||||||
@@ -169,5 +171,7 @@
|
|||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -36,6 +36,8 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "m-core.h"
|
#include "m-core.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* Define a mutex type based on C11 definition */
|
/* Define a mutex type based on C11 definition */
|
||||||
typedef mtx_t m_mutex_t[1];
|
typedef mtx_t m_mutex_t[1];
|
||||||
|
|
||||||
@@ -155,12 +157,33 @@ static inline void m_oncei_call(m_oncei_t o, void (*func)(void))
|
|||||||
// Attribute to use to allocate a global variable to a thread.
|
// Attribute to use to allocate a global variable to a thread.
|
||||||
#define M_THREAD_ATTR _Thread_local
|
#define M_THREAD_ATTR _Thread_local
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
// MSYS2 doesn't define _WIN32 by default.
|
// MSYS2 doesn't define _WIN32 by default but __CYGWIN__
|
||||||
#elif defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
|
#elif defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
|
||||||
/****************************** WIN32 version ******************************/
|
/****************************** WIN32 version ******************************/
|
||||||
|
|
||||||
|
/* CLANG provides some useless and wrong warnings:
|
||||||
|
* - _WIN32_WINNT starts with '_' which is reserved by the standard
|
||||||
|
* as per the MSVC compiler, it is needed to be defined by the user
|
||||||
|
* to define which version of windows it want to be compatible with.
|
||||||
|
* - windows.h may be different than the case used by the file sytem
|
||||||
|
* there is however no normalized case.
|
||||||
|
*
|
||||||
|
* So, theses warnings have to be ignored and are disabled.
|
||||||
|
*
|
||||||
|
* We cannot add theses warnings in M_BEGIN_PROTECTED_CODE
|
||||||
|
* as they need to be disabled **BEFORE** including any system header
|
||||||
|
* and m-core includes some system headers.
|
||||||
|
* So we need to disable them explictly here.
|
||||||
|
*/
|
||||||
|
#if defined(__clang__) && __clang_major__ >= 4
|
||||||
|
_Pragma("clang diagnostic push")
|
||||||
|
_Pragma("clang diagnostic ignore \"-Wreserved-id-macro\"")
|
||||||
|
_Pragma("clang diagnostic ignore \"-Wnonportable-system-include-path\"")
|
||||||
|
#endif
|
||||||
|
|
||||||
/* CriticalSection & ConditionVariable are available from Windows Vista */
|
/* CriticalSection & ConditionVariable are available from Windows Vista */
|
||||||
#ifndef WINVER
|
#ifndef WINVER
|
||||||
#define WINVER _WIN32_WINNT_VISTA
|
#define WINVER _WIN32_WINNT_VISTA
|
||||||
@@ -168,11 +191,19 @@ static inline void m_oncei_call(m_oncei_t o, void (*func)(void))
|
|||||||
#ifndef _WIN32_WINNT
|
#ifndef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT _WIN32_WINNT_VISTA
|
#define _WIN32_WINNT _WIN32_WINNT_VISTA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Include system headers */
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "m-core.h"
|
#include "m-core.h"
|
||||||
|
|
||||||
|
#if defined(__clang__) && __clang_major__ >= 4
|
||||||
|
_Pragma("clang diagnostic pop")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* Define a thread type based on WINDOWS definition */
|
/* Define a thread type based on WINDOWS definition */
|
||||||
typedef HANDLE m_thread_t[1];
|
typedef HANDLE m_thread_t[1];
|
||||||
|
|
||||||
@@ -300,6 +331,8 @@ static inline void m_oncei_call(m_oncei_t o, void (*func)(void))
|
|||||||
# define M_THREAD_ATTR __thread
|
# define M_THREAD_ATTR __thread
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/**************************** PTHREAD version ******************************/
|
/**************************** PTHREAD version ******************************/
|
||||||
@@ -315,6 +348,8 @@ static inline void m_oncei_call(m_oncei_t o, void (*func)(void))
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "m-core.h"
|
#include "m-core.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* Define a mutex type based on PTHREAD definition */
|
/* Define a mutex type based on PTHREAD definition */
|
||||||
typedef pthread_mutex_t m_mutex_t[1];
|
typedef pthread_mutex_t m_mutex_t[1];
|
||||||
|
|
||||||
@@ -440,6 +475,8 @@ static inline void m_oncei_call(m_oncei_t o, void (*func)(void))
|
|||||||
|
|
||||||
#define M_THREAD_ATTR __thread
|
#define M_THREAD_ATTR __thread
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: m_thread_sleep doesn't yield thread during waiting, making it a poor choice for active waiting.
|
// TODO: m_thread_sleep doesn't yield thread during waiting, making it a poor choice for active waiting.
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
#include "m-core.h"
|
#include "m-core.h"
|
||||||
#include "m-string.h"
|
#include "m-string.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* Internal service:
|
/* Internal service:
|
||||||
* Write size_t in the stream in a compact form to reduce consumption
|
* Write size_t in the stream in a compact form to reduce consumption
|
||||||
* (and I/O bandwidth)
|
* (and I/O bandwidth)
|
||||||
@@ -586,4 +588,6 @@ typedef m_serial_read_t m_serial_bin_read_t;
|
|||||||
#define M_OPL_m_serial_bin_read_t() \
|
#define M_OPL_m_serial_bin_read_t() \
|
||||||
(INIT_WITH(m_serial_bin_read_init), CLEAR(m_serial_bin_read_clear), TYPE(m_serial_bin_read_t) )
|
(INIT_WITH(m_serial_bin_read_init), CLEAR(m_serial_bin_read_clear), TYPE(m_serial_bin_read_t) )
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -28,6 +28,8 @@
|
|||||||
#include "m-core.h"
|
#include "m-core.h"
|
||||||
#include "m-string.h"
|
#include "m-string.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* Write the boolean 'data' into the serial stream 'serial'.
|
/* Write the boolean 'data' into the serial stream 'serial'.
|
||||||
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
|
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
|
||||||
static inline m_serial_return_code_t
|
static inline m_serial_return_code_t
|
||||||
@@ -562,4 +564,6 @@ typedef m_serial_read_t m_serial_json_read_t;
|
|||||||
#define M_OPL_m_serial_json_read_t() \
|
#define M_OPL_m_serial_json_read_t() \
|
||||||
(INIT_WITH(m_serial_json_read_init), CLEAR(m_serial_json_read_clear), TYPE(m_serial_json_read_t) )
|
(INIT_WITH(m_serial_json_read_init), CLEAR(m_serial_json_read_clear), TYPE(m_serial_json_read_t) )
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -29,6 +29,8 @@
|
|||||||
#include "m-atomic.h"
|
#include "m-atomic.h"
|
||||||
#include "m-genint.h"
|
#include "m-genint.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* Define the oplist of a shared pointer.
|
/* Define the oplist of a shared pointer.
|
||||||
USAGE: SHARED_OPLIST(name [, oplist_of_the_type]) */
|
USAGE: SHARED_OPLIST(name [, oplist_of_the_type]) */
|
||||||
#define SHARED_PTR_OPLIST(...) \
|
#define SHARED_PTR_OPLIST(...) \
|
||||||
@@ -450,5 +452,6 @@ static inline int sharedi_integer_cref(int *p) { return *p; }
|
|||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -29,6 +29,8 @@
|
|||||||
#include "m-core.h"
|
#include "m-core.h"
|
||||||
#include "m-genint.h"
|
#include "m-genint.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* Define a Single Producer Single Consummer snapshot and its functions
|
/* Define a Single Producer Single Consummer snapshot and its functions
|
||||||
USAGE: SNAPSHOT_SPSC_DEF(name, type[, oplist]) */
|
USAGE: SNAPSHOT_SPSC_DEF(name, type[, oplist]) */
|
||||||
#define SNAPSHOT_SPSC_DEF(name, ...) \
|
#define SNAPSHOT_SPSC_DEF(name, ...) \
|
||||||
@@ -676,4 +678,6 @@ static inline void snapshot_mrsw_int_read_end(snapshot_mrsw_int_t s, unsigned in
|
|||||||
|
|
||||||
//TODO: _set_, _init_set
|
//TODO: _set_, _init_set
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include "m-core.h"
|
#include "m-core.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/********************************** INTERNAL ************************************/
|
/********************************** INTERNAL ************************************/
|
||||||
|
|
||||||
/* If within the tests, perform additional checks */
|
/* If within the tests, perform additional checks */
|
||||||
@@ -2126,5 +2128,6 @@ namespace m_string {
|
|||||||
((const struct M_C(name, _s) *)(m_string::m_bounded_string<sizeof (M_C(name, _t))>(string).s))
|
((const struct M_C(name, _s) *)(m_string::m_bounded_string<sizeof (M_C(name, _t))>(string).s))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -93,6 +93,8 @@
|
|||||||
# error M_USE_WORKER_CPP_FUNCTION and M_USE_WORKER_CLANG_BLOCK are both defined. This is not supported.
|
# error M_USE_WORKER_CPP_FUNCTION and M_USE_WORKER_CLANG_BLOCK are both defined. This is not supported.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* Definition of a work order */
|
/* Definition of a work order */
|
||||||
typedef struct work_order_s {
|
typedef struct work_order_s {
|
||||||
struct worker_sync_s *block; // Reference to the shared Synchronization block
|
struct worker_sync_s *block; // Reference to the shared Synchronization block
|
||||||
@@ -522,6 +524,7 @@ worker_count(worker_t g)
|
|||||||
#define WORKER_PROPAGATE_LOCAL_OUTPUT(...) \
|
#define WORKER_PROPAGATE_LOCAL_OUTPUT(...) \
|
||||||
M_MAP(WORKER_PROPAGATE_SINGLE_OUTPUT, __VA_ARGS__)
|
M_MAP(WORKER_PROPAGATE_SINGLE_OUTPUT, __VA_ARGS__)
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#else /* M_USE_WORKER */
|
#else /* M_USE_WORKER */
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include "m-string.h"
|
#include "m-string.h"
|
||||||
|
|
||||||
|
M_BEGIN_PROTECTED_CODE
|
||||||
|
|
||||||
/* This is a trivial encapsulation of an opaque structure.
|
/* This is a trivial encapsulation of an opaque structure.
|
||||||
Used for test purpose only.*/
|
Used for test purpose only.*/
|
||||||
typedef struct testobj_s {
|
typedef struct testobj_s {
|
||||||
@@ -170,4 +172,6 @@ static inline void testobj_str(string_t str, const testobj_t z, bool append)
|
|||||||
CMP(testobj_cmp) \
|
CMP(testobj_cmp) \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
M_END_PROTECTED_CODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in new issue
Block a user