kdecore/malloc doesn't compile

Michael Matz matz at kde.org
Fri Apr 19 11:08:08 BST 2002


Hi,

On Thu, 18 Apr 2002, Malte Starostik wrote:

> ../../../../kdelibs/kdecore/malloc/malloc.c: In function `unlock':
> ../../../../kdelibs/kdecore/malloc/x86.h:40: inconsistent operand constraints
> in an `asm'
> ../../../../kdelibs/kdecore/malloc/malloc.c: At top level:
> ../../../../kdelibs/kdecore/malloc/malloc.c:4614: warning: `mSTATs' defined
> but not used
> make: *** [malloc.lo] Error 1
>
> What is this for?:
>   __asm __volatile ("" : "=m" (m->lock) : "0" (m->lock));

This is a logical memory barrier limited to one address (logical because
it's just for gcc, instead of being a real write-order ensuring
instruction).  It ensures, that nothing touching m->lock is scheduled
before the 0-setting of it.  This is a problem here, because the function
gets inlined, so possibly mixed with other instructions.  I don't remember
anymore, if a version of gcc really had problems with the above form, and
what an alternative was, but
__asm __volatile ("" : : : "memory");
is a real memory barrier (not just limited to m->lock that is).


Ciao,
Michael.





More information about the kde-core-devel mailing list