Index: src/once.h ================================================================== --- src/once.h +++ src/once.h @@ -24,11 +24,11 @@ typedef pthread_once_t of_once_t; # define OF_ONCE_INIT PTHREAD_ONCE_INIT #elif defined(OF_HAVE_ATOMIC_OPS) typedef volatile int of_once_t; # define OF_ONCE_INIT 0 -#elif !defined(OF_HAVE_THREADS) +#elif defined(OF_AMIGAOS) || !defined(OF_HAVE_THREADS) typedef int of_once_t; # define OF_ONCE_INIT 0 #endif #ifdef __cplusplus Index: src/once.m ================================================================== --- src/once.m +++ src/once.m @@ -16,10 +16,14 @@ */ #include "config.h" #import "once.h" + +#ifdef OF_AMIGAOS +# include +#endif #if defined(OF_HAVE_THREADS) && defined(OF_HAVE_ATOMIC_OPS) # import "atomic.h" # import "mutex.h" #endif @@ -42,9 +46,19 @@ of_atomic_int_inc(control); } else while (*control == 1) of_thread_yield(); +#elif defined(OF_AMIGAOS) + Forbid(); + @try { + if (*control == 0) { + *control = 1; + func(); + } + } @finally { + Permit(); + } #else # error No of_once available #endif }