Index: gatomic.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gatomic.c,v
retrieving revision 1.11
diff -u -p -w -r1.11 gatomic.c
--- gatomic.c	24 Oct 2004 01:37:42 -0000	1.11
+++ gatomic.c	6 Jan 2005 21:15:24 -0000
@@ -455,6 +455,14 @@ g_atomic_pointer_compare_and_exchange (g
 
 #ifdef DEFINE_WITH_WIN32_INTERLOCKED
 # include <windows.h>
+/* Following indicates that InterlockedCompareExchangePointer is declared
+   in winbase.h (included by windows.h) and needs to be commented out if
+   not true.  It is defined iff WINVER > 0x0400, which is usually correct
+   but can be wrong if WINVER is set before windows.h is included. */
+# if WINVER > 0x0400
+#  define HAVE_INTERLOCKED_COMPARE_EXCHANGE_POINTER
+# endif
+
 gint32   
 g_atomic_int_exchange_and_add (gint32   *atomic, 
 			       gint32    val)
@@ -474,9 +482,15 @@ g_atomic_int_compare_and_exchange (gint3
 				   gint32    oldval, 
 				   gint32    newval)
 {
+#ifndef HAVE_INTERLOCKED_COMPARE_EXCHANGE_POINTER
   return (guint32)InterlockedCompareExchange ((PVOID*)atomic, 
                                               (PVOID)newval, 
                                               (PVOID)oldval) == oldval;
+#else
+  return InterlockedCompareExchange (atomic, 
+                                     newval, 
+                                     oldval) == oldval;
+#endif
 }
 
 gboolean 
@@ -484,9 +498,12 @@ g_atomic_pointer_compare_and_exchange (g
 				       gpointer  oldval, 
 				       gpointer  newval)
 {
+# ifdef HAVE_INTERLOCKED_COMPARE_EXCHANGE_POINTER
+  return InterlockedCompareExchangePointer (atomic, newval, oldval) == oldval;
+# else
 # if GLIB_SIZEOF_VOID_P != 4 /* no 32-bit system */
 #  error "InterlockedCompareExchangePointer needed"
-# else
+#  endif   
    return InterlockedCompareExchange (atomic, newval, oldval) == oldval;
 # endif
 }
