[Vm-dev] [commit][3618] Convery int to long in parameter passing in the SurfacePlugin ( nd its client the

commits at squeakvm.org commits at squeakvm.org
Sat Feb 20 20:49:01 UTC 2016


Revision: 3618
Author:   eliot
Date:     2016-02-20 12:49:01 -0800 (Sat, 20 Feb 2016)
Log Message:
-----------
Convery int to long in parameter passing in the SurfacePlugin (nd its client the
FFI plugin) to fix issues on 64-bits.

Modified Paths:
--------------
    trunk/platforms/Cross/plugins/SqueakFFIPrims/sqFFI.h
    trunk/platforms/Cross/plugins/SqueakFFIPrims/sqManualSurface.c
    trunk/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.c
    trunk/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.h

Property Changed:
----------------
    trunk/platforms/Cross/plugins/sqPluginsSCCSVersion.h

Modified: trunk/platforms/Cross/plugins/SqueakFFIPrims/sqFFI.h
===================================================================
--- trunk/platforms/Cross/plugins/SqueakFFIPrims/sqFFI.h	2016-02-20 20:20:49 UTC (rev 3617)
+++ trunk/platforms/Cross/plugins/SqueakFFIPrims/sqFFI.h	2016-02-20 20:49:01 UTC (rev 3618)
@@ -147,9 +147,9 @@
    -1 otherwise.  The other return true for success, and false for failure.
 */   
 #include "../SurfacePlugin/SurfacePlugin.h"
-void initManualSurfaceFunctionPointers(fn_ioRegisterSurface reg, fn_ioUnregisterSurface unreg, fn_ioFindSurface find);
-int createManualSurface(int width, int height, int rowPitch, int depth, int isMSB);
-int destroyManualSurface(int surfaceID);
-int setManualSurfacePointer(int surfaceID, void* ptr);
+void initManualSurfaceFunctionPolongers(fn_ioRegisterSurface reg, fn_ioUnregisterSurface unreg, fn_ioFindSurface find);
+long createManualSurface(long width, long height, long rowPitch, long depth, long isMSB);
+long destroyManualSurface(long surfaceID);
+long setManualSurfacePointer(long surfaceID, void* ptr);
 
 #endif /* SQ_FFI_H */

Modified: trunk/platforms/Cross/plugins/SqueakFFIPrims/sqManualSurface.c
===================================================================
--- trunk/platforms/Cross/plugins/SqueakFFIPrims/sqManualSurface.c	2016-02-20 20:20:49 UTC (rev 3617)
+++ trunk/platforms/Cross/plugins/SqueakFFIPrims/sqManualSurface.c	2016-02-20 20:49:01 UTC (rev 3618)
@@ -53,10 +53,10 @@
 
 /* Create the dispatch-table that SurfacePlugin will use to interact with
    instances of "struct ManualSurface" */
-static int manualSurfaceGetFormat(ManualSurface* surface, int* width, int* height, int* depth, int* isMSB);
-static void* manualSurfaceLock(ManualSurface* surface, int *pitch, int x, int y, int w, int h);
-static int manualSurfaceUnlock(ManualSurface* surface, int x, int y, int w, int h);
-static int manualSurfaceShow(ManualSurface* surface, int x, int y, int w, int h);
+static long manualSurfaceGetFormat(ManualSurface* surface, long* width, long* height, long* depth, long* isMSB);
+static void* manualSurfaceLock(ManualSurface* surface, long *pitch, long x, long y, long w, long h);
+static long manualSurfaceUnlock(ManualSurface* surface, long x, long y, long w, long h);
+static long manualSurfaceShow(ManualSurface* surface, long x, long y, long w, long h);
 static sqSurfaceDispatch manualSurfaceDispatch = {
   1,
   0,
@@ -68,16 +68,16 @@
 
 /* sqSurfaceDispatch functions *****************************************************************************/
 
-int manualSurfaceGetFormat(ManualSurface* surface, int* width, int* height, int* depth, int* isMSB) {
+long manualSurfaceGetFormat(ManualSurface* surface, long* width, long* height, long* depth, long* isMSB) {
 	*width = surface->width;
 	*height = surface->height;
 	*depth = surface->depth;
 	*isMSB = surface->isMSB;
-	DPRINTF(("Getting Surface Format: %lx %d %d %d %d\n", ((int) surface), *width, *height, *depth, *isMSB));
+	DPRINTF(("Getting Surface Format: %lx %ld %ld %ld %ld\n", (long) surface, *width, *height, *depth, *isMSB));
 	return 1;
 }
 
-void* manualSurfaceLock(ManualSurface* surface, int *pitch, int x, int y, int w, int h) {
+void* manualSurfaceLock(ManualSurface* surface, long *pitch, long x, long y, long w, long h) {
 	/* Ideally, would be atomic.  But it doens't matter for the forseeable future,
 	   since it is only called via BitBlt primitives. */
 	int wasLocked = surface->isLocked;
@@ -94,17 +94,17 @@
 	
 	/* Success!  Return the pointer. */
 	*pitch = surface->rowPitch;
-	DPRINTF(("Locked Surface: %lx Input Rect: %d %d %d %d  Row Pitch: %d\n", ((int) surface), x, y, w, h, *pitch));
+	DPRINTF(("Locked Surface: %lx Input Rect: %ld %ld %ld %ld  Row Pitch: %ld\n", (long) surface, x, y, w, h, *pitch));
 	return surface->ptr;
 }
 
-int manualSurfaceUnlock(ManualSurface* surface, int x, int y, int w, int h) {
+long manualSurfaceUnlock(ManualSurface* surface, long x, long y, long w, long h) {
     surface->isLocked = 0;
-	DPRINTF(("Unlocked Surface: %lx Rect: %d %d %d %d\n", ((int) surface), x, y, w, h));
+	DPRINTF(("Unlocked Surface: %lx Rect: %ld %ld %ld %ld\n", (long) surface, x, y, w, h));
 	return 1;	
 }
 
-int manualSurfaceShow(ManualSurface* surface, int x, int y, int w, int h) {
+long manualSurfaceShow(ManualSurface* surface, long x, long y, long w, long h) {
 	/* Unsupported */
 	return 0;
 }
@@ -112,10 +112,9 @@
 /* primitive interface functions (i.e. called from Squeak) *********************************************/
 
 /* Answer non-negative surfaceID if successful, and -1 for failure. */
-int createManualSurface(int width, int height, int rowPitch, int depth, int isMSB) {
+long createManualSurface(long width, long height, long rowPitch, long depth, long isMSB) {
 	ManualSurface* newSurface;
-	int surfaceID;
-	int result;
+	long surfaceID, result;
 	
 	if (width < 0) return -1;
 	if (height < 0) return -1;
@@ -133,32 +132,30 @@
 	newSurface->ptr = NULL;
 	newSurface->isLocked = FALSE;
 	
-	result = registerSurface((int)newSurface, &manualSurfaceDispatch, &surfaceID);
+	result = registerSurface((long)newSurface, &manualSurfaceDispatch, &surfaceID);
 	if (!result) {
 		/* Failed to register surface. */
 		free(newSurface);
 		return -1;
 	}
-	else {
-		return surfaceID;
-	}
+	return surfaceID;
 }
 
-int destroyManualSurface(int surfaceID) {
+long destroyManualSurface(long surfaceID) {
 	if (!unregisterSurface) return 0; /* failure... couldn't init function-pointer */
 	else return unregisterSurface(surfaceID);
 }
 
-int setManualSurfacePointer(int surfaceID, void* ptr) {
-	int surfaceHandle;
+long setManualSurfacePointer(long surfaceID, void* ptr) {
+	long surfaceHandle;
 	ManualSurface *surface;
-	int result;
+	long result;
 	if (!findSurface) return FALSE; /* failure... couldn't init function-pointer */
 	result = findSurface(surfaceID, NULL, &surfaceHandle);
 	if (!result) return FALSE; /* failed to find surface */
 	surface = (ManualSurface*)surfaceHandle;	
 	if (surface->isLocked) return FALSE; /* can't set pointer while surface is locked */
 	surface->ptr = ptr;
-	DPRINTF(("Set Surface: %lx Pointer: %lx\n", surfaceID, ((int)ptr) ));
+	DPRINTF(("Set Surface: %lx Polonger: %lx\n", surfaceID, (long)ptr));
 	return TRUE;
 }

Modified: trunk/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.c
===================================================================
--- trunk/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.c	2016-02-20 20:20:49 UTC (rev 3617)
+++ trunk/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.c	2016-02-20 20:49:01 UTC (rev 3618)
@@ -32,13 +32,13 @@
 #endif
 
 typedef struct SqueakSurface {
-	int handle; /* client supplied handle */
+	long handle; /* client supplied handle */
 	sqSurfaceDispatch *dispatch;
 } SqueakSurface;
 
 static SqueakSurface *surfaceArray = NULL;
-static int numSurfaces = 0;
-static int maxSurfaces = 0;
+static long numSurfaces = 0;
+static long maxSurfaces = 0;
 
 #ifdef SQUEAK_BUILTIN_PLUGIN
 static const char *moduleName = "SurfacePlugin "__DATE__" (i)";
@@ -51,29 +51,29 @@
 
 #pragma export on
 /* module initialization/shutdown */
-EXPORT(int) setInterpreter(struct VirtualMachine *interpreterProxy);
+EXPORT(long) setInterpreter(struct VirtualMachine *interpreterProxy);
 EXPORT(const char*) getModuleName(void);
-EXPORT(int) initialiseModule(void);
-EXPORT(int) shutdownModule(void);
+EXPORT(long) initialiseModule(void);
+EXPORT(long) shutdownModule(void);
 
 /* critical FXBlt entry points */
-EXPORT(int) ioGetSurfaceFormat (int surfaceID, int* width, int* height, int* depth, int* isMSB);
-EXPORT(int) ioLockSurface (int surfaceID, int *pitch, int x, int y, int w, int h);
-EXPORT(int) ioUnlockSurface(int surfaceID, int x, int y, int w, int h);
+EXPORT(long) ioGetSurfaceFormat (long surfaceID, long* width, long* height, long* depth, long* isMSB);
+EXPORT(long) ioLockSurface (long surfaceID, long *pitch, long x, long y, long w, long h);
+EXPORT(long) ioUnlockSurface(long surfaceID, long x, long y, long w, long h);
 
 /* interpreter entry point */
-EXPORT(int) ioShowSurface(int surfaceID, int x, int y, int w, int h);
+EXPORT(long) ioShowSurface(long surfaceID, long x, long y, long w, long h);
 
 /* client entry points */
-EXPORT(int) ioRegisterSurface(int surfaceHandle, sqSurfaceDispatch *fn, int *surfaceID);
-EXPORT(int) ioUnregisterSurface(int surfaceID);
-EXPORT(int) ioFindSurface(int surfaceID, sqSurfaceDispatch *fn, int *surfaceHandle);
+EXPORT(long) ioRegisterSurface(long surfaceHandle, sqSurfaceDispatch *fn, long *surfaceID);
+EXPORT(long) ioUnregisterSurface(long surfaceID);
+EXPORT(long) ioFindSurface(long surfaceID, sqSurfaceDispatch *fn, long *surfaceHandle);
 #pragma export off
 
 /* ioGetSurfaceFormat:
 	Return information describing the given surface.
 	Return true if successful, false otherwise. */
-EXPORT(int) ioGetSurfaceFormat (int surfaceID, int* width, int* height, int* depth, int* isMSB)
+EXPORT(long) ioGetSurfaceFormat (long surfaceID, long* width, long* height, long* depth, long* isMSB)
 {
 	SqueakSurface *surface;
 	if(surfaceID < 0 || surfaceID >= maxSurfaces) FAIL;
@@ -87,7 +87,7 @@
 	Lock the bits of the surface. 
 	Return a pointer to the actual surface bits,
 	or NULL on failure. */
-EXPORT(int) ioLockSurface (int surfaceID, int *pitch, int x, int y, int w, int h)
+EXPORT(long) ioLockSurface (long surfaceID, long *pitch, long x, long y, long w, long h)
 {
 	SqueakSurface *surface;
 	if(surfaceID < 0 || surfaceID >= maxSurfaces) FAIL;
@@ -100,7 +100,7 @@
 /* ioUnlockSurface:
 	Unlock the bits of the surface. 
 	The return value is ignored. */
-EXPORT(int) ioUnlockSurface(int surfaceID, int x, int y, int w, int h)
+EXPORT(long) ioUnlockSurface(long surfaceID, long x, long y, long w, long h)
 {
 	SqueakSurface *surface;
 	if(surfaceID < 0 || surfaceID >= maxSurfaces) FAIL;
@@ -112,7 +112,7 @@
 
 /* ioShowSurface:
 	Transfer the bits of a surface to the screen. */
-EXPORT(int) ioShowSurface(int surfaceID, int x, int y, int w, int h)
+EXPORT(long) ioShowSurface(long surfaceID, long x, long y, long w, long h)
 {
 	SqueakSurface *surface;
 	if(surfaceID < 0 || surfaceID >= maxSurfaces) FAIL;
@@ -127,9 +127,9 @@
 	the set of surface functions. The new ID is returned
 	in surfaceID. Returns true if successful, false 
 	otherwise. */
-EXPORT(int) ioRegisterSurface(int surfaceHandle, sqSurfaceDispatch *fn, int *surfaceID)
+EXPORT(long) ioRegisterSurface(long surfaceHandle, sqSurfaceDispatch *fn, long *surfaceID)
 {
-	int index;
+	long index;
 
 	if(!fn) return 0;
 	if(fn->majorVersion != 1 && fn->minorVersion != 0) return 0;
@@ -157,7 +157,7 @@
 /* ioUnregisterSurface:
 	Unregister the surface with the given handle.
 	Returns true if successful, false otherwise. */
-EXPORT(int) ioUnregisterSurface(int surfaceID)
+EXPORT(long) ioUnregisterSurface(long surfaceID)
 {
 	SqueakSurface *surface;
 	if(surfaceID < 0 || surfaceID >= maxSurfaces) return 0;
@@ -174,7 +174,7 @@
 	the given set of surface functions. The registered handle
 	is returned in surfaceHandle. Return true if successful
 	(e.g., the surface has been found), false otherwise. */
-EXPORT(int) ioFindSurface(int surfaceID, sqSurfaceDispatch *fn, int *surfaceHandle)
+EXPORT(long) ioFindSurface(long surfaceID, sqSurfaceDispatch *fn, long *surfaceHandle)
 {
 	SqueakSurface *surface;
 	if(surfaceID < 0 || surfaceID >= maxSurfaces) return 0;
@@ -185,8 +185,8 @@
 	return 1;
 }
 
-EXPORT(int) setInterpreter(struct VirtualMachine* anInterpreter) {
-    int ok;
+EXPORT(long) setInterpreter(struct VirtualMachine* anInterpreter) {
+    long ok;
 
 	interpreterProxy = anInterpreter;
 	ok = interpreterProxy->majorVersion() == VM_PROXY_MAJOR;
@@ -200,14 +200,14 @@
 	return moduleName;
 }
 
-EXPORT(int) initialiseModule() {
+EXPORT(long) initialiseModule() {
 	surfaceArray = NULL;
 	numSurfaces = 0;
 	maxSurfaces = 0;
 	return 1;
 }
 
-EXPORT(int) shutdownModule() {
+EXPORT(long) shutdownModule() {
 	/* This module can only be shut down if no surfaces are registered */
 	if(numSurfaces != 0) return 0;
 	free(surfaceArray);
@@ -230,4 +230,3 @@
   {NULL, NULL, NULL}
 };
 #endif /* ifdef SQ_BUILTIN_PLUGIN */
-

Modified: trunk/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.h
===================================================================
--- trunk/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.h	2016-02-20 20:20:49 UTC (rev 3617)
+++ trunk/platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.h	2016-02-20 20:49:01 UTC (rev 3618)
@@ -6,17 +6,17 @@
 
 /* Plugins creating their own surfaces must register these using
    the following set of functions. The typedefs are for easier casts. */
-typedef int (*fn_getSurfaceFormat)(int surfaceHandle, int* width, int* height, int* depth, int* isMSB);
-typedef int (*fn_lockSurface)(int surfaceHandle, int *pitch, int x, int y, int w, int h);
-typedef int (*fn_unlockSurface)(int surfaceHandle, int x, int y, int w, int h);
-typedef int (*fn_showSurface)(int surfaceHandle, int x, int y, int w, int h);
+typedef long (*fn_getSurfaceFormat)(long surfaceHandle, long* width, long* height, long* depth, long* isMSB);
+typedef long (*fn_lockSurface)(long surfaceHandle, long *pitch, long x, long y, long w, long h);
+typedef long (*fn_unlockSurface)(long surfaceHandle, long x, long y, long w, long h);
+typedef long (*fn_showSurface)(long surfaceHandle, long x, long y, long w, long h);
 
 typedef struct sqSurfaceDispatch {
 	/* Version information. Must be provided by the client
 	   so the surface manager can check if certain operations
 	   are supported. */
-	int majorVersion;
-	int minorVersion;
+	long majorVersion;
+	long minorVersion;
 
 	/* Version 1.0 */
 	fn_getSurfaceFormat getSurfaceFormat;
@@ -27,14 +27,14 @@
 
 /* The functions for sqSurfaceDispatch are:
 
-	int getSurfaceFormat(int handle, int* width, int* height, int* depth, int* isMSB);
+	long getSurfaceFormat(long handle, long* width, long* height, long* depth, long* isMSB);
 		Return general information about the OS drawing surface.
 		Return true if successful, false otherwise.
 
 		The returned values describe the basic properties such as
 		width, height, depth and LSB vs. MSB pixels.
 
-	int lockSurface(int handle, int *pitch, int x, int y, int w, int h);
+	long lockSurface(long handle, long *pitch, long x, long y, long w, long h);
 		Lock the bits of the surface.
 		Return a pointer to the actual surface bits, or NULL on failure.
 		If successful, store the pitch of the surface (e.g., the bytes
@@ -65,14 +65,14 @@
 		be inside the source and dest boundingBox) but it is not aligned to word boundaries
 		yet. It is up to the support code to compute accurate alignment if necessary.
 
-	int unlockSurface(int handle, int x, int y, int w, int h);
+	long unlockSurface(long handle, long x, long y, long w, long h);
 		Unlock the bits of a (possibly modified) surface after BitBlt completed.
 		The return value is ignored.
 
 		The arguments provided specify the dirty region of the surface. If the
 		surface is unmodified all arguments are set to zero.
 
-	int showSurface(int handle, int x, int y, int w, int h);
+	long showSurface(long handle, long x, long y, long w, long h);
 		Display the contents of the surface on the actual screen.
 
 		If ioShowSurface() is called the surface in question represents
@@ -81,9 +81,9 @@
 	FXBlt uses a variant of the above functions which are exported from
 	the surface plugin:
 
-	int ioGetSurfaceFormat(int surfaceID, int* width, int* height, int* depth, int* isMSB);
-	int ioLockSurface(int surfaceID, int *pitch, int x, int y, int w, int h);
-	int ioUnlockSurface(int surfaceID, int x, int y, int w, int h);
+	long ioGetSurfaceFormat(long surfaceID, long* width, long* height, long* depth, long* isMSB);
+	long ioLockSurface(long surfaceID, long *pitch, long x, long y, long w, long h);
+	long ioUnlockSurface(long surfaceID, long x, long y, long w, long h);
 
 	These functions are looked up in the registered surfaces and invoked
 	as appropriate. The meaning of all values is exactly the same as for
@@ -93,7 +93,7 @@
 
 	Interpreter itself uses a separate entry point for updating the display
 
-	int ioShowSurface(int surfaceID, int x, int y, int w, int h);
+	long ioShowSurface(long surfaceID, long x, long y, long w, long h);
 
 	since the management of deferred updates is currently an intrinsic
 	property of the VM (which is bad - deferred updates should be a
@@ -104,17 +104,17 @@
 
 /* The following are the entry points for the surface manager:
 
-	int ioRegisterSurface(int surfaceHandle, sqSurfaceDispatch *fn, int *surfaceID);
+	long ioRegisterSurface(long surfaceHandle, sqSurfaceDispatch *fn, long *surfaceID);
 		Register a new surface with the given handle and
 		the set of surface functions. The new ID is returned
 		in surfaceID. Returns true if successful, false 
 		otherwise.
 
-	int ioUnregisterSurface(int surfaceID);
+	long ioUnregisterSurface(long surfaceID);
 		Unregister the surface with the given handle.
 		Returns true if successful, false otherwise.
 
-	int ioFindSurface(int surfaceID, sqSurfaceDispatch *fn, int *surfaceHandle);
+	long ioFindSurface(long surfaceID, sqSurfaceDispatch *fn, long *surfaceHandle);
 		Find the surface with the given ID, and, optionally,
 		the given set of surface functions. The registered handle
 		is returned in surfaceHandle. Return true if successful
@@ -124,8 +124,8 @@
 		interpreterProxy->ioLoadFunctionFrom("ioRegisterSurface","SurfacePlugin");
 	The typedefs below are for easier casts.
 */
-typedef int (*fn_ioRegisterSurface)(int surfaceHandle, sqSurfaceDispatch *fn, int *surfaceID);
-typedef int (*fn_ioUnregisterSurface)(int surfaceID);
-typedef int (*fn_ioFindSurface)(int surfaceID, sqSurfaceDispatch *fn, int *surfaceHandle);
+typedef long (*fn_ioRegisterSurface)(long surfaceHandle, sqSurfaceDispatch *fn, long *surfaceID);
+typedef long (*fn_ioUnregisterSurface)(long surfaceID);
+typedef long (*fn_ioFindSurface)(long surfaceID, sqSurfaceDispatch *fn, long *surfaceHandle);
 
 #endif /* __SQ_DRAW_SURFACE_H */


Property changes on: trunk/platforms/Cross/plugins/sqPluginsSCCSVersion.h
___________________________________________________________________
Modified: checkindate
   - Fri Feb 19 16:18:52 PST 2016
   + Sat Feb 20 12:48:09 PST 2016



More information about the Vm-dev mailing list