[llvm-commits] [release_14] CVS: llvm-gcc/libstdc++-v3/src/globals.cc

John Criswell criswell at cs.uiuc.edu
Wed Dec 8 07:30:49 PST 2004



Changes in directory llvm-gcc/libstdc++-v3/src:

globals.cc updated: 1.2 -> 1.2.6.1
---
Log message:

Merging critical change into the release branch.
This tricks LLVM to aligning these arrays on long boundaries (32 bit on
i386, 64 bit on sparc), so that i386 runs faster and sparc doesn't
bus error or segfault.


---
Diffs of the changes:  (+48 -46)

Index: llvm-gcc/libstdc++-v3/src/globals.cc
diff -u llvm-gcc/libstdc++-v3/src/globals.cc:1.2 llvm-gcc/libstdc++-v3/src/globals.cc:1.2.6.1
--- llvm-gcc/libstdc++-v3/src/globals.cc:1.2	Fri Jan  9 10:54:35 2004
+++ llvm-gcc/libstdc++-v3/src/globals.cc	Wed Dec  8 09:30:35 2004
@@ -53,11 +53,13 @@
 
 namespace std
 {
+#define lsizeof(a) (((a)+sizeof(long)-1)/sizeof(long))
+
   // Standard stream objects.
   // NB: Iff <iostream> is included, these definitions become wonky.
-  typedef char fake_istream[sizeof(istream)]
+  typedef long fake_istream[lsizeof(sizeof(istream)) ]
   __attribute__ ((aligned(__alignof__(istream))));
-  typedef char fake_ostream[sizeof(ostream)] 
+  typedef long fake_ostream[lsizeof(sizeof(ostream)) ] 
   __attribute__ ((aligned(__alignof__(ostream))));
   fake_istream cin;
   fake_ostream cout;
@@ -65,9 +67,9 @@
   fake_ostream clog;
 
 #ifdef _GLIBCXX_USE_WCHAR_T
-  typedef char fake_wistream[sizeof(wistream)] 
+  typedef long fake_wistream[lsizeof(sizeof(wistream)) ] 
   __attribute__ ((aligned(__alignof__(wistream))));
-  typedef char fake_wostream[sizeof(wostream)] 
+  typedef long fake_wostream[lsizeof(sizeof(wostream)) ] 
   __attribute__ ((aligned(__alignof__(wostream))));
   fake_wistream wcin;
   fake_wostream wcout;
@@ -82,189 +84,189 @@
 
   // We use different stream buffer types depending on whether
   // ios_base::sync_with_stdio(false) has been called.
-  typedef char fake_stdiobuf[sizeof(stdio_sync_filebuf<char>)]
+  typedef long fake_stdiobuf[lsizeof(sizeof(stdio_sync_filebuf<char>)) ]
   __attribute__ ((aligned(__alignof__(stdio_sync_filebuf<char>))));
   fake_stdiobuf buf_cout_sync;
   fake_stdiobuf buf_cin_sync;
   fake_stdiobuf buf_cerr_sync;
 
-  typedef char fake_filebuf[sizeof(stdio_filebuf<char>)]
+  typedef long fake_filebuf[lsizeof(sizeof(stdio_filebuf<char>)) ]
   __attribute__ ((aligned(__alignof__(stdio_filebuf<char>))));
   fake_filebuf buf_cout;
   fake_filebuf buf_cin;
   fake_filebuf buf_cerr;
 
 #ifdef _GLIBCXX_USE_WCHAR_T
-  typedef char fake_wstdiobuf[sizeof(stdio_sync_filebuf<wchar_t>)]
+  typedef long fake_wstdiobuf[lsizeof(sizeof(stdio_sync_filebuf<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(stdio_sync_filebuf<wchar_t>))));
   fake_wstdiobuf buf_wcout_sync;
   fake_wstdiobuf buf_wcin_sync;
   fake_wstdiobuf buf_wcerr_sync;
 
-  typedef char fake_wfilebuf[sizeof(stdio_filebuf<wchar_t>)]
+  typedef long fake_wfilebuf[lsizeof(sizeof(stdio_filebuf<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(stdio_filebuf<wchar_t>))));
   fake_wfilebuf buf_wcout;
   fake_wfilebuf buf_wcin;
   fake_wfilebuf buf_wcerr;
 #endif
 
-  typedef char fake_locale_Impl[sizeof(locale::_Impl)]
+  typedef long fake_locale_Impl[lsizeof(sizeof(locale::_Impl)) ]
   __attribute__ ((aligned(__alignof__(locale::_Impl))));
   fake_locale_Impl c_locale_impl;
 
-  typedef char fake_locale[sizeof(locale)]
+  typedef long fake_locale[lsizeof(sizeof(locale)) ]
   __attribute__ ((aligned(__alignof__(locale))));
   fake_locale c_locale;
 
-  typedef char fake_name_vec[sizeof(char*)]
+  typedef long fake_name_vec[lsizeof(sizeof(char*)) ]
   __attribute__ ((aligned(__alignof__(char*))));
   fake_name_vec name_vec[6 + _GLIBCXX_NUM_CATEGORIES];
 
-  typedef char fake_names[sizeof(char[2])]
+  typedef long fake_names[lsizeof(sizeof(char[2])) ]
   __attribute__ ((aligned(__alignof__(char[2]))));
   fake_names name_c[6 + _GLIBCXX_NUM_CATEGORIES];
 
-  typedef char fake_facet_vec[sizeof(locale::facet*)]
+  typedef long fake_facet_vec[lsizeof(sizeof(locale::facet*)) ]
   __attribute__ ((aligned(__alignof__(locale::facet*))));
   fake_facet_vec facet_vec[_GLIBCXX_NUM_FACETS];
 
-  typedef char fake_cache_vec[sizeof(locale::facet*)]
+  typedef long fake_cache_vec[lsizeof(sizeof(locale::facet*)) ]
   __attribute__ ((aligned(__alignof__(locale::facet*))));
   fake_cache_vec cache_vec[_GLIBCXX_NUM_FACETS];
 
-  typedef char fake_ctype_c[sizeof(std::ctype<char>)]
+  typedef long fake_ctype_c[lsizeof(sizeof(std::ctype<char>)) ]
   __attribute__ ((aligned(__alignof__(std::ctype<char>))));
   fake_ctype_c ctype_c;
 
-  typedef char fake_collate_c[sizeof(std::collate<char>)]
+  typedef long fake_collate_c[lsizeof(sizeof(std::collate<char>)) ]
   __attribute__ ((aligned(__alignof__(std::collate<char>))));
   fake_collate_c collate_c;
 
-  typedef char fake_numpunct_c[sizeof(numpunct<char>)]
+  typedef long fake_numpunct_c[lsizeof(sizeof (numpunct<char>)) ]
   __attribute__ ((aligned(__alignof__(numpunct<char>))));
   fake_numpunct_c numpunct_c;
 
-  typedef char fake_num_get_c[sizeof(num_get<char>)]
+  typedef long fake_num_get_c[lsizeof(sizeof (num_get<char>)) ]
   __attribute__ ((aligned(__alignof__(num_get<char>))));
   fake_num_get_c num_get_c;
 
-  typedef char fake_num_put_c[sizeof(num_put<char>)]
+  typedef long fake_num_put_c[lsizeof(sizeof(num_put<char>)) ]
   __attribute__ ((aligned(__alignof__(num_put<char>))));
   fake_num_put_c num_put_c;
 
-  typedef char fake_codecvt_c[sizeof(codecvt<char, char, mbstate_t>)]
+  typedef long fake_codecvt_c[lsizeof(sizeof(codecvt<char, char, mbstate_t>)) ]
   __attribute__ ((aligned(__alignof__(codecvt<char, char, mbstate_t>))));
   fake_codecvt_c codecvt_c;
 
-  typedef char fake_moneypunct_c[sizeof(moneypunct<char, true>)]
+  typedef long fake_moneypunct_c[lsizeof(sizeof(moneypunct<char, true>)) ]
   __attribute__ ((aligned(__alignof__(moneypunct<char, true>))));
   fake_moneypunct_c moneypunct_ct;
   fake_moneypunct_c moneypunct_cf;
 
-  typedef char fake_money_get_c[sizeof(money_get<char>)]
+  typedef long fake_money_get_c[lsizeof(sizeof(money_get<char>)) ]
   __attribute__ ((aligned(__alignof__(money_get<char>))));
   fake_money_get_c money_get_c;
   
-  typedef char fake_money_put_c[sizeof(money_put<char>)]
+  typedef long fake_money_put_c[lsizeof(sizeof(money_put<char>)) ]
   __attribute__ ((aligned(__alignof__(money_put<char>))));
   fake_money_put_c money_put_c;
 
-  typedef char fake_timepunct_c[sizeof(__timepunct<char>)]
+  typedef long fake_timepunct_c[lsizeof(sizeof(__timepunct<char>)) ]
   __attribute__ ((aligned(__alignof__(__timepunct<char>))));
   fake_timepunct_c timepunct_c;
 
-  typedef char fake_time_get_c[sizeof(time_get<char>)]
+  typedef long fake_time_get_c[lsizeof(sizeof(time_get<char>)) ]
   __attribute__ ((aligned(__alignof__(time_get<char>))));
   fake_time_get_c time_get_c;
 
-  typedef char fake_time_put_c[sizeof(time_put<char>)]
+  typedef long fake_time_put_c[lsizeof(sizeof (time_put<char>)) ]
   __attribute__ ((aligned(__alignof__(time_put<char>))));
   fake_time_put_c time_put_c;
 
-  typedef char fake_messages_c[sizeof(messages<char>)]
+  typedef long fake_messages_c[lsizeof(sizeof (messages<char>)) ]
   __attribute__ ((aligned(__alignof__(messages<char>))));
   fake_messages_c messages_c;
 
 #ifdef  _GLIBCXX_USE_WCHAR_T
-  typedef char fake_wtype_w[sizeof(std::ctype<wchar_t>)]
+  typedef long fake_wtype_w[lsizeof(sizeof (std::ctype<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(std::ctype<wchar_t>))));
   fake_wtype_w ctype_w;
 
-  typedef char fake_wollate_w[sizeof(std::collate<wchar_t>)]
+  typedef long fake_wollate_w[lsizeof(sizeof (std::collate<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(std::collate<wchar_t>))));
   fake_wollate_w collate_w;
 
-  typedef char fake_numpunct_w[sizeof(numpunct<wchar_t>)]
+  typedef long fake_numpunct_w[lsizeof(sizeof (numpunct<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(numpunct<wchar_t>))));
   fake_numpunct_w numpunct_w;
 
-  typedef char fake_num_get_w[sizeof(num_get<wchar_t>)]
+  typedef long fake_num_get_w[lsizeof(sizeof (num_get<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(num_get<wchar_t>))));
   fake_num_get_w num_get_w;
 
-  typedef char fake_num_put_w[sizeof(num_put<wchar_t>)]
+  typedef long fake_num_put_w[lsizeof(sizeof (num_put<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(num_put<wchar_t>))));
   fake_num_put_w num_put_w;
 
-  typedef char fake_wodecvt_w[sizeof(codecvt<wchar_t, char, mbstate_t>)]
+  typedef long fake_wodecvt_w[lsizeof(sizeof (codecvt<wchar_t, char, mbstate_t>)) ]
   __attribute__ ((aligned(__alignof__(codecvt<wchar_t, char, mbstate_t>))));
   fake_wodecvt_w codecvt_w;
 
-  typedef char fake_moneypunct_w[sizeof(moneypunct<wchar_t, true>)]
+  typedef long fake_moneypunct_w[lsizeof(sizeof (moneypunct<wchar_t, true>)) ]
   __attribute__ ((aligned(__alignof__(moneypunct<wchar_t, true>))));
   fake_moneypunct_w moneypunct_wt;
   fake_moneypunct_w moneypunct_wf;
 
-  typedef char fake_money_get_w[sizeof(money_get<wchar_t>)]
+  typedef long fake_money_get_w[lsizeof(sizeof (money_get<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(money_get<wchar_t>))));
   fake_money_get_w money_get_w;
   
-  typedef char fake_money_put_w[sizeof(money_put<wchar_t>)]
+  typedef long fake_money_put_w[lsizeof(sizeof (money_put<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(money_put<wchar_t>))));
   fake_money_put_w money_put_w;
 
-  typedef char fake_timepunct_w[sizeof(__timepunct<wchar_t>)]
+  typedef long fake_timepunct_w[lsizeof(sizeof (__timepunct<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(__timepunct<wchar_t>))));
   fake_timepunct_w timepunct_w;
 
-  typedef char fake_time_get_w[sizeof(time_get<wchar_t>)]
+  typedef long fake_time_get_w[lsizeof(sizeof (time_get<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(time_get<wchar_t>))));
   fake_time_get_w time_get_w;
 
-  typedef char fake_time_put_w[sizeof(time_put<wchar_t>)]
+  typedef long fake_time_put_w[lsizeof(sizeof (time_put<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(time_put<wchar_t>))));
   fake_time_put_w time_put_w;
 
-  typedef char fake_messages_w[sizeof(messages<wchar_t>)]
+  typedef long fake_messages_w[lsizeof(sizeof (messages<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(messages<wchar_t>))));
   fake_messages_w messages_w;
 #endif
 
   // Storage for "C" locale caches.
-  typedef char fake_num_cache_c[sizeof(std::__numpunct_cache<char>)]
+  typedef long fake_num_cache_c[lsizeof(sizeof (std::__numpunct_cache<char>)) ]
   __attribute__ ((aligned(__alignof__(std::__numpunct_cache<char>))));
   fake_num_cache_c numpunct_cache_c;
 
-  typedef char fake_money_cache_c[sizeof(std::__moneypunct_cache<char>)]
+  typedef long fake_money_cache_c[lsizeof(sizeof (std::__moneypunct_cache<char>)) ]
   __attribute__ ((aligned(__alignof__(std::__moneypunct_cache<char>))));
   fake_money_cache_c moneypunct_cache_ct;
   fake_money_cache_c moneypunct_cache_cf;
 
-  typedef char fake_time_cache_c[sizeof(std::__timepunct_cache<char>)]
+  typedef long fake_time_cache_c[lsizeof(sizeof (std::__timepunct_cache<char>)) ]
   __attribute__ ((aligned(__alignof__(std::__timepunct_cache<char>))));
   fake_time_cache_c timepunct_cache_c;
 
 #ifdef _GLIBCXX_USE_WCHAR_T
-  typedef char fake_num_cache_w[sizeof(std::__numpunct_cache<wchar_t>)]
+  typedef long fake_num_cache_w[lsizeof(sizeof (std::__numpunct_cache<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(std::__numpunct_cache<wchar_t>))));
   fake_num_cache_w numpunct_cache_w;
 
-  typedef char fake_money_cache_w[sizeof(std::__moneypunct_cache<wchar_t>)]
+  typedef long fake_money_cache_w[lsizeof(sizeof (std::__moneypunct_cache<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(std::__moneypunct_cache<wchar_t>))));
   fake_money_cache_w moneypunct_cache_wt;
   fake_money_cache_w moneypunct_cache_wf;
 
-  typedef char fake_time_cache_w[sizeof(std::__timepunct_cache<wchar_t>)]
+  typedef long fake_time_cache_w[lsizeof(sizeof (std::__timepunct_cache<wchar_t>)) ]
   __attribute__ ((aligned(__alignof__(std::__timepunct_cache<wchar_t>))));
   fake_time_cache_w timepunct_cache_w;
 #endif






More information about the llvm-commits mailing list