From 96dcdea7ce6a1298d7f4e9a73c04b815af3bbb85 Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Mon, 18 May 2020 11:49:48 -0700 Subject: [PATCH] Fix various issues with Windows build --- src/system4.c | 7 ++++++- src/tools/fnl/fnldump.c | 6 +++--- src/vm.c | 9 ++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/system4.c b/src/system4.c index 82a5c99..506eecc 100644 --- a/src/system4.c +++ b/src/system4.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "debugger.h" #include "file.h" @@ -206,10 +205,14 @@ static void config_init(void) mkdir_p(new_save_dir); } + +#if (!defined(_WIN32) && !defined(__WIN32__)) +#include void cleanup(possibly_unused int signal) { while (waitpid((pid_t)-1, 0, WNOHANG) > 0); } +#endif static void ain_audit(FILE *f, struct ain *ain) { @@ -320,7 +323,9 @@ int main(int argc, char *argv[]) ERROR("Not an AIN/INI file: %s", &argv[0][len - 4]); } +#if (!defined(_WIN32) && !defined(__WIN32__)) signal(SIGCHLD, cleanup); +#endif config_init(); diff --git a/src/tools/fnl/fnldump.c b/src/tools/fnl/fnldump.c index 4bd25de..0017e61 100644 --- a/src/tools/fnl/fnldump.c +++ b/src/tools/fnl/fnldump.c @@ -108,13 +108,13 @@ int main(int argc, char *argv[]) struct fnl *fnl = fnl_open(argv[0]); for (size_t font = 0; font < fnl->nr_fonts; font++) { - NOTICE("FONT %zu", font); + NOTICE("FONT %u", (unsigned)font); for (size_t face = 0; face < fnl->fonts[font].nr_faces; face++) { struct fnl_font_face *font_face = &fnl->fonts[font].faces[face]; NOTICE("\tsize %lu (%lu glyphs)", font_face->height, font_face->nr_glyphs); // create subdir - sprintf(path, "%s/font_%zu/face_%zu", output_dir, font, face); + sprintf(path, "%s/font_%u/face_%u", output_dir, (unsigned)font, (unsigned)face); mkdir_p(path); // extract glyphs @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) if (!glyph->data) continue; - sprintf(path, "%s/font_%zu/face_%zu/glyph_%zu.webp", output_dir, font, face, g); + sprintf(path, "%s/font_%u/face_%u/glyph_%u.webp", output_dir, (unsigned)font, (unsigned)face, (unsigned)g); FILE *f = fopen(path, "wb"); if (!f) { ERROR("fopen failed: %s", strerror(errno)); diff --git a/src/vm.c b/src/vm.c index 5e0b47c..f2794af 100644 --- a/src/vm.c +++ b/src/vm.c @@ -21,7 +21,6 @@ #include #include #include -#include #include // for system.MsgBox #include "debugger.h" @@ -37,6 +36,10 @@ #include "vm/heap.h" #include "vm/page.h" +#if (!defined(_WIN32) && !defined(__WIN32__)) +#include +#endif + extern char **environ; static inline int32_t lint_clamp(int64_t n) @@ -430,6 +433,9 @@ static void system_call(enum syscall_code code) break; } case SYS_OPEN_WEB: { +#if (defined(_WIN32) || defined(__WIN32__)) + WARNING("system.OpenWeb not implemented on Windows"); +#else struct string *url = stack_peek_string(0); char *browser = getenv("BROWSER"); if (!browser || !*browser) { @@ -442,6 +448,7 @@ static void system_call(enum syscall_code code) if ((err = posix_spawnp(&child, browser, NULL, NULL, argv, environ))) { WARNING("posix_spawn failed: %s", strerror(err)); } +#endif heap_unref(stack_pop().i); break; };