Index: src/atomic.h ================================================================== --- src/atomic.h +++ src/atomic.h @@ -66,11 +66,11 @@ return OSAtomicAdd64Barrier(i, p); # endif else abort(); #else -# error No atomic operations available! +# error of_atomic_add_int not implemented! #endif } static OF_INLINE int32_t of_atomic_add_32(volatile int32_t *p, int32_t i) @@ -90,11 +90,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_add_and_fetch(p, i); #elif defined(OF_HAVE_OSATOMIC) return OSAtomicAdd32Barrier(i, p); #else -# error No atomic operations available! +# error of_atomic_add_32 not implemented! #endif } static OF_INLINE void* of_atomic_add_ptr(void* volatile *p, intptr_t i) @@ -131,11 +131,11 @@ return (void*)OSAtomicAdd64Barrier(i, (int64_t*)p); # endif else abort(); #else -# error No atomic operations available! +# error of_atomic_add_ptr not implemented! #endif } static OF_INLINE int of_atomic_sub_int(volatile int *p, int i) @@ -177,11 +177,11 @@ return OSAtomicAdd64Barrier(-i, p); # endif else abort(); #else -# error No atomic operations available! +# error of_atomic_sub_int not implemented! #endif } static OF_INLINE int32_t of_atomic_sub_32(volatile int32_t *p, int32_t i) @@ -202,11 +202,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_sub_and_fetch(p, i); #elif defined(OF_HAVE_OSATOMIC) return OSAtomicAdd32Barrier(-i, p); #else -# error No atomic operations available! +# error of_atomic_sub_32 not implemented! #endif } static OF_INLINE void* of_atomic_sub_ptr(void* volatile *p, intptr_t i) @@ -245,11 +245,11 @@ return (void*)OSAtomicAdd64Barrier(-i, (int64_t*)p); # endif else abort(); #else -# error No atomic operations available! +# error of_atomic_sub_ptr not implemented! #endif } static OF_INLINE int of_atomic_inc_int(volatile int *p) @@ -295,11 +295,11 @@ return OSAtomicDecrement64Barrier(p); # endif else abort(); #else -# error No atomic operations available! +# error of_atomic_inc_int not implemented! #endif } static OF_INLINE int32_t of_atomic_inc_32(volatile int32_t *p) @@ -323,11 +323,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_add_and_fetch(p, 1); #elif defined(OF_HAVE_OSATOMIC) return OSAtomicIncrement32Barrier(p); #else -# error No atomic operations available! +# error of_atomic_inc_32 not implemented! #endif } static OF_INLINE int of_atomic_dec_int(volatile int *p) @@ -373,11 +373,11 @@ return OSAtomicDecrement64Barrier(p); # endif else abort(); #else -# error No atomic operations available! +# error of_atomic_dec_int not implemented! #endif } static OF_INLINE int32_t of_atomic_dec_32(volatile int32_t *p) @@ -401,11 +401,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_sub_and_fetch(p, 1); #elif defined(OF_HAVE_OSATOMIC) return OSAtomicDecrement32Barrier(p); #else -# error No atomic operations available! +# error of_atomic_dec_32 not implemented! #endif } static OF_INLINE unsigned int of_atomic_or_int(volatile unsigned int *p, unsigned int i) @@ -455,11 +455,11 @@ return OSAtomicOr64Barrier(i, p); # endif else abort(); #else -# error No atomic operations available! +# error of_atomic_or_int not implemented! #endif } static OF_INLINE uint32_t of_atomic_or_32(volatile uint32_t *p, uint32_t i) @@ -484,11 +484,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_or_and_fetch(p, i); #elif defined(OF_HAVE_OSATOMIC) return OSAtomicOr32Barrier(i, p); #else -# error No atomic operations available! +# error of_atomic_or_32 not implemented! #endif } static OF_INLINE unsigned int of_atomic_and_int(volatile unsigned int *p, unsigned int i) @@ -538,11 +538,11 @@ return OSAtomicAnd64Barrier(i, p); # endif else abort(); #else -# error No atomic operations available! +# error of_atomic_and_int not implemented! #endif } static OF_INLINE uint32_t of_atomic_and_32(volatile uint32_t *p, uint32_t i) @@ -567,11 +567,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_and_and_fetch(p, i); #elif defined(OF_HAVE_OSATOMIC) return OSAtomicAnd32Barrier(i, p); #else -# error No atomic operations available! +# error of_atomic_and_32 not implemented! #endif } static OF_INLINE unsigned int of_atomic_xor_int(volatile unsigned int *p, unsigned int i) @@ -621,11 +621,11 @@ return OSAtomicXor64Barrier(i, p); # endif else abort(); #else -# error No atomic operations available! +# error of_atomic_xor_int not implemented! #endif } static OF_INLINE uint32_t of_atomic_xor_32(volatile uint32_t *p, uint32_t i) @@ -650,11 +650,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_xor_and_fetch(p, i); #elif defined(OF_HAVE_OSATOMIC) return OSAtomicXor32Barrier(i, p); #else -# error No atomic operations available! +# error of_atomic_xor_32 not implemented! #endif } static OF_INLINE bool of_atomic_cmpswap_int(volatile int *p, int o, int n) @@ -683,11 +683,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_bool_compare_and_swap(p, o, n); #elif defined(OF_HAVE_OSATOMIC) return OSAtomicCompareAndSwapIntBarrier(o, n, p); #else -# error No atomic operations available! +# error of_atomic_cmpswap_int not implemented! #endif } static OF_INLINE bool of_atomic_cmpswap_32(volatile int32_t *p, int32_t o, int32_t n) @@ -716,11 +716,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_bool_compare_and_swap(p, o, n); #elif defined(OF_HAVE_OSATOMIC) return OSAtomicCompareAndSwap32Barrier(o, n, p); #else -# error No atomic operations available! +# error of_atomic_cmpswap_32 not implemented! #endif } static OF_INLINE bool of_atomic_cmpswap_ptr(void* volatile *p, void *o, void *n) @@ -749,11 +749,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) return __sync_bool_compare_and_swap(p, o, n); #elif defined(OF_HAVE_OSATOMIC) return OSAtomicCompareAndSwapPtrBarrier(o, n, p); #else -# error No atomic operations available! +# error of_atomic_cmpswap_ptr not implemented! #endif } static OF_INLINE void of_memory_barrier(void) @@ -766,11 +766,11 @@ #elif defined(OF_HAVE_GCC_ATOMIC_OPS) __sync_synchronize(); #elif defined(OF_HAVE_OSATOMIC) OSMemoryBarrier(); #else -# error No atomic operations available! +# error of_memory_barrier not implemented! #endif } static OF_INLINE void of_memory_read_barrier(void) Index: src/threading.h ================================================================== --- src/threading.h +++ src/threading.h @@ -15,11 +15,11 @@ */ #import "objfw-defs.h" #if !defined(OF_HAVE_THREADS) || \ - (!defined(OF_HAVE_PTHREADS) && !defined(_WIN32)) + (!defined(OF_HAVE_PTHREADS) && !defined(_WIN32)) # error No threads available! #endif #include @@ -40,10 +40,12 @@ typedef CRITICAL_SECTION of_mutex_t; typedef struct { HANDLE event; int count; } of_condition_t; +#else +# error No threads available! #endif #if defined(OF_HAVE_ATOMIC_OPS) # import "atomic.h" typedef volatile int of_spinlock_t; @@ -67,10 +69,13 @@ # define of_thread_is_current(t) pthread_equal(t, pthread_self()) # define of_thread_current pthread_self #elif defined(_WIN32) # define of_thread_is_current(t) (t == GetCurrentThread()) # define of_thread_current GetCurrentThread +#else +# error of_thread_is_current not implemented! +# error of_thread_current not implemented! #endif static OF_INLINE bool of_thread_new(of_thread_t *thread, id (*function)(id), id data) { @@ -80,10 +85,12 @@ #elif defined(_WIN32) *thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)function, (__bridge void*)data, 0, NULL); return (thread != NULL); +#else +# error of_thread_new not implemented! #endif } static OF_INLINE bool of_thread_join(of_thread_t thread) @@ -104,10 +111,12 @@ return false; CloseHandle(thread); return true; +#else +# error of_thread_join not implemented! #endif } static OF_INLINE bool of_thread_detach(of_thread_t thread) @@ -115,10 +124,12 @@ #if defined(OF_HAVE_PTHREADS) return !pthread_detach(thread); #elif defined(_WIN32) /* FIXME */ return true; +#else +# error of_thread_detach not implemented! #endif } static OF_INLINE void of_thread_exit(void) @@ -125,10 +136,12 @@ { #if defined(OF_HAVE_PTHREADS) pthread_exit(NULL); #elif defined(_WIN32) ExitThread(0); +#else +# error of_thread_exit not implemented! #endif } static OF_INLINE bool of_mutex_new(of_mutex_t *mutex) @@ -136,10 +149,12 @@ #if defined(OF_HAVE_PTHREADS) return !pthread_mutex_init(mutex, NULL); #elif defined(_WIN32) InitializeCriticalSection(mutex); return true; +#else +# error of_mutex_new not implemented! #endif } static OF_INLINE bool of_mutex_free(of_mutex_t *mutex) @@ -147,10 +162,12 @@ #if defined(OF_HAVE_PTHREADS) return !pthread_mutex_destroy(mutex); #elif defined(_WIN32) DeleteCriticalSection(mutex); return true; +#else +# error of_mutex_free not implemented! #endif } static OF_INLINE bool of_mutex_lock(of_mutex_t *mutex) @@ -158,10 +175,12 @@ #if defined(OF_HAVE_PTHREADS) return !pthread_mutex_lock(mutex); #elif defined(_WIN32) EnterCriticalSection(mutex); return true; +#else +# error of_mutex_lock not implemented! #endif } static OF_INLINE bool of_mutex_trylock(of_mutex_t *mutex) @@ -168,10 +187,12 @@ { #if defined(OF_HAVE_PTHREADS) return !pthread_mutex_trylock(mutex); #elif defined(_WIN32) return TryEnterCriticalSection(mutex); +#else +# error of_mutex_trylock not implemented! #endif } static OF_INLINE bool of_mutex_unlock(of_mutex_t *mutex) @@ -179,10 +200,12 @@ #if defined(OF_HAVE_PTHREADS) return !pthread_mutex_unlock(mutex); #elif defined(_WIN32) LeaveCriticalSection(mutex); return true; +#else +# error of_mutex_unlock not implemented! #endif } static OF_INLINE bool of_condition_new(of_condition_t *condition) @@ -194,10 +217,12 @@ if ((condition->event = CreateEvent(NULL, FALSE, 0, NULL)) == NULL) return false; return true; +#else +# error of_condition_new not implemented! #endif } static OF_INLINE bool of_condition_wait(of_condition_t *condition, of_mutex_t *mutex) @@ -219,10 +244,12 @@ if (!of_mutex_lock(mutex)) return false; return true; +#else +# error of_condition_wait not implemented! #endif } static OF_INLINE bool of_condition_timed_wait(of_condition_t *condition, of_mutex_t *mutex, @@ -251,10 +278,12 @@ if (!of_mutex_lock(mutex)) return false; return true; +#else +# error of_condition_timed_wait not implemented! #endif } static OF_INLINE bool of_condition_signal(of_condition_t *condition) @@ -261,10 +290,12 @@ { #if defined(OF_HAVE_PTHREADS) return !pthread_cond_signal(condition); #elif defined(_WIN32) return SetEvent(condition->event); +#else +# error of_condition_signal not implemented! #endif } static OF_INLINE bool of_condition_broadcast(of_condition_t *condition) @@ -277,10 +308,12 @@ for (i = 0; i < condition->count; i++) if (!SetEvent(condition->event)) return false; return true; +#else +# error of_condition_broadcast not implemented! #endif } static OF_INLINE bool of_condition_free(of_condition_t *condition) @@ -290,10 +323,12 @@ #elif defined(_WIN32) if (condition->count) return false; return CloseHandle(condition->event); +#else +# error of_condition_free not implemented! #endif } static OF_INLINE bool of_tlskey_new(of_tlskey_t *key) @@ -300,10 +335,12 @@ { #if defined(OF_HAVE_PTHREADS) return !pthread_key_create(key, NULL); #elif defined(_WIN32) return ((*key = TlsAlloc()) != TLS_OUT_OF_INDEXES); +#else +# error of_tlskey_new not implemented! #endif } static OF_INLINE void* of_tlskey_get(of_tlskey_t key) @@ -310,10 +347,12 @@ { #if defined(OF_HAVE_PTHREADS) return pthread_getspecific(key); #elif defined(_WIN32) return TlsGetValue(key); +#else +# error of_tlskey_get not implemented! #endif } static OF_INLINE bool of_tlskey_set(of_tlskey_t key, void *ptr) @@ -320,10 +359,12 @@ { #if defined(OF_HAVE_PTHREADS) return !pthread_setspecific(key, ptr); #elif defined(_WIN32) return TlsSetValue(key, ptr); +#else +# error of_tlskey_set not implemented! #endif } static OF_INLINE bool of_tlskey_free(of_tlskey_t key) @@ -330,10 +371,12 @@ { #if defined(OF_HAVE_PTHREADS) return !pthread_key_delete(key); #elif defined(_WIN32) return TlsFree(key); +#else +# error of_tlskey_free not implemented! #endif } static OF_INLINE bool of_spinlock_new(of_spinlock_t *spinlock)