On Tue, 23 Mar 2010, Mindaugas Kavaliauskas wrote:

Hi,

> >2010-03-23 15:19 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
> >  * harbour/include/hbatomic.h
> >    + added HB_SPINLOCK_TRY(l)
> >    + added support for recursive spin locks
> I'm interested why sl parameter in hb_spinlock_try_r()
> (hbatomic.h#486) is used in brackets. It's a function, it's not the
> macro define. Is it just copy-paste typo, or has some meaning?

It's not a typo. This code is correct but the redundant parenthesis
in (sl) are results of workarounds for BCC. This compiler was not
able to inline this functions:

   static _HB_INLINE_ int hb_spinlock_try_r( struct hb_spinlock_r * sl )
   {
      HB_SPINLOCK_T * l = &sl->lock;
      if( *l != HB_SPINLOCK_INIT )
      {
         if( sl->thid == HB_THREAD_SELF() )
         {
            sl->count++;
            return 1;
         }
      }
      else if( HB_SPINLOCK_TRY( l ) )
      {
         sl->thid = HB_THREAD_SELF();
         sl->count = 1;
         return 1;
      }
      return 0;
   }

and was generating warning about it. The same was with
hb_spinlock_acquire_r(). Finally I converted the second
one to macro and introduced additional variable 'r' to
pacify the warnings. Anyhow maybe I'll change it to macro
to in the future so I left parenthesis encapsulating 'sl'
parameter.
BTW what pragma allows to disable this BCC warnings?
I do not like that I have to introduce such hacks so
I'd prefer to simply disable warnings in BCC builds.

best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to