Fix various issues with Windows build

This commit is contained in:
Nunuhara Cabbage
2020-05-18 11:49:48 -07:00
parent 05d998886f
commit 96dcdea7ce
3 changed files with 17 additions and 5 deletions
+6 -1
View File
@@ -21,7 +21,6 @@
#include <dirent.h>
#include <ctype.h>
#include <signal.h>
#include <sys/wait.h>
#include <getopt.h>
#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 <sys/wait.h>
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();
+3 -3
View File
@@ -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));
+8 -1
View File
@@ -21,7 +21,6 @@
#include <math.h>
#include <time.h>
#include <errno.h>
#include <spawn.h>
#include <SDL.h> // for system.MsgBox
#include "debugger.h"
@@ -37,6 +36,10 @@
#include "vm/heap.h"
#include "vm/page.h"
#if (!defined(_WIN32) && !defined(__WIN32__))
#include <spawn.h>
#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;
};