Add changes from Brian Johnson:

- Update MIPSpro compiler flags
- Only define static variables if they are to be used
- Try to lock the pthreads mutex prior to unlocking/destroying it
This commit is contained in:
gbeauche 2002-11-24 20:07:25 +00:00
parent 3711aa4520
commit 1477b501d1
2 changed files with 25 additions and 15 deletions

View File

@ -360,13 +360,13 @@ irix*)
LIBS="$LIBS -laudio"
WANT_ESD=no
dnl Check if our compiler supports -Ofast (MIPSPro)
HAVE_OFAST=no
dnl Check if our compiler supports -IPA (MIPSPro)
HAVE_IPA=no
ocflags="$CFLAGS"
CFLAGS=`echo $CFLAGS | sed -e 's/ -g / -Ofast /;s/^-g /-Ofast /;s/-g$/ -Ofast/;s/^-g$/-Ofast/'`
AC_MSG_CHECKING(if "-Ofast" works)
CFLAGS=`echo "$CFLAGS -IPA" | sed -e "s/-g//g"`
AC_MSG_CHECKING(if "-IPA" works)
dnl Do a test compile of an empty function
AC_TRY_COMPILE(,, [AC_MSG_RESULT(yes); HAVE_OFAST=yes], AC_MSG_RESULT(no))
AC_TRY_COMPILE(,, [AC_MSG_RESULT(yes); HAVE_IPA=yes], AC_MSG_RESULT(no))
CFLAGS="$ocflags"
;;
@ -1092,12 +1092,12 @@ if [[ "x$HAVE_GCC27" = "xyes" ]]; then
CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g//g'`
fi
dnl Or if we have -Ofast
if [[ "x$HAVE_OFAST" = "xyes" ]]; then
CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -Ofast"
CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -Ofast"
dnl Or if we have -IPA (MIPSPro compilers)
if [[ "x$HAVE_IPA" = "xyes" ]]; then
CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
CXXFLAGS="-LANG:std $CXXFLAGS"
LDFLAGS="$LDFLAGS -ipa"
LDFLAGS="$LDFLAGS -O3 -OPT:Olimit=0 -IPA"
fi
dnl Generate Makefile.

View File

@ -94,7 +94,9 @@ extern void (*flush_icache)(int); // from compemu_support.cpp
// Constants
const char ROM_FILE_NAME[] = "ROM";
#if !EMULATED_68K
const int SIG_STACK_SIZE = SIGSTKSZ; // Size of signal stack
#endif
const int SCRATCH_MEM_SIZE = 0x10000; // Size of scratch memory area
@ -123,7 +125,9 @@ Display *x_display = NULL; // X11 display handle
static uint8 last_xpram[XPRAM_SIZE]; // Buffer for monitoring XPRAM changes
#ifdef HAVE_PTHREADS
#if !EMULATED_68K
static pthread_t emul_thread; // Handle of MacOS emulation thread (main thread)
#endif
static bool xpram_thread_active = false; // Flag: XPRAM watchdog installed
static volatile bool xpram_thread_cancel = false; // Flag: Cancel XPRAM thread
@ -157,12 +161,14 @@ uint16 EmulatedSR; // Emulated bits of SR (supervisor bit and interrupt mask
uint8 *ScratchMem = NULL; // Scratch memory for Mac ROM writes
#endif
#if !defined(HAVE_PTHREADS)
static struct sigaction timer_sa; // sigaction used for timer
#if defined(HAVE_TIMER_CREATE) && defined(_POSIX_REALTIME_SIGNALS)
#define SIG_TIMER SIGRTMIN
static timer_t timer; // 60Hz timer
#endif
#endif // !HAVE_PTHREADS
#ifdef ENABLE_MON
static struct sigaction sigint_sa; // sigaction for SIGINT handler
@ -503,15 +509,15 @@ int main(int argc, char **argv)
QuitEmulator();
D(bug("Initialization complete\n"));
#if !EMULATED_68K
// (Virtual) supervisor mode, disable interrupts
EmulatedSR = 0x2700;
#ifdef HAVE_PTHREADS
// Get handle of main thread
emul_thread = pthread_self();
#endif
#if !EMULATED_68K
// (Virtual) supervisor mode, disable interrupts
EmulatedSR = 0x2700;
// Create and install stack for signal handlers
sig_stack = malloc(SIG_STACK_SIZE);
D(bug("Signal stack at %p\n", sig_stack));
@ -821,7 +827,11 @@ struct B2_mutex {
pthread_mutex_init(&m, &attr);
pthread_mutexattr_destroy(&attr);
}
~B2_mutex() { pthread_mutex_unlock(&m); pthread_mutex_destroy(&m); }
~B2_mutex() {
pthread_mutex_trylock(&m); // Make sure it's locked before
pthread_mutex_unlock(&m); // unlocking it.
pthread_mutex_destroy(&m);
}
pthread_mutex_t m;
};