diff -ru Math-Pari-2.0304_01080603.orig\Pari.xs Math-Pari-2.0304_01080603.new\Pari.xs
--- Math-Pari-2.0304_01080603.orig\Pari.xs	Fri Dec 11 03:18:24 2009
+++ Math-Pari-2.0304_01080603.new\Pari.xs	Wed Mar 03 12:29:27 2010
@@ -1,3 +1,9 @@
+/* we need to include windows.h quite early to avoid some macro name collisions */
+#ifdef _WIN32
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>
+#endif
+
 #  include <pari.h>
 #  include <graph/rect.h>
 #  include <language/anal.h>
diff -ru Math-Pari-2.0304_01080603.orig\patches\diff_2.1.7_mingw-w64 Math-Pari-2.0304_01080603.new\patches\diff_2.1.7_mingw-w64
--- Math-Pari-2.0304_01080603.orig\patches\diff_2.1.7_mingw-w64	Wed Mar 03 12:39:46 2010
+++ Math-Pari-2.0304_01080603.new\patches\diff_2.1.7_mingw-w64	Wed Mar 03 09:26:18 2010
@@ -0,0 +1,17 @@
+diff -ru pari-2.1.7.orig\src\gp\highlvl.c pari-2.1.7\src\gp\highlvl.c
+--- pari-2.1.7.orig\src\gp\highlvl.c Tue Apr 23 17:29:37 2002
++++ pari-2.1.7\src\gp\highlvl.c Wed Mar 03 09:21:11 2010
+@@ -18,6 +18,13 @@
+ /*        SOME GP FUNCTION THAT MAY BE USEFUL OUTSIDE OF IT        */
+ /*                                                                 */
+ /*******************************************************************/
++
++/* we need to include windows.h quite early to avoid some macro name collisions */
++#ifdef _WIN32
++#  define WIN32_LEAN_AND_MEAN
++#  include <windows.h>
++#endif
++
+ #include "pari.h"
+ #ifdef macintosh
+ #  include "rect.h"
diff -ru Math-Pari-2.0304_01080603.orig\patches\diff_2.3.5_mingw-w64 Math-Pari-2.0304_01080603.new\patches\diff_2.3.5_mingw-w64
--- Math-Pari-2.0304_01080603.orig\patches\diff_2.3.5_mingw-w64	Wed Mar 03 12:39:41 2010
+++ Math-Pari-2.0304_01080603.new\patches\diff_2.3.5_mingw-w64	Wed Mar 03 12:31:39 2010
@@ -0,0 +1,17 @@
+diff -ru pari-2.3.5.orig\src\gp\highlvl.c pari-2.3.5\src\gp\highlvl.c
+--- pari-2.3.5.orig\src\gp\highlvl.c    Thu Feb 04 11:55:42 2010
++++ pari-2.3.5\src\gp\highlvl.c Wed Mar 03 12:28:18 2010
+@@ -18,6 +18,13 @@
+ /*        SOME GP FUNCTION THAT MAY BE USEFUL OUTSIDE OF IT        */
+ /*                                                                 */
+ /*******************************************************************/
++
++/* we need to include windows.h quite early to avoid some macro name collisions */
++#ifdef _WIN32
++#  define WIN32_LEAN_AND_MEAN
++#  include <windows.h>
++#endif
++
+ #include "pari.h"
+ #include "paripriv.h"
+ #include "../graph/rect.h"
diff -ru Math-Pari-2.0304_01080603.orig\utils\Math\PariBuild.pm Math-Pari-2.0304_01080603.new\utils\Math\PariBuild.pm
--- Math-Pari-2.0304_01080603.orig\utils\Math\PariBuild.pm	Fri Dec 11 02:45:28 2009
+++ Math-Pari-2.0304_01080603.new\utils\Math\PariBuild.pm	Wed Mar 03 12:34:57 2010
@@ -481,11 +481,14 @@
 			      'patches/diff_2.1.6_no-common'],
 		 '2.1.7' =>  [
 			($^O =~ /darwin/i ? 'patches/diff_2.1.6_no-common' : ()),
+			($^O eq 'MSWin32' ? 'patches/diff_2.1.7_mingw-w64' : ()),
 			      'patches/patch-pari-unnormalized-float',
 			      'patches/diff_2.1.7_-O',
 			      'patches/diff_2.1.7_div',
 			      'patches/diff_2.1.6_align_power_of_2',
 			      'patches/diff_2.1.7_restart'],
+		 '2.3.5' =>  [
+			($^O eq 'MSWin32' ? 'patches/diff_2.3.5_mingw-w64' : ())],
 		);
   print "Looking for patches for $v...\n";
   my @p = $patches{$v} ? @{$patches{$v}} : ();
@@ -507,7 +510,7 @@
   return '/' unless $^O =~ /win32/i;
   my($patch, $p) = (shift, 'utils/inc_h.diff');
   $p =~ s,/,\\,g;
-  system "$patch --binary < $p"
+  system "$patch -p0 --binary < $p"
     or warn("... Apparently, your patch takes flag --binary...\n"),
        return ('\\', '--binary');
   return '\\';
@@ -887,6 +890,8 @@
 	   or $os eq 'freebsd' or $os =~ /^cygwin/) {
     chomp($machine = `uname -m`);
     $machine ||= 'ix86';
+  } elsif (($Config{archname} eq 'MSWin32-x86-multi-thread') && ($Config{cc} =~ /gcc/)) {
+    $machine = 'ix86'; 
   } elsif (0 and $os =~ /win32/i and not $Config{gccversion}) {
     # Not needed with rename of kernel1.s to kernel1.c?
     $machine = 'port'; # Win32 compilers would not understand the assmebler anyway
