diff options
Diffstat (limited to 'include/my_global.h')
-rw-r--r-- | include/my_global.h | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/include/my_global.h b/include/my_global.h index 7fc0f9250e0..38cc87bb42d 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -567,31 +567,43 @@ int __void__; #endif #endif /* DONT_DEFINE_VOID */ -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) -#define LINT_INIT(var) var=0 /* No uninitialize-warning */ -#else -#define LINT_INIT(var) -#endif +/* + Try to suppress warning for not initialized variables. -#include <my_valgrind.h> + With gcc when using C, we suppress the uninitialized variable warning + without generating code. We can't do this with C++ + for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772). +*/ -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(HAVE_valgrind) -#define VALGRIND_OR_LINT_INIT(var) var=0 +#if defined(FORCE_INIT_OF_VARS) +#define LINT_INIT(var) var= 0 +#if defined(__cplusplus) || !defined(__GNUC__) +#define UNINIT_VAR(x) x= 0 +#else +/* GCC specific self-initialization which inhibits the warning. */ +#define UNINIT_VAR(x) x= x +#endif +#else /* !FORCE_INIT_OF_VARS */ +#define LINT_INIT(var) +#if !defined(__cplusplus) && !defined(__GNUC__) +/* GCC specific self-initialization which inhibits the warning. */ +#define UNINIT_VAR(x) x= x #else -#define VALGRIND_OR_LINT_INIT(var) +#define UNINIT_VAR(x) x #endif +#endif /* FORCE_INIT_OF_VARS */ -/* - Suppress uninitialized variable warning without generating code. +#include <my_valgrind.h> - The _cplusplus is a temporary workaround for C++ code pending a fix - for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772). +/* + The following is to force some unitialized variables to 0 if we are + running valgrind. This is needed when the compiler may access the variable + even if the value of it is never used. */ -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(__cplusplus) || \ - !defined(__GNUC__) -#define UNINIT_VAR(x) x= 0 +#if defined(HAVE_valgrind) +#define VALGRIND_OR_LINT_INIT(var) var=0 #else -#define UNINIT_VAR(x) x= x +#define VALGRIND_OR_LINT_INIT(var) LINT_INIT(var) #endif /* Define some useful general macros */ @@ -613,8 +625,8 @@ typedef unsigned short ushort; #define test(a) ((a) ? 1 : 0) #define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0) #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0) -#define test_all_bits(a,b) (((a) & (b)) == (b)) #define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1)) +#define test_all_bits(a,b) (((a) & (b)) == (b)) #define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0]))) /* Define some general constants */ @@ -635,7 +647,7 @@ typedef unsigned short ushort; #define my_const_cast(A) (A) #endif -#include <my_attribute.h> +#include <my_compiler.h> /* Wen using the embedded library, users might run into link problems, @@ -671,7 +683,7 @@ C_MODE_END # endif #endif -typedef char my_bool; /* Small bool */ +typedef char my_bool; /* Small bool; Needed by my_dbug.h */ #include <my_dbug.h> #define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/ @@ -950,13 +962,11 @@ typedef long long my_ptrdiff_t; #define ALIGN_MAX_UNIT (sizeof(double)) /* Size to make adressable obj. */ #define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A), sizeof(double))) +/* Offset of field f in structure t */ #define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f) #define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size) #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B)) -#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B)) -#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))] - /* Custom version of standard offsetof() macro which can be used to get offsets of members in class for non-POD types (according to the current |