This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fwd: [cxx-mem-model] libstdc++ changes for generic atomic functions


Last of the major functionality.

This patch has some of my changes for non-integral atomic classes to utilize the new generic functions, plus bkoz's restructuring and tweaking of various bits of libstdc++ that were beyond me :-).

With this patch, lock free routines are utilized for arbitrary user classes if the size maps to a lock free supported size.
ie (excuse my crappy c++ :-)


   #include <atomic>
   #include <stdio.h>

   class andrew {
   public:
      int a;
      andrew(int i) noexcept {a = i; }
      andrew() noexcept { a = 0; }
      operator int() noexcept { return a; }
   };

std::atomic<andrew> m;

   int main()
   {
      andrew i(10);
      andrew w,z;
      m = i;
      w.a = 20;
      z = m.exchange (w.a);
      printf (" 20 20 10  : %d %d %d\n",(andrew)m, w, z);
   }

<beast:/home/amacleod>/install/cxx-checkins/bin/g++ -std=c++0x a.C

   <beast:/home/amacleod>./a.out
     20 20 10  : 20 20 10



Bootstraps on x86_64-unknown-linux-gnu with no new regressions.

Andrew

Attachment: lib.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]