diff --git a/src/Makefile.mingw b/src/Makefile.mingw index 83987d9c4..20374043e 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -8,7 +8,7 @@ # # Modified Makefile for Win32 (MinGW32) environment. # -# Version: @(#)Makefile.mingw 1.0.24 2017/06/04 +# Version: @(#)Makefile.mingw 1.0.25 2017/06/04 # # Authors: Miran Grca, # Fred N. van Kempen, @@ -143,9 +143,9 @@ SYSOBJ = model.o \ scat.o \ sis496.o \ wd76c10.o \ - laserxt.o \ acer386sx.o acerm3a.o amstrad.o \ - compaq.o olivetti_m24.o jim.o ps1.o ps2.o ps2_mca.o \ + compaq.o laserxt.o jim.o \ + olivetti_m24.o ps1.o ps2.o ps2_mca.o \ tandy_eeprom.o tandy_rom.o DEVOBJ = bugger.o lpt.o serial.o \ um8669f.o pc87306.o sis85c471.o w83877f.o \ diff --git a/src/SOUND/sound.c b/src/SOUND/sound.c index 5a96ff15c..c233c0966 100644 --- a/src/SOUND/sound.c +++ b/src/SOUND/sound.c @@ -8,27 +8,28 @@ * * Sound emulation core. * - * Version: @(#)sound.c 1.0.0 2017/05/30 + * Version: @(#)sound.c 1.0.1 2017/06/04 * - * Author: Sarah Walker, + * Authors: Sarah Walker, * Miran Grca, * Copyright 2008-2017 Sarah Walker. * Copyright 2016-2017 Miran Grca. */ - #include #include #include #include "../ibm.h" #include "../device.h" #include "../timer.h" -#include "../thread.h" #include "../cdrom.h" +#include "../win/plat_thread.h" #include "sound.h" #include "snd_opl.h" #include "snd_adlib.h" #include "snd_adlibgold.h" -/* #include "snd_pas16.h" */ +#if 0 +#include "snd_pas16.h" +#endif #include "snd_sb.h" #include "snd_sb_dsp.h" #include "snd_wss.h" @@ -48,26 +49,27 @@ typedef struct static SOUND_CARD sound_cards[] = { - {"None", "none", NULL}, - {"Adlib", "adlib", &adlib_device}, - {"Adlib MCA", "adlib_mca", &adlib_mca_device}, - {"Sound Blaster 1.0", "sb", &sb_1_device}, - {"Sound Blaster 1.5", "sb1.5", &sb_15_device}, - {"Sound Blaster MCV", "sbmcv", &sb_mcv_device}, - {"Sound Blaster 2.0", "sb2.0", &sb_2_device}, - {"Sound Blaster Pro v1", "sbprov1", &sb_pro_v1_device}, - {"Sound Blaster Pro v2", "sbprov2", &sb_pro_v2_device}, - {"Sound Blaster Pro MCV", "sbpromcv", &sb_pro_mcv_device}, - {"Sound Blaster 16", "sb16", &sb_16_device}, - {"Sound Blaster AWE32", "sbawe32", &sb_awe32_device}, - {"Adlib Gold", "adlibgold", &adgold_device}, - {"Windows Sound System", "wss", &wss_device}, + { "None", "none", NULL }, + { "Adlib", "adlib", &adlib_device }, + { "Adlib MCA", "adlib_mca", &adlib_mca_device }, + { "Sound Blaster 1.0", "sb", &sb_1_device }, + { "Sound Blaster 1.5", "sb1.5", &sb_15_device }, + { "Sound Blaster MCV", "sbmcv", &sb_mcv_device }, + { "Sound Blaster 2.0", "sb2.0", &sb_2_device }, + { "Sound Blaster Pro v1", "sbprov1", &sb_pro_v1_device }, + { "Sound Blaster Pro v2", "sbprov2", &sb_pro_v2_device }, + { "Sound Blaster Pro MCV", "sbpromcv", &sb_pro_mcv_device }, + { "Sound Blaster 16", "sb16", &sb_16_device }, + { "Sound Blaster AWE32", "sbawe32", &sb_awe32_device }, + { "Adlib Gold", "adlibgold", &adgold_device }, + { "Windows Sound System", "wss", &wss_device }, #if 0 - {"Pro Audio Spectrum 16", "pas16", &pas16_device}, + { "Pro Audio Spectrum 16", "pas16", &pas16_device }, #endif - {"", "", NULL} + { "", "", NULL } }; + int sound_card_available(int card) { if (sound_cards[card].device) @@ -112,7 +114,7 @@ int sound_card_get_from_internal_name(char *s) return 0; } -void sound_card_init() +void sound_card_init(void) { if (sound_cards[sound_card_current].device) device_add(sound_cards[sound_card_current].device); @@ -235,7 +237,7 @@ static float *outbuffer_ex; static int cd_thread_enable = 0; -void sound_init() +void sound_init(void) { int i = 0; int available_cdrom_drives = 0; @@ -306,12 +308,12 @@ void sound_poll(void *priv) } } -void sound_speed_changed() +void sound_speed_changed(void) { sound_poll_latch = (int)((double)TIMER_USEC * (1000000.0 / 48000.0)); } -void sound_reset() +void sound_reset(void) { int i = 0; @@ -330,7 +332,7 @@ void sound_reset() } } -void sound_cd_thread_reset() +void sound_cd_thread_reset(void) { int i = 0; int available_cdrom_drives = 0; diff --git a/src/VIDEO/vid_ati_mach64.c b/src/VIDEO/vid_ati_mach64.c index 8668d21e7..4d530c7b9 100644 --- a/src/VIDEO/vid_ati_mach64.c +++ b/src/VIDEO/vid_ati_mach64.c @@ -8,14 +8,13 @@ * * ATi Mach64 graphics card emulation. * - * Version: @(#)vid_ati_mach64.c 1.0.0 2017/05/30 + * Version: @(#)vid_ati_mach64.c 1.0.1 2017/06/04 * - * Author: Sarah Walker, + * Authors: Sarah Walker, * Miran Grca, * Copyright 2008-2017 Sarah Walker. * Copyright 2016-2017 Miran Grca. */ - #include #include "../ibm.h" #include "../device.h" @@ -23,7 +22,7 @@ #include "../mem.h" #include "../pci.h" #include "../rom.h" -#include "../thread.h" +#include "../win/plat_thread.h" #include "video.h" #include "vid_svga.h" #include "vid_svga_render.h" diff --git a/src/VIDEO/vid_et4000w32.c b/src/VIDEO/vid_et4000w32.c index 7a4d84659..254fe8072 100644 --- a/src/VIDEO/vid_et4000w32.c +++ b/src/VIDEO/vid_et4000w32.c @@ -10,7 +10,7 @@ #include "../pci.h" #include "../rom.h" #include "../device.h" -#include "../thread.h" +#include "../win/plat_thread.h" #include "video.h" #include "vid_svga.h" #include "vid_icd2061.h" diff --git a/src/VIDEO/vid_nv_riva128.c b/src/VIDEO/vid_nv_riva128.c index d6bcd839b..c5b61a3e6 100644 --- a/src/VIDEO/vid_nv_riva128.c +++ b/src/VIDEO/vid_nv_riva128.c @@ -9,9 +9,9 @@ #include "../pci.h" #include "../pic.h" #include "../rom.h" -#include "../thread.h" #include "../timer.h" #include "../device.h" +#include "../win/plat_thread.h" #include "video.h" #include "vid_nv_riva128.h" #include "vid_svga.h" diff --git a/src/VIDEO/vid_s3.c b/src/VIDEO/vid_s3.c index c44021f04..8b762aeb9 100644 --- a/src/VIDEO/vid_s3.c +++ b/src/VIDEO/vid_s3.c @@ -9,22 +9,21 @@ * Emulation of the S3 Trio32, S3 Trio64, and S3 Vision864 * graphics cards. * - * Version: @(#)vid_s3.c 1.0.0 2017/05/30 + * Version: @(#)vid_s3.c 1.0.1 2017/06/04 * - * Author: Sarah Walker, + * Authors: Sarah Walker, * Miran Grca, * Copyright 2008-2017 Sarah Walker. * Copyright 2016-2017 Miran Grca. */ - #include #include "../ibm.h" #include "../io.h" #include "../mem.h" #include "../pci.h" #include "../rom.h" -#include "../thread.h" #include "../device.h" +#include "../win/plat_thread.h" #include "video.h" #include "vid_s3.h" #include "vid_svga.h" diff --git a/src/VIDEO/vid_s3_virge.c b/src/VIDEO/vid_s3_virge.c index 845c915d3..95f040128 100644 --- a/src/VIDEO/vid_s3_virge.c +++ b/src/VIDEO/vid_s3_virge.c @@ -9,7 +9,7 @@ #include "../pci.h" #include "../rom.h" #include "../device.h" -#include "../thread.h" +#include "../win/plat_thread.h" #include "video.h" #include "vid_s3_virge.h" #include "vid_svga.h" diff --git a/src/VIDEO/vid_tgui9440.c b/src/VIDEO/vid_tgui9440.c index e365ed4ac..d0a11d317 100644 --- a/src/VIDEO/vid_tgui9440.c +++ b/src/VIDEO/vid_tgui9440.c @@ -9,7 +9,7 @@ #include "../pci.h" #include "../rom.h" #include "../device.h" -#include "../thread.h" +#include "../win/plat_thread.h" #include "video.h" #include "vid_svga.h" #include "vid_svga_render.h" diff --git a/src/VIDEO/vid_voodoo.c b/src/VIDEO/vid_voodoo.c index 38d789a87..9b823e1a2 100644 --- a/src/VIDEO/vid_voodoo.c +++ b/src/VIDEO/vid_voodoo.c @@ -6,9 +6,9 @@ #include "../mem.h" #include "../rom.h" #include "../pci.h" -#include "../thread.h" #include "../timer.h" #include "../device.h" +#include "../win/plat_thread.h" #include "video.h" #include "vid_svga.h" #include "vid_voodoo.h" diff --git a/src/VIDEO/video.c b/src/VIDEO/video.c index 07531f033..fa541958c 100644 --- a/src/VIDEO/video.c +++ b/src/VIDEO/video.c @@ -12,8 +12,8 @@ #include "../rom.h" #include "../config.h" #include "../device.h" -#include "../thread.h" #include "../timer.h" +#include "../win/plat_thread.h" #include "video.h" #include "vid_svga.h" #ifndef __unix diff --git a/src/WIN/win.c b/src/WIN/win.c index 975aaf0c9..5a76bcc94 100644 --- a/src/WIN/win.c +++ b/src/WIN/win.c @@ -8,10 +8,11 @@ * * The Emulator's Windows core. * - * Version: @(#)win.c 1.0.1 2017/06/03 + * Version: @(#)win.c 1.0.2 2017/06/04 * * Authors: Sarah Walker, * Miran Grca, + * Fred N. van Kempen, * Copyright 2008-2017 Sarah Walker. * Copyright 2016-2017 Miran Grca. */ @@ -29,7 +30,6 @@ #include "../mem.h" #include "../rom.h" #include "../nvr.h" -#include "../thread.h" #include "../config.h" #include "../model.h" #include "../ide.h" @@ -48,6 +48,7 @@ #include "plat_iodev.h" #include "plat_mouse.h" #include "plat_midi.h" +#include "plat_thread.h" #include "win.h" #include "win_cgapal.h" diff --git a/src/cdrom_ioctl_linux.c b/src/lnx/cdrom_ioctl_linux.c similarity index 100% rename from src/cdrom_ioctl_linux.c rename to src/lnx/cdrom_ioctl_linux.c diff --git a/src/lnx/lnx_thread.c b/src/lnx/lnx_thread.c new file mode 100644 index 000000000..d9f16a0ef --- /dev/null +++ b/src/lnx/lnx_thread.c @@ -0,0 +1,108 @@ +/* Copyright holders: Sarah Walker + see COPYING for more details +*/ +#include +#include +#include +#include +#include "plat_thread.h" + + +typedef struct { + pthread_cond_t cond; + pthread_mutex_t mutex; +} event_pthread_t; + + +thread_t *thread_create(void (*thread_rout)(void *param), void *param) +{ + pthread_t *thread = malloc(sizeof(pthread_t)); + + if (thread != NULL) + pthread_create(thread, NULL, thread_rout, param); + + return(thread); +} + + +void thread_kill(thread_t *handle) +{ + pthread_t *thread = (pthread_t *)handle; + + if (thread != NULL) { + pthread_cancel(*thread); + pthread_join(*thread, NULL); + + free(thread); + } +} + + +event_t *thread_create_event(void) +{ + event_pthread_t *event = malloc(sizeof(event_pthread_t)); + + if (event != NULL) { + pthread_cond_init(&event->cond, NULL); + pthread_mutex_init(&event->mutex, NULL); + } + + return((event_t *)event); +} + + +void thread_set_event(event_t *handle) +{ + event_pthread_t *event = (event_pthread_t *)handle; + + if (event != NULL) { + pthread_mutex_lock(&event->mutex); + pthread_cond_broadcast(&event->cond); + pthread_mutex_unlock(&event->mutex); + } +} + + +void thread_reset_event(event_t *handle) +{ +} + + +int thread_wait_event(event_t *handle, int timeout) +{ + event_pthread_t *event = (event_pthread_t *)handle; + struct timespec abstime; + + clock_gettime(CLOCK_REALTIME, &abstime); + abstime.tv_nsec += (timeout % 1000) * 1000000; + abstime.tv_sec += (timeout / 1000); + if (abstime.tv_nsec > 1000000000) { + abstime.tv_nsec -= 1000000000; + abstime.tv_sec++; + } + + pthread_mutex_lock(&event->mutex); + pthread_cond_timedwait(&event->cond, &event->mutex, &abstime); + pthread_mutex_unlock(&event->mutex); + + return(0); +} + + +void thread_destroy_event(event_t *handle) +{ + event_pthread_t *event = (event_pthread_t *)handle; + + if (event != NULL) { + pthread_cond_destroy(&event->cond); + pthread_mutex_destroy(&event->mutex); + + free(event); + } +} + + +void thread_sleep(int t) +{ + usleep(t * 1000); +} diff --git a/src/lnx/plat_thread.h b/src/lnx/plat_thread.h new file mode 100644 index 000000000..dfb3a9c26 --- /dev/null +++ b/src/lnx/plat_thread.h @@ -0,0 +1,24 @@ +/* Copyright holders: Sarah Walker + see COPYING for more details +*/ +#ifndef PLAT_THREAD_H +# define PLAT_THREAD_H + + +typedef void thread_t; +typedef void event_t; + + +extern thread_t *thread_create(void (*thread_rout)(void *param), void *param); +extern void thread_kill(thread_t *handle); + +extern event_t *thread_create_event(void); +extern void thread_set_event(event_t *event); +extern void thread_reset_event(event_t *_event); +extern int thread_wait_event(event_t *event, int timeout); +extern void thread_destroy_event(event_t *_event); + +extern void thread_sleep(int t); + + +#endif /*PLAT_THREAD_H*/ diff --git a/src/net_pcap.c b/src/net_pcap.c index 3e6affcd9..8e2860be2 100644 --- a/src/net_pcap.c +++ b/src/net_pcap.c @@ -8,7 +8,7 @@ * * Handle WinPcap library processing. * - * Version: @(#)net_pcap.c 1.0.4 2017/05/23 + * Version: @(#)net_pcap.c 1.0.5 2017/06/04 * * Author: Fred N. van Kempen, */ @@ -19,10 +19,10 @@ #include #include "ibm.h" #include "config.h" -#include "thread.h" #include "device.h" #include "network.h" #include "plat_dynld.h" +#include "plat_thread.h" static void *pcap_handle; /* handle to WinPcap DLL */ diff --git a/src/net_slirp.c b/src/net_slirp.c index 4659d3d45..f49167cbd 100644 --- a/src/net_slirp.c +++ b/src/net_slirp.c @@ -21,8 +21,8 @@ #include "ibm.h" #include "config.h" #include "device.h" -#include "thread.h" #include "network.h" +#include "plat_thread.h" static queueADT slirpq; /* SLiRP library handle */ diff --git a/src/thread-pthread.c b/src/thread-pthread.c deleted file mode 100644 index dd56ef896..000000000 --- a/src/thread-pthread.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -#include -#include -#include -#include -#include "thread.h" - -typedef struct event_pthread_t -{ - pthread_cond_t cond; - pthread_mutex_t mutex; -} event_pthread_t; - -thread_t *thread_create(void (*thread_rout)(void *param), void *param) -{ - pthread_t *thread = malloc(sizeof(pthread_t)); - - pthread_create(thread, NULL, thread_rout, param); - - return thread; -} - -void thread_kill(thread_t *handle) -{ - pthread_t *thread = (pthread_t *)handle; - - pthread_cancel(*thread); - pthread_join(*thread, NULL); - - free(thread); -} - -event_t *thread_create_event() -{ - event_pthread_t *event = malloc(sizeof(event_pthread_t)); - - pthread_cond_init(&event->cond, NULL); - pthread_mutex_init(&event->mutex, NULL); - - return (event_t *)event; -} - -void thread_set_event(event_t *handle) -{ - event_pthread_t *event = (event_pthread_t *)handle; - - pthread_mutex_lock(&event->mutex); - pthread_cond_broadcast(&event->cond); - pthread_mutex_unlock(&event->mutex); -} - -void thread_reset_event(event_t *handle) -{ -} - -int thread_wait_event(event_t *handle, int timeout) -{ - event_pthread_t *event = (event_pthread_t *)handle; - struct timespec abstime; - - clock_gettime(CLOCK_REALTIME, &abstime); - abstime.tv_nsec += (timeout % 1000) * 1000000; - abstime.tv_sec += (timeout / 1000); - if (abstime.tv_nsec > 1000000000) - { - abstime.tv_nsec -= 1000000000; - abstime.tv_sec++; - } - - pthread_mutex_lock(&event->mutex); - pthread_cond_timedwait(&event->cond, &event->mutex, &abstime); - pthread_mutex_unlock(&event->mutex); - - return 0; -} - -void thread_destroy_event(event_t *handle) -{ - event_pthread_t *event = (event_pthread_t *)handle; - - pthread_cond_destroy(&event->cond); - pthread_mutex_destroy(&event->mutex); - - free(event); -} - -void thread_sleep(int t) -{ - usleep(t * 1000); -} diff --git a/src/thread.h b/src/thread.h deleted file mode 100644 index 3397760fe..000000000 --- a/src/thread.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -typedef void thread_t; -thread_t *thread_create(void (*thread_rout)(void *param), void *param); -void thread_kill(thread_t *handle); - -typedef void event_t; -event_t *thread_create_event(); -void thread_set_event(event_t *event); -void thread_reset_event(event_t *_event); -int thread_wait_event(event_t *event, int timeout); -void thread_destroy_event(event_t *_event); - -void thread_sleep(int t);