Created
January 26, 2017 07:03
-
-
Save SaitoAtsushi/cecae81c0285ffe79e2d5f954a633541 to your computer and use it in GitHub Desktop.
Patch of cyclone-bootstrap to build on msys2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Makefile b/Makefile | |
index 0d31152..d09b1df 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -6,10 +6,16 @@ | |
include Makefile.config | |
+UNAME = $(shell uname -a) | |
COBJ = scheme/base scheme/read scheme/write scheme/case-lambda scheme/char scheme/complex scheme/cxr scheme/eval scheme/file scheme/inexact scheme/lazy scheme/load scheme/process-context scheme/time scheme/cyclone/common scheme/cyclone/libraries scheme/cyclone/macros scheme/cyclone/transforms scheme/cyclone/ast scheme/cyclone/cps-optimizations scheme/cyclone/cgen scheme/cyclone/util scheme/cyclone/test scheme/cyclone/pretty-print scheme/cyclone/primitives srfi/1 srfi/2 srfi/9 srfi/18 srfi/27 srfi/69 srfi/106 srfi/111 srfi/113 srfi/117 srfi/128 srfi/132 srfi/133 | |
CFILES = $(addsuffix .c, $(COBJ)) | |
COBJECTS=$(CFILES:.c=.o) | |
+ifneq (,$(findstring MINGW32_NT, $(UNAME))) | |
+ LIBS+=-lws2_32 | |
+ CFLAGS+=-D__USE_MINGW_ANSI_STDIO=1 | |
+endif | |
+ | |
%.o: %.c %.h | |
$(CC) $(CFLAGS) $< -c -o $@ | |
diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h | |
index b40e021..24b791b 100644 | |
--- a/include/cyclone/runtime.h | |
+++ b/include/cyclone/runtime.h | |
@@ -297,7 +297,9 @@ object copy2heap(void *data, object obj); | |
void Cyc_st_add(void *data, char *frame); | |
void Cyc_st_print(void *data, FILE * out); | |
+#ifndef __MINGW32__ | |
char *_strdup(const char *s); | |
+#endif | |
object add_symbol(symbol_type * psym); | |
object add_symbol_by_name(const char *name); | |
object find_symbol_by_name(const char *name); | |
diff --git a/include/cyclone/types.h b/include/cyclone/types.h | |
index e7be94f..6d56bf3 100644 | |
--- a/include/cyclone/types.h | |
+++ b/include/cyclone/types.h | |
@@ -316,6 +316,10 @@ typedef struct { | |
} cond_var_type; | |
typedef cond_var_type *cond_var; | |
+#ifdef __MINGW32__ | |
+#define boolean cyclone_boolean | |
+#endif | |
+ | |
/* Define boolean type. */ | |
typedef struct { | |
gc_header_type hdr; | |
diff --git a/runtime.c b/runtime.c | |
index 76e6f8b..257e724 100644 | |
--- a/runtime.c | |
+++ b/runtime.c | |
@@ -350,6 +350,7 @@ void Cyc_st_print(void *data, FILE * out) | |
For now, GC of symbols is missing. long-term it probably would be desirable | |
*/ | |
+#ifndef __MINGW32__ | |
char *_strdup(const char *s) | |
{ | |
char *d = malloc(strlen(s) + 1); | |
@@ -358,6 +359,7 @@ char *_strdup(const char *s) | |
} | |
return d; | |
} | |
+#endif | |
object find_symbol_by_name(const char *name) | |
{ | |
diff --git a/srfi/106.c b/srfi/106.c | |
index 1ab2569..05850ce 100644 | |
--- a/srfi/106.c | |
+++ b/srfi/106.c | |
@@ -182,10 +182,19 @@ if (type_is_pair_prim(clo)) { \ | |
}} | |
#include <sys/types.h> | |
+#ifndef __MINGW32__ | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> | |
#include <netdb.h> | |
+#else | |
+#include <ws2tcpip.h> | |
+#include <winsock2.h> | |
+#define AI_ADDRCONFIG 0x0400 | |
+#define SHUT_RDWR 0x02 | |
+#define SHUT_WR 0x01 | |
+#define SHUT_RD 0x00 | |
+#endif | |
#include <unistd.h> | |
#include <errno.h> | |
#include "cyclone/types.h" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment