208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
#endif
}
static OF_INLINE BOOL
of_spinlock_trylock(of_spinlock_t *s)
{
#if defined(OF_ATOMIC_OPS)
return (of_atomic_cmpswap32(s, 0, 1) ? YES : NO);
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return (pthread_spin_trylock(s) ? NO : YES);
#else
return of_mutex_trylock(s);
#endif
}
|
|
|
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
#endif
}
static OF_INLINE BOOL
of_spinlock_trylock(of_spinlock_t *s)
{
#if defined(OF_ATOMIC_OPS)
return (of_atomic_cmpswap_32(s, 0, 1) ? YES : NO);
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return (pthread_spin_trylock(s) ? NO : YES);
#else
return of_mutex_trylock(s);
#endif
}
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
#endif
}
static OF_INLINE BOOL
of_spinlock_unlock(of_spinlock_t *s)
{
#if defined(OF_ATOMIC_OPS)
of_atomic_and32((uint32_t*)s, 0);
return YES;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return (pthread_spin_unlock(s) ? NO : YES);
#else
return of_mutex_unlock(s);
#endif
}
|
|
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
#endif
}
static OF_INLINE BOOL
of_spinlock_unlock(of_spinlock_t *s)
{
#if defined(OF_ATOMIC_OPS)
of_atomic_and_32((uint32_t*)s, 0);
return YES;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return (pthread_spin_unlock(s) ? NO : YES);
#else
return of_mutex_unlock(s);
#endif
}
|