From e60af6c29d87b1cd1e58a8435d9ca97567af2912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Tue, 19 Apr 2022 23:06:39 +0200 Subject: [PATCH] Clean up plat.h a bit --- src/86box.c | 32 +++++++++-------- src/cdrom/cdrom_image.c | 3 +- src/cdrom/cdrom_image_backend.c | 5 +-- src/config.c | 9 ++--- src/disk/hdd_image.c | 9 ++--- src/disk/mo.c | 3 +- src/floppy/fdd.c | 3 +- src/floppy/fdd_img.c | 3 +- src/gdbstub.c | 1 + src/include/86box/path.h | 7 ++++ src/include/86box/plat.h | 50 -------------------------- src/include/86box/thread.h | 46 ++++++++++++++++++++++++ src/mem/rom.c | 11 +++--- src/network/net_pcap.c | 1 + src/network/net_slirp.c | 1 + src/network/network.c | 1 + src/nvr.c | 3 +- src/printer/prt_escp.c | 9 ++--- src/printer/prt_ps.c | 9 ++--- src/printer/prt_text.c | 5 +-- src/qt/qt_platform.cpp | 21 +++++------ src/sound/midi_fluidsynth.c | 1 + src/sound/midi_mt32.c | 1 + src/sound/sound.c | 1 + src/thread.cpp | 1 + src/unix/unix.c | 24 +++++++------ src/unix/unix_thread.c | 1 + src/video/vid_ati_mach64.c | 1 + src/video/vid_im1024.c | 1 + src/video/vid_mga.c | 1 + src/video/vid_pgc.c | 1 + src/video/vid_s3.c | 1 + src/video/vid_s3_virge.c | 1 + src/video/vid_voodoo.c | 1 + src/video/vid_voodoo_banshee.c | 1 + src/video/vid_voodoo_banshee_blitter.c | 1 + src/video/vid_voodoo_blitter.c | 1 + src/video/vid_voodoo_display.c | 1 + src/video/vid_voodoo_fb.c | 1 + src/video/vid_voodoo_fifo.c | 1 + src/video/vid_voodoo_reg.c | 1 + src/video/vid_voodoo_render.c | 1 + src/video/vid_voodoo_setup.c | 1 + src/video/vid_voodoo_texture.c | 1 + src/video/video.c | 6 ++-- src/win/win.c | 18 +++++----- src/win/win_icon.c | 11 +++--- src/win/win_opengl.c | 1 + src/win/win_thread.c | 1 + 49 files changed, 184 insertions(+), 131 deletions(-) create mode 100644 src/include/86box/path.h create mode 100644 src/include/86box/thread.h diff --git a/src/86box.c b/src/86box.c index 8011b7e7c..4d59d9e13 100644 --- a/src/86box.c +++ b/src/86box.c @@ -91,7 +91,9 @@ #include <86box/snd_speaker.h> #include <86box/video.h> #include <86box/ui.h> +#include <86box/path.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/version.h> #include <86box/gdbstub.h> @@ -411,14 +413,14 @@ pc_init(int argc, char *argv[]) /* Grab the executable's full path. */ plat_get_exe_name(exe_path, sizeof(exe_path)-1); - p = plat_get_filename(exe_path); + p = path_get_filename(exe_path); *p = '\0'; #if !defined(_WIN32) && !defined(__APPLE__) /* Grab the actual path if we are an AppImage. */ appimage = getenv("APPIMAGE"); if (appimage && (appimage[0] != '\0')) { - plat_get_dirname(exe_path, appimage); + path_get_dirname(exe_path, appimage); } #endif @@ -557,8 +559,8 @@ usage: if (c != argc) goto usage; - plat_path_slash(usr_path); - plat_path_slash(rom_path); + path_slash(usr_path); + path_slash(rom_path); /* * If the user provided a path for files, use that @@ -567,7 +569,7 @@ usage: * make it absolute. */ if (ppath != NULL) { - if (! plat_path_abs(ppath)) { + if (! path_abs(ppath)) { /* * This looks like a relative path. * @@ -590,11 +592,11 @@ usage: } // Add the VM-local ROM path. - plat_append_filename(temp, usr_path, "roms"); + path_append_filename(temp, usr_path, "roms"); rom_add_path(temp); // Add the standard ROM path in the same directory as the executable. - plat_append_filename(temp, exe_path, "roms"); + path_append_filename(temp, exe_path, "roms"); rom_add_path(temp); plat_init_rom_paths(); @@ -606,7 +608,7 @@ usage: * make it absolute. */ if (rpath != NULL) { - if (! plat_path_abs(rpath)) { + if (! path_abs(rpath)) { /* * This looks like a relative path. * @@ -641,7 +643,7 @@ usage: * This can happen when people load a config * file using the UI, for example. */ - p = plat_get_filename(cfg); + p = path_get_filename(cfg); if (cfg != p) { /* * OK, the configuration file name has a @@ -656,19 +658,19 @@ usage: * Otherwise, assume the pathname given is * relative to whatever the usr_path is. */ - if (plat_path_abs(cfg)) + if (path_abs(cfg)) strcpy(usr_path, cfg); else strcat(usr_path, cfg); } /* Make sure we have a trailing backslash. */ - plat_path_slash(usr_path); + path_slash(usr_path); if (rom_path[0] != '\0') - plat_path_slash(rom_path); + path_slash(rom_path); /* At this point, we can safely create the full path name. */ - plat_append_filename(cfg_path, usr_path, p); + path_append_filename(cfg_path, usr_path, p); /* * Get the current directory's name @@ -679,8 +681,8 @@ usage: */ if (strlen(vm_name) == 0) { char ltemp[1024] = { '\0'}; - plat_get_dirname(ltemp, usr_path); - strcpy(vm_name, plat_get_filename(ltemp)); + path_get_dirname(ltemp, usr_path); + strcpy(vm_name, path_get_filename(ltemp)); } /* diff --git a/src/cdrom/cdrom_image.c b/src/cdrom/cdrom_image.c index 582b0631b..9a653b310 100644 --- a/src/cdrom/cdrom_image.c +++ b/src/cdrom/cdrom_image.c @@ -26,6 +26,7 @@ #define HAVE_STDARG_H #include <86box/86box.h> #include <86box/config.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/scsi_device.h> #include <86box/cdrom_image_backend.h> @@ -286,7 +287,7 @@ cdrom_image_open(cdrom_t *dev, const char *fn) return image_open_abort(dev); /* All good, reset state. */ - if (! strcasecmp(plat_get_extension((char *) fn), "ISO")) + if (! strcasecmp(path_get_extension((char *) fn), "ISO")) dev->cd_status = CD_STATUS_DATA_ONLY; else dev->cd_status = CD_STATUS_STOPPED; diff --git a/src/cdrom/cdrom_image_backend.c b/src/cdrom/cdrom_image_backend.c index 19f790cf3..72c49304a 100644 --- a/src/cdrom/cdrom_image_backend.c +++ b/src/cdrom/cdrom_image_backend.c @@ -33,6 +33,7 @@ #include #define HAVE_STDARG_H #include <86box/86box.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/cdrom_image_backend.h> @@ -831,7 +832,7 @@ cdi_load_cue(cd_img_t *cdi, const char *cuefile) /* Get a copy of the filename into pathname, we need it later. */ memset(pathname, 0, MAX_FILENAME_LENGTH * sizeof(char)); - plat_get_dirname(pathname, cuefile); + path_get_dirname(pathname, cuefile); /* Open the file. */ fp = plat_fopen(cuefile, "r"); @@ -986,7 +987,7 @@ cdi_load_cue(cd_img_t *cdi, const char *cuefile) if (!strcmp(type, "BINARY")) { memset(temp, 0, MAX_FILENAME_LENGTH * sizeof(char)); - plat_append_filename(filename, pathname, ansi); + path_append_filename(filename, pathname, ansi); trk.file = track_file_init(filename, &error); } if (error) { diff --git a/src/config.c b/src/config.c index 27f0fb9ee..556a13b09 100644 --- a/src/config.c +++ b/src/config.c @@ -63,6 +63,7 @@ #include <86box/midi.h> #include <86box/snd_mpu401.h> #include <86box/video.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/plat_dir.h> #include <86box/ui.h> @@ -1422,12 +1423,12 @@ load_hard_disks(void) wcsncpy(hdd[c].fn, &wp[wcslen(usr_path)], sizeof_w(hdd[c].fn)); } else #endif - if (plat_path_abs(p)) { + if (path_abs(p)) { strncpy(hdd[c].fn, p, sizeof(hdd[c].fn) - 1); } else { - plat_append_filename(hdd[c].fn, usr_path, p); + path_append_filename(hdd[c].fn, usr_path, p); } - plat_path_normalize(hdd[c].fn); + path_normalize(hdd[c].fn); /* If disk is empty or invalid, mark it for deletion. */ if (! hdd_is_valid(c)) { @@ -2841,7 +2842,7 @@ save_hard_disks(void) sprintf(temp, "hdd_%02i_fn", c+1); if (hdd_is_valid(c) && (strlen(hdd[c].fn) != 0)) { - plat_path_normalize(hdd[c].fn); + path_normalize(hdd[c].fn); if (!strnicmp(hdd[c].fn, usr_path, strlen(usr_path))) config_set_string(cat, temp, &hdd[c].fn[strlen(usr_path)]); else diff --git a/src/disk/hdd_image.c b/src/disk/hdd_image.c index d0ec68fc4..eff860804 100644 --- a/src/disk/hdd_image.c +++ b/src/disk/hdd_image.c @@ -27,6 +27,7 @@ #include #define HAVE_STDARG_H #include <86box/86box.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/random.h> #include <86box/hdd.h> @@ -76,7 +77,7 @@ hdd_image_log(const char *fmt, ...) int image_is_hdi(const char *s) { - if (! strcasecmp(plat_get_extension((char *) s), "HDI")) + if (! strcasecmp(path_get_extension((char *) s), "HDI")) return 1; else return 0; @@ -90,7 +91,7 @@ image_is_hdx(const char *s, int check_signature) uint64_t filelen; uint64_t signature; - if (! strcasecmp(plat_get_extension((char *) s), "HDX")) { + if (! strcasecmp(path_get_extension((char *) s), "HDX")) { if (check_signature) { f = plat_fopen(s, "rb"); if (!f) @@ -124,7 +125,7 @@ image_is_vhd(const char *s, int check_signature) { FILE* f; - if (! strcasecmp(plat_get_extension((char *) s), "VHD")) { + if (! strcasecmp(path_get_extension((char *) s), "VHD")) { if (check_signature) { f = plat_fopen(s, "rb"); if (!f) @@ -251,7 +252,7 @@ hdd_image_load(int id) memset(empty_sector, 0, sizeof(empty_sector)); if (fn) { - plat_path_normalize(fn); + path_normalize(fn); } diff --git a/src/disk/mo.c b/src/disk/mo.c index a07349e59..d30cf9d94 100644 --- a/src/disk/mo.c +++ b/src/disk/mo.c @@ -33,6 +33,7 @@ #include <86box/device.h> #include <86box/scsi_device.h> #include <86box/nvr.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/ui.h> #include <86box/hdc.h> @@ -332,7 +333,7 @@ mo_load_abort(mo_t *dev) int image_is_mdi(const char *s) { - if (! strcasecmp(plat_get_extension((char *) s), "MDI")) + if (! strcasecmp(path_get_extension((char *) s), "MDI")) return 1; else return 0; diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index 1344c3f02..2f3dd4fc9 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -26,6 +26,7 @@ #define HAVE_STDARG_H #include <86box/86box.h> #include <86box/timer.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/ui.h> #include <86box/fdd.h> @@ -485,7 +486,7 @@ fdd_load(int drive, char *fn) if (!fn) return; - p = plat_get_extension(fn); + p = path_get_extension(fn); if (!p) return; f = plat_fopen(fn, "rb"); diff --git a/src/floppy/fdd_img.c b/src/floppy/fdd_img.c index a8704e7ff..722a25af9 100644 --- a/src/floppy/fdd_img.c +++ b/src/floppy/fdd_img.c @@ -33,6 +33,7 @@ #include <86box/86box.h> #include <86box/timer.h> #include <86box/config.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/fdd.h> #include <86box/fdd_86f.h> @@ -644,7 +645,7 @@ img_load(int drive, char *fn) int size; int i; - ext = plat_get_extension(fn); + ext = path_get_extension(fn); d86f_unregister(drive); diff --git a/src/gdbstub.c b/src/gdbstub.c index 7ce2f360f..8ef15d7c8 100644 --- a/src/gdbstub.c +++ b/src/gdbstub.c @@ -38,6 +38,7 @@ #include <86box/io.h> #include <86box/mem.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/gdbstub.h> #define FAST_RESPONSE(s) \ diff --git a/src/include/86box/path.h b/src/include/86box/path.h new file mode 100644 index 000000000..85cb0814d --- /dev/null +++ b/src/include/86box/path.h @@ -0,0 +1,7 @@ +extern void path_get_dirname(char *dest, const char *path); +extern char *path_get_filename(char *s); +extern char *path_get_extension(char *s); +extern void path_append_filename(char *dest, const char *s1, const char *s2); +extern void path_slash(char *path); +extern void path_normalize(char *path); +extern int path_abs(char *path); \ No newline at end of file diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index ad7006165..1f787da9e 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -105,15 +105,6 @@ extern int plat_chdir(char *path); extern void plat_tempfile(char *bufp, char *prefix, char *suffix); extern void plat_get_exe_name(char *s, int size); extern void plat_init_rom_paths(); -extern char *plat_get_basename(const char *path); -extern void plat_get_dirname(char *dest, const char *path); -extern char *plat_get_filename(char *s); -extern char *plat_get_extension(char *s); -extern void plat_append_filename(char *dest, const char *s1, const char *s2); -extern void plat_put_backslash(char *s); -extern void plat_path_slash(char *path); -extern void plat_path_normalize(char *path); -extern int plat_path_abs(char *path); extern int plat_dir_check(char *path); extern int plat_dir_create(char *path); extern void *plat_mmap(size_t size, uint8_t executable); @@ -169,47 +160,6 @@ extern int ioctl_open(uint8_t id, char d); extern void ioctl_reset(uint8_t id); extern void ioctl_close(uint8_t id); -#ifdef __APPLE__ -#define thread_t plat_thread_t -#define event_t plat_event_t -#define mutex_t plat_mutex_t - -#define thread_create plat_thread_create -#define thread_wait plat_thread_wait -#define thread_create_event plat_thread_create_event -#define thread_set_event plat_thread_set_event -#define thread_reset_event plat_thread_reset_event -#define thread_wait_event plat_thread_wait_event -#define thread_destroy_event plat_thread_destroy_event - -#define thread_create_mutex plat_thread_create_mutex -#define thread_create_mutex_with_spin_count plat_thread_create_mutex_with_spin_count -#define thread_close_mutex plat_thread_close_mutex -#define thread_wait_mutex plat_thread_wait_mutex -#define thread_release_mutex plat_thread_release_mutex -#endif - -/* Thread support. */ -typedef void thread_t; -typedef void event_t; -typedef void mutex_t; - -extern thread_t *thread_create(void (*thread_func)(void *param), void *param); -extern int thread_wait(thread_t *arg); -extern event_t *thread_create_event(void); -extern void thread_set_event(event_t *arg); -extern void thread_reset_event(event_t *arg); -extern int thread_wait_event(event_t *arg, int timeout); -extern void thread_destroy_event(event_t *arg); - -#define MUTEX_DEFAULT_SPIN_COUNT 1024 - -extern mutex_t *thread_create_mutex(void); -extern void thread_close_mutex(mutex_t *arg); -extern int thread_test_mutex(mutex_t *arg); -extern int thread_wait_mutex(mutex_t *arg); -extern int thread_release_mutex(mutex_t *mutex); - /* Other stuff. */ extern void startblit(void); extern void endblit(void); diff --git a/src/include/86box/thread.h b/src/include/86box/thread.h new file mode 100644 index 000000000..a34dbefb5 --- /dev/null +++ b/src/include/86box/thread.h @@ -0,0 +1,46 @@ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __APPLE__ +#define thread_t plat_thread_t +#define event_t plat_event_t +#define mutex_t plat_mutex_t + +#define thread_create plat_thread_create +#define thread_wait plat_thread_wait +#define thread_create_event plat_thread_create_event +#define thread_set_event plat_thread_set_event +#define thread_reset_event plat_thread_reset_event +#define thread_wait_event plat_thread_wait_event +#define thread_destroy_event plat_thread_destroy_event + +#define thread_create_mutex plat_thread_create_mutex +#define thread_create_mutex_with_spin_count plat_thread_create_mutex_with_spin_count +#define thread_close_mutex plat_thread_close_mutex +#define thread_wait_mutex plat_thread_wait_mutex +#define thread_release_mutex plat_thread_release_mutex +#endif + +/* Thread support. */ +typedef void thread_t; +typedef void event_t; +typedef void mutex_t; + +extern thread_t *thread_create(void (*thread_func)(void *param), void *param); +extern int thread_wait(thread_t *arg); +extern event_t *thread_create_event(void); +extern void thread_set_event(event_t *arg); +extern void thread_reset_event(event_t *arg); +extern int thread_wait_event(event_t *arg, int timeout); +extern void thread_destroy_event(event_t *arg); + +extern mutex_t *thread_create_mutex(void); +extern void thread_close_mutex(mutex_t *arg); +extern int thread_test_mutex(mutex_t *arg); +extern int thread_wait_mutex(mutex_t *arg); +extern int thread_release_mutex(mutex_t *mutex); + +#ifdef __cplusplus +} +#endif diff --git a/src/mem/rom.c b/src/mem/rom.c index 3373ca530..62b03bc11 100644 --- a/src/mem/rom.c +++ b/src/mem/rom.c @@ -33,6 +33,7 @@ #include "cpu.h" #include <86box/mem.h> #include <86box/rom.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/machine.h> #include <86box/m_xt_xi8088.h> @@ -76,16 +77,16 @@ rom_add_path(const char* path) } // Save the path, turning it into absolute if needed. - if (!plat_path_abs((char*) path)) { + if (!path_abs((char*) path)) { plat_getcwd(cwd, sizeof(cwd)); - plat_path_slash(cwd); + path_slash(cwd); snprintf(rom_path->path, sizeof(rom_path->path), "%s%s", cwd, path); } else { snprintf(rom_path->path, sizeof(rom_path->path), "%s", path); } // Ensure the path ends with a separator. - plat_path_slash(rom_path->path); + path_slash(rom_path->path); } @@ -99,7 +100,7 @@ rom_fopen(char *fn, char *mode) if (strstr(fn, "roms/") == fn) { /* Relative path */ for (rom_path = &rom_paths; rom_path != NULL; rom_path = rom_path->next) { - plat_append_filename(temp, rom_path->path, fn + 5); + path_append_filename(temp, rom_path->path, fn + 5); if ((fp = plat_fopen(temp, mode)) != NULL) { return fp; @@ -123,7 +124,7 @@ rom_getfile(char *fn, char *s, int size) if (strstr(fn, "roms/") == fn) { /* Relative path */ for (rom_path = &rom_paths; rom_path != NULL; rom_path = rom_path->next) { - plat_append_filename(temp, rom_path->path, fn + 5); + path_append_filename(temp, rom_path->path, fn + 5); if (rom_present(temp)) { strncpy(s, temp, size); diff --git a/src/network/net_pcap.c b/src/network/net_pcap.c index 52573907b..049cd661a 100644 --- a/src/network/net_pcap.c +++ b/src/network/net_pcap.c @@ -55,6 +55,7 @@ #include <86box/device.h> #include <86box/plat.h> #include <86box/plat_dynld.h> +#include <86box/thread.h> #include <86box/network.h> diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index fc4afcf78..bc7c68783 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -30,6 +30,7 @@ #include <86box/86box.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/network.h> #include <86box/machine.h> #include <86box/timer.h> diff --git a/src/network/network.c b/src/network/network.c index 8f84be44e..49915024a 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -61,6 +61,7 @@ #include <86box/device.h> #include <86box/timer.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/ui.h> #include <86box/network.h> #include <86box/net_3c503.h> diff --git a/src/nvr.c b/src/nvr.c index 7f44981c2..b73aa6fa7 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -58,6 +58,7 @@ #include <86box/machine.h> #include <86box/mem.h> #include <86box/timer.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/nvr.h> @@ -213,7 +214,7 @@ nvr_path(char *str) plat_dir_create(temp); /* Now append the actual filename. */ - plat_path_slash(temp); + path_slash(temp); strcat(temp, str); return(temp); diff --git a/src/printer/prt_escp.c b/src/printer/prt_escp.c index e5f43257c..ec07dc95f 100644 --- a/src/printer/prt_escp.c +++ b/src/printer/prt_escp.c @@ -63,6 +63,7 @@ #include <86box/mem.h> #include <86box/rom.h> #include <86box/pit.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/plat_dynld.h> #include <86box/ui.h> @@ -596,7 +597,7 @@ update_font(escp_t *dev) /* Create a full pathname for the ROM file. */ strcpy(path, dev->fontpath); - plat_path_slash(path); + path_slash(path); strcat(path, fn); escp_log("Temp file=%s\n", path); @@ -2062,14 +2063,14 @@ escp_init(void *lpt) } strcpy(dev->fontpath, exe_path); - plat_path_slash(dev->fontpath); + path_slash(dev->fontpath); strcat(dev->fontpath, "roms/printer/fonts/"); /* Create the full path for the page images. */ - plat_append_filename(dev->pagepath, usr_path, "printer"); + path_append_filename(dev->pagepath, usr_path, "printer"); if (! plat_dir_check(dev->pagepath)) plat_dir_create(dev->pagepath); - plat_path_slash(dev->pagepath); + path_slash(dev->pagepath); dev->page_width = PAGE_WIDTH; dev->page_height = PAGE_HEIGHT; diff --git a/src/printer/prt_ps.c b/src/printer/prt_ps.c index e90e19e82..231707897 100644 --- a/src/printer/prt_ps.c +++ b/src/printer/prt_ps.c @@ -27,6 +27,7 @@ #include <86box/lpt.h> #include <86box/timer.h> #include <86box/pit.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/plat_dynld.h> #include <86box/ui.h> @@ -152,7 +153,7 @@ convert_to_pdf(ps_t *dev) char input_fn[1024], output_fn[1024], *gsargv[9]; strcpy(input_fn, dev->printer_path); - plat_path_slash(input_fn); + path_slash(input_fn); strcat(input_fn, dev->filename); strcpy(output_fn, input_fn); @@ -206,7 +207,7 @@ write_buffer(ps_t *dev, bool finish) plat_tempfile(dev->filename, NULL, ".ps"); strcpy(path, dev->printer_path); - plat_path_slash(path); + path_slash(path); strcat(path, dev->filename); fp = plat_fopen(path, "a"); @@ -365,10 +366,10 @@ ps_init(void *lpt) /* Cache print folder path. */ memset(dev->printer_path, 0x00, sizeof(dev->printer_path)); - plat_append_filename(dev->printer_path, usr_path, "printer"); + path_append_filename(dev->printer_path, usr_path, "printer"); if (!plat_dir_check(dev->printer_path)) plat_dir_create(dev->printer_path); - plat_path_slash(dev->printer_path); + path_slash(dev->printer_path); timer_add(&dev->pulse_timer, pulse_timer, dev, 0); timer_add(&dev->timeout_timer, timeout_timer, dev, 0); diff --git a/src/printer/prt_text.c b/src/printer/prt_text.c index 7c791227f..c57a4fef3 100644 --- a/src/printer/prt_text.c +++ b/src/printer/prt_text.c @@ -60,6 +60,7 @@ #include <86box/device.h> #include <86box/timer.h> #include <86box/pit.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/lpt.h> #include <86box/printer.h> @@ -150,10 +151,10 @@ dump_page(prnt_t *dev) /* Create the full path for this file. */ memset(path, 0x00, sizeof(path)); - plat_append_filename(path, usr_path, "printer"); + path_append_filename(path, usr_path, "printer"); if (! plat_dir_check(path)) plat_dir_create(path); - plat_path_slash(path); + path_slash(path); strcat(path, dev->filename); /* Create the file. */ diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index 366e05970..499c6bbac 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -88,6 +88,7 @@ extern "C" { #include <86box/gameport.h> #include <86box/timer.h> #include <86box/nvr.h> +#include <86box/path.h> #include <86box/plat_dynld.h> #include <86box/mem.h> #include <86box/rom.h> @@ -140,7 +141,7 @@ void plat_get_exe_name(char *s, int size) memcpy(s, exepath_temp.data(), std::min((qsizetype)exepath_temp.size(),(qsizetype)size)); - plat_path_slash(s); + path_slash(s); } uint32_t @@ -188,14 +189,14 @@ plat_getcwd(char *bufp, int max) } void -plat_get_dirname(char *dest, const char *path) +path_get_dirname(char *dest, const char *path) { QFileInfo fi(path); CharPointer(dest, -1) = fi.dir().path().toUtf8(); } char * -plat_get_extension(char *s) +path_get_extension(char *s) { auto len = strlen(s); auto idx = QByteArray::fromRawData(s, len).lastIndexOf('.'); @@ -206,7 +207,7 @@ plat_get_extension(char *s) } char * -plat_get_filename(char *s) +path_get_filename(char *s) { #ifdef Q_OS_WINDOWS int c = strlen(s) - 1; @@ -228,7 +229,7 @@ plat_get_filename(char *s) } int -plat_path_abs(char *path) +path_abs(char *path) { #ifdef Q_OS_WINDOWS if ((path[1] == ':') || (path[0] == '\\') || (path[0] == '/')) @@ -241,7 +242,7 @@ plat_path_abs(char *path) } void -plat_path_normalize(char* path) +path_normalize(char* path) { #ifdef Q_OS_WINDOWS while (*path++ != 0) @@ -252,7 +253,7 @@ plat_path_normalize(char* path) } void -plat_path_slash(char *path) +path_slash(char *path) { auto len = strlen(path); auto separator = '/'; @@ -260,14 +261,14 @@ plat_path_slash(char *path) path[len] = separator; path[len+1] = 0; } - plat_path_normalize(path); + path_normalize(path); } void -plat_append_filename(char *dest, const char *s1, const char *s2) +path_append_filename(char *dest, const char *s1, const char *s2) { strcpy(dest, s1); - plat_path_slash(dest); + path_slash(dest); strcat(dest, s2); } diff --git a/src/sound/midi_fluidsynth.c b/src/sound/midi_fluidsynth.c index 7f3d39383..749c74b9f 100644 --- a/src/sound/midi_fluidsynth.c +++ b/src/sound/midi_fluidsynth.c @@ -15,6 +15,7 @@ # include <86box/midi.h> # include <86box/plat.h> # include <86box/plat_dynld.h> +# include <86box/thread.h> # include <86box/sound.h> # include <86box/ui.h> diff --git a/src/sound/midi_mt32.c b/src/sound/midi_mt32.c index 87255e319..bb86210f3 100644 --- a/src/sound/midi_mt32.c +++ b/src/sound/midi_mt32.c @@ -9,6 +9,7 @@ #include <86box/mem.h> #include <86box/midi.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/rom.h> #include <86box/sound.h> #include <86box/ui.h> diff --git a/src/sound/sound.c b/src/sound/sound.c index 5110b9c59..ec9e51f91 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -33,6 +33,7 @@ #include <86box/machine.h> #include <86box/midi.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/snd_ac97.h> #include <86box/snd_azt2316a.h> #include <86box/timer.h> diff --git a/src/thread.cpp b/src/thread.cpp index 1003dd871..6a7af25b8 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -3,6 +3,7 @@ #include #include <86box/plat.h> +#include <86box/thread.h> struct event_cpp11_t { diff --git a/src/unix/unix.c b/src/unix/unix.c index e4be19e05..a7ef1abe7 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -27,8 +27,10 @@ #include <86box/keyboard.h> #include <86box/mouse.h> #include <86box/config.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/plat_dynld.h> +#include <86box/thread.h> #include <86box/device.h> #include <86box/gameport.h> #include <86box/unix_sdl.h> @@ -293,24 +295,24 @@ plat_fopen64(const char *path, const char *mode) } int -plat_path_abs(char *path) +path_abs(char *path) { return path[0] == '/'; } void -plat_path_normalize(char* path) +path_normalize(char* path) { /* No-op. */ } void -plat_path_slash(char *path) +path_slash(char *path) { if ((path[strlen(path)-1] != '/')) { strcat(path, "/"); } - plat_path_normalize(path); + path_normalize(path); } void @@ -337,7 +339,7 @@ plat_get_basename(const char *path) return((char *)path); } char * -plat_get_filename(char *s) +path_get_filename(char *s) { int c = strlen(s) - 1; @@ -352,7 +354,7 @@ plat_get_filename(char *s) char * -plat_get_extension(char *s) +path_get_extension(char *s) { int c = strlen(s) - 1; @@ -370,10 +372,10 @@ plat_get_extension(char *s) void -plat_append_filename(char *dest, const char *s1, const char *s2) +path_append_filename(char *dest, const char *s1, const char *s2) { strcpy(dest, s1); - plat_path_slash(dest); + path_slash(dest); strcat(dest, s2); } @@ -485,7 +487,7 @@ ui_sb_update_text() } void -plat_get_dirname(char *dest, const char *path) +path_get_dirname(char *dest, const char *path) { int c = (int)strlen(path); char *ptr; @@ -758,7 +760,7 @@ plat_init_rom_paths() if (getenv("XDG_DATA_HOME")) { char xdg_rom_path[1024] = { 0 }; strncpy(xdg_rom_path, getenv("XDG_DATA_HOME"), 1024); - plat_path_slash(xdg_rom_path); + path_slash(xdg_rom_path); strncat(xdg_rom_path, "86Box/", 1024); if (!plat_dir_check(xdg_rom_path)) @@ -791,7 +793,7 @@ plat_init_rom_paths() while ((cur_xdg_rom_path = local_strsep(&xdg_rom_paths, ";")) != NULL) { char real_xdg_rom_path[1024] = { '\0' }; strcat(real_xdg_rom_path, cur_xdg_rom_path); - plat_path_slash(real_xdg_rom_path); + path_slash(real_xdg_rom_path); strcat(real_xdg_rom_path, "86Box/roms/"); rom_add_path(real_xdg_rom_path); } diff --git a/src/unix/unix_thread.c b/src/unix/unix_thread.c index 564b1943b..dc7625e12 100644 --- a/src/unix/unix_thread.c +++ b/src/unix/unix_thread.c @@ -5,6 +5,7 @@ #include #include <86box/86box.h> #include <86box/plat.h> +#include <86box/thread.h> typedef struct event_pthread_t diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index 3caa710e7..2fe70c322 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -31,6 +31,7 @@ #include <86box/pci.h> #include <86box/rom.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/i2c.h> #include <86box/vid_ddc.h> diff --git a/src/video/vid_im1024.c b/src/video/vid_im1024.c index 96ce1ce6a..932faecb7 100644 --- a/src/video/vid_im1024.c +++ b/src/video/vid_im1024.c @@ -62,6 +62,7 @@ #include <86box/device.h> #include <86box/pit.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_pgc.h> diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index bfb83d9c2..87ed16ba5 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -27,6 +27,7 @@ #include <86box/device.h> #include <86box/dma.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/i2c.h> #include <86box/vid_ddc.h> diff --git a/src/video/vid_pgc.c b/src/video/vid_pgc.c index 3d64b9eaf..e956cb12e 100644 --- a/src/video/vid_pgc.c +++ b/src/video/vid_pgc.c @@ -87,6 +87,7 @@ #include <86box/device.h> #include <86box/pit.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_cga.h> #include <86box/vid_pgc.h> diff --git a/src/video/vid_s3.c b/src/video/vid_s3.c index ba86de08a..406f6a20e 100644 --- a/src/video/vid_s3.c +++ b/src/video/vid_s3.c @@ -30,6 +30,7 @@ #include <86box/pci.h> #include <86box/rom.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/i2c.h> #include <86box/vid_ddc.h> diff --git a/src/video/vid_s3_virge.c b/src/video/vid_s3_virge.c index 9aa5b0973..dd1c03fa4 100644 --- a/src/video/vid_s3_virge.c +++ b/src/video/vid_s3_virge.c @@ -32,6 +32,7 @@ #include <86box/rom.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/i2c.h> #include <86box/vid_ddc.h> diff --git a/src/video/vid_voodoo.c b/src/video/vid_voodoo.c index 7631dcf8f..df3d59076 100644 --- a/src/video/vid_voodoo.c +++ b/src/video/vid_voodoo.c @@ -32,6 +32,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_voodoo_common.h> diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index 48d14a5b6..020cb65a4 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -32,6 +32,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/i2c.h> #include <86box/vid_ddc.h> diff --git a/src/video/vid_voodoo_banshee_blitter.c b/src/video/vid_voodoo_banshee_blitter.c index 4d8ba2518..4062acb3a 100644 --- a/src/video/vid_voodoo_banshee_blitter.c +++ b/src/video/vid_voodoo_banshee_blitter.c @@ -24,6 +24,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_voodoo_common.h> diff --git a/src/video/vid_voodoo_blitter.c b/src/video/vid_voodoo_blitter.c index f60ed2c0b..94fb9dfa1 100644 --- a/src/video/vid_voodoo_blitter.c +++ b/src/video/vid_voodoo_blitter.c @@ -30,6 +30,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_voodoo_common.h> diff --git a/src/video/vid_voodoo_display.c b/src/video/vid_voodoo_display.c index a52249bee..8e4e952d2 100644 --- a/src/video/vid_voodoo_display.c +++ b/src/video/vid_voodoo_display.c @@ -29,6 +29,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_voodoo_common.h> diff --git a/src/video/vid_voodoo_fb.c b/src/video/vid_voodoo_fb.c index b9ccad399..3ab482bff 100644 --- a/src/video/vid_voodoo_fb.c +++ b/src/video/vid_voodoo_fb.c @@ -29,6 +29,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_voodoo_common.h> diff --git a/src/video/vid_voodoo_fifo.c b/src/video/vid_voodoo_fifo.c index fcc87af11..013c21db3 100644 --- a/src/video/vid_voodoo_fifo.c +++ b/src/video/vid_voodoo_fifo.c @@ -29,6 +29,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_voodoo_common.h> diff --git a/src/video/vid_voodoo_reg.c b/src/video/vid_voodoo_reg.c index 796f0aac7..797fa130f 100644 --- a/src/video/vid_voodoo_reg.c +++ b/src/video/vid_voodoo_reg.c @@ -29,6 +29,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_voodoo_common.h> diff --git a/src/video/vid_voodoo_render.c b/src/video/vid_voodoo_render.c index 751c91d09..362f45abe 100644 --- a/src/video/vid_voodoo_render.c +++ b/src/video/vid_voodoo_render.c @@ -29,6 +29,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_voodoo_common.h> diff --git a/src/video/vid_voodoo_setup.c b/src/video/vid_voodoo_setup.c index e8722608f..92a984c87 100644 --- a/src/video/vid_voodoo_setup.c +++ b/src/video/vid_voodoo_setup.c @@ -29,6 +29,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_voodoo_common.h> diff --git a/src/video/vid_voodoo_texture.c b/src/video/vid_voodoo_texture.c index 80bf53d23..784ea17fe 100644 --- a/src/video/vid_voodoo_texture.c +++ b/src/video/vid_voodoo_texture.c @@ -29,6 +29,7 @@ #include <86box/timer.h> #include <86box/device.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_voodoo_common.h> diff --git a/src/video/video.c b/src/video/video.c index a950369c4..f58b29c84 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -66,7 +66,9 @@ #include <86box/rom.h> #include <86box/config.h> #include <86box/timer.h> +#include <86box/path.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/vid_svga.h> @@ -404,12 +406,12 @@ video_screenshot(uint32_t *buf, int start_x, int start_y, int row_len) memset(fn, 0, sizeof(fn)); memset(path, 0, sizeof(path)); - plat_append_filename(path, usr_path, SCREENSHOT_PATH); + path_append_filename(path, usr_path, SCREENSHOT_PATH); if (! plat_dir_check(path)) plat_dir_create(path); - plat_path_slash(path); + path_slash(path); plat_tempfile(fn, NULL, ".png"); strcat(path, fn); diff --git a/src/win/win.c b/src/win/win.c index 18f3a1697..cd938217e 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -47,8 +47,10 @@ #include <86box/video.h> #include <86box/mem.h> #include <86box/rom.h> +#include <86box/path.h> #define GLOBAL #include <86box/plat.h> +#include <86box/thread.h> #include <86box/ui.h> #ifdef USE_VNC # include <86box/vnc.h> @@ -736,14 +738,14 @@ plat_remove(char *path) } void -plat_path_normalize(char* path) +path_normalize(char* path) { /* No-op */ } /* Make sure a path ends with a trailing (back)slash. */ void -plat_path_slash(char *path) +path_slash(char *path) { if ((path[strlen(path)-1] != '\\') && (path[strlen(path)-1] != '/')) { @@ -754,7 +756,7 @@ plat_path_slash(char *path) /* Check if the given path is absolute or not. */ int -plat_path_abs(char *path) +path_abs(char *path) { if ((path[1] == ':') || (path[0] == '\\') || (path[0] == '/')) return(1); @@ -781,7 +783,7 @@ plat_get_basename(const char *path) /* Return the 'directory' element of a pathname. */ void -plat_get_dirname(char *dest, const char *path) +path_get_dirname(char *dest, const char *path) { int c = (int)strlen(path); char *ptr; @@ -804,7 +806,7 @@ plat_get_dirname(char *dest, const char *path) char * -plat_get_filename(char *s) +path_get_filename(char *s) { int c = strlen(s) - 1; @@ -819,7 +821,7 @@ plat_get_filename(char *s) char * -plat_get_extension(char *s) +path_get_extension(char *s) { int c = strlen(s) - 1; @@ -837,10 +839,10 @@ plat_get_extension(char *s) void -plat_append_filename(char *dest, const char *s1, const char *s2) +path_append_filename(char *dest, const char *s1, const char *s2) { strcpy(dest, s1); - plat_path_slash(dest); + path_slash(dest); strcat(dest, s2); } diff --git a/src/win/win_icon.c b/src/win/win_icon.c index e118276f1..c11125ecd 100644 --- a/src/win/win_icon.c +++ b/src/win/win_icon.c @@ -23,6 +23,7 @@ #include #include <86box/86box.h> #include <86box/config.h> +#include <86box/path.h> #include <86box/plat.h> #include <86box/ui.h> #include <86box/win.h> @@ -116,10 +117,10 @@ void win_get_icons_path(char* path_root) if (rom_path[0]) strcpy(roms_root, rom_path); else - plat_append_filename(roms_root, exe_path, "roms"); + path_append_filename(roms_root, exe_path, "roms"); - plat_append_filename(path_root, roms_root, "icons"); - plat_path_slash(path_root); + path_append_filename(path_root, roms_root, "icons"); + path_slash(path_root); } void win_load_icon_set() @@ -137,13 +138,13 @@ void win_load_icon_set() win_get_icons_path(path_root); strcat(path_root, icon_set); - plat_path_slash(path_root); + path_slash(path_root); int i, count = sizeof(icon_files) / sizeof(_ICON_DATA), x = win_get_system_metrics(SM_CXSMICON, dpi), y = win_get_system_metrics(SM_CYSMICON, dpi); for (i = 0; i < count; i++) { - plat_append_filename(temp, path_root, icon_files[i].filename); + path_append_filename(temp, path_root, icon_files[i].filename); mbstoc16s(wtemp, temp, strlen(temp) + 1); HICON ictemp; diff --git a/src/win/win_opengl.c b/src/win/win_opengl.c index 5670fafa2..b1dab78ca 100644 --- a/src/win/win_opengl.c +++ b/src/win/win_opengl.c @@ -54,6 +54,7 @@ typedef LONG atomic_flag; #include <86box/86box.h> #include <86box/plat.h> +#include <86box/thread.h> #include <86box/video.h> #include <86box/win.h> #include <86box/language.h> diff --git a/src/win/win_thread.c b/src/win/win_thread.c index 2bb8a6cf5..1ad0fc469 100644 --- a/src/win/win_thread.c +++ b/src/win/win_thread.c @@ -29,6 +29,7 @@ #include #include <86box/86box.h> #include <86box/plat.h> +#include <86box/thread.h> typedef struct {