octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Switch to std::atomic?


From: John W. Eaton
Subject: Re: Switch to std::atomic?
Date: Fri, 27 Sep 2019 01:59:29 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 9/26/19 4:25 PM, Dmitri A. Sergatskov wrote:

There are some errors on clang compiles, e.g.:

http://buildbot.octave.org:8010/#/builders/9/builds/1121



../src/liboctave/util/oct-atomic.c:34:3: error: address argument to
atomic operation must be a pointer to _Atomic type ('octave_idx_type
*' (aka 'long *') invalid)
   atomic_fetch_add (x, 1);
   ^                 ~
/usr/lib64/clang/8.0.0/include/stdatomic.h:146:43: note: expanded from
macro 'atomic_fetch_add'
#define atomic_fetch_add(object, operand)
__c11_atomic_fetch_add(object, operand, __ATOMIC_SEQ_CST)
                                           ^                      ~~~~~~
../src/liboctave/util/oct-atomic.c:42:3: error: address argument to
atomic operation must be a pointer to _Atomic type ('octave_idx_type
*' (aka 'long *') invalid)
   atomic_fetch_sub (x, 1);
   ^                 ~
/usr/lib64/clang/8.0.0/include/stdatomic.h:149:43: note: expanded from
macro 'atomic_fetch_sub'
#define atomic_fetch_sub(object, operand)
__c11_atomic_fetch_sub(object, operand, __ATOMIC_SEQ_CST)
                                           ^                      ~~~~~~
2 errors generated.
make[2]: *** [Makefile:16937: liboctave/util/libutil_la-oct-atomic.lo] Error 1


Dmitri.
--


Is the following change OK or is this a dangerous or invalid cast?

--- a/liboctave/util/oct-atomic.c
+++ b/liboctave/util/oct-atomic.c
@@ -31,7 +31,7 @@ along with Octave; see the file COPYING.
 octave_idx_type
 octave_atomic_increment (octave_idx_type *x)
 {
-  atomic_fetch_add (x, 1);
+  atomic_fetch_add ((_Atomic octave_idx_type *) x, 1);

   return *x;
 }
@@ -39,7 +39,7 @@ octave_atomic_increment (octave_idx_type
 octave_idx_type
 octave_atomic_decrement (octave_idx_type *x)
 {
-  atomic_fetch_sub (x, 1);
+  atomic_fetch_sub ((_Atomic octave_idx_type *) x, 1);

   return *x;
 }

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]