List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:July 23 2010 12:42pm
Subject:bzr commit into mysql-next-mr-bugfixing branch (davi:3321)
View as plain text  
# At a local mysql-next-mr-bugfixing repository of davi

 3321 Davi Arnaut	2010-07-23 [merge]
      Merge of mysql-trunk-bugfixing into mysql-next-mr-bugfixing.

    modified:
      include/atomic/gcc_builtins.h
      include/atomic/nolock.h
      include/atomic/x86-gcc.h
      include/my_atomic.h
      sql/sql_error.cc
      unittest/mysys/my_atomic-t.c
=== modified file 'include/atomic/gcc_builtins.h'
--- a/include/atomic/gcc_builtins.h	2009-11-27 17:11:05 +0000
+++ b/include/atomic/gcc_builtins.h	2010-07-23 12:37:10 +0000
@@ -22,8 +22,9 @@
   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;
+  int ## S cmp_val= *cmp;                           \
+  sav= __sync_val_compare_and_swap(a, cmp_val, set);\
+  if (!(ret= (sav == cmp_val))) *cmp= sav
 
 #ifdef MY_ATOMIC_MODE_DUMMY
 #define make_atomic_load_body(S)   ret= *a

=== modified file 'include/atomic/nolock.h'
--- a/include/atomic/nolock.h	2009-12-23 08:27:41 +0000
+++ b/include/atomic/nolock.h	2010-07-23 12:37:10 +0000
@@ -29,21 +29,22 @@
   We choose implementation as follows:
   ------------------------------------
   On Windows using Visual C++ the native implementation should be
-  preferrable. When using gcc we prefer the native x86 implementation,
-  we prefer the Solaris implementation before the gcc because of
-  stability preference, we choose gcc implementation if nothing else
-  works on gcc. If neither Visual C++ or gcc we still choose the
-  Solaris implementation on Solaris (mainly for SunStudio compiles.
+  preferrable. When using gcc we prefer the Solaris implementation
+  before the gcc because of stability preference, we choose gcc
+  builtins if available, otherwise we choose the somewhat broken
+  native x86 implementation. If neither Visual C++ or gcc we still
+  choose the Solaris implementation on Solaris (mainly for SunStudio
+  compilers).
 */
 #  if defined(_MSV_VER)
 #    include "generic-msvc.h"
 #  elif __GNUC__
-#    if defined(__i386__) || defined(__x86_64__)
-#      include "x86-gcc.h"
-#    elif defined(HAVE_SOLARIS_ATOMIC)
+#    if defined(HAVE_SOLARIS_ATOMIC)
 #      include "solaris.h"
 #    elif defined(HAVE_GCC_ATOMIC_BUILTINS)
 #      include "gcc_builtins.h"
+#    elif defined(__i386__) || defined(__x86_64__)
+#      include "x86-gcc.h"
 #    endif
 #  elif defined(HAVE_SOLARIS_ATOMIC)
 #    include "solaris.h"

=== modified file 'include/atomic/x86-gcc.h'
--- a/include/atomic/x86-gcc.h	2010-02-19 14:20:29 +0000
+++ b/include/atomic/x86-gcc.h	2010-07-23 12:37:10 +0000
@@ -53,18 +53,29 @@
 #endif
 
 #define make_atomic_add_body32                                  \
-  asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a))
+  asm volatile (LOCK_prefix "; xadd %0, %1;"                    \
+                : "+r" (v), "=m" (*a)                           \
+                : "m" (*a)                                      \
+                : "memory")
 
 #define make_atomic_cas_body32                                  \
+  __typeof__(*cmp) sav;                                         \
   asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;"	\
-               : "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set))
+                : "=m" (*a), "=a" (sav), "=q" (ret)             \
+                : "r" (set), "m" (*a), "a" (*cmp)               \
+                : "memory");                                    \
+  if (!ret)                                                     \
+    *cmp= sav
 
 #ifdef __x86_64__
 #define make_atomic_add_body64 make_atomic_add_body32
 #define make_atomic_cas_body64 make_atomic_cas_body32
 
-#define make_atomic_fas_body(S)                                        \
-  asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a))
+#define make_atomic_fas_body(S)                                 \
+  asm volatile ("xchg %0, %1;"                                  \
+                : "+r" (v), "=m" (*a)                           \
+                : "m" (*a)                                      \
+                : "memory")
 
 /*
   Actually 32-bit reads/writes are always atomic on x86
@@ -73,9 +84,14 @@
 #define make_atomic_load_body(S)                                \
   ret=0;                                                        \
   asm volatile (LOCK_prefix "; cmpxchg %2, %0"                  \
-                : "+m" (*a), "+a" (ret): "r" (ret))
+                : "=m" (*a), "=a" (ret)                         \
+                : "r" (ret), "m" (*a)                           \
+                : "memory")
 #define make_atomic_store_body(S)                               \
-  asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v))
+  asm volatile ("; xchg %0, %1;"                                \
+                : "=m" (*a), "+r" (v)                           \
+                : "m" (*a)                                      \
+                : "memory")
 
 #else
 /*
@@ -104,12 +120,13 @@
   platforms the much simpler make_atomic_cas_body32 will work
   fine.
 */
-#define make_atomic_cas_body64                                  \
-  int32 ebx=(set & 0xFFFFFFFF), ecx=(set >> 32);                \
-  asm volatile ("push %%ebx; movl %3, %%ebx;"                   \
-                LOCK_prefix "; cmpxchg8b %0; setz %2; pop %%ebx"\
-               : "+m" (*a), "+A" (*cmp), "=c" (ret)             \
-               :"m" (ebx), "c" (ecx))
+#define make_atomic_cas_body64                                    \
+  int32 ebx=(set & 0xFFFFFFFF), ecx=(set >> 32);                  \
+  asm volatile ("push %%ebx; movl %3, %%ebx;"                     \
+                LOCK_prefix "; cmpxchg8b %0; setz %2; pop %%ebx"  \
+                : "=m" (*a), "+A" (*cmp), "=c" (ret)               \
+                : "m" (ebx), "c" (ecx), "m" (*a)                  \
+                : "memory", "esp")
 #endif
 
 /*

=== modified file 'include/my_atomic.h'
--- a/include/my_atomic.h	2010-02-23 15:49:21 +0000
+++ b/include/my_atomic.h	2010-07-23 12:37:10 +0000
@@ -20,6 +20,7 @@
   This header defines five atomic operations:
 
   my_atomic_add#(&var, what)
+    'Fetch and Add'
     add 'what' to *var, and return the old value of *var
 
   my_atomic_fas#(&var, what)
@@ -27,9 +28,10 @@
     store 'what' in *var, and return the old value of *var
 
   my_atomic_cas#(&var, &old, new)
-    'Compare And Swap'
+    An odd variation of 'Compare And Set/Swap'
     if *var is equal to *old, then store 'new' in *var, and return TRUE
     otherwise store *var in *old, and return FALSE
+    Usually, &old should not be accessed if the operation is successful.
 
   my_atomic_load#(&var)
     return *var

=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc	2010-07-02 02:58:51 +0000
+++ b/sql/sql_error.cc	2010-07-23 12:42:28 +0000
@@ -587,16 +587,11 @@ void push_warning(THD *thd, MYSQL_ERROR:
   DBUG_PRINT("enter", ("code: %d, msg: %s", code, msg));
 
   /*
-    Calling push_warning/push_warning_printf with a
-    level of WARN_LEVEL_ERROR *is* a bug.
-    Either use my_error(), or WARN_LEVEL_WARN.
-    Please fix the calling code, and do *NOT*
-    add more work around code in the assert below.
+    Calling push_warning/push_warning_printf with a level of
+    WARN_LEVEL_ERROR *is* a bug.  Either use my_printf_error(),
+    my_error(), or WARN_LEVEL_WARN.
   */
-  DBUG_ASSERT(   (level != MYSQL_ERROR::WARN_LEVEL_ERROR)
-              || (code == ER_CANT_CREATE_TABLE) /* See Bug#47233 */
-              || (code == ER_ILLEGAL_HA_CREATE_OPTION) /* See Bug#47233 */
-             );
+  DBUG_ASSERT(level != MYSQL_ERROR::WARN_LEVEL_ERROR);
 
   if (level == MYSQL_ERROR::WARN_LEVEL_ERROR)
     level= MYSQL_ERROR::WARN_LEVEL_WARN;

=== modified file 'unittest/mysys/my_atomic-t.c'
--- a/unittest/mysys/my_atomic-t.c	2009-11-27 17:11:05 +0000
+++ b/unittest/mysys/my_atomic-t.c	2010-07-23 12:37:10 +0000
@@ -15,13 +15,6 @@
 
 #include "thr_template.c"
 
-/* at least gcc 3.4.5 and 3.4.6 (but not 3.2.3) on RHEL */
-#if __GNUC__ == 3 && __GNUC_MINOR__ == 4
-#define GCC_BUG_WORKAROUND volatile
-#else
-#define GCC_BUG_WORKAROUND
-#endif
-
 volatile uint32 b32;
 volatile int32  c32;
 my_atomic_rwlock_t rwl;
@@ -29,8 +22,8 @@ my_atomic_rwlock_t rwl;
 /* add and sub a random number in a loop. Must get 0 at the end */
 pthread_handler_t test_atomic_add(void *arg)
 {
-  int    m= (*(int *)arg)/2;
-  GCC_BUG_WORKAROUND int32 x;
+  int m= (*(int *)arg)/2;
+  int32 x;
   for (x= ((int)(intptr)(&m)); m ; m--)
   {
     x= (x*m+0x87654321) & INT_MAX32;
@@ -52,8 +45,8 @@ volatile int64 a64;
 /* add and sub a random number in a loop. Must get 0 at the end */
 pthread_handler_t test_atomic_add64(void *arg)
 {
-  int    m= (*(int *)arg)/2;
-  GCC_BUG_WORKAROUND int64 x;
+  int m= (*(int *)arg)/2;
+  int64 x;
   for (x= ((int64)(intptr)(&m)); m ; m--)
   {
     x= (x*m+0xfdecba987654321LL) & INT_MAX64;
@@ -128,8 +121,8 @@ pthread_handler_t test_atomic_fas(void *
 */
 pthread_handler_t test_atomic_cas(void *arg)
 {
-  int    m= (*(int *)arg)/2, ok= 0;
-  GCC_BUG_WORKAROUND int32 x, y;
+  int m= (*(int *)arg)/2, ok= 0;
+  int32 x, y;
   for (x= ((int)(intptr)(&m)); m ; m--)
   {
     my_atomic_rwlock_wrlock(&rwl);


Attachment: [text/bzr-bundle] bzr/davi.arnaut@oracle.com-20100723124228-nh2n0vmq01c217kj.bundle
Thread
bzr commit into mysql-next-mr-bugfixing branch (davi:3321) Davi Arnaut23 Jul