Skip to content

Instantly share code, notes, and snippets.

@SaitoAtsushi
Created February 3, 2016 19:34
Show Gist options
  • Save SaitoAtsushi/161d3292a3d57ea18fe0 to your computer and use it in GitHub Desktop.
Save SaitoAtsushi/161d3292a3d57ea18fe0 to your computer and use it in GitHub Desktop.
MinGW32 で picrin のビルドを通すパッチ
diff --git a/contrib/10.roundtrip/emyg_atod.c b/contrib/10.roundtrip/emyg_atod.c
index f742e15..f69c50e 100644
--- a/contrib/10.roundtrip/emyg_atod.c
+++ b/contrib/10.roundtrip/emyg_atod.c
@@ -44,6 +44,10 @@
#include <ctype.h> // used by emyg_strtod
#include <math.h> // scalb()
+#ifdef __MINGW32__
+#define scalb _scalb
+#endif
+
#include "emyg_pow5.h" // in separate file to support alternate implementations, and it's big
#ifdef TESTING_QUOREM
diff --git a/contrib/30.regexp/src/regexp.c b/contrib/30.regexp/src/regexp.c
index ce54d65..d6e3a50 100644
--- a/contrib/30.regexp/src/regexp.c
+++ b/contrib/30.regexp/src/regexp.c
@@ -1,6 +1,10 @@
#include "picrin.h"
+#ifdef __MINGW32__
+#include <onigposix.h>
+#else
#include <regex.h>
+#endif
struct pic_regexp_t {
regex_t reg;
diff --git a/contrib/40.srfi/nitro.mk b/contrib/40.srfi/nitro.mk
index e68b7a2..7347af1 100644
--- a/contrib/40.srfi/nitro.mk
+++ b/contrib/40.srfi/nitro.mk
@@ -17,6 +17,12 @@ CONTRIB_SRCS += \
contrib/40.srfi/src/106.c
CONTRIB_TESTS += test-srfi
+UNAME = $(shell uname -a)
+
+ifneq (,$(findstring MINGW32, $(UNAME)))
+ LDFLAGS += -lonig /c/windows/system32/ws2_32.dll
+endif
+
test-srfi: bin/picrin
for test in `ls contrib/40.srfi/t/*.scm`; do \
$(TEST_RUNNER) "$$test"; \
diff --git a/contrib/40.srfi/src/106.c b/contrib/40.srfi/src/106.c
index c6772aa..f137110 100644
--- a/contrib/40.srfi/src/106.c
+++ b/contrib/40.srfi/src/106.c
@@ -1,12 +1,19 @@
#include "picrin.h"
#include <errno.h>
+
+#ifndef __MINGW32__
#include <netdb.h>
#include <netinet/in.h>
+#include <sys/socket.h>
+#else
+#include <winsock2.h>
+#include <Ws2tcpip.h>
+int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **);
+#endif
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
-#include <sys/socket.h>
#include <unistd.h>
#ifndef EWOULDBLOCK
@@ -101,9 +108,11 @@ pic_socket_make_socket(pic_state *pic)
result = getaddrinfo(node, service, &hints, &ai);
} while (result == EAI_AGAIN);
if (result) {
+#ifndef __MINGW32__
if (result == EAI_SYSTEM) {
pic_errorf(pic, "%s", strerror(errno));
}
+#endif
pic_errorf(pic, "%s", gai_strerror(result));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment