Rudimentary MacOS support

This commit is contained in:
Seth Morabito 2022-09-02 14:57:50 -07:00
parent 2eed0f3623
commit b7e829d303
3 changed files with 20 additions and 6 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ lib/target
dmd5620 dmd5620
/.ccls /.ccls
/.ccls-cache /.ccls-cache
/compile_flags.txt

View File

@ -16,9 +16,14 @@ PREFIX := /usr/local
endif endif
ifdef DEBUG ifdef DEBUG
CFLAGS+ = -g -O0 CFLAGS+ = -g -O0
else else
CFLAGS += -O3 -Os -s UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
CFLAGS += -O3 -Os
else
CFLAGS += -O3 -Os -s
endif
endif endif
.PHONY: all clean .PHONY: all clean

View File

@ -33,7 +33,13 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#if defined __APPLE__
#include <util.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#else
#include <pty.h> #include <pty.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <utmp.h> #include <utmp.h>
#include <fcntl.h> #include <fcntl.h>
@ -333,8 +339,6 @@ pty_io_poll()
} }
} }
} }
} else {
fprintf(stderr, "Nothing to poll!!\n");
} }
i = 0; i = 0;
@ -442,11 +446,15 @@ tty_set_blocking(int fd, int should_block)
} }
} }
#ifdef __APPLE__
#endif
/* /*
* This is the main thread for stepping the DMD emulator. * This is the main thread for stepping the DMD emulator.
*/ */
static void * static void *
dmd_cpu_thread(void *threadid) dmd_cpu_thread(void *thread_id)
{ {
struct timespec sleep_time_req, sleep_time_rem; struct timespec sleep_time_req, sleep_time_rem;
int size; int size;
@ -795,7 +803,7 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int c, errflg = 0; int c, errflg = 0;
long thread_id = 0; pthread_t thread_id = 0;
int rs; int rs;
char *shell = NULL; char *shell = NULL;
char *device = NULL; char *device = NULL;