List:Commits« Previous MessageNext Message »
From:Mikael Ronstrom Date:May 3 2011 11:18am
Subject:bzr commit into mysql-5.5 branch (mikael.ronstrom:3140)
View as plain text  
#At file:///home/mikael/mysql_clones/mysql-5.5-wl5136_community/ based on revid:mikael.ronstrom@stripped

 3140 Mikael Ronstrom	2011-05-03
      Introduced possibility to cache line alignment of variables in portable manner

    modified:
      include/my_global.h
=== modified file 'include/my_global.h'
--- a/include/my_global.h	revid:mikael.ronstrom@stripped
+++ b/include/my_global.h	revid:mikael.ronstrom@stripped
@@ -1464,6 +1464,41 @@ static inline double rint(double x)
 #endif
 #endif
 
+/* Define for cache aligned data declaration */
+#define CACHE_LINE_SIZE 128
+#ifdef _MSC_VER
+/* Aligned declarations are available since Visual C++ .Net 2003 == _MSC_VER=1310 */
+#  if (_MSC_VER >= 1310)
+#    define CACHE_ALIGNED_DECLARE(declare, var_name) __declspec( align (CACHE_LINE_SIZE)) declare
+#  else
+#    define CACHE_ALIGNED_DECLARE(declare) declare
+#  endif
+#elif (defined(__GNUC__))
+/* Aligned declarations are available since GCC 3.0 == __GNUC__ >= 3 */
+#  if (__GNUC__ >= 3)
+#    define CACHE_ALIGNED_DECLARE(declare, varname) declare __attribute__ ((aligned (CACHE_LINE_SIZE)))
+#  else
+#    define CACHE_ALIGNED_DECLARE(declare) declare
+#  endif
+#elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
+/*
+  Aligned declarations are available at least as of Sun Studio 11. However
+  didn't manage to discover what __SUNPRO_C is set to for Sun Studio 11 so
+  used 0x590 instead which is Sun Studio 12.
+
+  Note that within a namespace the varname must be mangled name of the variable.
+*/
+#  if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x590) || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590)
+#    define CACHE_ALIGNED_DECLARE(declare, varname) \
+     pragma align CACHE_LINE_SIZE(varname) \
+     declare
+#  else
+#    define CACHE_ALIGNED_DECLARE(declare) declare
+#  endif
+#else
+#define CACHE_ALIGNED_DECLARE(declare) declare
+#endif
+
 /* Defines that are unique to the embedded version of MySQL */
 
 #ifdef EMBEDDED_LIBRARY


Attachment: [text/bzr-bundle] bzr/mikael.ronstrom@oracle.com-20110503111819-a61w98bpfzmfjp1k.bundle
Thread
bzr commit into mysql-5.5 branch (mikael.ronstrom:3140) Mikael Ronstrom3 May
  • Re: bzr commit into mysql-5.5 branch (mikael.ronstrom:3140)Davi Arnaut3 May