ObjFW  Diff

Differences From Artifact [656c95cd33]:

To Artifact [7d26f1a4ec]:

  • File src/threading.m — part of check-in [0c3e3da576] at 2016-07-30 23:29:38 on branch trunk — atomic.h: Use the OSAtomic variant without barrier

    This matches what the assembly versions does. However, the __sync_*
    versions still use the barrier, but unfortunately, no version without it
    is provided. The only way around this would be to use the new __atomic_*
    that has been added in GCC 4.7. (user: js, size: 2588) [annotate] [blame] [check-ins using]


28
29
30
31
32
33
34



35
36
37
38
39
40
41

#ifndef OF_HAVE_PTHREADS
void
of_once(of_once_t *control, void (*func)(void))
{
	if (of_atomic_int_cmpswap(control, 0, 1)) {
		func();



		of_atomic_int_inc(control);
	} else
		while (*control == 1)
			of_thread_yield();
}
#endif








>
>
>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

#ifndef OF_HAVE_PTHREADS
void
of_once(of_once_t *control, void (*func)(void))
{
	if (of_atomic_int_cmpswap(control, 0, 1)) {
		func();

		of_memory_barrier();

		of_atomic_int_inc(control);
	} else
		while (*control == 1)
			of_thread_yield();
}
#endif