@all
I wanted to make a library and found this thread, so I'm resurrecting it regarding my question(s):
The idltool writes dummy Quote:
and Quote:
function which contains embedded assembler. Personal I'm no fan of having asm code embedded in c/c++ code. So i lookup what the meaning of the asm code is.
Basically it is an atomic inc/der of the RefCount field.
So a little bit of google I found that at least gcc offers the Quote:
family of functions. So wouldn't it be possible to write the Quote:
like this in pure C:
STATIC uint32 _manager_Obtain(struct LibraryManagerInterface *Self)
{
uint32 res = atomic_fetch_add_explicit( &Self->Data.RefCount,1,memory_order_acquire );
return res;
}
which generates the following assembler code for the function:
000001fc <_manager_Obtain>:
1fc: 39 23 00 14 addi r9,r3,20
200: 7c 60 48 28 lwarx r3,0,r9
204: 39 43 00 01 addi r10,r3,1
208: 7d 40 49 2d stwcx. r10,0,r9
20c: 40 a2 ff f4 bne 200 <_manager_Obtain+0x4>
210: 4c 00 01 2c isync
214: 4e 80 00 20 blr
Which looks pretty close to the version with embedded asm code:
000001dc <_manager_Obtain>:
1dc: 39 23 00 14 addi r9,r3,20
1e0: 7c 60 48 28 lwarx r3,0,r9
1e4: 30 63 00 01 addic r3,r3,1
1e8: 7c 60 49 2d stwcx. r3,0,r9
1ec: 40 a2 ff f4 bne 1e0 <_manager_Obtain+0x4>
1f0: 4e 80 00 20 blr
Or do I miss something?