[cfe-commits] [libcxx] r161497 - /libcxx/trunk/src/stdexcept.cpp

Howard Hinnant hhinnant at apple.com
Wed Aug 8 09:17:31 PDT 2012


Author: hhinnant
Date: Wed Aug  8 11:17:31 2012
New Revision: 161497

URL: http://llvm.org/viewvc/llvm-project?rev=161497&view=rev
Log:
Change size of reference count field in __libcpp_nmstr from 32 bits to 64 bits for 64 bit targets.  This is controls the data layout of all exceptions defined in <stdexcept>.  This aligns the ABI with that of gcc-4.2.

Modified:
    libcxx/trunk/src/stdexcept.cpp

Modified: libcxx/trunk/src/stdexcept.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/stdexcept.cpp?rev=161497&r1=161496&r2=161497&view=diff
==============================================================================
--- libcxx/trunk/src/stdexcept.cpp (original)
+++ libcxx/trunk/src/stdexcept.cpp Wed Aug  8 11:17:31 2012
@@ -34,7 +34,7 @@
     const char* str_;
 
     typedef std::size_t unused_t;
-    typedef std::int32_t count_t;
+    typedef std::ptrdiff_t count_t;
 
     static const std::ptrdiff_t offset = static_cast<std::ptrdiff_t>(2*sizeof(unused_t) +
                                                                        sizeof(count_t));
@@ -72,7 +72,7 @@
     const char* p = str_;
     str_ = s.str_;
     __sync_add_and_fetch(&count(), 1);
-    if (__sync_add_and_fetch((count_t*)(p-sizeof(count_t)), -1) < 0)
+    if (__sync_add_and_fetch((count_t*)(p-sizeof(count_t)), count_t(-1)) < 0)
         delete [] (p-offset);
     return *this;
 }
@@ -80,7 +80,7 @@
 inline
 __libcpp_nmstr::~__libcpp_nmstr()
 {
-    if (__sync_add_and_fetch(&count(), -1) < 0)
+    if (__sync_add_and_fetch(&count(), count_t(-1)) < 0)
         delete [] (str_ - offset);
 }
 





More information about the cfe-commits mailing list