[Boost-bugs] [Boost C++ Libraries] #13265: boost atomic lib memory_order error

Subject: [Boost-bugs] [Boost C++ Libraries] #13265: boost atomic lib memory_order error
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-10-19 11:08:26


#13265: boost atomic lib memory_order error
------------------------------+--------------------------
 Reporter: haisql@… | Owner: timblechmann
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: atomic
  Version: Boost 1.63.0 | Severity: Showstopper
 Keywords: |
------------------------------+--------------------------
 boost atomic lib memory_order error.

 someone deleted memory_order_release/memory_order_acquire code,
 which should be translate to sfence/lfence ,
 but now you see that they were removed.

 BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT
 {
     if (order == memory_order_seq_cst)
     {
         __asm__ __volatile__
         (
 #if defined(__x86_64__) || defined(__SSE2__)
             "mfence\n"
 #else
             "lock; addl $0, (%%esp)\n"
 #endif
             ::: "memory"
         );
     }
     else if ((order & (memory_order_acquire | memory_order_release)) != 0)
     {
         __asm__ __volatile__ ("" ::: "memory");
     }
 }

 I suggest code is:

 BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT
 {
     if (order == memory_order_seq_cst)
     {
         __asm__ __volatile__
         (
 #if defined(__x86_64__) || defined(__SSE2__)
             "mfence\n"
 #else
             "lock; addl $0, (%%esp)\n"
 #endif
             ::: "memory"
         );
     return;
     }

  if ((order & (memory_order_acquire )!=0 ){
         __asm__ __volatile__
         (
 #if defined(__x86_64__) || defined(__SSE2__)
             "lfence\n"
 #else
             "lock; addl $0, (%%esp)\n"
 #endif
             ::: "memory"
    );
   return;
   }
  if ((order & (memory_order_release )!=0 ){
         __asm__ __volatile__
         (
 #if defined(__x86_64__) || defined(__SSE2__)
             "sfence\n"
 #else
             "lock; addl $0, (%%esp)\n"
 #endif
             ::: "memory"
    );
   }
 }

 Linux system do not delete lfence and sfence code, but why C++ lib
 deleted, this will cause error in multi_thread programe.

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13265>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-10-19 11:14:16 UTC