packages (MYSQL_5_0): mysql/mysql.spec, mysql/mysql-atomic.patch (NEW) - ba...
arekm
arekm at pld-linux.org
Wed Sep 9 12:33:33 CEST 2009
Author: arekm Date: Wed Sep 9 10:33:33 2009 GMT
Module: packages Tag: MYSQL_5_0
---- Log message:
- backport atomic stuff from 5.1
---- Files affected:
packages/mysql:
mysql.spec (1.353.2.78 -> 1.353.2.79) , mysql-atomic.patch (NONE -> 1.1.2.1) (NEW)
---- Diffs:
================================================================
Index: packages/mysql/mysql.spec
diff -u packages/mysql/mysql.spec:1.353.2.78 packages/mysql/mysql.spec:1.353.2.79
--- packages/mysql/mysql.spec:1.353.2.78 Wed Aug 26 13:34:11 2009
+++ packages/mysql/mysql.spec Wed Sep 9 12:33:27 2009
@@ -71,6 +71,7 @@
Patch18: %{name}-xtrabackup.patch
Patch19: %{name}-fixes.patch
Patch20: %{name}-gcc3.patch
+Patch21: %{name}-atomic.patch
# <percona patches, http://www.percona.com/percona-lab.html>
Patch100: %{name}-show_patches.patch
Patch101: %{name}-microslow_innodb.patch
@@ -552,11 +553,13 @@
%if "%{cxx_version}" < "4.1"
%patch20 -p1
%endif
+%patch21 -p0
%build
%{__libtoolize}
%{__aclocal}
%{__automake}
+%{__autoheader}
%{__autoconf}
# The compiler flags are as per their "official" spec ;)
@@ -1107,6 +1110,9 @@
All persons listed below can be reached at <cvs_login>@pld-linux.org
$Log$
+Revision 1.353.2.79 2009/09/09 10:33:27 arekm
+- backport atomic stuff from 5.1
+
Revision 1.353.2.78 2009/08/26 11:34:11 glen
- cosmetics
================================================================
Index: packages/mysql/mysql-atomic.patch
diff -u /dev/null packages/mysql/mysql-atomic.patch:1.1.2.1
--- /dev/null Wed Sep 9 12:33:33 2009
+++ packages/mysql/mysql-atomic.patch Wed Sep 9 12:33:27 2009
@@ -0,0 +1,1023 @@
+------------------------------------------------------------
+revno: 2169.5.4
+committer: serg at serg.mylan
+timestamp: Wed 2006-05-31 18:44:09 +0200
+message:
+ WL#2595 - atomic operations
+=== modified file 'configure.in'
+--- configure.in 2006-05-26 11:17:09 +0000
++++ configure.in 2006-05-31 16:44:09 +0000
+@@ -778,48 +778,6 @@
+ AC_SUBST(WRAPLIBS)
+
+ if test "$TARGET_LINUX" = "true"; then
+- AC_MSG_CHECKING([for atomic operations])
+-
+- AC_LANG_SAVE
+- AC_LANG_CPLUSPLUS
+-
+- atom_ops=
+- AC_TRY_RUN([
+-#include <asm/atomic.h>
+-int main()
+-{
+- atomic_t v;
+-
+- atomic_set(&v, 23);
+- atomic_add(5, &v);
+- return atomic_read(&v) == 28 ? 0 : -1;
+-}
+- ],
+- [AC_DEFINE([HAVE_ATOMIC_ADD], [1],
+- [atomic_add() from <asm/atomic.h> (Linux only)])
+- atom_ops="${atom_ops}atomic_add "],
+- )
+- AC_TRY_RUN([
+-#include <asm/atomic.h>
+-int main()
+-{
+- atomic_t v;
+-
+- atomic_set(&v, 23);
+- atomic_sub(5, &v);
+- return atomic_read(&v) == 18 ? 0 : -1;
+-}
+- ],
+- [AC_DEFINE([HAVE_ATOMIC_SUB], [1],
+- [atomic_sub() from <asm/atomic.h> (Linux only)])
+- atom_ops="${atom_ops}atomic_sub "],
+- )
+-
+- if test -z "$atom_ops"; then atom_ops="no"; fi
+- AC_MSG_RESULT($atom_ops)
+-
+- AC_LANG_RESTORE
+-
+ AC_ARG_WITH(pstack,
+ [ --with-pstack Use the pstack backtrace library],
+ [ USE_PSTACK=$withval ],
+@@ -1631,6 +1589,20 @@
+ fi
+ fi
+
++AC_ARG_WITH([atomic-ops],
++ AC_HELP_STRING([--with-atomic-ops=rwlocks|smp|up],
++ [Implement atomic operations using pthread rwlocks or atomic CPU
++ instructions for multi-processor (default) or uniprocessor
++ configuration]), , [with_atomic_ops=smp])
++case "$with_atomic_ops" in
++ "up") AC_DEFINE([MY_ATOMIC_MODE_DUMMY], [1],
++ [Assume single-CPU mode, no concurrency]) ;;
++ "rwlocks") AC_DEFINE([MY_ATOMIC_MODE_RWLOCKS], [1],
++ [Use pthread rwlocks for atomic ops]) ;;
++ "smp") ;;
++ *) AC_MSG_ERROR(["$with_atomic_ops" is not a valid value for --with-atomic-ops]) ;;
++esac
++
+ # Force static compilation to avoid linking problems/get more speed
+ AC_ARG_WITH(mysqld-ldflags,
+ [ --with-mysqld-ldflags Extra linking arguments for mysqld],
+
+=== added directory 'include/atomic'
+=== added file 'include/atomic/nolock.h'
+--- include/atomic/nolock.h 1970-01-01 00:00:00 +0000
++++ include/atomic/nolock.h 2006-05-31 16:44:09 +0000
+@@ -0,0 +1,169 @@
++/* 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; either version 2 of the License, or
++ (at your option) any later version.
++
++ 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(_M_IX86)
++#ifdef MY_ATOMIC_MODE_DUMMY
++# define LOCK ""
++#else
++# define LOCK "lock "
++#endif
++#ifdef __GNUC__
++#include "x86-gcc.h"
++#elif defined(_MSC_VER)
++#include "x86-msvc.h"
++#endif
++#endif
++
++#ifdef make_atomic_add_body8
++
++#ifdef HAVE_INLINE
++
++#define make_atomic_add(S) \
++static inline uint ## S _my_atomic_add ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v) \
++{ \
++ make_atomic_add_body ## S; \
++ return v; \
++}
++
++#define make_atomic_swap(S) \
++static inline uint ## S _my_atomic_swap ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v) \
++{ \
++ make_atomic_swap_body ## S; \
++ return v; \
++}
++
++#define make_atomic_cas(S) \
++static inline uint _my_atomic_cas ## S(my_atomic_ ## S ## _t *a,\
++ uint ## S *cmp, uint ## S set) \
++{ \
++ uint8 ret; \
++ make_atomic_cas_body ## S; \
++ return ret; \
++}
++
++#define make_atomic_load(S) \
++static inline uint ## S _my_atomic_load ## S( \
++ my_atomic_ ## S ## _t *a) \
++{ \
++ uint ## S ret; \
++ make_atomic_load_body ## S; \
++ return ret; \
++}
++
++#define make_atomic_store(S) \
++static inline void _my_atomic_store ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v) \
++{ \
++ make_atomic_store_body ## S; \
++}
++
++#else /* no inline functions */
++
++#define make_atomic_add(S) \
++extern uint ## S _my_atomic_add ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v);
++
++#define make_atomic_swap(S) \
++extern uint ## S _my_atomic_swap ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v);
++
++#define make_atomic_cas(S) \
++extern uint _my_atomic_cas ## S(my_atomic_ ## S ## _t *a, \
++ uint ## S *cmp, uint ## S set);
++
++#define make_atomic_load(S) \
++extern uint ## S _my_atomic_load ## S( \
++ my_atomic_ ## S ## _t *a);
++
++#define make_atomic_store(S) \
++extern void _my_atomic_store ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v);
++
++#endif
++
++make_atomic_add( 8)
++make_atomic_add(16)
++make_atomic_add(32)
++
++make_atomic_cas( 8)
++make_atomic_cas(16)
++make_atomic_cas(32)
++
++make_atomic_load( 8)
++make_atomic_load(16)
++make_atomic_load(32)
++
++make_atomic_store( 8)
++make_atomic_store(16)
++make_atomic_store(32)
++
++make_atomic_swap( 8)
++make_atomic_swap(16)
++make_atomic_swap(32)
++
++#undef make_atomic_add_body8
++#undef make_atomic_cas_body8
++#undef make_atomic_load_body8
++#undef make_atomic_store_body8
++#undef make_atomic_swap_body8
++#undef make_atomic_add_body16
++#undef make_atomic_cas_body16
++#undef make_atomic_load_body16
++#undef make_atomic_store_body16
++#undef make_atomic_swap_body16
++#undef make_atomic_add_body32
++#undef make_atomic_cas_body32
++#undef make_atomic_load_body32
++#undef make_atomic_store_body32
++#undef make_atomic_swap_body32
++#undef make_atomic_add
++#undef make_atomic_cas
++#undef make_atomic_load
++#undef make_atomic_store
++#undef make_atomic_swap
++
++#define my_atomic_add8(a,v,L) _my_atomic_add8(a,v)
++#define my_atomic_add16(a,v,L) _my_atomic_add16(a,v)
++#define my_atomic_add32(a,v,L) _my_atomic_add32(a,v)
++
++#define my_atomic_cas8(a,c,v,L) _my_atomic_cas8(a,c,v)
++#define my_atomic_cas16(a,c,v,L) _my_atomic_cas16(a,c,v)
++#define my_atomic_cas32(a,c,v,L) _my_atomic_cas32(a,c,v)
++
++#define my_atomic_load8(a,L) _my_atomic_load8(a)
++#define my_atomic_load16(a,L) _my_atomic_load16(a)
++#define my_atomic_load32(a,L) _my_atomic_load32(a)
++
++#define my_atomic_store8(a,v,L) _my_atomic_store8(a,v)
++#define my_atomic_store16(a,v,L) _my_atomic_store16(a,v)
++#define my_atomic_store32(a,v,L) _my_atomic_store32(a,v)
++
++#define my_atomic_swap8(a,v,L) _my_atomic_swap8(a,v)
++#define my_atomic_swap16(a,v,L) _my_atomic_swap16(a,v)
++#define my_atomic_swap32(a,v,L) _my_atomic_swap32(a,v)
++
++#define my_atomic_rwlock_t typedef int
++#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
++
+
+=== added file 'include/atomic/rwlock.h'
+--- include/atomic/rwlock.h 1970-01-01 00:00:00 +0000
++++ include/atomic/rwlock.h 2006-05-31 16:44:09 +0000
+@@ -0,0 +1,161 @@
++/* 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; either version 2 of the License, or
++ (at your option) any later version.
++
++ 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_rwlock_t rw;} my_atomic_rwlock_t;
++
++#ifdef MY_ATOMIC_EXTRA_DEBUG
++#define CHECK_RW if (rw) if (a->rw) assert(rw == a->rw); else a->rw=rw;
++#else
++#define CHECK_RW
++#endif
++
++#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)
++#else
++#define my_atomic_rwlock_destroy(name) pthread_rwlock_destroy(& (name)->rw)
++#define my_atomic_rwlock_init(name) pthread_rwlock_init(& (name)->rw, 0)
++#define my_atomic_rwlock_rdlock(name) pthread_rwlock_rdlock(& (name)->rw)
++#define my_atomic_rwlock_wrlock(name) pthread_rwlock_wrlock(& (name)->rw)
++#define my_atomic_rwlock_rdunlock(name) pthread_rwlock_unlock(& (name)->rw)
++#define my_atomic_rwlock_wrunlock(name) pthread_rwlock_unlock(& (name)->rw)
++#endif
++
++#ifdef HAVE_INLINE
++
++#define make_atomic_add(S) \
++static inline uint ## S my_atomic_add ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw) \
++{ \
++ uint ## S ret; \
++ CHECK_RW; \
++ if (rw) my_atomic_rwlock_wrlock(rw); \
++ ret= a->val; \
++ a->val+= v; \
++ if (rw) my_atomic_rwlock_wrunlock(rw); \
++ return ret; \
++}
++
++#define make_atomic_swap(S) \
++static inline uint ## S my_atomic_swap ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw) \
++{ \
++ uint ## S ret; \
++ CHECK_RW; \
++ if (rw) my_atomic_rwlock_wrlock(rw); \
++ ret= a->val; \
++ a->val= v; \
++ if (rw) my_atomic_rwlock_wrunlock(rw); \
++ return ret; \
++}
++
++#define make_atomic_cas(S) \
++static inline uint my_atomic_cas ## S(my_atomic_ ## S ## _t *a, \
++ uint ## S *cmp, uint ## S set, my_atomic_rwlock_t *rw) \
++{ \
++ uint ret; \
++ CHECK_RW; \
++ if (rw) my_atomic_rwlock_wrlock(rw); \
++ if (ret= (a->val == *cmp)) a->val= set; else *cmp=a->val; \
++ if (rw) my_atomic_rwlock_wrunlock(rw); \
++ return ret; \
++}
++
++#define make_atomic_load(S) \
++static inline uint ## S my_atomic_load ## S( \
++ my_atomic_ ## S ## _t *a, my_atomic_rwlock_t *rw) \
++{ \
++ uint ## S ret; \
++ CHECK_RW; \
++ if (rw) my_atomic_rwlock_wrlock(rw); \
++ ret= a->val; \
++ if (rw) my_atomic_rwlock_wrunlock(rw); \
++ return ret; \
++}
++
++#define make_atomic_store(S) \
++static inline void my_atomic_store ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw) \
++{ \
++ CHECK_RW; \
++ if (rw) my_atomic_rwlock_rdlock(rw); \
++ (a)->val= (v); \
++ if (rw) my_atomic_rwlock_rdunlock(rw); \
++}
++
++#else /* no inline functions */
++
++#define make_atomic_add(S) \
++extern uint ## S my_atomic_add ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw);
++
++#define make_atomic_swap(S) \
++extern uint ## S my_atomic_swap ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw);
++
++#define make_atomic_cas(S) \
++extern uint my_atomic_cas ## S(my_atomic_ ## S ## _t *a, \
++ uint ## S *cmp, uint ## S set, my_atomic_rwlock_t *rw);
++
++#define make_atomic_load(S) \
++extern uint ## S my_atomic_load ## S( \
++ my_atomic_ ## S ## _t *a, my_atomic_rwlock_t *rw);
++
++#define make_atomic_store(S) \
++extern void my_atomic_store ## S( \
++ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw);
++
++#endif
++
++make_atomic_add( 8)
++make_atomic_add(16)
++make_atomic_add(32)
++make_atomic_add(64)
++make_atomic_cas( 8)
++make_atomic_cas(16)
++make_atomic_cas(32)
++make_atomic_cas(64)
++make_atomic_load( 8)
++make_atomic_load(16)
++make_atomic_load(32)
++make_atomic_load(64)
++make_atomic_store( 8)
++make_atomic_store(16)
++make_atomic_store(32)
++make_atomic_store(64)
++make_atomic_swap( 8)
++make_atomic_swap(16)
++make_atomic_swap(32)
++make_atomic_swap(64)
++#undef make_atomic_add
++#undef make_atomic_cas
++#undef make_atomic_load
++#undef make_atomic_store
++#undef make_atomic_swap
++#undef CHECK_RW
++
++
+
+=== added file 'include/atomic/x86-gcc.h'
+--- include/atomic/x86-gcc.h 1970-01-01 00:00:00 +0000
++++ include/atomic/x86-gcc.h 2006-05-31 16:44:09 +0000
+@@ -0,0 +1,56 @@
++/* 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; either version 2 of the License, or
++ (at your option) any later version.
++
++ 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
++*/
++
++#define make_atomic_add_body8 \
++ asm volatile (LOCK "xadd %0, %1;" : "+r" (v) , "+m" (a->val))
++#define make_atomic_swap_body8 \
++ asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (a->val))
++#define make_atomic_cas_body8 \
++ asm volatile (LOCK "cmpxchg %3, %0; setz %2;" \
++ : "+m" (a->val), "+a" (*cmp), "=q" (ret): "r" (set))
++
++#ifdef MY_ATOMIC_MODE_DUMMY
++#define make_atomic_load_body8 ret=a->val
++#define make_atomic_store_body8 a->val=v
++#else
++/*
++ Actually 32-bit reads/writes are always atomic on x86
++ But we add LOCK here anyway to force memory barriers
++*/
++#define make_atomic_load_body8 \
++ ret=0; \
++ asm volatile (LOCK "cmpxchg %2, %0" \
++ : "+m" (a->val), "+a" (ret): "r" (ret))
++#define make_atomic_store_body8 \
++ asm volatile ("xchg %0, %1;" : "+m" (a->val) : "r" (v))
++#endif
++
++#define make_atomic_add_body16 make_atomic_add_body8
++#define make_atomic_add_body32 make_atomic_add_body8
++#define make_atomic_cas_body16 make_atomic_cas_body8
++#define make_atomic_cas_body32 make_atomic_cas_body8
++#define make_atomic_load_body16 make_atomic_load_body8
++#define make_atomic_load_body32 make_atomic_load_body8
++#define make_atomic_store_body16 make_atomic_store_body8
++#define make_atomic_store_body32 make_atomic_store_body8
++#define make_atomic_swap_body16 make_atomic_swap_body8
++#define make_atomic_swap_body32 make_atomic_swap_body8
++
+
+=== added file 'include/atomic/x86-msvc.h'
+--- include/atomic/x86-msvc.h 1970-01-01 00:00:00 +0000
++++ include/atomic/x86-msvc.h 2006-05-31 16:44:09 +0000
+@@ -0,0 +1,85 @@
++/* 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; either version 2 of the License, or
++ (at your option) any later version.
++
++ 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
++*/
++
++// Would it be better to use intrinsics ?
++// (InterlockedCompareExchange, InterlockedCompareExchange16
++// InterlockedExchangeAdd, InterlockedExchange)
++
++#define make_atomic_add_body(REG) \
++ _asm { \
++ _asm mov REG, v \
++ _asm LOCK xadd a->val, REG \
++ _asm movzx v, REG \
++ }
++#define make_atomic_cas_body(AREG,REG2) \
++ _asm { \
++ _asm mov AREG, *cmp \
++ _asm mov REG2, set \
++ _asm LOCK cmpxchg a->val, REG2 \
++ _asm mov *cmp, AREG \
++ _asm setz al \
++ _asm movzx ret, al \
++ }
++#define make_atomic_swap_body(REG) \
++ _asm { \
++ _asm mov REG, v \
++ _asm xchg a->val, REG \
++ _asm mov v, REG \
++ }
++
++#ifdef MY_ATOMIC_MODE_DUMMY
++#define make_atomic_load_body(AREG,REG) ret=a->val
++#define make_atomic_store_body(REG) a->val=v
++#else
++/*
++ Actually 32-bit reads/writes are always atomic on x86
++ But we add LOCK here anyway to force memory barriers
++*/
++#define make_atomic_load_body(AREG,REG2) \
++ _asm { \
++ _asm mov AREG, 0 \
++ _asm mov REG2, AREG \
++ _asm LOCK cmpxchg a->val, REG2 \
++ _asm mov ret, AREG \
++ }
++#define make_atomic_store_body(REG) \
++ _asm { \
++ _asm mov REG, v \
++ _asm xchg a->val, REG \
++ }
++#endif
<<Diff was trimmed, longer than 597 lines>>
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/mysql/mysql.spec?r1=1.353.2.78&r2=1.353.2.79&f=u
More information about the pld-cvs-commit
mailing list