Index: src/mutex.h ================================================================== --- src/mutex.h +++ src/mutex.h @@ -18,11 +18,11 @@ #include "objfw-defs.h" #include "platform.h" #if !defined(OF_HAVE_THREADS) || \ - (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS)) + (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)) # error No mutexes available! #endif #import "macros.h" @@ -30,10 +30,13 @@ # include typedef pthread_mutex_t of_mutex_t; #elif defined(OF_WINDOWS) # include typedef CRITICAL_SECTION of_mutex_t; +#elif defined(OF_AMIGAOS) +# include +typedef struct SignalSemaphore of_mutex_t; #endif #if defined(OF_HAVE_ATOMIC_OPS) # import "atomic.h" typedef volatile int of_spinlock_t; @@ -46,13 +49,15 @@ #ifdef OF_HAVE_SCHED_YIELD # include #endif -#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(OF_WINDOWS) +#if defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) || defined(OF_WINDOWS) || \ + defined(OF_AMIGAOS) # define of_rmutex_t of_mutex_t #else +# import "tlskey.h" typedef struct { of_mutex_t mutex; of_tlskey_t count; } of_rmutex_t; #endif Index: src/mutex.m ================================================================== --- src/mutex.m +++ src/mutex.m @@ -21,13 +21,16 @@ #if defined(OF_HAVE_PTHREADS) # include "mutex_pthread.m" #elif defined(OF_WINDOWS) # include "mutex_winapi.m" +#elif defined(OF_AMIGAOS) +# include "mutex_amiga.m" #endif -#if !defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) && !defined(OF_WINDOWS) +#if !defined(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES) && !defined(OF_WINDOWS) && \ + !defined(OF_AMIGAOS) bool of_rmutex_new(of_rmutex_t *rmutex) { if (!of_mutex_new(&rmutex->mutex)) return false; ADDED src/mutex_amiga.m Index: src/mutex_amiga.m ================================================================== --- src/mutex_amiga.m +++ src/mutex_amiga.m @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, + * 2018, 2019 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include + +bool +of_mutex_new(of_mutex_t *mutex) +{ + InitSemaphore(mutex); + + return true; +} + +bool +of_mutex_lock(of_mutex_t *mutex) +{ + ObtainSemaphore(mutex); + + return true; +} + +bool +of_mutex_trylock(of_mutex_t *mutex) +{ + return AttemptSemaphore(mutex); +} + +bool +of_mutex_unlock(of_mutex_t *mutex) +{ + ReleaseSemaphore(mutex); + + return true; +} + +bool +of_mutex_free(of_mutex_t *mutex) +{ + return true; +} + +bool +of_rmutex_new(of_rmutex_t *rmutex) +{ + return of_mutex_new(rmutex); +} + +bool +of_rmutex_lock(of_rmutex_t *rmutex) +{ + return of_mutex_lock(rmutex); +} + +bool +of_rmutex_trylock(of_rmutex_t *rmutex) +{ + return of_mutex_trylock(rmutex); +} + +bool +of_rmutex_unlock(of_rmutex_t *rmutex) +{ + return of_mutex_unlock(rmutex); +} + +bool +of_rmutex_free(of_rmutex_t *rmutex) +{ + return of_mutex_free(rmutex); +}