From: Date: December 4 2008 11:00pm Subject: bzr commit into mysql-6.0-falcon-team branch (olav:2926) Bug#37622 List-Archive: http://lists.mysql.com/commits/60667 X-Bug: 37622 Message-Id: <20081204220020.29449.qmail@khepri11> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/os136802/mysql/develop/repo/mysql-6.0-falcon-sparc-ss/ based on revid:hky@stripped 2926 Olav Sandstaa 2008-12-04 Fix for Bug#37622 Falcon does not compile on Solaris 9 on SPARC using Sun Studio compiler. Implements Interlock operations using Sun Studio's inline assembly for Solaris 9 on SPARC. added: storage/falcon/CompareAndSwapSparc.h modified: storage/falcon/CompareAndSwapSparc.il storage/falcon/Interlock.h storage/falcon/plug.in per-file messages: storage/falcon/CompareAndSwapSparc.h Include file for the interface for the compare and swap function implemented using Sun Studio's inline assembly. storage/falcon/CompareAndSwapSparc.il Implemented compare and swap using SPARC assembly for Sun Studio compiler. storage/falcon/Interlock.h Added support for Solaris 9 on SPARC. The implementation is found in CompareAndSwapSparc.il and is implemented using Sun Studio's inline assembly. storage/falcon/plug.in Make Falcon a supported when running configure on Solaris 9 on SPARC using Sun Studio 12 compiler. === added file 'storage/falcon/CompareAndSwapSparc.h' === added file 'storage/falcon/CompareAndSwapSparc.h' --- a/storage/falcon/CompareAndSwapSparc.h 1970-01-01 00:00:00 +0000 +++ b/storage/falcon/CompareAndSwapSparc.h 2008-12-04 22:00:04 +0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 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 */ + +#ifndef __COMPAREANDSWAPSPARC_H +#define __COMPAREANDSWAPSPARC_H + +#if defined(__SUNPRO_CC) && defined(__sparc) + +/* Declaration of C prototypes for code written as assembly using + Sun Studio's inline templates. The implementation is found in + CompareAndSwapSparc.il */ +extern "C" int cas_sparc(volatile int *target, int compare, int exchange); +extern "C" int cas_pointer_sparc32(volatile void **target, void *compare, + void *exchange); +extern "C" int cas_pointer_sparc64(volatile void **target, void *compare, + void *exchange); + + +inline int cas_pointer_sparc(volatile void **target, void *compare, + void *exchange) +{ + if (sizeof(void*) == 4) + return cas_pointer_sparc32(target, compare, exchange); + else + return cas_pointer_sparc64(target, compare, exchange); +} + +#endif /* __SUNPRO_CC && __sparc */ + +#endif /* __COMPAREANDSWAPSPARC_H */ === modified file 'storage/falcon/CompareAndSwapSparc.il' --- a/storage/falcon/CompareAndSwapSparc.il 2008-07-10 09:27:51 +0000 +++ b/storage/falcon/CompareAndSwapSparc.il 2008-12-04 22:00:04 +0000 @@ -1,12 +1,64 @@ - - -/* Implements inline_cas_uint - empty this far */ -.inline compareswap - nop -.end - - -/* Implements inline_cas_ptr - empty this far */ -.inline compareswapptr - nop +/* Copyright (C) 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 */ + + +/* Implements compare and swap. The signature of the function is: + + int cas_sparc(volatile int *target, int compare, int exchange); + + Return value: if the swap took place, 1 will be returned, + otherwise 0 is returned. +*/ +.inline cas_sparc + membar #LoadStore|#StoreStore + cas [%o0],%o1,%o2 + cmp %o1,%o2 + mov 1,%o0 + movne %icc,0,%o0 +.end + + +/* Implements compare and swap for 32 bit pointers. Signature: + + int cas_pointer_sparc32(volatile void **target, void *compare, + void *exchange); + + Return value: if the swap took place, 1 will be returned, + otherwise 0 is returned. +*/ +.inline cas_pointer_sparc32 + membar #LoadStore|#StoreStore + cas [%o0],%o1,%o2 + cmp %o1,%o2 + mov 1,%o0 + movne %icc,0,%o0 +.end + + +/* Implements compare and swap for 64 bit pointers. Signature: + + int cas_pointer_sparc64(volatile void **target, void *compare, + void *exchange); + + Return value: if the swap took place, 1 will be returned, + otherwise 0 is returned. +*/ +.inline cas_pointer_sparc64 + membar #LoadStore|#StoreStore + casx [%o0],%o1,%o2 + cmp %o1,%o2 + mov 1,%o0 + movne %icc,0,%o0 .end === modified file 'storage/falcon/Interlock.h' --- a/storage/falcon/Interlock.h 2008-09-09 19:02:38 +0000 +++ b/storage/falcon/Interlock.h 2008-12-04 22:00:04 +0000 @@ -19,10 +19,9 @@ #if defined(__sparcv8) || defined(__sparcv9) || defined(__sun) #include -#if defined(__SunOS_5_9) -extern "C" int compareswap(volatile int *target, int compare, int exchange); -extern "C" char compareswapptr(volatile void **target, void *compare, void *exchange); -#endif /* __SunOS_5_9 */ +#if defined(__SunOS_5_9) && defined(__SUNPRO_CC) && defined(__sparc) +#include "CompareAndSwapSparc.h" +#endif /* __SunOS_5_9 && __SUNPRO_CC && __sparc */ #endif @@ -152,11 +151,8 @@ #if defined(__SunOS_5_10) || defined(__SunOS_5_11) return (compare == atomic_cas_uint((volatile uint_t *)target, compare, exchange)); #else -# error cas not defined. We need >= Solaris 10 - /* Not implemented yet - just an example of how to call inline assembly */ - char ret = compareswap(target, compare, exchange); - - return ret; + /* Use inline assembly for Solaris 9 */ + return cas_sparc(target, compare, exchange); #endif #else @@ -266,11 +262,8 @@ #if defined(__SunOS_5_10) || defined(__SunOS_5_11) return (char)(compare == atomic_cas_ptr(target, compare, exchange)); #else -# error cas not defined. We need >= Solaris 10 - /* Not implemented yet - just an example for calling inline assembly */ - char ret = compareswapptr(target, compare, exchange); - - return ret; + /* Use inline assembly for Solaris 9 */ + return cas_pointer_sparc(target, compare, exchange); #endif #else === modified file 'storage/falcon/plug.in' --- a/storage/falcon/plug.in 2008-11-27 09:22:22 +0000 +++ b/storage/falcon/plug.in 2008-12-04 22:00:04 +0000 @@ -23,14 +23,23 @@ int exchange= 2; ],[ #if defined(__SUNPRO_C) || defined(__SUNPRO_CC) - /* When compiling with Sun Studio compiler we need the Solaris atomic - functions. These were first introduced in Solaris 10. */ + /* When compiling with Sun Studio compiler we use the Solaris atomic + functions if they are available. These were first introduced in + Solaris 10. */ #if defined(HAVE_SOLARIS_ATOMIC) return 0; +#else + /* If the atomic functions are not available we use our own assembly + implementation for these. These are implemented using Sun Studio's + inline assembly templates which is only supported by Sun Studio 12 + and newer versions (compiler version 5.9 or newer). */ +#if (__SUNPRO_C) >= 0x590 || (__SUNPRO_CC >= 0x590) + return 0; #else - /* Fail if the atomic functions are not available. Support for this - will be added when the fix for bug 37622 is completed. */ -#error Need Solaris atomic functions to use Sun Studio compiler + /* Fail if we do not have the atomic functions and the Sun Studio version + is older that Sun Studio 12. */ +#error To compile Falcon with Sun Studio for Solaris on SPARC we need either Solaris 10 or newer or Sun Studio 12 or newer +#endif #endif /* HAVE_SOLARIS_ATOMIC */ #else /* Use gcc style inline assembly when compiling with gcc */