Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated MySQL to version 6.0.2

  • Loading branch information...
commit ecf74ba853f4389cab780740faa80beaf16dc920 1 parent 4c71cf2
@TheDushan authored
Showing with 7,596 additions and 9,602 deletions.
  1. +38 −0 src/libs/mysql/include/atomic/gcc_builtins.h
  2. +115 −0 src/libs/mysql/include/atomic/generic-msvc.h
  3. +48 −0 src/libs/mysql/include/atomic/nolock.h
  4. +57 −0 src/libs/mysql/include/atomic/rwlock.h
  5. +69 −0 src/libs/mysql/include/atomic/x86-gcc.h
  6. +49 −0 src/libs/mysql/include/base64.h
  7. +392 −0 src/libs/mysql/include/config-win.h
  8. +11 −11 src/libs/mysql/include/decimal.h
  9. +1 −6 src/libs/mysql/include/errmsg.h
  10. +84 −0 src/libs/mysql/include/hash.h
  11. +20 −13 src/libs/mysql/include/keycache.h
  12. +260 −0 src/libs/mysql/include/lf.h
  13. +95 −101 src/libs/mysql/include/m_ctype.h
  14. +124 −26 src/libs/mysql/include/m_string.h
  15. +65 −0 src/libs/mysql/include/my_aes.h
  16. +58 −0 src/libs/mysql/include/my_alarm.h
  17. +2 −11 src/libs/mysql/include/my_alloc.h
  18. +254 −0 src/libs/mysql/include/my_atomic.h
  19. +0 −6 src/libs/mysql/include/my_attribute.h
  20. +626 −0 src/libs/mysql/include/my_base.h
  21. +109 −0 src/libs/mysql/include/my_bit.h
  22. +182 −0 src/libs/mysql/include/my_bitmap.h
  23. +57 −0 src/libs/mysql/include/my_charsets.h
  24. +0 −145 src/libs/mysql/include/my_compiler.h
  25. +111 −441 src/libs/mysql/include/my_config.h
  26. +9 −63 src/libs/mysql/include/my_dbug.h
  27. +9 −9 src/libs/mysql/include/my_dir.h
  28. +18 −55 src/libs/mysql/include/my_getopt.h
  29. +409 −272 src/libs/mysql/include/my_global.h
  30. +11 −16 src/libs/mysql/include/{mysql/services.h → my_libwrap.h}
  31. +1 −1  src/libs/mysql/include/my_list.h
  32. +54 −0 src/libs/mysql/include/my_md5.h
  33. +41 −5 src/libs/mysql/include/my_net.h
  34. +50 −0 src/libs/mysql/include/my_no_pthread.h
  35. +52 −0 src/libs/mysql/include/my_nosys.h
  36. +143 −351 src/libs/mysql/include/my_pthread.h
  37. +66 −0 src/libs/mysql/include/my_stacktrace.h
  38. +236 −113 src/libs/mysql/include/my_sys.h
  39. +172 −0 src/libs/mysql/include/my_time.h
  40. +96 −0 src/libs/mysql/include/my_tree.h
  41. +141 −0 src/libs/mysql/include/my_trie.h
  42. +1,479 −0 src/libs/mysql/include/my_uctype.h
  43. +38 −0 src/libs/mysql/include/my_vle.h
  44. +238 −0 src/libs/mysql/include/myisampack.h
  45. +63 −23 src/libs/mysql/include/mysql.h
  46. +0 −162 src/libs/mysql/include/mysql/client_plugin.h
  47. +0 −36 src/libs/mysql/include/mysql/innodb_priv.h
  48. +0 −633 src/libs/mysql/include/mysql/plugin.h
  49. +0 −138 src/libs/mysql/include/mysql/plugin_audit.h
  50. +0 −125 src/libs/mysql/include/mysql/plugin_auth.h
  51. +0 −105 src/libs/mysql/include/mysql/plugin_auth_common.h
  52. +0 −211 src/libs/mysql/include/mysql/plugin_ftparser.h
  53. +0 −1,434 src/libs/mysql/include/mysql/psi/mysql_file.h
  54. +0 −1,071 src/libs/mysql/include/mysql/psi/mysql_thread.h
  55. +0 −1,312 src/libs/mysql/include/mysql/psi/psi.h
  56. +0 −26 src/libs/mysql/include/mysql/psi/psi_abi_v1.h
  57. +0 −26 src/libs/mysql/include/mysql/psi/psi_abi_v2.h
  58. +0 −101 src/libs/mysql/include/mysql/service_my_snprintf.h
  59. +0 −130 src/libs/mysql/include/mysql/service_thd_alloc.h
  60. +0 −83 src/libs/mysql/include/mysql/service_thd_wait.h
  61. +0 −65 src/libs/mysql/include/mysql/service_thread_scheduler.h
  62. +47 −80 src/libs/mysql/include/mysql_com.h
  63. +0 −30 src/libs/mysql/include/mysql_embed.h
  64. +11 −15 src/libs/mysql/include/mysql_version.h
  65. +0 −711 src/libs/mysql/include/mysqld_ername.h
  66. +116 −99 src/libs/mysql/include/mysqld_error.h
  67. +41 −0 src/libs/mysql/include/mysys/rijndael.h
  68. +90 −0 src/libs/mysql/include/mysys_err.h
  69. +0 −633 src/libs/mysql/include/plugin.h
  70. +0 −138 src/libs/mysql/include/plugin_audit.h
  71. +0 −211 src/libs/mysql/include/plugin_ftparser.h
  72. +72 −0 src/libs/mysql/include/queues.h
  73. +66 −0 src/libs/mysql/include/sha1.h
  74. +72 −0 src/libs/mysql/include/sha2.h
  75. +2 −65 src/libs/mysql/include/sql_common.h
  76. +0 −220 src/libs/mysql/include/sql_state.h
  77. +0 −4 src/libs/mysql/include/sslopt-case.h
  78. +0 −49 src/libs/mysql/include/sslopt-longopts.h
  79. +0 −4 src/libs/mysql/include/sslopt-vars.h
  80. +254 −0 src/libs/mysql/include/t_ctype.h
  81. +110 −0 src/libs/mysql/include/thr_alarm.h
  82. +181 −0 src/libs/mysql/include/thr_lock.h
  83. +2 −17 src/libs/mysql/include/typelib.h
  84. +222 −0 src/libs/mysql/include/violite.h
  85. +130 −0 src/libs/mysql/include/waiting_threads.h
  86. +27 −0 src/libs/mysql/include/wqueue.h
  87. BIN  src/libs/mysql/lib/win32/libmysql.dll
  88. BIN  src/libs/mysql/lib/win32/libmysql.lib
  89. BIN  src/libs/mysql/lib/win32/libmysqld.dll
  90. BIN  src/libs/mysql/lib/win32/libmysqld.lib
  91. BIN  src/libs/mysql/lib/win64/libmysql.dll
  92. BIN  src/libs/mysql/lib/win64/libmysql.lib
  93. BIN  src/libs/mysql/lib/win64/libmysqld.dll
  94. BIN  src/libs/mysql/lib/win64/libmysqld.lib
View
38 src/libs/mysql/include/atomic/gcc_builtins.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 2008 MySQL AB
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#define MY_ATOMIC_MODE "atomic_builtins"
+
+#define make_atomic_add_body(S) \
+ v= __sync_fetch_and_add(a, v);
+#define make_atomic_swap_body(S) \
+ v= __sync_lock_test_and_set(a, v);
+#define make_atomic_cas_body(S) \
+ int ## S sav; \
+ sav= __sync_val_compare_and_swap(a, *cmp, set); \
+ if (!(ret= (sav == *cmp))) *cmp= sav;
+
+#ifdef MY_ATOMIC_MODE_DUMMY
+#define make_atomic_load_body(S) ret= *a
+#define make_atomic_store_body(S) *a= v
+#define MY_ATOMIC_MODE "gcc-builtins-up"
+
+#else
+#define MY_ATOMIC_MODE "gcc-builtins-smp"
+#define make_atomic_load_body(S) \
+ ret= __sync_fetch_and_or(a, 0);
+#define make_atomic_store_body(S) \
+ (void) __sync_lock_test_and_set(a, v);
+#endif
View
115 src/libs/mysql/include/atomic/generic-msvc.h
@@ -0,0 +1,115 @@
+/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef _atomic_h_cleanup_
+#define _atomic_h_cleanup_ "atomic/generic-msvc.h"
+
+/*
+ We don't implement anything specific for MY_ATOMIC_MODE_DUMMY, always use
+ intrinsics.
+ 8 and 16-bit atomics are not implemented, but it can be done if necessary.
+*/
+
+/*
+ x86 compilers (both VS2003 or VS2005) never use instrinsics, but generate
+ function calls to kernel32 instead, even in the optimized build.
+ We force intrinsics as described in MSDN documentation for
+ _InterlockedCompareExchange.
+*/
+#ifdef _M_IX86
+
+#if (_MSC_VER >= 1500)
+#include <intrin.h>
+#else
+C_MODE_START
+/*Visual Studio 2003 and earlier do not have prototypes for atomic intrinsics*/
+LONG _InterlockedExchange (LONG volatile *Target,LONG Value);
+LONG _InterlockedCompareExchange (LONG volatile *Target, LONG Value, LONG Comp);
+LONG _InterlockedExchangeAdd (LONG volatile *Addend, LONG Value);
+C_MODE_END
+
+#pragma intrinsic(_InterlockedExchangeAdd)
+#pragma intrinsic(_InterlockedCompareExchange)
+#pragma intrinsic(_InterlockedExchange)
+#endif
+
+#define InterlockedExchange _InterlockedExchange
+#define InterlockedExchangeAdd _InterlockedExchangeAdd
+#define InterlockedCompareExchange _InterlockedCompareExchange
+/*
+ No need to do something special for InterlockedCompareExchangePointer
+ as it is a #define to InterlockedCompareExchange. The same applies to
+ InterlockedExchangePointer.
+*/
+#endif /*_M_IX86*/
+
+#define MY_ATOMIC_MODE "msvc-intrinsics"
+#define IL_EXCHG_ADD32(X,Y) InterlockedExchangeAdd((volatile LONG *)(X),(Y))
+#define IL_COMP_EXCHG32(X,Y,Z) InterlockedCompareExchange((volatile LONG *)(X),(Y),(Z))
+#define IL_COMP_EXCHGptr InterlockedCompareExchangePointer
+#define IL_EXCHG32(X,Y) InterlockedExchange((volatile LONG *)(X),(Y))
+#define IL_EXCHGptr InterlockedExchangePointer
+#define make_atomic_add_body(S) \
+ v= IL_EXCHG_ADD ## S (a, v)
+#define make_atomic_cas_body(S) \
+ int ## S initial_cmp= *cmp; \
+ int ## S initial_a= IL_COMP_EXCHG ## S (a, set, initial_cmp); \
+ if (!(ret= (initial_a == initial_cmp))) *cmp= initial_a;
+#define make_atomic_swap_body(S) \
+ v= IL_EXCHG ## S (a, v)
+#define make_atomic_load_body(S) \
+ ret= 0; /* avoid compiler warning */ \
+ ret= IL_COMP_EXCHG ## S (a, ret, ret);
+
+/*
+ my_yield_processor (equivalent of x86 PAUSE instruction) should be used
+ to improve performance on hyperthreaded CPUs. Intel recommends to use it in
+ spin loops also on non-HT machines to reduce power consumption (see e.g
+ http://softwarecommunity.intel.com/articles/eng/2004.htm)
+
+ Running benchmarks for spinlocks implemented with InterlockedCompareExchange
+ and YieldProcessor shows that much better performance is achieved by calling
+ YieldProcessor in a loop - that is, yielding longer. On Intel boxes setting
+ loop count in the range 200-300 brought best results.
+ */
+#ifndef YIELD_LOOPS
+#define YIELD_LOOPS 200
+#endif
+
+static __inline int my_yield_processor()
+{
+ int i;
+ for(i=0; i<YIELD_LOOPS; i++)
+ {
+#if (_MSC_VER <= 1310)
+ /* On older compilers YieldProcessor is not available, use inline assembly*/
+ __asm { rep nop }
+#else
+ YieldProcessor();
+#endif
+ }
+ return 1;
+}
+
+#define LF_BACKOFF my_yield_processor()
+#else /* cleanup */
+
+#undef IL_EXCHG_ADD32
+#undef IL_COMP_EXCHG32
+#undef IL_COMP_EXCHGptr
+#undef IL_EXCHG32
+#undef IL_EXCHGptr
+
+#endif
View
48 src/libs/mysql/include/atomic/nolock.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2006 MySQL AB
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#if defined(__i386__) || defined(_MSC_VER) || defined(__x86_64__) \
+ || defined(HAVE_GCC_ATOMIC_BUILTINS)
+
+# ifdef MY_ATOMIC_MODE_DUMMY
+# define LOCK_prefix ""
+# else
+# define LOCK_prefix "lock"
+# endif
+
+# ifdef HAVE_GCC_ATOMIC_BUILTINS
+# include "gcc_builtins.h"
+# elif __GNUC__
+# include "x86-gcc.h"
+# elif defined(_MSC_VER)
+# include "generic-msvc.h"
+# endif
+#endif
+
+#ifdef make_atomic_cas_body
+/*
+ Type not used so minimal size (emptry struct has different size between C
+ and C++, zero-length array is gcc-specific).
+*/
+typedef char my_atomic_rwlock_t __attribute__ ((unused));
+#define my_atomic_rwlock_destroy(name)
+#define my_atomic_rwlock_init(name)
+#define my_atomic_rwlock_rdlock(name)
+#define my_atomic_rwlock_wrlock(name)
+#define my_atomic_rwlock_rdunlock(name)
+#define my_atomic_rwlock_wrunlock(name)
+
+#endif
+
View
57 src/libs/mysql/include/atomic/rwlock.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 2006 MySQL AB
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
+#define MY_ATOMIC_MODE_RWLOCKS 1
+
+#ifdef MY_ATOMIC_MODE_DUMMY
+/*
+ the following can never be enabled by ./configure, one need to put #define in
+ a source to trigger the following warning. The resulting code will be broken,
+ it only makes sense to do it to see now test_atomic detects broken
+ implementations (another way is to run a UP build on an SMP box).
+*/
+#warning MY_ATOMIC_MODE_DUMMY and MY_ATOMIC_MODE_RWLOCKS are incompatible
+#define my_atomic_rwlock_destroy(name)
+#define my_atomic_rwlock_init(name)
+#define my_atomic_rwlock_rdlock(name)
+#define my_atomic_rwlock_wrlock(name)
+#define my_atomic_rwlock_rdunlock(name)
+#define my_atomic_rwlock_wrunlock(name)
+#define MY_ATOMIC_MODE "dummy (non-atomic)"
+#else
+/*
+ we're using read-write lock macros but map them to mutex locks, and they're
+ faster. Still, having semantically rich API we can change the
+ underlying implementation, if necessary.
+*/
+#define my_atomic_rwlock_destroy(name) pthread_mutex_destroy(& (name)->rw)
+#define my_atomic_rwlock_init(name) pthread_mutex_init(& (name)->rw, 0)
+#define my_atomic_rwlock_rdlock(name) pthread_mutex_lock(& (name)->rw)
+#define my_atomic_rwlock_wrlock(name) pthread_mutex_lock(& (name)->rw)
+#define my_atomic_rwlock_rdunlock(name) pthread_mutex_unlock(& (name)->rw)
+#define my_atomic_rwlock_wrunlock(name) pthread_mutex_unlock(& (name)->rw)
+#define MY_ATOMIC_MODE "mutex"
+#ifndef MY_ATOMIC_MODE_RWLOCKS
+#define MY_ATOMIC_MODE_RWLOCKS 1
+#endif
+#endif
+
+#define make_atomic_add_body(S) int ## S sav; sav= *a; *a+= v; v=sav;
+#define make_atomic_fas_body(S) int ## S sav; sav= *a; *a= v; v=sav;
+#define make_atomic_cas_body(S) if ((ret= (*a == *cmp))) *a= set; else *cmp=*a;
+#define make_atomic_load_body(S) ret= *a;
+#define make_atomic_store_body(S) *a= v;
+
View
69 src/libs/mysql/include/atomic/x86-gcc.h
@@ -0,0 +1,69 @@
+/* Copyright (C) 2006 MySQL AB
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ XXX 64-bit atomic operations can be implemented using
+ cmpxchg8b, if necessary. Though I've heard that not all 64-bit
+ architectures support double-word (128-bit) cas.
+*/
+
+#ifdef __x86_64__
+# ifdef MY_ATOMIC_NO_XADD
+# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix "-no-xadd"
+# else
+# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix
+# endif
+#else
+# ifdef MY_ATOMIC_NO_XADD
+# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix "-no-xadd"
+# else
+# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix
+# endif
+#endif
+
+/* fix -ansi errors while maintaining readability */
+#ifndef asm
+#define asm __asm__
+#endif
+
+#ifndef MY_ATOMIC_NO_XADD
+#define make_atomic_add_body(S) \
+ asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a))
+#endif
+#define make_atomic_fas_body(S) \
+ asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a))
+#define make_atomic_cas_body(S) \
+ asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \
+ : "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set))
+
+#ifdef MY_ATOMIC_MODE_DUMMY
+#define make_atomic_load_body(S) ret=*a
+#define make_atomic_store_body(S) *a=v
+#else
+/*
+ Actually 32-bit reads/writes are always atomic on x86
+ But we add LOCK_prefix here anyway to force memory barriers
+*/
+#define make_atomic_load_body(S) \
+ ret=0; \
+ asm volatile (LOCK_prefix "; cmpxchg %2, %0" \
+ : "+m" (*a), "+a" (ret): "r" (ret))
+#define make_atomic_store_body(S) \
+ asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v))
+#endif
+
+/* TODO test on intel whether the below helps. on AMD it makes no difference */
+//#define LF_BACKOFF ({asm volatile ("rep; nop"); 1; })
+
View
49 src/libs/mysql/include/base64.h
@@ -0,0 +1,49 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef __BASE64_H_INCLUDED__
+#define __BASE64_H_INCLUDED__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ Calculate how much memory needed for dst of base64_encode()
+*/
+int my_base64_needed_encoded_length(int length_of_data);
+
+/*
+ Calculate how much memory needed for dst of base64_decode()
+*/
+int my_base64_needed_decoded_length(int length_of_encoded_data);
+
+
+/*
+ Encode data as a base64 string
+*/
+int my_base64_encode(const void *src, size_t src_len, char *dst);
+
+/*
+ Decode a base64 string into data
+*/
+int my_base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !__BASE64_H_INCLUDED__ */
View
392 src/libs/mysql/include/config-win.h
@@ -0,0 +1,392 @@
+/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/* Defines for Win32 to make it compatible for MySQL */
+
+#define BIG_TABLES
+
+/*
+ Minimal version of Windows we should be able to run on.
+ Currently Windows 2000
+*/
+#define _WIN32_WINNT 0x0500
+
+
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+/* Avoid endless warnings about sprintf() etc. being unsafe. */
+#define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+
+#include <sys/locking.h>
+#include <sys/stat.h> /* chmod() constants*/
+#include <winsock2.h>
+#include <Ws2tcpip.h>
+#include <fcntl.h>
+#include <io.h>
+#include <malloc.h>
+#include <sys/stat.h>
+#include <process.h> /* getpid()*/
+
+#define HAVE_SMEM 1
+
+#if defined(_WIN64) || defined(WIN64)
+#define SYSTEM_TYPE "Win64"
+#elif defined(_WIN32) || defined(WIN32)
+#define SYSTEM_TYPE "Win32"
+#else
+#define SYSTEM_TYPE "Windows"
+#endif
+
+#if defined(_M_IA64)
+#define MACHINE_TYPE "ia64"
+#elif defined(_M_IX86)
+#define MACHINE_TYPE "ia32"
+#elif defined(_M_ALPHA)
+#define MACHINE_TYPE "axp"
+#else
+#define MACHINE_TYPE "unknown" /* Define to machine type name */
+#endif
+
+#if !(defined(_WIN64) || defined(WIN64))
+#ifndef _WIN32
+#define _WIN32 /* Compatible with old source */
+#endif
+#ifndef __WIN32__
+#define __WIN32__
+#endif
+#endif /* _WIN64 */
+#ifndef __WIN__
+#define __WIN__ /* To make it easier in VC++ */
+#endif
+
+#ifndef MAX_INDEXES
+#define MAX_INDEXES 64
+#endif
+
+/* File and lock constants */
+#ifdef __BORLANDC__
+#define F_RDLCK LK_NBLCK /* read lock */
+#define F_WRLCK LK_NBRLCK /* write lock */
+#define F_UNLCK LK_UNLCK /* remove lock(s) */
+#else
+#define F_RDLCK _LK_NBLCK /* read lock */
+#define F_WRLCK _LK_NBRLCK /* write lock */
+#define F_UNLCK _LK_UNLCK /* remove lock(s) */
+#endif
+
+#define F_EXCLUSIVE 1 /* We have only exclusive locking */
+#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */
+#define F_OK 0 /* parameter to access() */
+#define W_OK 2
+
+#define S_IROTH S_IREAD /* for my_lib */
+
+/* for MY_S_ISFIFO() macro from my_lib */
+#if defined (_S_IFIFO) && !defined (S_IFIFO)
+#define S_IFIFO _S_IFIFO
+#endif
+
+/* Winsock2 constant (Vista SDK and later)*/
+#define IPPROTO_IPV6 41
+#ifndef IPV6_V6ONLY
+#define IPV6_V6ONLY 27
+#endif
+
+/*
+ Constants used by chmod. Note, that group/others is ignored
+ - because unsupported by Windows due to different access control model.
+*/
+#define S_IRWXU S_IREAD|S_IWRITE
+#define S_IRWXG 0
+#define S_IRWXO 0
+typedef int mode_t;
+
+#ifdef __BORLANDC__
+#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
+#define O_TEMPORARY 0
+#define O_SHORT_LIVED 0
+#define SH_DENYNO _SH_DENYNO
+#else
+#define O_BINARY _O_BINARY /* compability with older style names */
+#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */
+#define O_TEMPORARY _O_TEMPORARY
+#define O_SHORT_LIVED _O_SHORT_LIVED
+#define SH_DENYNO _SH_DENYNO
+#endif
+#define NO_OPEN_3 /* For my_create() */
+
+#define SIGQUIT SIGTERM /* No SIGQUIT */
+
+#undef _REENTRANT /* Crashes something for win32 */
+#undef SAFE_MUTEX /* Can't be used on windows */
+
+#define LONGLONG_MIN 0x8000000000000000LL
+#define LONGLONG_MAX 0x7FFFFFFFFFFFFFFFLL
+#define ULONGLONG_MAX 0xFFFFFFFFFFFFFFFFULL
+
+/* Type information */
+
+#if !defined(HAVE_UINT)
+#undef HAVE_UINT
+#define HAVE_UINT
+typedef unsigned short ushort;
+typedef unsigned int uint;
+#endif /* !defined(HAVE_UINT) */
+
+typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
+typedef __int64 longlong;
+#ifndef HAVE_SIGSET_T
+typedef int sigset_t;
+#endif
+#define longlong_defined
+/*
+ off_t should not be __int64 because of conflicts in header files;
+ Use my_off_t or os_off_t instead
+*/
+#ifndef HAVE_OFF_T
+typedef long off_t;
+#endif
+typedef __int64 os_off_t;
+#ifdef _WIN64
+typedef UINT_PTR rf_SetTimer;
+#else
+typedef uint rf_SetTimer;
+#endif
+
+#ifndef HAVE_SIZE_T
+#ifndef _SIZE_T_DEFINED
+typedef SIZE_T size_t;
+#define _SIZE_T_DEFINED
+#endif
+#endif
+
+#ifndef HAVE_SSIZE_T
+#ifndef _SSIZE_T_DEFINED
+typedef SSIZE_T ssize_t;
+#define _SSIZE_T_DEFINED
+#endif
+#endif
+
+#define Socket_defined
+#define my_socket SOCKET
+#define SIGPIPE SIGINT
+#define RETQSORTTYPE void
+#define QSORT_TYPE_IS_VOID
+#define SOCKET_SIZE_TYPE int
+#define my_socket_defined
+#define byte_defined
+#define HUGE_PTR
+#define STDCALL __stdcall /* Used by libmysql.dll */
+#define isnan(X) _isnan(X)
+#define finite(X) _finite(X)
+
+#ifndef UNDEF_THREAD_HACK
+#define THREAD
+#endif
+#define VOID_SIGHANDLER
+#define SIZEOF_CHAR 1
+#define SIZEOF_INT 4
+#define SIZEOF_LONG 4
+#define SIZEOF_LONG_LONG 8
+#define SIZEOF_OFF_T 8
+#ifdef _WIN64
+#define SIZEOF_CHARP 8
+#else
+#define SIZEOF_CHARP 4
+#endif
+#define HAVE_BROKEN_NETINET_INCLUDES
+#ifdef _WIN32
+#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
+#endif
+
+/* ERROR is defined in wingdi.h */
+#undef ERROR
+
+/* We need to close files to break connections on shutdown */
+#ifndef SIGNAL_WITH_VIO_CLOSE
+#define SIGNAL_WITH_VIO_CLOSE
+#endif
+
+/* All windows servers should support .sym files */
+#undef USE_SYMDIR
+#define USE_SYMDIR
+
+/* If LOAD DATA LOCAL INFILE should be enabled by default */
+#define ENABLED_LOCAL_INFILE 1
+
+/* If query profiling should be enabled by default */
+#define ENABLED_PROFILING 1
+
+/* Convert some simple functions to Posix */
+
+#define my_sigset(A,B) signal((A),(B))
+#define finite(A) _finite(A)
+#define sleep(A) Sleep((A)*1000)
+#define popen(A,B) _popen((A),(B))
+#define pclose(A) _pclose(A)
+
+#ifndef __BORLANDC__
+#define access(A,B) _access(A,B)
+#endif
+
+#if !defined(__cplusplus)
+#define inline __inline
+#endif /* __cplusplus */
+
+#ifdef _WIN64
+#define ulonglong2double(A) ((double) (ulonglong) (A))
+#define my_off_t2double(A) ((double) (my_off_t) (A))
+
+#else
+inline double ulonglong2double(ulonglong value)
+{
+ longlong nr=(longlong) value;
+ if (nr >= 0)
+ return (double) nr;
+ return (18446744073709551616.0 + (double) nr);
+}
+#define my_off_t2double(A) ulonglong2double(A)
+#endif /* _WIN64 */
+
+inline ulonglong double2ulonglong(double d)
+{
+ double t= d - (double) 0x8000000000000000ULL;
+
+ if (t >= 0)
+ return ((ulonglong) t) + 0x8000000000000000ULL;
+ return (ulonglong) d;
+}
+
+#if SIZEOF_OFF_T > 4
+#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
+#define tell(A) _telli64(A)
+#endif
+
+#define STACK_DIRECTION -1
+
+/* Difference between GetSystemTimeAsFileTime() and now() */
+#define OFFSET_TO_EPOCH 116444736000000000ULL
+
+#define HAVE_PERROR
+#define HAVE_VFPRINT
+#define HAVE_RENAME /* Have rename() as function */
+#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */
+#define HAVE_LONG_JMP /* Have long jump function */
+#define HAVE_LOCKING /* have locking() call */
+#define HAVE_ERRNO_AS_DEFINE /* errno is a define */
+#define HAVE_STDLIB /* everything is include in this file */
+#define HAVE_MEMCPY
+#define HAVE_MEMMOVE
+#define HAVE_GETCWD
+#define HAVE_TELL
+#define HAVE_TZNAME
+#define HAVE_PUTENV
+#define HAVE_SELECT
+#define HAVE_SETLOCALE
+#define HAVE_SOCKET /* Giangi */
+#define HAVE_FLOAT_H
+#define HAVE_LIMITS_H
+#define HAVE_STDDEF_H
+#define NO_FCNTL_NONBLOCK /* No FCNTL */
+#define HAVE_ALLOCA
+#define HAVE_STRPBRK
+#define HAVE_STRSTR
+#define HAVE_COMPRESS
+#define HAVE_CREATESEMAPHORE
+#define HAVE_ISNAN
+#define HAVE_FINITE
+#define HAVE_QUERY_CACHE
+#define SPRINTF_RETURNS_INT
+#define HAVE_SETFILEPOINTER
+#define HAVE_VIO_READ_BUFF
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+/* strnlen() appeared in Studio 2005 */
+#define HAVE_STRNLEN
+#endif
+#define HAVE_WINSOCK2
+
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+
+#ifndef _WIN32
+#undef FILE_SHARE_DELETE
+#define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */
+#endif
+
+#ifdef NOT_USED
+#define HAVE_SNPRINTF /* Gave link error */
+#define _snprintf snprintf
+#endif
+
+#ifdef _MSC_VER
+#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
+#define HAVE_ANSI_INCLUDE
+#define HAVE_SYS_UTIME_H
+#define HAVE_STRTOUL
+#endif
+#define my_reinterpret_cast(A) reinterpret_cast <A>
+#define my_const_cast(A) const_cast<A>
+
+
+/* MYSQL OPTIONS */
+
+#ifdef _CUSTOMCONFIG_
+#include <custom_conf.h>
+#else
+#define DEFAULT_MYSQL_HOME "c:\\mysql"
+#define DATADIR "c:\\mysql\\data"
+#define PACKAGE "mysql"
+#define DEFAULT_BASEDIR "C:\\"
+#define SHAREDIR "share"
+#define DEFAULT_CHARSET_HOME "C:/mysql/"
+#endif
+#ifndef DEFAULT_HOME_ENV
+#define DEFAULT_HOME_ENV MYSQL_HOME
+#endif
+#ifndef DEFAULT_GROUP_SUFFIX_ENV
+#define DEFAULT_GROUP_SUFFIX_ENV MYSQL_GROUP_SUFFIX
+#endif
+
+/* File name handling */
+
+#define FN_LIBCHAR '\\'
+#define FN_ROOTDIR "\\"
+#define FN_DEVCHAR ':'
+#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
+#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
+#define OS_FILE_LIMIT UINT_MAX /* No limit*/
+
+#define DO_NOT_REMOVE_THREAD_WRAPPERS
+#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
+#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
+/* The following is only used for statistics, so it should be good enough */
+#ifdef _WIN32 /* This should also work on Win98 but .. */
+#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
+#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
+#endif
+
+#define shared_memory_buffer_length 16000
+#define default_shared_memory_base_name "MYSQL"
+
+#define HAVE_SPATIAL 1
+#define HAVE_RTREE_KEYS 1
+
+#define HAVE_OPENSSL 1
+#define HAVE_YASSL 1
+
+#define COMMUNITY_SERVER 1
+#define ENABLED_PROFILING 1
+
+#define HAVE_BOOL 1
View
22 src/libs/mysql/include/decimal.h
@@ -29,14 +29,14 @@ typedef struct st_decimal_t {
int internal_str2dec(const char *from, decimal_t *to, char **end,
my_bool fixed);
-int decimal2string(const decimal_t *from, char *to, int *to_len,
+int decimal2string(decimal_t *from, char *to, int *to_len,
int fixed_precision, int fixed_decimals,
char filler);
int decimal2ulonglong(decimal_t *from, ulonglong *to);
int ulonglong2decimal(ulonglong from, decimal_t *to);
int decimal2longlong(decimal_t *from, longlong *to);
int longlong2decimal(longlong from, decimal_t *to);
-int decimal2double(const decimal_t *from, double *to);
+int decimal2double(decimal_t *from, double *to);
int double2decimal(double from, decimal_t *to);
int decimal_actual_fraction(decimal_t *from);
int decimal2bin(decimal_t *from, uchar *to, int precision, int scale);
@@ -47,17 +47,17 @@ int decimal_bin_size(int precision, int scale);
int decimal_result_size(decimal_t *from1, decimal_t *from2, char op,
int param);
-int decimal_intg(const decimal_t *from);
-int decimal_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
-int decimal_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
-int decimal_cmp(const decimal_t *from1, const decimal_t *from2);
-int decimal_mul(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
-int decimal_div(const decimal_t *from1, const decimal_t *from2, decimal_t *to,
+int decimal_intg(decimal_t *from);
+int decimal_add(decimal_t *from1, decimal_t *from2, decimal_t *to);
+int decimal_sub(decimal_t *from1, decimal_t *from2, decimal_t *to);
+int decimal_cmp(decimal_t *from1, decimal_t *from2);
+int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to);
+int decimal_div(decimal_t *from1, decimal_t *from2, decimal_t *to,
int scale_incr);
-int decimal_mod(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
-int decimal_round(const decimal_t *from, decimal_t *to, int new_scale,
+int decimal_mod(decimal_t *from1, decimal_t *from2, decimal_t *to);
+int decimal_round(decimal_t *from, decimal_t *to, int new_scale,
decimal_round_mode mode);
-int decimal_is_zero(const decimal_t *from);
+int decimal_is_zero(decimal_t *from);
void max_decimal(int precision, int frac, decimal_t *to);
#define string2decimal(A,B,C) internal_str2dec((A), (B), (C), 0)
View
7 src/libs/mysql/include/errmsg.h
@@ -1,6 +1,3 @@
-#ifndef ERRMSG_INCLUDED
-#define ERRMSG_INCLUDED
-
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -101,8 +98,6 @@ extern const char *client_errors[]; /* Error messages */
#define CR_STMT_CLOSED 2056
#define CR_NEW_STMT_METADATA 2057
#define CR_ALREADY_CONNECTED 2058
-#define CR_AUTH_PLUGIN_CANNOT_LOAD 2059
-#define CR_ERROR_LAST /*Copy last error nr:*/ 2059
+#define CR_ERROR_LAST /*Copy last error nr:*/ 2058
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
-#endif /* ERRMSG_INCLUDED */
View
84 src/libs/mysql/include/hash.h
@@ -0,0 +1,84 @@
+/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/* Dynamic hashing of record with different key-length */
+
+#ifndef _hash_h
+#define _hash_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ Overhead to store an element in hash
+ Can be used to approximate memory consumption for a hash
+ */
+#define HASH_OVERHEAD (sizeof(char*)*2)
+
+/* flags for hash_init */
+#define HASH_UNIQUE 1 /* hash_insert fails on duplicate key */
+
+typedef uchar *(*my_hash_get_key)(const uchar *,size_t*,my_bool);
+typedef void (*my_hash_free_key)(void *);
+typedef my_bool (*my_hash_walk_action)(void *,void *);
+
+typedef struct st_hash {
+ size_t key_offset,key_length; /* Length of key if const length */
+ size_t blength;
+ ulong records;
+ uint flags;
+ DYNAMIC_ARRAY array; /* Place for hash_keys */
+ my_hash_get_key get_key;
+ void (*free)(void *);
+ CHARSET_INFO *charset;
+} HASH;
+
+/* A search iterator state */
+typedef uint HASH_SEARCH_STATE;
+
+#define my_hash_init(A,B,C,D,E,F,G,H) \
+ _my_hash_init(A,0,B,C,D,E,F,G,H CALLER_INFO)
+#define my_hash_init2(A,B,C,D,E,F,G,H,I) \
+ _my_hash_init(A,B,C,D,E,F,G,H,I CALLER_INFO)
+my_bool _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
+ ulong default_array_elements, size_t key_offset,
+ size_t key_length, my_hash_get_key get_key,
+ void (*free_element)(void*),
+ uint flags CALLER_INFO_PROTO);
+void my_hash_free(HASH *tree);
+void my_hash_reset(HASH *hash);
+uchar *my_hash_element(HASH *hash, ulong idx);
+uchar *my_hash_search(const HASH *info, const uchar *key, size_t length);
+uchar *my_hash_first(const HASH *info, const uchar *key, size_t length,
+ HASH_SEARCH_STATE *state);
+uchar *my_hash_next(const HASH *info, const uchar *key, size_t length,
+ HASH_SEARCH_STATE *state);
+my_bool my_hash_insert(HASH *info, const uchar *data);
+my_bool my_hash_delete(HASH *hash, uchar *record);
+my_bool my_hash_update(HASH *hash, uchar *record, uchar *old_key,
+ size_t old_key_length);
+void my_hash_replace(HASH *hash, HASH_SEARCH_STATE *state, uchar *new_row);
+my_bool my_hash_check(HASH *hash); /* Only in debug library */
+my_bool my_hash_iterate(HASH *hash, my_hash_walk_action action, void *argument);
+
+#define my_hash_clear(H) bzero((char*) (H), sizeof(*(H)))
+#define my_hash_inited(H) ((H)->array.buffer != 0)
+#define my_hash_init_opt(A,B,C,D,E,F,G,H) \
+ (!my_hash_inited(A) && _my_hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO))
+
+#ifdef __cplusplus
+}
+#endif
+#endif
View
33 src/libs/mysql/include/keycache.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 MySQL AB, 2009 Sun Microsystems, Inc
+/* Copyright (C) 2003 MySQL AB
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
@@ -13,13 +13,13 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-/* Key cache variable structures */
+/**
+ @file
+ Key cache API
+*/
#ifndef _keycache_h
#define _keycache_h
-
-#include "my_sys.h" /* flush_type */
-
C_MODE_START
/* declare structures that is used by st_key_cache */
@@ -37,6 +37,10 @@ typedef struct st_keycache_wqueue
struct st_my_thread_var *last_thread; /* circular list of waiting threads */
} KEYCACHE_WQUEUE;
+/** Callback called when any block is flushed */
+typedef int (*KEYCACHE_POST_WRITE_CALLBACK)(void *arg, const uchar *buffert,
+ uint length, my_off_t filepos);
+
#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */
/*
@@ -70,10 +74,10 @@ typedef struct st_key_cache
HASH_LINK *free_hash_list; /* list of free hash links */
BLOCK_LINK *free_block_list; /* list of free blocks */
BLOCK_LINK *block_root; /* memory for block links */
- uchar *block_mem; /* memory for block buffers */
+ uchar HUGE_PTR *block_mem; /* memory for block buffers */
BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
- mysql_mutex_t cache_lock; /* to lock access to the cache structure */
+ pthread_mutex_t cache_lock; /* to lock access to the cache structure */
KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */
/*
Waiting for a zero resize count. Using a queue for symmetry though
@@ -84,16 +88,17 @@ typedef struct st_key_cache
KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */
BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/
BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/
+ KEYCACHE_POST_WRITE_CALLBACK post_write;/**< Called when flushing any block*/
/*
The following variables are and variables used to hold parameters for
initializing the key cache.
*/
- ulonglong param_buff_size; /* size the memory allocated for the cache */
- ulonglong param_block_size; /* size of the blocks in the key cache */
- ulonglong param_division_limit; /* min. percentage of warm blocks */
- ulonglong param_age_threshold; /* determines when hot block is downgraded */
+ ulonglong param_buff_size; /* size the memory allocated for the cache */
+ ulong param_block_size; /* size of the blocks in the key cache */
+ ulong param_division_limit; /* min. percentage of warm blocks */
+ ulong param_age_threshold; /* determines when hot block is downgraded */
/* Statistics variables. These are reset in reset_key_cache_counters(). */
ulong global_blocks_changed; /* number of currently dirty blocks */
@@ -127,7 +132,8 @@ extern int key_cache_insert(KEY_CACHE *keycache,
extern int key_cache_write(KEY_CACHE *keycache,
File file, my_off_t filepos, int level,
uchar *buff, uint length,
- uint block_length,int force_write);
+ uint block_length, int force_write,
+ void *post_write_arg);
extern int flush_key_blocks(KEY_CACHE *keycache,
int file, enum flush_type type);
extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup);
@@ -135,7 +141,8 @@ extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup);
/* Functions to handle multiple key caches */
extern my_bool multi_keycache_init(void);
extern void multi_keycache_free(void);
-extern KEY_CACHE *multi_key_cache_search(uchar *key, uint length);
+extern KEY_CACHE *multi_key_cache_search(uchar *key, uint length,
+ KEY_CACHE *def);
extern my_bool multi_key_cache_set(const uchar *key, uint length,
KEY_CACHE *key_cache);
extern void multi_key_cache_change(KEY_CACHE *old_data,
View
260 src/libs/mysql/include/lf.h
@@ -0,0 +1,260 @@
+/* Copyright (C) 2007-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef _lf_h
+#define _lf_h
+
+#include <my_atomic.h>
+
+/*
+ Helpers to define both func() and _func(), where
+ func() is a _func() protected by my_atomic_rwlock_wrlock()
+*/
+
+#define lock_wrap(f, t, proto_args, args, lock) \
+t _ ## f proto_args; \
+static inline t f proto_args \
+{ \
+ t ret; \
+ my_atomic_rwlock_wrlock(lock); \
+ ret= _ ## f args; \
+ my_atomic_rwlock_wrunlock(lock); \
+ return ret; \
+}
+
+#define lock_wrap_void(f, proto_args, args, lock) \
+void _ ## f proto_args; \
+static inline void f proto_args \
+{ \
+ my_atomic_rwlock_wrlock(lock); \
+ _ ## f args; \
+ my_atomic_rwlock_wrunlock(lock); \
+}
+
+#define nolock_wrap(f, t, proto_args, args) \
+t _ ## f proto_args; \
+static inline t f proto_args \
+{ \
+ return _ ## f args; \
+}
+
+#define nolock_wrap_void(f, proto_args, args) \
+void _ ## f proto_args; \
+static inline void f proto_args \
+{ \
+ _ ## f args; \
+}
+
+/*
+ wait-free dynamic array, see lf_dynarray.c
+
+ 4 levels of 256 elements each mean 4311810304 elements in an array - it
+ should be enough for a while
+*/
+#define LF_DYNARRAY_LEVEL_LENGTH 256
+#define LF_DYNARRAY_LEVELS 4
+
+typedef struct {
+ void * volatile level[LF_DYNARRAY_LEVELS];
+ uint size_of_element;
+ my_atomic_rwlock_t lock;
+} LF_DYNARRAY;
+
+typedef int (*lf_dynarray_func)(void *, void *);
+
+void lf_dynarray_init(LF_DYNARRAY *array, uint element_size);
+void lf_dynarray_destroy(LF_DYNARRAY *array);
+
+nolock_wrap(lf_dynarray_value, void *,
+ (LF_DYNARRAY *array, uint idx),
+ (array, idx))
+lock_wrap(lf_dynarray_lvalue, void *,
+ (LF_DYNARRAY *array, uint idx),
+ (array, idx),
+ &array->lock)
+nolock_wrap(lf_dynarray_iterate, int,
+ (LF_DYNARRAY *array, lf_dynarray_func func, void *arg),
+ (array, func, arg))
+
+/*
+ pin manager for memory allocator, lf_alloc-pin.c
+*/
+
+#define LF_PINBOX_PINS 4
+#define LF_PURGATORY_SIZE 10
+
+typedef void lf_pinbox_free_func(void *, void *, void*);
+
+typedef struct {
+ LF_DYNARRAY pinarray;
+ lf_pinbox_free_func *free_func;
+ void *free_func_arg;
+ uint free_ptr_offset;
+ uint32 volatile pinstack_top_ver; /* this is a versioned pointer */
+ uint32 volatile pins_in_array; /* number of elements in array */
+} LF_PINBOX;
+
+typedef struct {
+ void * volatile pin[LF_PINBOX_PINS];
+ LF_PINBOX *pinbox;
+ void **stack_ends_here;
+ void *purgatory;
+ uint32 purgatory_count;
+ uint32 volatile link;
+/* we want sizeof(LF_PINS) to be 64 to avoid false sharing */
+#if SIZEOF_INT*2+SIZEOF_CHARP*(LF_PINBOX_PINS+3) != 64
+ char pad[64-sizeof(uint32)*2-sizeof(void*)*(LF_PINBOX_PINS+3)];
+#endif
+} LF_PINS;
+
+/*
+ shortcut macros to do an atomic_wrlock on a structure that uses pins
+ (e.g. lf_hash).
+*/
+#define lf_rwlock_by_pins(PINS) \
+ my_atomic_rwlock_wrlock(&(PINS)->pinbox->pinarray.lock)
+#define lf_rwunlock_by_pins(PINS) \
+ my_atomic_rwlock_wrunlock(&(PINS)->pinbox->pinarray.lock)
+
+/*
+ compile-time assert, to require "no less than N" pins
+ it's enough if it'll fail on at least one compiler, so
+ we'll enable it on GCC only, which supports zero-length arrays.
+*/
+#if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG)
+#define LF_REQUIRE_PINS(N) \
+ static const char require_pins[LF_PINBOX_PINS-N] \
+ __attribute__ ((unused)); \
+ static const int LF_NUM_PINS_IN_THIS_FILE= N;
+#define _lf_pin(PINS, PIN, ADDR) \
+ ( \
+ assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \
+ my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)) \
+ )
+#else
+#define LF_REQUIRE_PINS(N)
+#define _lf_pin(PINS, PIN, ADDR) my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR))
+#endif
+
+#define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL)
+#define lf_pin(PINS, PIN, ADDR) \
+ do { \
+ lf_rwlock_by_pins(PINS); \
+ _lf_pin(PINS, PIN, ADDR); \
+ lf_rwunlock_by_pins(PINS); \
+ } while (0)
+#define lf_unpin(PINS, PIN) lf_pin(PINS, PIN, NULL)
+#define _lf_assert_pin(PINS, PIN) assert((PINS)->pin[PIN] != 0)
+#define _lf_assert_unpin(PINS, PIN) assert((PINS)->pin[PIN] == 0)
+
+void lf_pinbox_init(LF_PINBOX *pinbox, uint free_ptr_offset,
+ lf_pinbox_free_func *free_func, void * free_func_arg);
+void lf_pinbox_destroy(LF_PINBOX *pinbox);
+
+lock_wrap(lf_pinbox_get_pins, LF_PINS *,
+ (LF_PINBOX *pinbox),
+ (pinbox),
+ &pinbox->pinarray.lock)
+lock_wrap_void(lf_pinbox_put_pins,
+ (LF_PINS *pins),
+ (pins),
+ &pins->pinbox->pinarray.lock)
+lock_wrap_void(lf_pinbox_free,
+ (LF_PINS *pins, void *addr),
+ (pins, addr),
+ &pins->pinbox->pinarray.lock)
+
+/*
+ memory allocator, lf_alloc-pin.c
+*/
+
+typedef struct st_lf_allocator {
+ LF_PINBOX pinbox;
+ uchar * volatile top;
+ uint element_size;
+ uint32 volatile mallocs;
+ void (*constructor)(uchar *); /* called, when an object is malloc()'ed */
+ void (*destructor)(uchar *); /* called, when an object is free()'d */
+} LF_ALLOCATOR;
+
+void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset);
+void lf_alloc_destroy(LF_ALLOCATOR *allocator);
+uint lf_alloc_pool_count(LF_ALLOCATOR *allocator);
+/*
+ shortcut macros to access underlying pinbox functions from an LF_ALLOCATOR
+ see _lf_pinbox_get_pins() and _lf_pinbox_put_pins()
+*/
+#define _lf_alloc_free(PINS, PTR) _lf_pinbox_free((PINS), (PTR))
+#define lf_alloc_free(PINS, PTR) lf_pinbox_free((PINS), (PTR))
+#define _lf_alloc_get_pins(A) _lf_pinbox_get_pins(&(A)->pinbox)
+#define lf_alloc_get_pins(A) lf_pinbox_get_pins(&(A)->pinbox)
+#define _lf_alloc_put_pins(PINS) _lf_pinbox_put_pins(PINS)
+#define lf_alloc_put_pins(PINS) lf_pinbox_put_pins(PINS)
+#define lf_alloc_direct_free(ALLOC, ADDR) my_free((uchar*)(ADDR), MYF(0))
+
+lock_wrap(lf_alloc_new, void *,
+ (LF_PINS *pins),
+ (pins),
+ &pins->pinbox->pinarray.lock)
+
+/*
+ extendible hash, lf_hash.c
+*/
+#include <hash.h>
+
+#define LF_HASH_UNIQUE 1
+
+/* lf_hash overhead per element (that is, sizeof(LF_SLIST) */
+extern const int LF_HASH_OVERHEAD;
+
+typedef struct {
+ LF_DYNARRAY array; /* hash itself */
+ LF_ALLOCATOR alloc; /* allocator for elements */
+ my_hash_get_key get_key; /* see HASH */
+ CHARSET_INFO *charset; /* see HASH */
+ uint key_offset, key_length; /* see HASH */
+ uint element_size; /* size of memcpy'ed area on insert */
+ uint flags; /* LF_HASH_UNIQUE, etc */
+ int32 volatile size; /* size of array */
+ int32 volatile count; /* number of elements in the hash */
+} LF_HASH;
+
+void lf_hash_init(LF_HASH *hash, uint element_size, uint flags,
+ uint key_offset, uint key_length, my_hash_get_key get_key,
+ CHARSET_INFO *charset);
+void lf_hash_destroy(LF_HASH *hash);
+int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data);
+void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen);
+int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen);
+/*
+ shortcut macros to access underlying pinbox functions from an LF_HASH
+ see _lf_pinbox_get_pins() and _lf_pinbox_put_pins()
+*/
+#define _lf_hash_get_pins(HASH) _lf_alloc_get_pins(&(HASH)->alloc)
+#define lf_hash_get_pins(HASH) lf_alloc_get_pins(&(HASH)->alloc)
+#define _lf_hash_put_pins(PINS) _lf_pinbox_put_pins(PINS)
+#define lf_hash_put_pins(PINS) lf_pinbox_put_pins(PINS)
+#define lf_hash_search_unpin(PINS) lf_unpin((PINS), 2)
+/*
+ cleanup
+*/
+
+#undef lock_wrap_void
+#undef lock_wrap
+#undef nolock_wrap_void
+#undef nolock_wrap
+
+#endif
+
View
196 src/libs/mysql/include/m_ctype.h
@@ -15,13 +15,13 @@
/*
A better inplementation of the UNIX ctype(3) library.
+ Notes: my_global.h should be included before ctype.h
*/
#ifndef _m_ctype_h
#define _m_ctype_h
#include <my_attribute.h>
-#include "my_global.h" /* uint16, uchar */
#ifdef __cplusplus
extern "C" {
@@ -38,29 +38,11 @@ extern "C" {
#define my_wc_t ulong
-#define MY_CS_REPLACEMENT_CHARACTER 0xFFFD
-
-/*
- On i386 we store Unicode->CS conversion tables for
- some character sets using Big-endian order,
- to copy two bytes at onces.
- This gives some performance improvement.
-*/
-#ifdef __i386__
-#define MB2(x) (((x) >> 8) + (((x) & 0xFF) << 8))
-#define MY_PUT_MB2(s, code) { *((uint16*)(s))= (code); }
-#else
-#define MB2(x) (x)
-#define MY_PUT_MB2(s, code) { (s)[0]= code >> 8; (s)[1]= code & 0xFF; }
-#endif
-
-
-
typedef struct unicase_info_st
{
- uint32 toupper;
- uint32 tolower;
- uint32 sort;
+ uint16 toupper;
+ uint16 tolower;
+ uint16 sort;
} MY_UNICASE_INFO;
@@ -99,14 +81,13 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
#define MY_CS_BINSORT 16 /* if binary sort order */
#define MY_CS_PRIMARY 32 /* if primary collation */
#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */
-#define MY_CS_UNICODE 128 /* is a charset is BMP Unicode */
+#define MY_CS_UNICODE 128 /* is a charset is full unicode */
#define MY_CS_READY 256 /* if a charset is initialized */
#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
#define MY_CS_CSSORT 1024 /* if case sensitive sort order */
#define MY_CS_HIDDEN 2048 /* don't display in SHOW */
#define MY_CS_PUREASCII 4096 /* if a charset is pure ascii */
#define MY_CS_NONASCII 8192 /* if not ASCII-compatible */
-#define MY_CS_UNICODE_SUPPLEMENT 16384 /* Non-BMP Unicode characters */
#define MY_CHARSET_UNDEFINED 0
/* Character repertoire flags */
@@ -114,6 +95,39 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
#define MY_REPERTOIRE_EXTENDED 2 /* Extended characters: U+0080..U+FFFF */
#define MY_REPERTOIRE_UNICODE30 3 /* ASCII | EXTENDED: U+0000..U+FFFF */
+/* Flags for strxfrm */
+#define MY_STRXFRM_LEVEL1 0x00000001 /* for primary weights */
+#define MY_STRXFRM_LEVEL2 0x00000002 /* for secondary weights */
+#define MY_STRXFRM_LEVEL3 0x00000004 /* for tertiary weights */
+#define MY_STRXFRM_LEVEL4 0x00000008 /* fourth level weights */
+#define MY_STRXFRM_LEVEL5 0x00000010 /* fifth level weights */
+#define MY_STRXFRM_LEVEL6 0x00000020 /* sixth level weights */
+#define MY_STRXFRM_LEVEL_ALL 0x0000003F /* Bit OR for the above six */
+#define MY_STRXFRM_NLEVELS 6 /* Number of possible levels*/
+
+#define MY_STRXFRM_PAD_WITH_SPACE 0x00000040 /* if pad result with spaces */
+#define MY_STRXFRM_PAD_TO_MAXLEN 0x00000080 /* if pad tail(for filesort) */
+
+#define MY_STRXFRM_DESC_LEVEL1 0x00000100 /* if desc order for level1 */
+#define MY_STRXFRM_DESC_LEVEL2 0x00000200 /* if desc order for level2 */
+#define MY_STRXFRM_DESC_LEVEL3 0x00000300 /* if desc order for level3 */
+#define MY_STRXFRM_DESC_LEVEL4 0x00000800 /* if desc order for level4 */
+#define MY_STRXFRM_DESC_LEVEL5 0x00001000 /* if desc order for level5 */
+#define MY_STRXFRM_DESC_LEVEL6 0x00002000 /* if desc order for level6 */
+#define MY_STRXFRM_DESC_SHIFT 8
+
+#define MY_STRXFRM_UNUSED_00004000 0x00004000 /* for future extensions */
+#define MY_STRXFRM_UNUSED_00008000 0x00008000 /* for future extensions */
+
+#define MY_STRXFRM_REVERSE_LEVEL1 0x00010000 /* if reverse order for level1 */
+#define MY_STRXFRM_REVERSE_LEVEL2 0x00020000 /* if reverse order for level2 */
+#define MY_STRXFRM_REVERSE_LEVEL3 0x00040000 /* if reverse order for level3 */
+#define MY_STRXFRM_REVERSE_LEVEL4 0x00080000 /* if reverse order for level4 */
+#define MY_STRXFRM_REVERSE_LEVEL5 0x00100000 /* if reverse order for level5 */
+#define MY_STRXFRM_REVERSE_LEVEL6 0x00200000 /* if reverse order for level6 */
+#define MY_STRXFRM_REVERSE_SHIFT 16
+
+
typedef struct my_uni_idx_st
{
uint16 from;
@@ -157,9 +171,10 @@ typedef struct my_collation_handler_st
int (*strnncollsp)(struct charset_info_st *,
const uchar *, size_t, const uchar *, size_t,
my_bool diff_if_only_endspace_difference);
- size_t (*strnxfrm)(struct charset_info_st *,
- uchar *, size_t, const uchar *, size_t);
- size_t (*strnxfrmlen)(struct charset_info_st *, size_t);
+ size_t (*strnxfrm)(struct charset_info_st *,
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags);
+ size_t (*strnxfrmlen)(struct charset_info_st *, size_t);
my_bool (*like_range)(struct charset_info_st *,
const char *s, size_t s_length,
pchar w_prefix, pchar w_one, pchar w_many,
@@ -265,12 +280,6 @@ extern MY_CHARSET_HANDLER my_charset_8bit_handler;
extern MY_CHARSET_HANDLER my_charset_ucs2_handler;
-/*
- We define this CHARSET_INFO_DEFINED here to prevent a repeat of the
- typedef in hash.c, which will cause a compiler error.
-*/
-#define CHARSET_INFO_DEFINED
-
/* See strings/CHARSET_INFO.txt about information on this structure */
typedef struct charset_info_st
{
@@ -302,6 +311,8 @@ typedef struct charset_info_st
uint16 max_sort_char; /* For LIKE optimization */
uchar pad_char;
my_bool escape_with_backslash_is_dangerous;
+ uchar levels_for_compare;
+ uchar levels_for_order;
MY_CHARSET_HANDLER *cset;
MY_COLLATION_HANDLER *coll;
@@ -311,9 +322,6 @@ typedef struct charset_info_st
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_bin;
-extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_latin1;
-extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_filename;
-
extern CHARSET_INFO my_charset_big5_chinese_ci;
extern CHARSET_INFO my_charset_big5_bin;
extern CHARSET_INFO my_charset_cp932_japanese_ci;
@@ -323,10 +331,12 @@ extern CHARSET_INFO my_charset_eucjpms_japanese_ci;
extern CHARSET_INFO my_charset_eucjpms_bin;
extern CHARSET_INFO my_charset_euckr_korean_ci;
extern CHARSET_INFO my_charset_euckr_bin;
+extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_filename;
extern CHARSET_INFO my_charset_gb2312_chinese_ci;
extern CHARSET_INFO my_charset_gb2312_bin;
extern CHARSET_INFO my_charset_gbk_chinese_ci;
extern CHARSET_INFO my_charset_gbk_bin;
+extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_latin1;
extern CHARSET_INFO my_charset_latin1_german2_ci;
extern CHARSET_INFO my_charset_latin1_bin;
extern CHARSET_INFO my_charset_latin2_czech_ci;
@@ -345,47 +355,24 @@ extern CHARSET_INFO my_charset_utf16_unicode_ci;
extern CHARSET_INFO my_charset_utf32_bin;
extern CHARSET_INFO my_charset_utf32_general_ci;
extern CHARSET_INFO my_charset_utf32_unicode_ci;
-
-extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8_general_ci;
-extern CHARSET_INFO my_charset_utf8_unicode_ci;
-extern CHARSET_INFO my_charset_utf8_bin;
+extern CHARSET_INFO my_charset_utf8mb3_bin;
+extern CHARSET_INFO my_charset_utf8mb3_general_ci;
+extern CHARSET_INFO my_charset_utf8mb3_unicode_ci;
extern CHARSET_INFO my_charset_utf8mb4_bin;
-extern CHARSET_INFO my_charset_utf8mb4_general_ci;
+extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8mb4_general_ci;
extern CHARSET_INFO my_charset_utf8mb4_unicode_ci;
-#define MY_UTF8MB3 "utf8"
-#define MY_UTF8MB4 "utf8mb4"
-
-/* Helper functions to handle contraction */
-static inline my_bool
-my_cs_have_contractions(CHARSET_INFO *cs)
-{
- return cs->contractions != NULL;
-}
-
-static inline my_bool
-my_cs_can_be_contraction_head(CHARSET_INFO *cs, my_wc_t wc)
-{
- return ((const char *)cs->contractions)[0x40*0x40 + (wc & 0xFF)];
-}
-
-static inline my_bool
-my_cs_can_be_contraction_tail(CHARSET_INFO *cs, my_wc_t wc)
-{
- return ((const char *)cs->contractions)[0x40*0x40 + (wc & 0xFF)];
-}
-
-static inline uint16*
-my_cs_contraction2_weight(CHARSET_INFO *cs, my_wc_t wc1, my_wc_t wc2)
-{
- return &cs->contractions[(wc1 - 0x40) * 0x40 + wc2 - 0x40];
-}
+#define MY_UTF8MB3 "utf8mb3"
+#define MY_UTF8MB4 "utf8"
+#define my_charset_utf8_general_ci my_charset_utf8mb4_general_ci
+#define my_charset_utf8_bin my_charset_utf8mb4_bin
/* declarations for simple charsets */
-extern size_t my_strnxfrm_simple(CHARSET_INFO *, uchar *, size_t,
- const uchar *, size_t);
-size_t my_strnxfrmlen_simple(CHARSET_INFO *, size_t);
+extern size_t my_strnxfrm_simple(CHARSET_INFO *,
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags);
+size_t my_strnxfrmlen_simple(CHARSET_INFO *, size_t);
extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, size_t,
const uchar *, size_t, my_bool);
@@ -456,7 +443,6 @@ ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs,
void my_fill_8bit(CHARSET_INFO *cs, char* to, size_t l, int fill);
-/* For 8-bit character set */
my_bool my_like_range_simple(CHARSET_INFO *cs,
const char *ptr, size_t ptr_length,
pbool escape, pbool w_one, pbool w_many,
@@ -464,7 +450,6 @@ my_bool my_like_range_simple(CHARSET_INFO *cs,
char *min_str, char *max_str,
size_t *min_length, size_t *max_length);
-/* For ASCII-based multi-byte character sets with mbminlen=1 */
my_bool my_like_range_mb(CHARSET_INFO *cs,
const char *ptr, size_t ptr_length,
pbool escape, pbool w_one, pbool w_many,
@@ -472,13 +457,27 @@ my_bool my_like_range_mb(CHARSET_INFO *cs,
char *min_str, char *max_str,
size_t *min_length, size_t *max_length);
-/* For other character sets, with arbitrary mbminlen and mbmaxlen numbers */
-my_bool my_like_range_generic(CHARSET_INFO *cs,
- const char *ptr, size_t ptr_length,
- pbool escape, pbool w_one, pbool w_many,
- size_t res_length,
- char *min_str, char *max_str,
- size_t *min_length, size_t *max_length);
+my_bool my_like_range_ucs2(CHARSET_INFO *cs,
+ const char *ptr, size_t ptr_length,
+ pbool escape, pbool w_one, pbool w_many,
+ size_t res_length,
+ char *min_str, char *max_str,
+ size_t *min_length, size_t *max_length);
+
+my_bool my_like_range_utf16(CHARSET_INFO *cs,
+ const char *ptr, size_t ptr_length,
+ pbool escape, pbool w_one, pbool w_many,
+ size_t res_length,
+ char *min_str, char *max_str,
+ size_t *min_length, size_t *max_length);
+
+my_bool my_like_range_utf32(CHARSET_INFO *cs,
+ const char *ptr, size_t ptr_length,
+ pbool escape, pbool w_one, pbool w_many,
+ size_t res_length,
+ char *min_str, char *max_str,
+ size_t *min_length, size_t *max_length);
+
int my_wildcmp_8bit(CHARSET_INFO *,
const char *str,const char *str_end,
@@ -505,14 +504,6 @@ extern size_t my_caseup_mb(CHARSET_INFO *, char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_mb(CHARSET_INFO *, char *src, size_t srclen,
char *dst, size_t dstlen);
-extern size_t my_caseup_mb_varlen(CHARSET_INFO *, char *src, size_t srclen,
- char *dst, size_t dstlen);
-extern size_t my_casedn_mb_varlen(CHARSET_INFO *, char *src, size_t srclen,
- char *dst, size_t dstlen);
-extern size_t my_caseup_ujis(CHARSET_INFO *, char *src, size_t srclen,
- char *dst, size_t dstlen);
-extern size_t my_casedn_ujis(CHARSET_INFO *, char *src, size_t srclen,
- char *dst, size_t dstlen);
extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *);
int my_wildcmp_mb(CHARSET_INFO *,
@@ -550,14 +541,13 @@ int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)),
const uchar *key, size_t len,ulong *nr1, ulong *nr2);
-size_t my_strnxfrm_unicode(CHARSET_INFO *,
- uchar *dst, size_t dstlen,
- const uchar *src, size_t srclen);
+size_t my_strnxfrm_mb(CHARSET_INFO *,
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags);
-size_t my_strnxfrm_unicode_full_bin(CHARSET_INFO *,
- uchar *dst, size_t dstlen,
- const uchar *src, size_t srclen);
-size_t my_strnxfrmlen_unicode_full_bin(CHARSET_INFO *, size_t);
+size_t my_strnxfrm_unicode(CHARSET_INFO *,
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags);
int my_wildcmp_unicode(CHARSET_INFO *cs,
const char *str, const char *str_end,
@@ -569,8 +559,6 @@ extern my_bool my_parse_charset_xml(const char *bug, size_t len,
int (*add)(CHARSET_INFO *cs));
extern char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end,
pchar c);
-extern size_t my_strcspn(CHARSET_INFO *cs, const char *str, const char *end,
- const char *accept);
my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, size_t len);
my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, size_t len);
@@ -581,10 +569,15 @@ my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
my_bool my_charset_is_8bit_pure_ascii(CHARSET_INFO *cs);
uint my_charset_repertoire(CHARSET_INFO *cs);
-my_bool my_charset_is_ascii_compatible(CHARSET_INFO *cs);
-extern size_t my_vsnprintf_ex(CHARSET_INFO *cs, char *to, size_t n,
- const char* fmt, va_list ap);
+uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
+void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
+ uint flags, uint level);
+size_t my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs,
+ uchar *str, uchar *frmend, uchar *strend,
+ uint nweights, uint flags, uint level);
+
+my_bool my_charset_is_ascii_compatible(CHARSET_INFO *cs);
#define _MY_U 01 /* Upper case */
#define _MY_L 02 /* Lower case */
@@ -620,7 +613,8 @@ extern size_t my_vsnprintf_ex(CHARSET_INFO *cs, char *to, size_t n,
#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT)
#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM)
-#define my_strnxfrm(s, a, b, c, d) ((s)->coll->strnxfrm((s), (a), (b), (c), (d)))
+#define my_strnxfrm(cs, d, dl, s, sl) \
+ ((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE))
#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
View
150 src/libs/mysql/include/m_string.h
@@ -20,9 +20,6 @@
#ifndef _m_string_h
#define _m_string_h
-
-#include "my_global.h" /* HAVE_* */
-
#ifndef __USE_GNU
#define __USE_GNU /* We want to use stpcpy */
#endif
@@ -36,6 +33,10 @@
/* 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>
@@ -52,15 +53,21 @@
# define memmove(d, s, n) bmove ((d), (s), (n))
#elif defined(HAVE_MEMMOVE)
# define bmove(d, s, n) memmove((d), (s), (n))
+#else
+# define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
#endif
/* Unixware 7 */
#if !defined(HAVE_BFILL)
# define bfill(A,B,C) memset((A),(C),(B))
+# define bmove_align(A,B,C) memcpy((A),(B),(C))
#endif
-#if !defined(bzero) && !defined(HAVE_BZERO)
-# define bzero(A,B) memset((A),0,(B))
+#if !defined(HAVE_BCMP)
+# define bcopy(s, d, n) memcpy((d), (s), (n))
+# define bcmp(A,B,C) memcmp((A),(B),(C))
+# define bzero(A,B) memset((A),0,(B))
+# define bmove_align(A,B,C) memcpy((A),(B),(C))
#endif
#if defined(__cplusplus)
@@ -74,9 +81,7 @@ extern "C" {
extern void *(*my_str_malloc)(size_t);
extern void (*my_str_free)(void *);
-#if defined(HAVE_STPCPY) && MY_GNUC_PREREQ(3, 4) && !defined(__INTEL_COMPILER)
-#define strmov(A,B) __builtin_stpcpy((A),(B))
-#elif defined(HAVE_STPCPY)
+#if defined(HAVE_STPCPY)
#define strmov(A,B) stpcpy((A),(B))
#ifndef stpcpy
extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
@@ -84,40 +89,116 @@ extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
#endif
/* Declared in int2str() */
-extern char _dig_vec_upper[];
-extern char _dig_vec_lower[];
+extern char NEAR _dig_vec_upper[];
+extern char NEAR _dig_vec_lower[];
-#ifndef strmov
+#ifdef BAD_STRING_COMPILER
+#define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
+#else
#define strmov_overlapp(A,B) strmov(A,B)
#define strmake_overlapp(A,B,C) strmake(A,B,C)
#endif
+#ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
+#define memcpy_fixed(A,B,C) bmove((A),(B),(C))
+#else
+#define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
+#endif
+
+#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
+#define bmove512(A,B,C) memcpy(A,B,C)
+#endif
+
/* Prototypes for string functions */
+#if !defined(bfill) && !defined(HAVE_BFILL)
+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);
+#endif
+
+#if !defined(bcmp) && !defined(HAVE_BCMP)
+extern size_t bcmp(const uchar *s1,const uchar *s2,size_t len);
+#endif
+#ifdef HAVE_purify
+extern size_t my_bcmp(const uchar *s1,const uchar *s2,size_t len);
+#undef bcmp
+#define bcmp(A,B,C) my_bcmp((A),(B),(C))
+#define bzero_if_purify(A,B) bzero(A,B)
+#else
+#define bzero_if_purify(A,B)
+#endif /* HAVE_purify */
+
+#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
+#define LINT_INIT_STRUCT(var) bzero(&var, sizeof(var)) /* No uninitialize-warning */
+#else
+#define LINT_INIT_STRUCT(var)
+#endif
+
+#ifndef bmove512
+extern void bmove512(uchar *dst,const uchar *src,size_t len);
+#endif
+
+#if !defined(HAVE_BMOVE) && !defined(bmove)
+extern void bmove(uuchar *dst, const uchar *src,size_t len);
+#endif
+
extern void bmove_upp(uchar *dst,const uchar *src,size_t len);
extern void bchange(uchar *dst,size_t old_len,const uchar *src,
size_t new_len,size_t tot_len);
extern void strappend(char *s,size_t len,pchar fill);
extern char *strend(const char *s);
extern char *strcend(const char *, pchar);
+extern char *strfield(char *src,int fields,int chars,int blanks,
+ int tabch);
extern char *strfill(char * s,size_t len,pchar fill);
+extern size_t strinstr(const char *str,const char *search);
+extern size_t r_strinstr(const char *str, size_t from, const char *search);
+extern char *strkey(char *dst,char *head,char *tail,char *flags);
extern char *strmake(char *dst,const char *src,size_t length);
+#ifndef strmake_overlapp
+extern char *strmake_overlapp(char *dst,const char *src, size_t length);
+#endif
#ifndef strmov
extern char *strmov(char *dst,const char *src);
-#else
-extern char *strmov_overlapp(char *dst,const char *src);
#endif
-extern char *strnmov(char *dst, const char *src, size_t n);
-extern char *strcont(const char *src, const char *set);
-extern char *strxmov(char *dst, const char *src, ...);
-extern char *strxnmov(char *dst, size_t len, const char *src, ...);
+extern char *strnmov(char *dst,const char *src,size_t n);
+extern char *strsuff(const char *src,const char *suffix);
+extern char *strcont(const char *src,const char *set);
+extern char *strxcat _VARARGS((char *dst,const char *src, ...));
+extern char *strxmov _VARARGS((char *dst,const char *src, ...));
+extern char *strxcpy _VARARGS((char *dst,const char *src, ...));
+extern char *strxncat _VARARGS((char *dst,size_t len, const char *src, ...));
+extern char *strxnmov _VARARGS((char *dst,size_t len, const char *src, ...));
+extern char *strxncpy _VARARGS((char *dst,size_t len, const char *src, ...));
/* Prototypes of normal stringfunctions (with may ours) */
+
+#ifdef WANT_STRING_PROTOTYPES
+extern char *strcat(char *, const char *);
+extern char *strchr(const char *, pchar);
+extern char *strrchr(const char *, pchar);
+extern char *strcpy(char *, const char *);
+extern int strcmp(const char *, const char *);
+#ifndef __GNUC__
+extern size_t strlen(const char *);
+#endif
+#endif
#ifndef HAVE_STRNLEN
extern size_t strnlen(const char *s, size_t n);
#endif
+#if !defined(__cplusplus)
+#ifndef HAVE_STRPBRK
+extern char *strpbrk(const char *, const char *);
+#endif
+#ifndef HAVE_STRSTR
+extern char *strstr(const char *, const char *);
+#endif
+#endif
extern int is_prefix(const char *, const char *);
/* Conversion routines */
@@ -156,7 +237,8 @@ size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
(DBL_DIG + 2) significant digits + sign + "." + ("e-NNN" or
MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used).
*/
-#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + max(5, MAX_DECPT_FOR_F_FORMAT)) \
+#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + max(5, MAX_DECPT_FOR_F_FORMAT))
+
extern char *llstr(longlong value,char *buff);
extern char *ullstr(longlong value,char *buff);
@@ -172,6 +254,7 @@ extern char *str2int(const char *src,int radix,long lower,long upper,
longlong my_strtoll10(const char *nptr, char **endptr, int *error);
#if SIZEOF_LONG == SIZEOF_LONG_LONG
#define ll2str(A,B,C,D) int2str((A),(B),(C),(D))
+#define longlong2str(A,B,C) int2str((A),(B),(C),1)
#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
#undef strtoll
#define strtoll(A,B,C) strtol((A),(B),(C))
@@ -185,6 +268,7 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error);
#else
#ifdef HAVE_LONG_LONG
extern char *ll2str(longlong val,char *dst,int radix, int upcase);
+#define longlong2str(A,B,C) ll2str((A),(B),(C),1)
extern char *longlong10_to_str(longlong val,char *dst,int radix);
#if (!defined(HAVE_STRTOULL) || defined(NO_STRTOLL_PROTO))
extern longlong strtoll(const char *str, char **ptr, int base);
@@ -192,7 +276,13 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);
#endif
#endif
#endif
-#define longlong2str(A,B,C) ll2str((A),(B),(C),1)
+
+/* my_vsnprintf.c */
+
+extern size_t my_vsnprintf(char *str, size_t n,
+ const char *format, va_list ap);
+extern size_t my_snprintf(char *to, size_t n, const char *fmt, ...)
+ ATTRIBUTE_FORMAT(printf, 3, 4);
#if defined(__cplusplus)
}
@@ -203,13 +293,13 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);
(it's part of the plugin API as a MYSQL_LEX_STRING)
*/
-#include <mysql/plugin.h>
typedef struct st_mysql_lex_string LEX_STRING;
#define STRING_WITH_LEN(X) (X), ((size_t) (sizeof(X) - 1))
#define USTRING_WITH_LEN(X) ((uchar*) X), ((size_t) (sizeof(X) - 1))
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
+/* A variant with const */
struct st_mysql_const_lex_string
{
const char *str;
@@ -217,6 +307,14 @@ struct st_mysql_const_lex_string
};
typedef struct st_mysql_const_lex_string LEX_CSTRING;
+/* A variant with const and unsigned */
+struct st_mysql_const_unsigned_lex_string
+{
+ const uchar *str;
+ size_t length;
+};
+typedef struct st_mysql_const_unsigned_lex_string LEX_CUSTRING;
+
/* SPACE_INT is a word that contains only spaces */
#if SIZEOF_INT == 4
#define SPACE_INT 0x20202020
@@ -286,10 +384,10 @@ static inline const uchar *skip_trailing_space(const uchar *ptr,size_t len)
return (end);
}
-static inline void lex_string_set(LEX_STRING *lex_str, const char *c_str)
-{
- lex_str->str= (char *) c_str;
- lex_str->length= strlen(c_str);
-}
+#ifdef SAFEMALLOC
+#define TRASH(A,B) bfill(A, B, 0x8F)
+#else
+#define TRASH(A,B) /* nothing */
+#endif /* SAFEMALLOC */
-#endif
+#endif /* _m_string_h */
View
65 src/libs/mysql/include/my_aes.h
@@ -0,0 +1,65 @@
+/* Copyright (C) 2002 MySQL AB
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+
+/* Header file for my_aes.c */
+/* Wrapper to give simple interface for MySQL to AES standard encryption */
+
+#include "mysys/rijndael.h"
+
+C_MODE_START
+
+#define AES_KEY_LENGTH 128 /* Must be 128 192 or 256 */
+
+/*
+ my_aes_encrypt - Crypt buffer with AES encryption algorithm.
+ source - Pointer to data for encryption
+ source_length - size of encryption data
+ dest - buffer to place encrypted data (must be large enough)
+ key - Key to be used for encryption
+ kel_length - Length of the key. Will handle keys of any length
+
+ returns - size of encrypted data, or negative in case of error.
+*/
+
+int my_aes_encrypt(const char *source, int source_length, char *dest,
+ const char *key, int key_length);
+
+/*
+ my_aes_decrypt - DeCrypt buffer with AES encryption algorithm.
+ source - Pointer to data for decryption
+ source_length - size of encrypted data
+ dest - buffer to place decrypted data (must be large enough)
+ key - Key to be used for decryption
+ kel_length - Length of the key. Will handle keys of any length
+
+ returns - size of original data, or negative in case of error.
+*/
+
+
+int my_aes_decrypt(const char *source, int source_length, char *dest,
+ const char *key, int key_length);
+
+/*
+ my_aes_get_size - get size of buffer which will be large enough for encrypted
+ data
+ source_length - length of data to be encrypted
+
+ returns - size of buffer required to store encrypted data
+*/
+
+int my_aes_get_size(int source_length);
+
+C_MODE_END
View
58 src/libs/mysql/include/my_alarm.h
@@ -0,0 +1,58 @@
+/* Copyright (C) 2000 MySQL AB
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ File to include when we want to use alarm or a loop_counter to display
+ some information when a program is running
+*/
+#ifndef _my_alarm_h
+#define _my_alarm_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int volatile my_have_got_alarm;
+extern ulong my_time_to_wait_for_lock;
+
+#if defined(HAVE_ALARM) && !defined(NO_ALARM_LOOP)
+#include <signal.h>
+#define ALARM_VARIABLES uint alarm_old=0; \
+ sig_return alarm_signal=0
+#define ALARM_INIT my_have_got_alarm=0 ; \
+ alarm_old=(uint) alarm(MY_HOW_OFTEN_TO_ALARM); \
+ alarm_signal=signal(SIGALRM,my_set_alarm_variable);
+#define ALARM_END (void) signal(SIGALRM,alarm_signal); \
+ (void) alarm(alarm_old);
+#define ALARM_TEST my_have_got_alarm
+#ifdef DONT_REMEMBER_SIGNAL
+#define ALARM_REINIT (void) alarm(MY_HOW_OFTEN_TO_ALARM); \
+ (void) signal(SIGALRM,my_set_alarm_variable);\
+ my_have_got_alarm=0;
+#else
+#define ALARM_REINIT (void) alarm((uint) MY_HOW_OFTEN_TO_ALARM); \
+ my_have_got_alarm=0;
+#endif /* DONT_REMEMBER_SIGNAL */
+#else
+#define ALARM_VARIABLES long alarm_pos=0,alarm_end_pos=MY_HOW_OFTEN_TO_WRITE-1
+#define ALARM_INIT
+#define ALARM_END
+#define ALARM_TEST (alarm_pos++ >= alarm_end_pos)
+#define ALARM_REINIT alarm_end_pos+=MY_HOW_OFTEN_TO_WRITE
+#endif /* HAVE_ALARM */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
View
13 src/libs/mysql/include/my_alloc.h
@@ -23,15 +23,11 @@
#define ALLOC_MAX_BLOCK_TO_DROP 4096
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct st_used_mem
{ /* struct for once_alloc (block) */
struct st_used_mem *next; /* Next block in use */
- unsigned int left; /* memory left in block */
- unsigned int size; /* size of block */
+ size_t left; /* memory left in block */
+ size_t size; /* size of block */
} USED_MEM;
@@ -52,9 +48,4 @@ typedef struct st_mem_root
void (*error_handler)(void);
} MEM_ROOT;
-
-#ifdef __cplusplus
-}
-#endif
-
#endif
View
254 src/libs/mysql/include/my_atomic.h
@@ -0,0 +1,254 @@
+/* Copyright (C) 2006 MySQL AB
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ This header defines five atomic operations:
+
+ my_atomic_add#(&var, what)
+ add 'what' to *var, and return the old value of *var
+
+ my_atomic_fas#(&var, what)
+ 'Fetch And Store'
+ store 'what' in *var, and return the old value of *var
+
+ my_atomic_cas#(&var, &old, new)
+ 'Compare And Swap'
+ if *var is equal to *old, then store 'new' in *var, and return TRUE
+ otherwise store *var in *old, and return FALSE
+
+ my_atomic_load#(&var)
+ return *var
+
+ my_atomic_store#(&var, what)
+ store 'what' in *var
+
+ '#' is substituted by a size suffix - 8, 16, 32, or ptr
+ (e.g. my_atomic_add8, my_atomic_fas32, my_atomic_casptr).
+
+ NOTE This operations are not always atomic, so they always must be
+ enclosed in my_atomic_rwlock_rdlock(lock)/my_atomic_rwlock_rdunlock(lock)
+ or my_atomic_rwlock_wrlock(lock)/my_atomic_rwlock_wrunlock(lock).
+ Hint: if a code block makes intensive use of atomic ops, it make sense
+ to take/release rwlock once for the whole block, not for every statement.
+
+ On architectures where these operations are really atomic, rwlocks will
+ be optimized away.
+ 8- and 16-bit atomics aren't implemented for windows (see generic-msvc.h),
+ but can be added, if necessary.
+*/
+
+#ifndef my_atomic_rwlock_init
+
+#define intptr void *
+
+#ifndef MY_ATOMIC_MODE_RWLOCKS
+#include "atomic/nolock.h"
+#endif
+
+#ifndef make_atomic_cas_body
+/* nolock.h was not able to generate even a CAS function, fall back */
+#include "atomic/rwlock.h"
+#else
+/* define missing functions by using the already generated ones */
+#ifndef make_atomic_add_body
+#define make_atomic_add_body(S) \
+ int ## S tmp=*a; \
+ while (!my_atomic_cas ## S(a, &tmp, tmp+v)); \
+ v=tmp;
+#endif
+#ifndef make_atomic_fas_body
+#define make_atomic_fas_body(S) \
+ int ## S tmp=*a; \
+ while (!my_atomic_cas ## S(a, &tmp, v)); \
+ v=tmp;
+#endif
+#ifndef make_atomic_load_body
+#define make_atomic_load_body(S) \
+ ret= 0; /* avoid compiler warning */ \
+ (void)(my_atomic_cas ## S(a, &ret, ret));
+#endif
+#ifndef make_atomic_store_body
+#define make_atomic_store_body(S) \
+ (void)(my_atomic_fas ## S (a, v));
+#endif
+#endif
+
+/*
+ transparent_union doesn't work in g++
+ Bug ?
+
+ Darwin's gcc doesn't want to put pointers in a transparent_union
+ when built with -arch ppc64. Complains:
+ warning: 'transparent_union' attribute ignored
+*/
+#if defined(__GNUC__) && !defined(__cplusplus) && \
+ ! (defined(__APPLE__) && defined(_ARCH_PPC64))
+/*
+ we want to be able to use my_atomic_xxx functions with
+ both signed and unsigned integers. But gcc will issue a warning
+ "passing arg N of `my_atomic_XXX' as [un]signed due to prototype"
+ if the signedness of the argument doesn't match the prototype, or
+ "pointer targets in passing argument N of my_atomic_XXX differ in signedness"
+ if int* is used where uint* is expected (or vice versa).
+ Let's shut these warnings up
+*/
+#define make_transparent_unions(S) \
+ typedef union { \
+ int ## S i; \
+ uint ## S u; \
+ } U_ ## S __attribute__ ((transparent_union)); \
+ typedef union { \
+ int ## S volatile