This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix libgomp semaphores
On Mon, Nov 28, 2011 at 09:23:43AM +1030, Alan Modra wrote:
> + int count = *sem;
> +
> + while ((count & 0x7fffffff) != 0)
> + {
> + int oldval = count;
> + __atomic_compare_exchange_4 (sem, &oldval, count - 1,
> + false, MEMMODEL_ACQUIRE, MEMMODEL_RELAXED);
> + if (__builtin_expect (oldval == count, 1))
> + return;
Why aren't you instead testing the return value of
__atomic_compare_exchange_4 (here and in other cases)?
Jakub