ObjFW  Diff

Differences From Artifact [cdd5b61733]:

To Artifact [acfd94987f]:


21
22
23
24
25
26
27




















28
29
30
31
32
33
34
#if defined(OF_HAVE_PTHREADS)
# include "threading_pthread.m"
#elif defined(OF_WINDOWS)
# include "threading_winapi.m"
#else
# error No threads available!
#endif





















#if !defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) && !defined(OF_WINDOWS)
bool
of_rmutex_new(of_rmutex_t *rmutex)
{
	if (!of_mutex_new(&rmutex->mutex))
		return false;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#if defined(OF_HAVE_PTHREADS)
# include "threading_pthread.m"
#elif defined(OF_WINDOWS)
# include "threading_winapi.m"
#else
# error No threads available!
#endif

#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)
# if defined(HAVE_SCHED_YIELD)
			sched_yield();
# elif defined(OF_WINDOWS)
			Sleep(0);
# else
			;
# endif
	}
}
#endif

#if !defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) && !defined(OF_WINDOWS)
bool
of_rmutex_new(of_rmutex_t *rmutex)
{
	if (!of_mutex_new(&rmutex->mutex))
		return false;