[hatari-devel] Handing WinUAE CPU core write_log() |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi Thomas,
What do you think of the attached way of handling
WinUAE CPU core write_log()?
It uses C99 feature to map write_log() to Log_Printf()
instead of the bWriteLog stuff you added a while ago.
- Eero
diff -r 0b167d350b14 src/cpu/cpummu.c
--- a/src/cpu/cpummu.c Sun May 06 17:34:51 2018 +0300
+++ b/src/cpu/cpummu.c Sun May 06 18:25:05 2018 +0300
@@ -36,6 +36,7 @@
#include "newcpu.h"
#include "cpummu.h"
#include "debug.h"
+#include "log.h"
#define MMUDUMP 1
diff -r 0b167d350b14 src/cpu/cpummu030.c
--- a/src/cpu/cpummu030.c Sun May 06 17:34:51 2018 +0300
+++ b/src/cpu/cpummu030.c Sun May 06 18:25:05 2018 +0300
@@ -39,6 +39,7 @@
#include "memory.h"
#include "newcpu.h"
#include "debug.h"
+#include "log.h"
#include "cpummu030.h"
#define MMU030_OP_DBG_MSG 0
diff -r 0b167d350b14 src/cpu/fpp.c
--- a/src/cpu/fpp.c Sun May 06 17:34:51 2018 +0300
+++ b/src/cpu/fpp.c Sun May 06 18:25:05 2018 +0300
@@ -21,6 +21,7 @@
#include "sysconfig.h"
#include "sysdeps.h"
+#include "log.h"
#include "options_cpu.h"
#include "memory.h"
diff -r 0b167d350b14 src/cpu/gencpu.c
--- a/src/cpu/gencpu.c Sun May 06 17:34:51 2018 +0300
+++ b/src/cpu/gencpu.c Sun May 06 18:25:05 2018 +0300
@@ -6220,6 +6220,8 @@
return 0;
}
+#ifndef WINUAE_FOR_HATARI
void write_log (const TCHAR *format,...)
{
}
+#endif
diff -r 0b167d350b14 src/cpu/newcpu_common.c
--- a/src/cpu/newcpu_common.c Sun May 06 17:34:51 2018 +0300
+++ b/src/cpu/newcpu_common.c Sun May 06 18:25:05 2018 +0300
@@ -7,6 +7,7 @@
#include "main.h"
#include "hatari-glue.h"
+#include "log.h"
#include "options_cpu.h"
#include "memory.h"
diff -r 0b167d350b14 src/cpu/sysdeps.h
--- a/src/cpu/sysdeps.h Sun May 06 17:34:51 2018 +0300
+++ b/src/cpu/sysdeps.h Sun May 06 18:25:05 2018 +0300
@@ -276,7 +276,7 @@
/* While we're here, make abort more useful. */
#define abort() \
do { \
- write_log ("Internal error; file %s, line %d\n", __FILE__, __LINE__); \
+ fprintf (stderr, "FATAL: Internal error; file %s, line %d\n", __FILE__, __LINE__); \
(abort) (); \
} while (0)
#else
@@ -468,7 +468,10 @@
#define write_log write_log_standard
#endif
-#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 6
+#ifdef WINUAE_FOR_HATARI
+/* requires C99 (on Windows, VS Studio 2008 or newer?) */
+#define write_log(...) Log_Printf(LOG_DEBUG, __VA_ARGS__)
+#elif __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 6
extern void write_log(const TCHAR *, ...);
extern void write_logx(const TCHAR *, ...);
extern void write_log(const char *, ...) __attribute__ ((format (printf, 1, 2)));
diff -r 0b167d350b14 src/cpu/writelog.c
--- a/src/cpu/writelog.c Sun May 06 17:34:51 2018 +0300
+++ b/src/cpu/writelog.c Sun May 06 18:25:05 2018 +0300
@@ -8,6 +8,7 @@
#include "sysconfig.h"
#include "sysdeps.h"
+#ifndef WINUAE_FOR_HATARI
bool bCpuWriteLog = true;
void write_log (const char *fmt, ...)
@@ -22,6 +23,8 @@
va_end (ap);
}
+#endif
+
void f_out (void *f, const TCHAR *format, ...)
{
va_list parms;
diff -r 0b167d350b14 src/debug/log.c
--- a/src/debug/log.c Sun May 06 17:34:51 2018 +0300
+++ b/src/debug/log.c Sun May 06 18:25:05 2018 +0300
@@ -31,8 +31,6 @@
#include "vdi.h"
#include "options.h"
-extern bool bCpuWriteLog; /* Used to toggle log messages from the CPU core */
-
int ExceptionDebugMask;
typedef struct {
@@ -184,8 +182,6 @@
{
TextLogLevel = ConfigureParams.Log.nTextLogLevel;
AlertDlgLogLevel = ConfigureParams.Log.nAlertDlgLogLevel;
-
- bCpuWriteLog = (TextLogLevel == LOG_DEBUG);
}
/*-----------------------------------------------------------------------*/
diff -r 0b167d350b14 src/uae-cpu/hatari-glue.c
--- a/src/uae-cpu/hatari-glue.c Sun May 06 17:34:51 2018 +0300
+++ b/src/uae-cpu/hatari-glue.c Sun May 06 18:25:05 2018 +0300
@@ -40,20 +40,6 @@
int pendingInterrupts = 0;
-bool bCpuWriteLog = true;
-
-void write_log(const char *fmt, ...)
-{
- va_list ap;
-
- if (!bCpuWriteLog)
- return;
-
- va_start (ap, fmt);
- vfprintf (stderr, fmt, ap);
- va_end (ap);
-}
-
/**
* Reset custom chips
diff -r 0b167d350b14 src/uae-cpu/hatari-glue.h
--- a/src/uae-cpu/hatari-glue.h Sun May 06 17:34:51 2018 +0300
+++ b/src/uae-cpu/hatari-glue.h Sun May 06 18:25:05 2018 +0300
@@ -25,6 +25,7 @@
extern unsigned long OpCode_NatFeat_ID(uae_u32 opcode);
extern unsigned long OpCode_NatFeat_Call(uae_u32 opcode);
-extern void write_log(const char *fmt, ...);
+/* requires C99 (on Windows, VS Studio 2008 or newer?) */
+#define write_log(...) Log_Printf(LOG_DEBUG, __VA_ARGS__)
#endif /* HATARI_GLUE_H */
diff -r 0b167d350b14 tests/debugger/test-dummies.c
--- a/tests/debugger/test-dummies.c Sun May 06 17:34:51 2018 +0300
+++ b/tests/debugger/test-dummies.c Sun May 06 18:25:05 2018 +0300
@@ -88,7 +88,6 @@
#include "newcpu.h"
struct regstruct regs;
#if ENABLE_WINUAE_CPU
-void write_log(const char *f, ...) { }
void m68k_dumpstate(uaecptr *nextpc) { }
void m68k_dumpstate_file (FILE *f, uaecptr *n) { }
void m68k_disasm(uaecptr addr, uaecptr *nextpc, int cnt) { }