support mingw64
diff --git a/readme.md b/readme.md
index 9b8ab74..5e217ce 100644
--- a/readme.md
+++ b/readme.md
@@ -1,5 +1,5 @@
 
-Xbyak 5.66 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
+Xbyak 5.661 ; JIT assembler for x86(IA32), x64(AMD64, x86-64) by C++
 =============
 
 Abstract
@@ -333,6 +333,7 @@
 
 History
 -------------
+* 2018/Jul/26 ver 5.661 support mingw64
 * 2018/Jul/24 ver 5.66 add CodeArray::PROTECT_RE to mode of protect()
 * 2018/Jun/26 ver 5.65 fix push(qword [mem])
 * 2018/Mar/07 ver 5.64 fix zero division in Cpu() on some cpu
diff --git a/readme.txt b/readme.txt
index 4f17d00..83038eb 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,5 +1,5 @@
 

-    C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 5.66

+    C++用x86(IA-32), x64(AMD64, x86-64) JITアセンブラ Xbyak 5.661

 

 -----------------------------------------------------------------------------

 ◎概要

@@ -343,6 +343,7 @@
 -----------------------------------------------------------------------------

 ◎履歴

 

+2018/07/26 ver 5.661 mingw64対応

 2018/07/24 ver 5.66 protect()のmodeにCodeArray::PROTECT_REを追加

 2018/06/26 ver 5.65 fix push(qword [mem])

 2018/03/07 ver 5.64 Cpu()の中でzero divisionが出ることがあるのを修正

diff --git a/sample/test0.cpp b/sample/test0.cpp
index eabd745..cd19e48 100644
--- a/sample/test0.cpp
+++ b/sample/test0.cpp
@@ -162,11 +162,14 @@
 		{
 			// use memory allocated by user
 			using namespace Xbyak;
-			const size_t codeSize = 1024;
+			const size_t codeSize = 4096;
 			uint8 buf[codeSize + 16];
 			uint8 *p = CodeArray::getAlignedAddress(buf);
 			Sample s(p, codeSize);
-			CodeArray::protect(p, codeSize, CodeArray::PROTECT_RE);
+			if (!CodeArray::protect(p, codeSize, CodeArray::PROTECT_RWE)) {
+				fprintf(stderr, "can't protect\n");
+				return 1;
+			}
 			int (*func)(int) = s.getCode<int (*)(int)>();
 			if (Xbyak::CastTo<uint8*>(func) != p) {
 				fprintf(stderr, "internal error %p %p\n", p, Xbyak::CastTo<uint8*>(func));
diff --git a/xbyak/xbyak.h b/xbyak/xbyak.h
index c33f085..aa4ce87 100644
--- a/xbyak/xbyak.h
+++ b/xbyak/xbyak.h
@@ -105,7 +105,7 @@
 
 enum {
 	DEFAULT_MAX_CODE_SIZE = 4096,
-	VERSION = 0x5660 /* 0xABCD = A.BC(D) */
+	VERSION = 0x5661 /* 0xABCD = A.BC(D) */
 };
 
 #ifndef MIE_INTEGER_TYPE_DEFINED
@@ -970,7 +970,7 @@
 	*/
 	static inline bool protect(const void *addr, size_t size, int protectMode)
 	{
-#if defined(_MSC_VER)
+#if defined(_WIN32)
 		const DWORD c_rw = PAGE_READWRITE;
 		const DWORD c_rwe = PAGE_EXECUTE_READWRITE;
 		const DWORD c_re = PAGE_EXECUTE_READ;
@@ -988,7 +988,7 @@
 		default:
 			return false;
 		}
-#if defined(_MSC_VER)
+#if defined(_WIN32)
 		DWORD oldProtect;
 		return VirtualProtect(const_cast<void*>(addr), size, mode, &oldProtect) != 0;
 #elif defined(__GNUC__)
diff --git a/xbyak/xbyak_mnemonic.h b/xbyak/xbyak_mnemonic.h
index 07dd8f3..9be9e65 100644
--- a/xbyak/xbyak_mnemonic.h
+++ b/xbyak/xbyak_mnemonic.h
@@ -1,4 +1,4 @@
-const char *getVersionString() const { return "5.66"; }
+const char *getVersionString() const { return "5.661"; }
 void adc(const Operand& op, uint32 imm) { opRM_I(op, imm, 0x10, 2); }
 void adc(const Operand& op1, const Operand& op2) { opRM_RM(op1, op2, 0x10); }
 void adcx(const Reg32e& reg, const Operand& op) { opGen(reg, op, 0xF6, 0x66, isREG32_REG32orMEM, NONE, 0x38); }