Re: Help! Program crashed when call the inline assembly function continuously

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

 



"spark.z" <spark.yj.zhao@xxxxxxxxx> writes:

> void pincrement(int* target)
> {
>     __asm__ __volatile__ ("pushl %eax");
>     __asm__ __volatile__ ("lock ; incl (%%eax)" ::"a"(target));
>     __asm__ __volatile__ ("popl %eax");
> }

Besides all the other answers, don't write your asm code like this.
Put all the assembler code in a single asm statement rather than using
separate asm statements.

In any case the pushl and popl appear to be unnecessary here.

Also you should look into the __sync_fetch_and_add and
__sync_add_and_fetch builtin functions.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux