Fix logging issues.

This commit is contained in:
waltje
2017-12-10 02:53:10 -05:00
parent d52846d3be
commit c7946fbce7
18 changed files with 87 additions and 60 deletions

View File

@@ -8,7 +8,7 @@
*
* Main include file for the application.
*
* Version: @(#)86box.h 1.0.15 2017/12/03
* Version: @(#)86box.h 1.0.16 2017/12/09
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -122,8 +122,11 @@ extern int config_changed; /* config has changed */
/* Function prototypes. */
extern void pclog(const char *format, ...);
extern void fatal(const char *format, ...);
#ifdef HAVE_STDARG_H
extern void pclog_ex(const char *fmt, va_list);
#endif
extern void pclog(const char *fmt, ...);
extern void fatal(const char *fmt, ...);
extern void set_screen_size(int x, int y);
extern void set_screen_size_natural(void);
extern void pc_reload(wchar_t *fn);

View File

@@ -9,7 +9,7 @@
* Implementation of the CD-ROM drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage.
*
* Version: @(#)cdrom.c 1.0.23 2017/11/24
* Version: @(#)cdrom.c 1.0.24 2017/12/09
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../config.h"
#include "../timer.h"
@@ -723,15 +724,15 @@ int cdrom_do_log = ENABLE_CDROM_LOG;
static void
cdrom_log(const char *format, ...)
cdrom_log(const char *fmt, ...)
{
#ifdef ENABLE_CDROM_LOG
va_list ap;
if (cdrom_do_log)
{
va_start(ap, format);
pclog(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -9,7 +9,7 @@
* Implementation of the IDE emulation for hard disks and ATAPI
* CD-ROM devices.
*
* Version: @(#)hdc_ide.c 1.0.20 2017/11/24
* Version: @(#)hdc_ide.c 1.0.21 2017/12/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -26,6 +26,7 @@
#include <stdarg.h>
#include <inttypes.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../cpu/cpu.h"
#include "../machine/machine.h"
@@ -110,15 +111,15 @@ int ide_do_log = ENABLE_IDE_LOG;
#endif
static void ide_log(const char *format, ...)
static void ide_log(const char *fmt, ...)
{
#ifdef ENABLE_IDE_LOG
va_list ap;
if (ide_do_log)
{
va_start(ap, format);
pclog(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -12,7 +12,7 @@
* based design. Most cards were WD1003-WA2 or -WAH, where the
* -WA2 cards had a floppy controller as well (to save space.)
*
* Version: @(#)hdd_mfm_at.c 1.0.11 2017/11/04
* Version: @(#)hdc_mfm_at.c 1.0.12 2017/12/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Fred N. van Kempen, <decwiz@yahoo.com>

View File

@@ -8,7 +8,7 @@
*
* Handling of hard disk image files.
*
* Version: @(#)hdd_image.c 1.0.8 2017/11/24
* Version: @(#)hdd_image.c 1.0.9 2017/12/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -28,6 +28,7 @@
#include <stdarg.h>
#include <wchar.h>
#include <errno.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../plat.h"
#include "hdd.h"
@@ -55,15 +56,15 @@ int hdd_image_do_log = ENABLE_HDD_LOG;
static void
hdd_image_log(const char *format, ...)
hdd_image_log(const char *fmt, ...)
{
#ifdef ENABLE_HDD_LOG
va_list ap;
if (hdd_image_do_log)
{
va_start(ap, format);
pclog(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -9,7 +9,7 @@
* Implementation of the NEC uPD-765 and compatible floppy disk
* controller.
*
* Version: @(#)fdc.c 1.0.10 2017/12/08
* Version: @(#)fdc.c 1.0.11 2017/12/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -22,6 +22,7 @@
#include <string.h>
#include <stdarg.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../cpu/cpu.h"
#include "../machine/machine.h"
@@ -181,7 +182,7 @@ fdc_log(const char *fmt, ...)
if (fdc_do_log)
{
va_start(ap, fmt);
pclog(fmt, ap);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -10,7 +10,7 @@
* data in the form of FM/MFM-encoded transitions) which also
* forms the core of the emulator's floppy disk emulation.
*
* Version: @(#)floppy_86f.c 1.0.12 2017/11/24
* Version: @(#)floppy_86f.c 1.0.13 2017/12/09
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2016,2017 Miran Grca.
@@ -23,6 +23,7 @@
#include <assert.h>
#include <wchar.h>
#include "../lzf/lzf.h"
#define HAVE_STDARG_H
#include "../86box.h"
#include "../config.h"
#include "../dma.h"
@@ -246,15 +247,15 @@ int d86f_do_log = ENABLE_D86F_LOG;
static void
d86f_log(const char *format, ...)
d86f_log(const char *fmt, ...)
{
#ifdef ENABLE_D86F_LOG
va_list ap;
if (d86f_do_log)
{
va_start(ap, format);
pclog(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -10,7 +10,7 @@
*
* NOTE: The file will also implement an NE1000 for 8-bit ISA systems.
*
* Version: @(#)net_ne2000.c 1.0.24 2017/11/24
* Version: @(#)net_ne2000.c 1.0.25 2017/12/09
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Peter Grehan, grehan@iprg.nokia.com>
@@ -28,6 +28,7 @@
#include <stdarg.h>
#include <wchar.h>
#include <time.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../config.h"
#include "../machine/machine.h"
@@ -202,7 +203,7 @@ typedef struct {
int board;
int is_pci;
char name[32];
const char *name;
uint32_t base_address;
int base_irq;
uint32_t bios_addr,
@@ -232,7 +233,7 @@ nelog(int lvl, const char *fmt, ...)
if (nic_do_log >= lvl) {
va_start(ap, fmt);
pclog(fmt, ap);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif
@@ -1896,12 +1897,12 @@ nic_init(device_t *info)
dev = malloc(sizeof(nic_t));
memset(dev, 0x00, sizeof(nic_t));
dev->name = info->name;
dev->board = info->local;
rom = NULL;
switch(dev->board) {
#if defined(DEV_BRANCH) && defined(USE_NE1000)
case NE2K_NE1000:
strcpy(dev->name, "NE1000");
dev->maclocal[0] = 0x00; /* 00:00:D8 (NE1000 ISA OID) */
dev->maclocal[1] = 0x00;
dev->maclocal[2] = 0xD8;
@@ -1910,7 +1911,6 @@ nic_init(device_t *info)
#endif
case NE2K_NE2000:
strcpy(dev->name, "NE2000");
dev->maclocal[0] = 0x00; /* 00:A0:0C (NE2000 compatible OID) */
dev->maclocal[1] = 0xA0;
dev->maclocal[2] = 0x0C;
@@ -1919,7 +1919,6 @@ nic_init(device_t *info)
case NE2K_RTL8029AS:
dev->is_pci = (PCI) ? 1 : 0;
strcpy(dev->name, "RTL8029AS");
dev->maclocal[0] = 0x00; /* 00:20:18 (RTL 8029AS PCI OID) */
dev->maclocal[1] = 0x20;
dev->maclocal[2] = 0x18;

View File

@@ -25,6 +25,7 @@
#include <stdarg.h>
#include <time.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "86box.h"
#include "config.h"
#include "cpu/cpu.h"
@@ -172,15 +173,12 @@ static int unscaled_size_x = SCREEN_RES_X, /* current unscaled size X */
* being logged, and catch repeating entries.
*/
void
pclog(const char *fmt, ...)
pclog_ex(const char *fmt, va_list ap)
{
#ifndef RELEASE_BUILD
static char buff[1024];
static int seen = 0;
char temp[1024];
va_list ap;
va_start(ap, fmt);
if (stdlog == NULL) {
if (log_path[0] != L'\0') {
@@ -204,12 +202,25 @@ pclog(const char *fmt, ...)
fprintf(stdlog, temp, ap);
}
va_end(ap);
fflush(stdlog);
#endif
}
/* Log something. We only do this in non-release builds. */
void
pclog(const char *fmt, ...)
{
#ifndef RELEASE_BUILD
va_list ap;
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
#endif
}
/* Log a fatal error, and display a UI message before exiting. */
void
fatal(const char *fmt, ...)

View File

@@ -3,6 +3,7 @@
#include <string.h>
#include <stdarg.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "86box.h"
#include "machine/machine.h"
#include "cpu/cpu.h"
@@ -60,15 +61,15 @@ int pci_do_log = ENABLE_PCI_LOG;
static void
pcilog(const char *format, ...)
pcilog(const char *fmt, ...)
{
#ifdef ENABLE_PCI_LOG
va_list ap;
if (pci_do_log)
{
va_start(ap, format);
pclog(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -10,7 +10,7 @@
* made by Adaptec, Inc. These controllers were designed for
* the ISA bus.
*
* Version: @(#)scsi_aha154x.c 1.0.35 2017/11/24
* Version: @(#)scsi_aha154x.c 1.0.36 2017/12/09
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Original Buslogic version by SA1988 and Miran Grca.
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../io.h"
#include "../mca.h"
@@ -91,7 +92,7 @@ aha_log(const char *fmt, ...)
if (aha_do_log) {
va_start(ap, fmt);
pclog(fmt, ap);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -8,7 +8,7 @@
*
* The generic SCSI bus operations handler.
*
* Version: @(#)scsi_bus.c 1.0.4 2017/11/24
* Version: @(#)scsi_bus.c 1.0.5 2017/12/09
*
* NOTES: For now ported from PCem with some modifications
* but at least it's a start.
@@ -21,6 +21,7 @@
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "scsi.h"
#include "scsi_device.h"
@@ -44,14 +45,14 @@ int scsi_bus_do_log = ENABLE_SCSI_BUS_LOG;
static void
scsi_bus_log(const char *format, ...)
scsi_bus_log(const char *fmt, ...)
{
#ifdef ENABLE_SCSI_BUS_LOG
va_list ap;
if (scsi_bus_do_log) {
va_start(ap, format);
pclog(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -11,7 +11,7 @@
* 1 - BT-545S ISA;
* 2 - BT-958D PCI
*
* Version: @(#)scsi_buslogic.c 1.0.29 2017/11/24
* Version: @(#)scsi_buslogic.c 1.0.30 2017/12/09
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../io.h"
#include "../mca.h"
@@ -243,14 +244,14 @@ int buslogic_do_log = ENABLE_BUSLOGIC_LOG;
static void
buslogic_log(const char *format, ...)
buslogic_log(const char *fmt, ...)
{
#ifdef ENABLE_BUSLOGIC_LOG
va_list ap;
if (buslogic_do_log) {
va_start(ap, format);
pclog(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -6,7 +6,7 @@
*
* Emulation of SCSI fixed and removable disks.
*
* Version: @(#)scsi_disk.c 1.0.10 2017/11/24
* Version: @(#)scsi_disk.c 1.0.11 2017/12/09
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../timer.h"
#include "../device.h"
@@ -457,14 +458,14 @@ int scsi_hd_do_log = ENABLE_SCSI_DISK_LOG;
static void
scsi_hd_log(const char *format, ...)
scsi_hd_log(const char *fmt, ...)
{
#ifdef ENABLE_SCSI_DISK_LOG
va_list ap;
if (scsi_hd_do_log) {
va_start(ap, format);
pclog(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -9,7 +9,7 @@
* Implementation of the NCR 5380 series of SCSI Host Adapters
* made by NCR. These controllers were designed for the ISA bus.
*
* Version: @(#)scsi_ncr5380.c 1.0.7 2017/11/24
* Version: @(#)scsi_ncr5380.c 1.0.8 2017/12/09
*
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
* TheCollector1995, <mariogplayer@gmail.com>
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../io.h"
#include "../dma.h"
@@ -156,7 +157,7 @@ ncr_log(const char *fmt, ...)
if (ncr5380_do_log) {
va_start(ap, fmt);
pclog(fmt, ap);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -11,7 +11,7 @@
* series of SCSI Host Adapters made by Mylex.
* These controllers were designed for various buses.
*
* Version: @(#)scsi_x54x.c 1.0.6 2017/11/24
* Version: @(#)scsi_x54x.c 1.0.7 2017/12/09
*
* Authors: TheCollector1995, <mariogplayer@gmail.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../io.h"
#include "../dma.h"
@@ -81,7 +82,7 @@ x54x_log(const char *fmt, ...)
if (x54x_do_log) {
va_start(ap, fmt);
pclog(fmt, ap);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../device.h"
#include "../io.h"
@@ -131,14 +132,14 @@ int audiopci_do_log = ENABLE_AUDIOPCI_LOG;
static void
audiopci_log(const char *format, ...)
audiopci_log(const char *fmt, ...)
{
#ifdef ENABLE_AUDIOPCI_LOG
va_list ap;
if (audiopci_do_log) {
va_start(ap, format);
pclog(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif

View File

@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <wchar.h>
#include <math.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../device.h"
#include "../io.h"
@@ -298,14 +299,14 @@ int emu8k_do_log = ENABLE_EMU8K_LOG;
static void
emu8k_log(const char *format, ...)
emu8k_log(const char *fmt, ...)
{
#ifdef ENABLE_EMU8K_LOG
va_list ap;
if (emu8k_do_log) {
va_start(ap, format);
pclog(format, ap);
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif