Author: lnicoara Date: Wed Oct 10 23:52:45 2012 New Revision: 1396863 URL: http://svn.apache.org/viewvc?rev=1396863&view=rev Log: 2012-10-10 Liviu Nicoara <lnico...@apache.org>
STDCXX-1072 -- stricter mutex objects alignments for SPARC-V8. Replaced ad-hoc aligned buffers with the stricter aligned __rw_aligned_buffer: * 4.2.x/src/messages.cpp: replaced aligned buffers. * 4.2.x/src/use_facet.h: same. * 4.2.x/src/ctype.cpp: same. * 4.2.x/src/locale_body.cpp: same. * 4.2.x/src/locale_classic.cpp: same. Modified: stdcxx/branches/4.2.x/src/ctype.cpp stdcxx/branches/4.2.x/src/locale_body.cpp stdcxx/branches/4.2.x/src/locale_classic.cpp stdcxx/branches/4.2.x/src/messages.cpp stdcxx/branches/4.2.x/src/use_facet.h Modified: stdcxx/branches/4.2.x/src/ctype.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/ctype.cpp?rev=1396863&r1=1396862&r2=1396863&view=diff ============================================================================== --- stdcxx/branches/4.2.x/src/ctype.cpp (original) +++ stdcxx/branches/4.2.x/src/ctype.cpp Wed Oct 10 23:52:45 2012 @@ -626,12 +626,9 @@ _RWSTD_EXPORT __rw_facet* __rw_ct_ctype pfacet = new _STD::ctype_byname<char>(name, ref); } else { - static union { - void *align_; - char data_ [sizeof (_STD::ctype<char>)]; - } f; - static __rw_facet* const pf = - new (&f) _STD::ctype<char>(__rw_classic_tab, false, ref); + static __rw_aligned_buffer<_STD::ctype<char> > f; + static __rw_facet* const pf = new (f._C_store ()) + _STD::ctype<char> (__rw_classic_tab, false, ref); pfacet = pf; } Modified: stdcxx/branches/4.2.x/src/locale_body.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/locale_body.cpp?rev=1396863&r1=1396862&r2=1396863&view=diff ============================================================================== --- stdcxx/branches/4.2.x/src/locale_body.cpp (original) +++ stdcxx/branches/4.2.x/src/locale_body.cpp Wed Oct 10 23:52:45 2012 @@ -1024,14 +1024,12 @@ _C_manage (__rw_locale *plocale, const c // the classic C locale is statically allocated // and not destroyed during the lifetime of the process - static union { - void* _C_align; - char _C_buf [sizeof (__rw_locale)]; - } classic_body; + static __rw_aligned_buffer<__rw_locale> classic_body; // construct a locale body in place // with the initial reference count of 1 - classic = new (&classic_body) __rw_locale (locname); + classic = new (classic_body._C_store ()) + __rw_locale (locname); _RWSTD_ASSERT (1 == classic->_C_ref); } Modified: stdcxx/branches/4.2.x/src/locale_classic.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/locale_classic.cpp?rev=1396863&r1=1396862&r2=1396863&view=diff ============================================================================== --- stdcxx/branches/4.2.x/src/locale_classic.cpp (original) +++ stdcxx/branches/4.2.x/src/locale_classic.cpp Wed Oct 10 23:52:45 2012 @@ -33,16 +33,13 @@ #include <loc/_locale.h> // for locale #include "once.h" // for __rw_once() +#include "podarray.h" _RWSTD_NAMESPACE (__rw) { // static buffer for the classic "C" locale object -static union { - void* _C_align; - char _C_buf [sizeof (_STD::locale)]; -} __rw_classic; - +static __rw_aligned_buffer<_STD::locale> __rw_classic; // init-once flag for the classic "C" locale object static __rw_once_t @@ -67,7 +64,7 @@ __rw_init_classic () #endif // _RWSTDDEBUG // construct the classic "C" locale in the provided buffer - new (&__rw_classic) _STD::locale ("C"); + new (__rw_classic._C_store ()) _STD::locale ("C"); } } // extern "C" @@ -78,15 +75,14 @@ __rw_init_classic () _RWSTD_NAMESPACE (std) { -/* static */ const locale& locale:: -classic () +/* static */ const locale& +locale::classic () { // initialize classic locale in the static buffer exactly once _RW::__rw_once (&_RW::__rw_classic_once_init, _RW::__rw_init_classic); // cast the address of the buffer to a locale pointer - const locale* const pclassic = - _RWSTD_REINTERPRET_CAST (locale*, &_RW::__rw_classic); + const locale* const pclassic = _RW::__rw_classic._C_data (); _RWSTD_ASSERT (0 != pclassic->_C_body); Modified: stdcxx/branches/4.2.x/src/messages.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/messages.cpp?rev=1396863&r1=1396862&r2=1396863&view=diff ============================================================================== --- stdcxx/branches/4.2.x/src/messages.cpp (original) +++ stdcxx/branches/4.2.x/src/messages.cpp Wed Oct 10 23:52:45 2012 @@ -38,6 +38,7 @@ #include <rw/_mutex.h> +#include "podarray.h" #if !defined (_RWSTD_NO_NL_TYPES_H) && !defined (_RWSTD_NO_CATOPEN_CATGETS) # include <nl_types.h> @@ -64,10 +65,7 @@ _RWSTD_NAMESPACE (__rw) { struct __rw_open_cat_data { nl_catd catd; - union { - void *_C_align; - char _C_data [sizeof (_STD::locale)]; - } loc; + __rw_aligned_buffer<_STD::locale> loc; }; struct __rw_open_cat_page @@ -159,7 +157,8 @@ __rw_manage_cat_data (int &cat, __rw_op cat = int (n_catalogs); catalogs [cat]->catd = pcat_data->catd; - memcpy (&catalogs [cat]->loc, &pcat_data->loc, + memcpy (catalogs [cat]->loc._C_store (), + pcat_data->loc._C_store (), sizeof (_STD::locale)); if (size_t (cat) > largest_cat) @@ -175,7 +174,8 @@ __rw_manage_cat_data (int &cat, __rw_op } catalogs [cat]->catd = pcat_data->catd; - memcpy (&catalogs [cat]->loc, &pcat_data->loc, + memcpy (catalogs [cat]->loc._C_store (), + pcat_data->loc._C_store (), sizeof (_STD::locale)); if (size_t (cat) > largest_cat) @@ -258,8 +258,9 @@ int __rw_cat_open (const _STD::string &c return -1; __rw_open_cat_data cat_data; + cat_data.catd = catd; - new (&cat_data.loc) _STD::locale (loc); + new (cat_data.loc._C_store ()) _STD::locale (loc); int cat = -1; __rw_manage_cat_data (cat, &cat_data); @@ -307,7 +308,7 @@ const _STD::locale& __rw_get_locale (int _RWSTD_ASSERT (0 != pcat_data); - return *(_RWSTD_REINTERPRET_CAST (_STD::locale*, &(pcat_data->loc))); + return *pcat_data->loc._C_data (); } @@ -329,8 +330,7 @@ void __rw_cat_close (int cat) catclose (pcat_data->catd); - _STD::locale* const ploc = - _RWSTD_REINTERPRET_CAST (_STD::locale*, &pcat_data->loc); + _STD::locale* const ploc = pcat_data->loc._C_data (); ploc->~locale (); Modified: stdcxx/branches/4.2.x/src/use_facet.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/use_facet.h?rev=1396863&r1=1396862&r2=1396863&view=diff ============================================================================== --- stdcxx/branches/4.2.x/src/use_facet.h (original) +++ stdcxx/branches/4.2.x/src/use_facet.h Wed Oct 10 23:52:45 2012 @@ -37,6 +37,7 @@ #include <rw/_defs.h> #include "access.h" +#include "podarray.h" // helper macro _RWSTD_DEFINE_FACET_FACTORY() defines a facet factory @@ -63,12 +64,9 @@ } \ else { \ /* construct an ordinary facet in static memory */ \ - static union { \ - void *align_; \ - char data_ [sizeof (__rw_ ## fid ## _facet)]; \ - } f; \ + static __rw_aligned_buffer<__rw_ ## fid ## _facet> f; \ static __rw_facet* const pf = \ - new (&f) __rw_ ## fid ## _facet (ref); \ + new (f._C_store ()) __rw_ ## fid ## _facet (ref); \ pfacet = pf; \ } \ /* set the pointer to the facet id */ \ @@ -90,12 +88,9 @@ __rw_ct_ ## fid (_RWSTD_SIZE_T ref, const char*) \ { \ /* construct an ordinary facet in static memory */ \ - static union { \ - void *align_; \ - char data_ [sizeof (__rw_ ## fid ## _facet)]; \ - } f; \ + static __rw_aligned_buffer<__rw_ ## fid ## _facet> f; \ static __rw_facet* const pf = \ - new (&f) __rw_ ## fid ## _facet (ref); \ + new (f._C_store ()) __rw_ ## fid ## _facet (ref); \ /* set the pointer to the facet id */ \ __rw_access::_C_get_pid (*pf) = \ &(__rw_access::_C_get_id (__rw_ ## fid ## _facet::id)); \