diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 6 | ||||
-rw-r--r-- | include/m_string.h | 6 | ||||
-rw-r--r-- | include/my_bitmap.h | 16 | ||||
-rw-r--r-- | include/my_compiler.h | 129 | ||||
-rw-r--r-- | include/my_global.h | 56 | ||||
-rw-r--r-- | include/my_pthread.h | 7 | ||||
-rw-r--r-- | include/mysql.h | 2 | ||||
-rw-r--r-- | include/mysql.h.pp | 1 | ||||
-rw-r--r-- | include/mysys_err.h | 10 |
9 files changed, 177 insertions, 56 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 4d932d3159c..ff0eff4668c 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -40,7 +40,8 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \ my_vle.h my_user.h my_atomic.h atomic/nolock.h \ atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \ atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \ - wqueue.h waiting_threads.h + wqueue.h waiting_threads.h my_compiler.h + EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp # Remove built files and the symlinked directories @@ -68,6 +69,3 @@ my_config.h: config.h # generated by configure from the .h.in files dist-hook: $(RM) -f $(distdir)/mysql_version.h $(distdir)/my_config.h - -# Don't update the files from bitkeeper -%::SCCS/s.% diff --git a/include/m_string.h b/include/m_string.h index 6af7c7f9fa2..3331089a54c 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -33,10 +33,6 @@ /* need by my_vsnprintf */ #include <stdarg.h> -#ifdef _AIX -#undef HAVE_BCMP -#endif - /* This is needed for the definitions of bzero... on solaris */ #if defined(HAVE_STRINGS_H) #include <strings.h> @@ -114,7 +110,7 @@ extern void bfill(uchar *dst,size_t len,pchar fill); #endif #if !defined(bzero) && !defined(HAVE_BZERO) -extern void bzero(uchar * dst,size_t len); +extern void bzero(void * dst,size_t len); #endif #if !defined(bcmp) && !defined(HAVE_BCMP) diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 2c50ca3ec75..994c5cb4299 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -161,22 +161,6 @@ static inline my_bool bitmap_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2) #define bitmap_set_all(MAP) \ (memset((MAP)->bitmap, 0xFF, 4*no_words_in_map((MAP)))) -/** - check, set and clear a bit of interest of an integer. - - If the bit is out of range @retval -1. Otherwise - bit_is_set @return 0 or 1 reflecting the bit is set or not; - bit_do_set @return 1 (bit is set 1) - bit_do_clear @return 0 (bit is cleared to 0) -*/ - -#define bit_is_set(I,B) (sizeof(I) * CHAR_BIT > (B) ? \ - (((I) & (ULL(1) << (B))) == 0 ? 0 : 1) : -1) -#define bit_do_set(I,B) (sizeof(I) * CHAR_BIT > (B) ? \ - ((I) |= (ULL(1) << (B)), 1) : -1) -#define bit_do_clear(I,B) (sizeof(I) * CHAR_BIT > (B) ? \ - ((I) &= ~(ULL(1) << (B)), 0) : -1) - #ifdef __cplusplus } #endif diff --git a/include/my_compiler.h b/include/my_compiler.h new file mode 100644 index 00000000000..1cd46ff4260 --- /dev/null +++ b/include/my_compiler.h @@ -0,0 +1,129 @@ +#ifndef MY_COMPILER_INCLUDED +#define MY_COMPILER_INCLUDED + +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + Header for compiler-dependent features. + + Intended to contain a set of reusable wrappers for preprocessor + macros, attributes, pragmas, and any other features that are + specific to a target compiler. +*/ + +#include <my_global.h> /* stddef.h offsetof */ + +/** + Compiler-dependent internal convenience macros. +*/ + +/* GNU C/C++ */ +#if defined __GNUC__ +/* Any after 2.95... */ +# define MY_ALIGN_EXT + +/* Microsoft Visual C++ */ +#elif defined _MSC_VER +# define MY_ALIGNOF(type) __alignof(type) +# define MY_ALIGNED(n) __declspec(align(n)) + +/* Oracle Solaris Studio */ +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# if __SUNPRO_C >= 0x590 +# define MY_ALIGN_EXT +# endif + +/* IBM XL C/C++ */ +#elif defined __xlC__ +# if __xlC__ >= 0x0600 +# define MY_ALIGN_EXT +# endif + +/* HP aCC */ +#elif defined(__HP_aCC) || defined(__HP_cc) +# if (__HP_aCC >= 60000) || (__HP_cc >= 60000) +# define MY_ALIGN_EXT +# endif +#endif + +#ifdef MY_ALIGN_EXT +/** Specifies the minimum alignment of a type. */ +# define MY_ALIGNOF(type) __alignof__(type) +/** Determine the alignment requirement of a type. */ +# define MY_ALIGNED(n) __attribute__((__aligned__((n)))) +#endif + +/** + Generic compiler-dependent features. +*/ +#ifndef MY_ALIGNOF +# ifdef __cplusplus + template<typename type> struct my_alignof_helper { char m1; type m2; }; + /* Invalid for non-POD types, but most compilers give the right answer. */ +# define MY_ALIGNOF(type) offsetof(my_alignof_helper<type>, m2) +# else +# define MY_ALIGNOF(type) offsetof(struct { char m1; type m2; }, m2) +# endif +#endif + +/** + C++ Type Traits +*/ + +#ifdef __cplusplus + +/** + Opaque storage with a particular alignment. +*/ +# if defined(MY_ALIGNED) +/* Partial specialization used due to MSVC++. */ +template<size_t alignment> struct my_alignment_imp; +template<> struct MY_ALIGNED(1) my_alignment_imp<1> {}; +template<> struct MY_ALIGNED(2) my_alignment_imp<2> {}; +template<> struct MY_ALIGNED(4) my_alignment_imp<4> {}; +template<> struct MY_ALIGNED(8) my_alignment_imp<8> {}; +template<> struct MY_ALIGNED(16) my_alignment_imp<16> {}; +/* ... expand as necessary. */ +# else +template<size_t alignment> +struct my_alignment_imp { double m1; }; +# endif + +/** + A POD type with a given size and alignment. + + @remark If the compiler does not support a alignment attribute + (MY_ALIGN macro), the default alignment of a double is + used instead. + + @tparam size The minimum size. + @tparam alignment The desired alignment: 1, 2, 4, 8 or 16. +*/ +template <size_t size, size_t alignment> +struct my_aligned_storage +{ + union + { + char data[size]; + my_alignment_imp<alignment> align; + }; +}; + +#endif /* __cplusplus */ + +#include <my_attribute.h> + +#endif /* MY_COMPILER_INCLUDED */ 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 diff --git a/include/my_pthread.h b/include/my_pthread.h index 9b01146cdde..7d0d04764b3 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -274,13 +274,14 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */ we want to make sure that no such flags are set. */ #if defined(HAVE_SIGACTION) && !defined(my_sigset) -#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; int l_rc; \ +#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; \ + IF_DBUG(int l_rc); \ DBUG_ASSERT((A) != 0); \ sigemptyset(&l_set); \ l_s.sa_handler = (B); \ l_s.sa_mask = l_set; \ l_s.sa_flags = 0; \ - l_rc= sigaction((A), &l_s, (struct sigaction *) NULL);\ + IF_DBUG(l_rc=) sigaction((A), &l_s, NULL); \ DBUG_ASSERT(l_rc == 0); \ } while (0) #elif defined(HAVE_SIGSET) && !defined(my_sigset) @@ -755,7 +756,7 @@ extern uint thd_lib_detected; The implementation is guaranteed to be thread safe, on all platforms. Note that the calling code should *not* assume the counter is protected by the mutex given, as the implementation of these helpers may change - to use my_atomic operations instead. + to use atomic operations instead. */ /* diff --git a/include/mysql.h b/include/mysql.h index 074098aef1b..0a3c3241168 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -44,7 +44,9 @@ extern "C" { #endif #ifndef _global_h /* If not standard header */ +#ifndef MYSQL_ABI_CHECK #include <sys/types.h> +#endif #ifdef __LCC__ #include <winsock2.h> /* For windows */ #endif diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 3fb232cea51..c3d10e5a7b9 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -1,4 +1,3 @@ -#include <sys/types.h> typedef char my_bool; typedef int my_socket; #include "mysql_version.h" diff --git a/include/mysys_err.h b/include/mysys_err.h index defdaa71fa3..bbb7f6de7d8 100644 --- a/include/mysys_err.h +++ b/include/mysys_err.h @@ -62,10 +62,12 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */ #define EE_UNKNOWN_COLLATION 28 #define EE_FILENOTFOUND 29 #define EE_FILE_NOT_CLOSED 30 -#define EE_CANT_CHMOD 31 -#define EE_CANT_SEEK 32 -#define EE_CANT_COPY_OWNERSHIP 33 -#define EE_ERROR_LAST 33 /* Copy last error nr */ +#define EE_CHANGE_OWNERSHIP 31 +#define EE_CHANGE_PERMISSIONS 32 +#define EE_CANT_CHMOD 33 +#define EE_CANT_SEEK 34 +#define EE_CANT_COPY_OWNERSHIP 35 +#define EE_ERROR_LAST 35 /* Copy last error nr */ /* Add error numbers before EE_ERROR_LAST and change it accordingly. */ /* exit codes for all MySQL programs */ |