svn commit: r312973 - head/sys/powerpc/include

Justin Hibbits jhibbits at freebsd.org
Mon Jan 30 15:32:25 UTC 2017


On Mon, Jan 30, 2017 at 4:53 AM, Konstantin Belousov
<kostikbel at gmail.com> wrote:
>> +#ifdef __GNUCLIKE_ASM
>> +     __asm __volatile (
>> +             "1:\tlwarx %0, 0, %3\n\t"       /* load old value */
>> +             "cmplw %4, %0\n\t"              /* compare */
>> +             "bne 2f\n\t"                    /* exit if not equal */
>> +             "stwcx. %5, 0, %3\n\t"          /* attempt to store */
>> +             "bne- 1b\n\t"                   /* spin if failed */
>> +             "li %0, 1\n\t"                  /* success - retval = 1 */
>> +             "b 3f\n\t"                      /* we've succeeded */
>> +             "2:\n\t"
>> +             "stwcx. %0, 0, %3\n\t"          /* clear reservation (74xx) */
>> +             "stwx %0, 0, %7\n\t"
>> +             "li %0, 0\n\t"                  /* failure - retval = 0 */
>> +             "3:\n\t"
>> +             : "=&r" (ret), "=m" (*p), "=m" (*cmpval)
>> +             : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval)
>> +             : "cr0", "memory");
>> +#endif
>
> It seems that in case of failed conditional store, the code retries.
> Note that this is not incorrect but also not a desirable behaviour
> with fcmpset:  the function should return error and leave the retry
> to the caller.  There is no point in having embedded loop.


More information about the svn-src-all mailing list