changeset 1456:84de7511f79f

Fixed a bunch of 64-bit compatibility problems
author Sam Lantinga <slouken@libsdl.org>
date Wed, 01 Mar 2006 09:43:47 +0000
parents f487bb150acc
children 337665b695d1
files VisualC.zip configure.in include/SDL_stdinc.h src/audio/windib/SDL_dibaudio.c src/cdrom/win32/SDL_syscdrom.c src/file/SDL_rwops.c src/stdlib/SDL_getenv.c src/stdlib/SDL_malloc.c src/stdlib/SDL_qsort.c src/stdlib/SDL_string.c src/video/SDL_RLEaccel.c src/video/SDL_blit_A.c src/video/SDL_surface.c src/video/wincommon/SDL_sysevents.c src/video/wincommon/SDL_sysmouse.c src/video/wincommon/SDL_syswm.c src/video/windib/SDL_dibevents.c src/video/windx5/SDL_dx5events.c
diffstat 18 files changed, 117 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
Binary file VisualC.zip has changed
--- a/configure.in	Mon Feb 27 22:14:40 2006 +0000
+++ b/configure.in	Wed Mar 01 09:43:47 2006 +0000
@@ -116,7 +116,7 @@
     if test x$ac_cv_func_strtod = xyes; then
         AC_DEFINE(HAVE_STRTOD)
     fi
-    AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol _i64toa _ui64toa strtoll atoi atof strcmp strncmp stricmp strcasecmp sscanf snprintf vsnprintf sigaction setjmp nanosleep)
+    AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp stricmp strcasecmp sscanf snprintf vsnprintf sigaction setjmp nanosleep)
 
     AC_CHECK_LIB(m, pow, [BUILD_LDFLAGS="$BUILD_LDFLAGS -lm"])
 fi
--- a/include/SDL_stdinc.h	Mon Feb 27 22:14:40 2006 +0000
+++ b/include/SDL_stdinc.h	Wed Mar 01 09:43:47 2006 +0000
@@ -446,6 +446,12 @@
 extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base);
 #endif
 
+#if HAVE_STRTOUL
+#define SDL_strtoul      strtoul
+#else
+extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base);
+#endif
+
 #if SDL_HAS_64BIT_TYPE
 
 #if HAVE__I64TOA
@@ -466,6 +472,12 @@
 extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base);
 #endif
 
+#if HAVE_STRTOULL
+#define SDL_strtoull     strtoull
+#else
+extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base);
+#endif
+
 #endif /* SDL_HAS_64BIT_TYPE */
 
 #if HAVE_STRTOD
--- a/src/audio/windib/SDL_dibaudio.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/audio/windib/SDL_dibaudio.c	Wed Mar 01 09:43:47 2006 +0000
@@ -99,7 +99,7 @@
 
 
 /* The Win32 callback for filling the WAVE device */
-static void CALLBACK FillSound(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance,
+static void CALLBACK FillSound(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance,
 						DWORD dwParam1, DWORD dwParam2)
 {
 	SDL_AudioDevice *this = (SDL_AudioDevice *)dwInstance;
@@ -118,7 +118,7 @@
 
 static void SetMMerror(char *function, MMRESULT code)
 {
-	int len;
+	size_t len;
 	char errbuf[MAXERRORLENGTH];
 #ifdef _WIN32_WCE
 	wchar_t werrbuf[MAXERRORLENGTH];
@@ -132,7 +132,7 @@
 	waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH-len);
 	WideCharToMultiByte(CP_ACP,0,werrbuf,-1,errbuf+len,MAXERRORLENGTH-len,NULL,NULL);
 #else
-	waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len);
+	waveOutGetErrorText(code, errbuf+len, (UINT)(MAXERRORLENGTH-len));
 #endif
 
 	SDL_SetError("%s",errbuf);
@@ -266,7 +266,7 @@
 
 	/* Open the audio device */
 	result = waveOutOpen(&sound, WAVE_MAPPER, &waveformat,
-			(DWORD)FillSound, (DWORD)this, CALLBACK_FUNCTION);
+			(DWORD_PTR)FillSound, (DWORD_PTR)this, CALLBACK_FUNCTION);
 	if ( result != MMSYSERR_NOERROR ) {
 		SetMMerror("waveOutOpen()", result);
 		return(-1);
--- a/src/cdrom/win32/SDL_syscdrom.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/cdrom/win32/SDL_syscdrom.c	Wed Mar 01 09:43:47 2006 +0000
@@ -111,7 +111,7 @@
 {
 	MCIERROR mci_error;
 
-	mci_error = mciSendCommand(SDL_mciID[id], msg, flags, (DWORD)arg);
+	mci_error = mciSendCommand(SDL_mciID[id], msg, flags, (DWORD_PTR)arg);
 	if ( mci_error ) {
 		char error[256];
 
--- a/src/file/SDL_rwops.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/file/SDL_rwops.c	Wed Mar 01 09:43:47 2006 +0000
@@ -245,8 +245,8 @@
 }
 static int mem_read(SDL_RWops *context, void *ptr, int size, int maxnum)
 {
-	int total_bytes;
-	int mem_available;
+	size_t total_bytes;
+	size_t mem_available;
 
 	total_bytes = (maxnum * size);
 	if ( (maxnum <= 0) || (size <= 0) || ((total_bytes / maxnum) != size) ) {
--- a/src/stdlib/SDL_getenv.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/stdlib/SDL_getenv.c	Wed Mar 01 09:43:47 2006 +0000
@@ -33,12 +33,12 @@
 /* Note this isn't thread-safe! */
 
 static char *SDL_envmem = NULL;	/* Ugh, memory leak */
-static DWORD SDL_envmemlen = 0;
+static size_t SDL_envmemlen = 0;
 
 /* Put a variable of the form "name=value" into the environment */
 int SDL_putenv(const char *variable)
 {
-	DWORD bufferlen;
+	size_t bufferlen;
 	char *value;
 	const char *sep;
 
@@ -67,7 +67,7 @@
 /* Retrieve a variable named "name" from the environment */
 char *SDL_getenv(const char *name)
 {
-	DWORD bufferlen;
+	size_t bufferlen;
 
 	bufferlen = GetEnvironmentVariable(name, SDL_envmem, SDL_envmemlen);
 	if ( bufferlen == 0 ) {
--- a/src/stdlib/SDL_malloc.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/stdlib/SDL_malloc.c	Wed Mar 01 09:43:47 2006 +0000
@@ -1647,7 +1647,7 @@
 typedef struct malloc_chunk  mchunk;
 typedef struct malloc_chunk* mchunkptr;
 typedef struct malloc_chunk* sbinptr;  /* The type of bins of chunks */
-typedef unsigned int bindex_t;         /* Described below */
+typedef size_t bindex_t;               /* Described below */
 typedef unsigned int binmap_t;         /* Described below */
 typedef unsigned int flag_t;           /* The type of various bit flag sets */
 
--- a/src/stdlib/SDL_qsort.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/stdlib/SDL_qsort.c	Wed Mar 01 09:43:47 2006 +0000
@@ -263,7 +263,7 @@
 
 static char * pivot_big(char *first, char *mid, char *last, size_t size,
                         int compare(const void *, const void *)) {
-  int d=(((last-first)/size)>>3)*size;
+  size_t d=(((last-first)/size)>>3)*size;
   char *m1,*m2,*m3;
   { char *a=first, *b=first+d, *c=first+2*d;
 #ifdef DEBUG_QSORT
@@ -414,7 +414,7 @@
            int (*compare)(const void *, const void *)) {
 
   if (nmemb<=1) return;
-  if (((int)base|size)&(WORD_BYTES-1))
+  if (((uintptr_t)base|size)&(WORD_BYTES-1))
     qsort_nonaligned(base,nmemb,size,compare);
   else if (size!=WORD_BYTES)
     qsort_aligned(base,nmemb,size,compare);
--- a/src/stdlib/SDL_string.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/stdlib/SDL_string.c	Wed Mar 01 09:43:47 2006 +0000
@@ -69,7 +69,7 @@
 }
 #endif
 
-#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOD)
+#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
 static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
 {
     const char *textstart = text;
@@ -100,6 +100,37 @@
 }
 #endif
 
+#ifndef HAVE_SSCANF
+static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
+{
+    const char *textstart = text;
+    uintptr_t value = 0;
+
+    if ( radix == 16 && SDL_strncmp(text, "0x", 2) == 0 ) {
+        text += 2;
+    }
+    for ( ; ; ) {
+        int v;
+        if ( SDL_isdigit(*text) ) {
+            v = *text - '0';
+        } else if ( radix == 16 && SDL_isupperhex(*text) ) {
+            v = 10 + (*text - 'A');
+        } else if ( radix == 16 && SDL_islowerhex(*text) ) {
+            v = 10 + (*text - 'a');
+        } else {
+            break;
+        }
+        value *= radix;
+        value += v;
+        ++text;
+    }
+    if ( valuep ) {
+        *valuep = value;
+    }
+    return (text - textstart);
+}
+#endif
+
 #ifdef SDL_HAS_64BIT_TYPE
 #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOLL)
 static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
@@ -141,7 +172,7 @@
 }
 #endif
 
-#ifndef HAVE_SSCANF
+#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOULL)
 static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
 {
     const char *textstart = text;
@@ -488,6 +519,20 @@
 }
 #endif
 
+#ifndef HAVE_STRTOUL
+unsigned long SDL_strtoul(const char *string, char **endp, int base)
+{
+    size_t len;
+    unsigned long value;
+
+    len = SDL_ScanUnsignedLong(string, base ? base : 10, &value);
+    if ( endp ) {
+        *endp = (char *)string + len;
+    }
+    return value;
+}
+#endif
+
 #ifdef SDL_HAS_64BIT_TYPE
 
 #ifndef HAVE__I64TOA
@@ -556,6 +601,20 @@
 }
 #endif
 
+#ifndef HAVE_STRTOULL
+Uint64 SDL_strtoull(const char *string, char **endp, int base)
+{
+    size_t len;
+    Uint64 value;
+
+    len = SDL_ScanUnsignedLongLong(string, base ? base : 10, &value);
+    if ( endp ) {
+        *endp = (char *)string + len;
+    }
+    return value;
+}
+#endif
+
 #endif /* SDL_HAS_64BIT_TYPE */
 
 #ifndef HAVE_STRTOD
@@ -817,8 +876,8 @@
                         break;
                     case 'p':
                         {
-                            unsigned long value;
-                            text += SDL_ScanUnsignedLong(text, 16, &value);
+                            uintptr_t value;
+                            text += SDL_ScanUintPtrT(text, 16, &value);
                             if ( ! suppress ) {
                                 void** valuep = va_arg(ap, void**);
                                 *valuep = (void*)value;
@@ -1003,7 +1062,7 @@
     }
     return (text - textstart);
 }
-int  SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
+int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
 {
     char *textstart = text;
     if ( maxlen <= 0 ) {
--- a/src/video/SDL_RLEaccel.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/video/SDL_RLEaccel.c	Wed Mar 01 09:43:47 2006 +0000
@@ -587,12 +587,12 @@
 	unsigned n = (length);						\
 	Uint16 *src = (Uint16 *)(from);					\
 	Uint16 *dst = (Uint16 *)(to);					\
-	if(((unsigned long)src ^ (unsigned long)dst) & 3) {		\
+	if(((uintptr_t)src ^ (uintptr_t)dst) & 3) {			\
 	    /* source and destination not in phase, blit one by one */	\
 	    while(n--)							\
 		BLEND16_50(dst, src, mask);				\
 	} else {							\
-	    if((unsigned long)src & 3) {				\
+	    if((uintptr_t)src & 3) {					\
 		/* first odd pixel */					\
 		BLEND16_50(dst, src, mask);				\
 		n--;							\
@@ -1055,7 +1055,7 @@
 	    } while(ofs < w);						  \
 	    /* skip padding if necessary */				  \
 	    if(sizeof(Ptype) == 2)					  \
-		srcbuf += (unsigned long)srcbuf & 2;			  \
+		srcbuf += (uintptr_t)srcbuf & 2;			  \
 	    /* blit translucent pixels on the same line */		  \
 	    ofs = 0;							  \
 	    do {							  \
@@ -1147,7 +1147,7 @@
 		    } while(ofs < w);
 
 		    /* skip padding */
-		    srcbuf += (unsigned long)srcbuf & 2;
+		    srcbuf += (uintptr_t)srcbuf & 2;
 
 		    /* skip translucent line */
 		    ofs = 0;
@@ -1211,7 +1211,7 @@
 		} while(ofs < w);					 \
 		/* skip padding if necessary */				 \
 		if(sizeof(Ptype) == 2)					 \
-		    srcbuf += (unsigned long)srcbuf & 2;		 \
+		    srcbuf += (uintptr_t)srcbuf & 2;		 	 \
 		/* blit translucent pixels on the same line */		 \
 		ofs = 0;						 \
 		do {							 \
@@ -1547,7 +1547,7 @@
 	    } while(x < w);
 
 	    /* Make sure the next output address is 32-bit aligned */
-	    dst += (unsigned long)dst & 2;
+	    dst += (uintptr_t)dst & 2;
 
 	    /* Next, encode all translucent pixels of the same scan line */
 	    x = 0;
@@ -1874,7 +1874,7 @@
 
 	/* skip padding if needed */
 	if(bpp == 2)
-	    srcbuf += (unsigned long)srcbuf & 2;
+	    srcbuf += (uintptr_t)srcbuf & 2;
 	
 	/* copy translucent pixels */
 	ofs = 0;
--- a/src/video/SDL_blit_A.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/video/SDL_blit_A.c	Wed Mar 01 09:43:47 2006 +0000
@@ -1442,7 +1442,7 @@
 	int dstskip = info->d_skip >> 1;
 
 	while(height--) {
-		if(((unsigned long)srcp ^ (unsigned long)dstp) & 2) {
+		if(((uintptr_t)srcp ^ (uintptr_t)dstp) & 2) {
 			/*
 			 * Source and destination not aligned, pipeline it.
 			 * This is mostly a win for big blits but no loss for
@@ -1452,7 +1452,7 @@
 			int w = width;
 
 			/* handle odd destination */
-			if((unsigned long)dstp & 2) {
+			if((uintptr_t)dstp & 2) {
 				Uint16 d = *dstp, s = *srcp;
 				*dstp = BLEND16_50(d, s, mask);
 				dstp++;
@@ -1499,7 +1499,7 @@
 			int w = width;
 
 			/* first odd pixel? */
-			if((unsigned long)srcp & 2) {
+			if((uintptr_t)srcp & 2) {
 				Uint16 d = *dstp, s = *srcp;
 				*dstp = BLEND16_50(d, s, mask);
 				srcp++;
--- a/src/video/SDL_surface.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/video/SDL_surface.c	Wed Mar 01 09:43:47 2006 +0000
@@ -604,7 +604,7 @@
 			dstrect->x*dst->format->BytesPerPixel;
 	if ( dst->format->palette || (color == 0) ) {
 		x = dstrect->w*dst->format->BytesPerPixel;
-		if ( !color && !((long)row&3) && !(x&3) && !(dst->pitch&3) ) {
+		if ( !color && !((uintptr_t)row&3) && !(x&3) && !(dst->pitch&3) ) {
 			int n = x >> 2;
 			for ( y=dstrect->h; y; --y ) {
 				SDL_memset4(row, 0, n);
@@ -690,7 +690,7 @@
 				Uint16 c = (Uint16)color;
 				Uint32 cc = (Uint32)c << 16 | c;
 				int n = dstrect->w;
-				if((unsigned long)pixels & 3) {
+				if((uintptr_t)pixels & 3) {
 					*pixels++ = c;
 					n--;
 				}
--- a/src/video/wincommon/SDL_sysevents.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/video/wincommon/SDL_sysevents.c	Wed Mar 01 09:43:47 2006 +0000
@@ -191,7 +191,7 @@
 {
 	if ( ptme->dwFlags == TME_LEAVE ) {
 		return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100,
-		                (TIMERPROC)TrackMouseTimerProc);
+		                (TIMERPROC)TrackMouseTimerProc) != 0;
 	}
 	return FALSE;
 }
@@ -247,7 +247,7 @@
 /* The main Win32 event handler
 DJM: This is no longer static as (DX5/DIB)_CreateWindow needs it
 */
-LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
 	SDL_VideoDevice *this = current_video;
 	static int mouse_pressed = 0;
--- a/src/video/wincommon/SDL_sysmouse.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/video/wincommon/SDL_sysmouse.c	Wed Mar 01 09:43:47 2006 +0000
@@ -172,7 +172,7 @@
 
 	/* Create the cursor */
 	cursor->curs = CreateCursor(
-			(HINSTANCE)GetWindowLong(SDL_Window, GWL_HINSTANCE),
+			(HINSTANCE)GetWindowLongPtr(SDL_Window, GWL_HINSTANCE),
 					hot_x, hot_y, allowed_x, allowed_y, 
 						cursor->ands, cursor->xors);
 	if ( cursor->curs == NULL ) {
--- a/src/video/wincommon/SDL_syswm.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/video/wincommon/SDL_syswm.c	Wed Mar 01 09:43:47 2006 +0000
@@ -220,7 +220,7 @@
 	if ( screen_icn == NULL ) {
 		SDL_SetError("Couldn't create Win32 icon handle");
 	} else {
-		SetClassLong(SDL_Window, GCL_HICON, (LONG)screen_icn);
+		SetClassLongPtr(SDL_Window, GCL_HICON, (LONG_PTR)screen_icn);
 	}
 	SDL_stack_free(icon_win32);
 #endif /* DISABLE_ICON_SUPPORT */
--- a/src/video/windib/SDL_dibevents.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/video/windib/SDL_dibevents.c	Wed Mar 01 09:43:47 2006 +0000
@@ -84,8 +84,7 @@
 
 
 /* The main Win32 event handler */
-LONG
- DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
 	extern int posted;
 
@@ -417,7 +416,7 @@
 		SDL_Window = (HWND)wcstol(windowid_t, NULL, 0);
 		SDL_free(windowid_t);
 #else
-		SDL_Window = (HWND)SDL_strtol(windowid, NULL, 0);
+		SDL_Window = (HWND)SDL_strtoull(windowid, NULL, 0);
 #endif
 		if ( SDL_Window == NULL ) {
 			SDL_SetError("Couldn't get user specified window");
@@ -427,8 +426,8 @@
 		/* DJM: we want all event's for the user specified
 			window to be handled by SDL.
 		 */
-		userWindowProc = (WNDPROCTYPE)GetWindowLong(SDL_Window, GWL_WNDPROC);
-		SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage);
+		userWindowProc = (WNDPROCTYPE)GetWindowLongPtr(SDL_Window, GWL_WNDPROC);
+		SetWindowLongPtr(SDL_Window, GWL_WNDPROC, (LONG_PTR)WinMessage);
 	} else {
 		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
                         (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
@@ -445,7 +444,7 @@
 void DIB_DestroyWindow(_THIS)
 {
 	if ( SDL_windowid ) {
-		SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)userWindowProc);
+		SetWindowLongPtr(SDL_Window, GWL_WNDPROC, (LONG_PTR)userWindowProc);
 	} else {
 		DestroyWindow(SDL_Window);
 	}
--- a/src/video/windx5/SDL_dx5events.c	Mon Feb 27 22:14:40 2006 +0000
+++ b/src/video/windx5/SDL_dx5events.c	Wed Mar 01 09:43:47 2006 +0000
@@ -476,8 +476,7 @@
 }
 
 /* The main Win32 event handler */
-LONG
- DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
 	switch (msg) {
 #ifdef WM_ACTIVATEAPP
@@ -503,7 +502,7 @@
 
 #ifdef WM_DISPLAYCHANGE
 		case WM_DISPLAYCHANGE: {
-			WORD BitsPerPixel;
+			WPARAM BitsPerPixel;
 			WORD SizeX, SizeY;
 
 			/* Ack!  The display changed size and/or depth! */
@@ -866,7 +865,7 @@
 
 	SDL_windowid = (windowid != NULL);
 	if ( SDL_windowid ) {
-		SDL_Window = (HWND)SDL_strtol(windowid, NULL, 0);
+		SDL_Window = (HWND)SDL_strtoull(windowid, NULL, 0);
 		if ( SDL_Window == NULL ) {
 			SDL_SetError("Couldn't get user specified window");
 			return(-1);
@@ -875,8 +874,8 @@
 		/* DJM: we want all event's for the user specified
 			window to be handled by SDL.
 		 */
-		userWindowProc = (WNDPROCTYPE)GetWindowLong(SDL_Window, GWL_WNDPROC);
-		SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage);
+		userWindowProc = (WNDPROCTYPE)GetWindowLongPtr(SDL_Window, GWL_WNDPROC);
+		SetWindowLongPtr(SDL_Window, GWL_WNDPROC, (LONG_PTR)WinMessage);
 	} else {
 		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
                         (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
@@ -904,7 +903,7 @@
 
 	/* Destroy our window */
 	if ( SDL_windowid ) {
-		SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)userWindowProc);
+		SetWindowLongPtr(SDL_Window, GWL_WNDPROC, (LONG_PTR)userWindowProc);
 	} else {
 		DestroyWindow(SDL_Window);
 	}