From 987a926a1988ab3b63d2b9233286639642c82958 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Fri, 15 Apr 2016 12:58:36 -0700 Subject: [PATCH] Fixes to allow building for Windows. --- src/cortexm.c | 7 +++++++ src/platforms/libftdi/gdb_if.c | 7 ++++--- src/platforms/libftdi/platform.c | 1 + src/platforms/libftdi/platform.h | 4 +++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/cortexm.c b/src/cortexm.c index df1453d..599212e 100644 --- a/src/cortexm.c +++ b/src/cortexm.c @@ -38,6 +38,9 @@ #include +/* On some systems this is a macro and causes problems */ +#undef errno + static char cortexm_driver_str[] = "ARM Cortex-M"; static bool cortexm_vector_catch(target *t, int argc, char *argv[]); @@ -819,6 +822,10 @@ static bool cortexm_vector_catch(target *t, int argc, char *argv[]) return true; } +/* Windows defines this with some other meaning... */ +#ifdef SYS_OPEN +# undef SYS_OPEN +#endif /* Semihosting support */ /* ARM Semihosting syscall numbers, from ARM doc DUI0471C, Chapter 8 */ diff --git a/src/platforms/libftdi/gdb_if.c b/src/platforms/libftdi/gdb_if.c index ff49b57..e2981b2 100644 --- a/src/platforms/libftdi/gdb_if.c +++ b/src/platforms/libftdi/gdb_if.c @@ -29,6 +29,7 @@ # include # include #else +# include # include # include #endif @@ -55,7 +56,7 @@ int gdb_if_init(void) assert((gdb_if_serv = socket(PF_INET, SOCK_STREAM, 0)) != -1); opt = 1; - assert(setsockopt(gdb_if_serv, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) != -1); + assert(setsockopt(gdb_if_serv, SOL_SOCKET, SO_REUSEADDR, (void*)&opt, sizeof(opt)) != -1); assert(bind(gdb_if_serv, (void*)&addr, sizeof(addr)) != -1); assert(listen(gdb_if_serv, 1) != -1); @@ -76,7 +77,7 @@ unsigned char gdb_if_getchar(void) gdb_if_conn = accept(gdb_if_serv, NULL, NULL); DEBUG("Got connection\n"); } - i = recv(gdb_if_conn, &ret, 1, 0); + i = recv(gdb_if_conn, (void*)&ret, 1, 0); if(i <= 0) { gdb_if_conn = -1; DEBUG("Dropped broken connection\n"); @@ -111,6 +112,6 @@ void gdb_if_putchar(unsigned char c, int flush) (void)flush; if (gdb_if_conn > 0) - send(gdb_if_conn, &c, 1, 0); + send(gdb_if_conn, (void*)&c, 1, 0); } diff --git a/src/platforms/libftdi/platform.c b/src/platforms/libftdi/platform.c index 37f876b..7cb40af 100644 --- a/src/platforms/libftdi/platform.c +++ b/src/platforms/libftdi/platform.c @@ -22,6 +22,7 @@ #include "version.h" #include +#include #include struct ftdi_context *ftdic; diff --git a/src/platforms/libftdi/platform.h b/src/platforms/libftdi/platform.h index 969109c..757e3b5 100644 --- a/src/platforms/libftdi/platform.h +++ b/src/platforms/libftdi/platform.h @@ -26,7 +26,9 @@ #ifndef WIN32 # include #else -# define alloca __builtin_alloca +# ifndef alloca +# define alloca __builtin_alloca +# endif #endif #define FT2232_VID 0x0403