Use B2_mutex instead of pthread mutexes when ENABLE_EXCLUSIVE_SPCFLAGS is

set. However, this is not used at the moment. Is there an advantage? People
may want to add arch-optimized SPCFLAGS_{SET,CLEAR}.
This commit is contained in:
gbeauche 2002-09-01 16:32:02 +00:00
parent 7972082c56
commit d3bda319a8
3 changed files with 19 additions and 16 deletions

View File

@ -12,12 +12,13 @@
#include "sysdeps.h"
#include "cpu_emulation.h"
#include "main.h"
#include "video.h"
#include "m68k.h"
#include "memory.h"
#include "readcpu.h"
#include "newcpu.h"
#include "main.h"
#include "video.h"
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING

View File

@ -23,9 +23,8 @@ extern int intlev(void); // From baisilisk_glue.cpp
#include "readcpu.h"
#include "newcpu.h"
#if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS) && defined(HAVE_PTHREADS)
#include <pthread.h>
pthread_mutex_t spcflags_lock = PTHREAD_MUTEX_INITIALIZER;
#if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS)
B2_mutex *spcflags_lock = NULL;
#endif
#if ENABLE_MON
@ -265,6 +264,10 @@ void init_m68k (void)
do_merges ();
build_cpufunctbl ();
#if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS)
spcflags_lock = B2_create_mutex();
#endif
fpu_init ();
fpu_set_integral_fpu (CPUType == 4);
@ -273,6 +276,9 @@ void init_m68k (void)
void exit_m68k (void)
{
fpu_exit ();
#if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS)
B2_delete_mutex(spcflags_lock);
#endif
}
struct regstruct regs, lastint_regs;

View File

@ -61,29 +61,25 @@ enum {
__asm__ __volatile__("lock\n\tandl %1,%0" : "=m" (regs.spcflags) : "i" (~(m))); \
} while (0)
#elif defined(HAVE_PTHREADS)
#else
#undef HAVE_HARDWARE_LOCKS
#include <pthread.h>
extern pthread_mutex_t spcflags_lock;
#include "main.h"
extern B2_mutex *spcflags_lock;
#define SPCFLAGS_SET(m) do { \
pthread_mutex_lock(&spcflags_lock); \
B2_lock_mutex(spcflags_lock); \
regs.spcflags |= (m); \
pthread_mutex_unlock(&spcflags_lock); \
B2_unlock_mutex(spcflags_lock); \
} while (0)
#define SPCFLAGS_CLEAR(m) do { \
pthread_mutex_lock(&spcflags_lock); \
B2_lock_mutex(spcflags_lock); \
regs.spcflags &= ~(m); \
pthread_mutex_unlock(&spcflags_lock); \
B2_unlock_mutex(spcflags_lock); \
} while (0)
#else
#error "Can't handle spcflags atomically!"
#endif
#endif /* SPCFLAGS_H */