Skip to content

Commit

Permalink
Third wave of Surface x64 fixes: agree on surfaceID,x,y,w,h,pitch,isM…
Browse files Browse the repository at this point in the history
…SB types

They were declared either long or int depending on files.
This is not 64bits compatible.
Since all those values will fit into an int, use int.
  • Loading branch information
nicolas-cellier-aka-nice committed Nov 12, 2016
1 parent 4dae33d commit 22385dc
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 58 deletions.
8 changes: 4 additions & 4 deletions platforms/Cross/plugins/SqueakFFIPrims/sqFFI.h
Expand Up @@ -157,9 +157,9 @@ int ffiLogCallOfLength(void *nameIndex, int nameLength);
void initSurfacePluginFunctionPointers();
void initManualSurfaceFunctionPointers
(fn_ioRegisterSurface, fn_ioUnregisterSurface, fn_ioFindSurface);
long createManualSurface
(long width, long height, long rowPitch, long depth, long isMSB);
long destroyManualSurface(long surfaceID);
long setManualSurfacePointer(long surfaceID, void* ptr);
int createManualSurface
(int width, int height, int rowPitch, int depth, int isMSB);
int destroyManualSurface(int surfaceID);
int setManualSurfacePointer(int surfaceID, void* ptr);

#endif /* SQ_FFI_H */
26 changes: 13 additions & 13 deletions platforms/Cross/plugins/SqueakFFIPrims/sqManualSurface.c
Expand Up @@ -53,10 +53,10 @@ typedef struct {

/* Create the dispatch-table that SurfacePlugin will use to interact with
instances of "struct ManualSurface" */
static long manualSurfaceGetFormat(sqIntptr_t, long*, long*, long*, long*);
static sqIntptr_t manualSurfaceLock(sqIntptr_t, long *, long, long, long, long);
static long manualSurfaceUnlock(sqIntptr_t, long, long, long, long);
static long manualSurfaceShow(sqIntptr_t, long, long, long, long);
static int manualSurfaceGetFormat(sqIntptr_t, int*, int*, int*, int*);
static sqIntptr_t manualSurfaceLock(sqIntptr_t, int *, int, int, int, int);
static int manualSurfaceUnlock(sqIntptr_t, int, int, int, int);
static int manualSurfaceShow(sqIntptr_t, int, int, int, int);
static sqSurfaceDispatch manualSurfaceDispatch = {
1,
0,
Expand All @@ -68,7 +68,7 @@ static sqSurfaceDispatch manualSurfaceDispatch = {

/* sqSurfaceDispatch functions *****************************************************************************/

long manualSurfaceGetFormat(sqIntptr_t surfaceArg, long* width, long* height, long* depth, long* isMSB) {
int manualSurfaceGetFormat(sqIntptr_t surfaceArg, int* width, int* height, int* depth, int* isMSB) {
ManualSurface* surface = (ManualSurface *)surfaceArg;
*width = surface->width;
*height = surface->height;
Expand All @@ -78,7 +78,7 @@ long manualSurfaceGetFormat(sqIntptr_t surfaceArg, long* width, long* height, lo
return 1;
}

sqIntptr_t manualSurfaceLock(sqIntptr_t surfaceArg, long *pitch, long x, long y, long w, long h) {
sqIntptr_t manualSurfaceLock(sqIntptr_t surfaceArg, int *pitch, int x, int y, int w, int h) {
ManualSurface* surface = (ManualSurface *)surfaceArg;
/* Ideally, would be atomic. But it doens't matter for the forseeable future,
since it is only called via BitBlt primitives. */
Expand All @@ -100,24 +100,24 @@ sqIntptr_t manualSurfaceLock(sqIntptr_t surfaceArg, long *pitch, long x, long y,
return (sqIntptr_t)(surface->ptr);
}

long manualSurfaceUnlock(sqIntptr_t surfaceArg, long x, long y, long w, long h) {
int manualSurfaceUnlock(sqIntptr_t surfaceArg, int x, int y, int w, int h) {
ManualSurface* surface = (ManualSurface *)surfaceArg;
surface->isLocked = 0;
DPRINTF(("Unlocked Surface: %" PRIxSQPTR " Rect: %ld %ld %ld %ld\n", (sqIntptr_t) surface, x, y, w, h));
return 1;
}

long manualSurfaceShow(sqIntptr_t surfaceArg, long x, long y, long w, long h) {
int manualSurfaceShow(sqIntptr_t surfaceArg, int x, int y, int w, int h) {
/* Unsupported */
return 0;
}

/* primitive interface functions (i.e. called from Squeak) *********************************************/

/* Answer non-negative surfaceID if successful, and -1 for failure. */
long createManualSurface(long width, long height, long rowPitch, long depth, long isMSB) {
int createManualSurface(int width, int height, int rowPitch, int depth, int isMSB) {
ManualSurface* newSurface;
long surfaceID, result;
int surfaceID, result;

if (width < 0) return -1;
if (height < 0) return -1;
Expand All @@ -144,15 +144,15 @@ long createManualSurface(long width, long height, long rowPitch, long depth, lon
return surfaceID;
}

long destroyManualSurface(long surfaceID) {
int destroyManualSurface(int surfaceID) {
if (!unregisterSurface) return 0; /* failure... couldn't init function-pointer */
return unregisterSurface(surfaceID);
}

long setManualSurfacePointer(long surfaceID, void* ptr) {
int setManualSurfacePointer(int surfaceID, void* ptr) {
sqIntptr_t surfaceHandle;
ManualSurface *surface;
long result;
int result;
if (!findSurface) return FALSE; /* failure... couldn't init function-pointer */
result = findSurface(surfaceID, NULL, &surfaceHandle);
if (!result) return FALSE; /* failed to find surface */
Expand Down
34 changes: 17 additions & 17 deletions platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.c
Expand Up @@ -37,8 +37,8 @@ typedef struct SqueakSurface {
} SqueakSurface;

static SqueakSurface *surfaceArray = NULL;
static long numSurfaces = 0;
static long maxSurfaces = 0;
static int numSurfaces = 0;
static int maxSurfaces = 0;

#ifdef SQUEAK_BUILTIN_PLUGIN
static const char *moduleName = "SurfacePlugin "__DATE__" (i)";
Expand All @@ -57,23 +57,23 @@ EXPORT(long) initialiseModule(void);
EXPORT(long) shutdownModule(void);

/* critical FXBlt entry points */
EXPORT(long) ioGetSurfaceFormat (long surfaceID, long* width, long* height, long* depth, long* isMSB);
EXPORT(sqIntptr_t) 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);
EXPORT(int) ioGetSurfaceFormat (int surfaceID, int* width, int* height, int* depth, int* isMSB);
EXPORT(sqIntptr_t) 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);

/* interpreter entry point */
EXPORT(long) ioShowSurface(long surfaceID, long x, long y, long w, long h);
EXPORT(int) ioShowSurface(int surfaceID, int x, int y, int w, int h);

/* client entry points */
EXPORT(long) ioRegisterSurface(sqIntptr_t surfaceHandle, sqSurfaceDispatch *fn, long *surfaceID);
EXPORT(long) ioUnregisterSurface(long surfaceID);
EXPORT(long) ioFindSurface(long surfaceID, sqSurfaceDispatch *fn, sqIntptr_t *surfaceHandle);
EXPORT(int) ioRegisterSurface(sqIntptr_t surfaceHandle, sqSurfaceDispatch *fn, int *surfaceID);
EXPORT(int) ioUnregisterSurface(int surfaceID);
EXPORT(int) ioFindSurface(int surfaceID, sqSurfaceDispatch *fn, sqIntptr_t *surfaceHandle);
#pragma export off

/* ioGetSurfaceFormat:
Return information describing the given surface.
Return true if successful, false otherwise. */
EXPORT(long) ioGetSurfaceFormat (long surfaceID, long* width, long* height, long* depth, long* isMSB)
EXPORT(int) ioGetSurfaceFormat (int surfaceID, int* width, int* height, int* depth, int* isMSB)
{
SqueakSurface *surface;
if(surfaceID < 0 || surfaceID >= maxSurfaces) FAIL;
Expand All @@ -87,7 +87,7 @@ EXPORT(long) ioGetSurfaceFormat (long surfaceID, long* width, long* height, long
Lock the bits of the surface.
Return a pointer to the actual surface bits,
or NULL on failure. */
EXPORT(sqIntptr_t) ioLockSurface (long surfaceID, long *pitch, long x, long y, long w, long h)
EXPORT(sqIntptr_t) ioLockSurface (int surfaceID, int *pitch, int x, int y, int w, int h)
{
SqueakSurface *surface;
if(surfaceID < 0 || surfaceID >= maxSurfaces) FAIL;
Expand All @@ -100,7 +100,7 @@ EXPORT(sqIntptr_t) ioLockSurface (long surfaceID, long *pitch, long x, long y, l
/* ioUnlockSurface:
Unlock the bits of the surface.
The return value is ignored. */
EXPORT(long) ioUnlockSurface(long surfaceID, long x, long y, long w, long h)
EXPORT(int) ioUnlockSurface(int surfaceID, int x, int y, int w, int h)
{
SqueakSurface *surface;
if(surfaceID < 0 || surfaceID >= maxSurfaces) FAIL;
Expand All @@ -112,7 +112,7 @@ EXPORT(long) ioUnlockSurface(long surfaceID, long x, long y, long w, long h)

/* ioShowSurface:
Transfer the bits of a surface to the screen. */
EXPORT(long) ioShowSurface(long surfaceID, long x, long y, long w, long h)
EXPORT(int) ioShowSurface(int surfaceID, int x, int y, int w, int h)
{
SqueakSurface *surface;
if(surfaceID < 0 || surfaceID >= maxSurfaces) FAIL;
Expand All @@ -127,9 +127,9 @@ EXPORT(long) ioShowSurface(long surfaceID, long x, long y, long w, long h)
the set of surface functions. The new ID is returned
in surfaceID. Returns true if successful, false
otherwise. */
EXPORT(long) ioRegisterSurface(sqIntptr_t surfaceHandle, sqSurfaceDispatch *fn, long *surfaceID)
EXPORT(int) ioRegisterSurface(sqIntptr_t surfaceHandle, sqSurfaceDispatch *fn, int *surfaceID)
{
long index;
int index;

if(!fn) return 0;
if(fn->majorVersion != 1 && fn->minorVersion != 0) return 0;
Expand Down Expand Up @@ -157,7 +157,7 @@ EXPORT(long) ioRegisterSurface(sqIntptr_t surfaceHandle, sqSurfaceDispatch *fn,
/* ioUnregisterSurface:
Unregister the surface with the given ID.
Returns true if successful, false otherwise. */
EXPORT(long) ioUnregisterSurface(long surfaceID)
EXPORT(int) ioUnregisterSurface(int surfaceID)
{
SqueakSurface *surface;
if(surfaceID < 0 || surfaceID >= maxSurfaces) return 0;
Expand All @@ -174,7 +174,7 @@ EXPORT(long) ioUnregisterSurface(long surfaceID)
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(long) ioFindSurface(long surfaceID, sqSurfaceDispatch *fn, sqIntptr_t *surfaceHandle)
EXPORT(int) ioFindSurface(int surfaceID, sqSurfaceDispatch *fn, sqIntptr_t *surfaceHandle)
{
SqueakSurface *surface;
if(surfaceID < 0 || surfaceID >= maxSurfaces) return 0;
Expand Down
40 changes: 20 additions & 20 deletions platforms/Cross/plugins/SurfacePlugin/SurfacePlugin.h
Expand Up @@ -8,17 +8,17 @@

/* Plugins creating their own surfaces must register these using
the following set of functions. The typedefs are for easier casts. */
typedef long (*fn_getSurfaceFormat)(sqIntptr_t surfaceHandle, long* width, long* height, long* depth, long* isMSB);
typedef sqIntptr_t (*fn_lockSurface)(sqIntptr_t surfaceHandle, long *pitch, long x, long y, long w, long h);
typedef long (*fn_unlockSurface)(sqIntptr_t surfaceHandle, long x, long y, long w, long h);
typedef long (*fn_showSurface)(sqIntptr_t surfaceHandle, long x, long y, long w, long h);
typedef int (*fn_getSurfaceFormat)(sqIntptr_t surfaceHandle, int* width, int* height, int* depth, int* isMSB);
typedef sqIntptr_t (*fn_lockSurface)(sqIntptr_t surfaceHandle, int *pitch, int x, int y, int w, int h);
typedef int (*fn_unlockSurface)(sqIntptr_t surfaceHandle, int x, int y, int w, int h);
typedef int (*fn_showSurface)(sqIntptr_t surfaceHandle, int x, int y, int w, int h);

typedef struct sqSurfaceDispatch {
/* Version information. Must be provided by the client
so the surface manager can check if certain operations
are supported. */
long majorVersion;
long minorVersion;
int majorVersion;
int minorVersion;

/* Version 1.0 */
fn_getSurfaceFormat getSurfaceFormat;
Expand All @@ -29,14 +29,14 @@ typedef struct sqSurfaceDispatch {

/* The functions for sqSurfaceDispatch are:
long getSurfaceFormat(sqIntptr_t handle, long* width, long* height, long* depth, long* isMSB);
int getSurfaceFormat(sqIntptr_t handle, int* width, int* height, int* depth, int* 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.
sqIntptr_t lockSurface(sqIntptr_t handle, long *pitch, long x, long y, long w, long h);
sqIntptr_t lockSurface(sqIntptr_t handle, int *pitch, int x, int y, int w, int 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
Expand Down Expand Up @@ -67,14 +67,14 @@ typedef struct sqSurfaceDispatch {
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.
long unlockSurface(sqIntptr_t handle, long x, long y, long w, long h);
int unlockSurface(sqIntptr_t handle, int x, int y, int w, int 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.
long showSurface(sqIntptr_t handle, long x, long y, long w, long h);
int showSurface(sqIntptr_t handle, int x, int y, int w, int h);
Display the contents of the surface on the actual screen.
If ioShowSurface() is called the surface in question represents
Expand All @@ -83,9 +83,9 @@ typedef struct sqSurfaceDispatch {
FXBlt uses a variant of the above functions which are exported from
the surface plugin:
long ioGetSurfaceFormat(long surfaceID, long* width, long* height, long* depth, long* isMSB);
sqIntptr_t 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);
int ioGetSurfaceFormat(int surfaceID, int* width, int* height, int* depth, int* isMSB);
sqIntptr_t 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);
These functions are looked up in the registered surfaces and invoked
as appropriate. The meaning of all values is exactly the same as for
Expand All @@ -95,7 +95,7 @@ typedef struct sqSurfaceDispatch {
Interpreter itself uses a separate entry point for updating the display
long ioShowSurface(long surfaceID, long x, long y, long w, long h);
int ioShowSurface(int surfaceID, int x, int y, int w, int h);
since the management of deferred updates is currently an intrinsic
property of the VM (which is bad - deferred updates should be a
Expand All @@ -106,17 +106,17 @@ typedef struct sqSurfaceDispatch {

/* The following are the entry points for the surface manager:
long ioRegisterSurface(sqIntptr_t surfaceHandle, sqSurfaceDispatch *fn, long *surfaceID);
int ioRegisterSurface(sqIntptr_t surfaceHandle, sqSurfaceDispatch *fn, int *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.
long ioUnregisterSurface(long surfaceID);
int ioUnregisterSurface(int surfaceID);
Unregister the surface with the given ID.
Returns true if successful, false otherwise.
long ioFindSurface(long surfaceID, sqSurfaceDispatch *fn, sqIntptr_t *surfaceHandle);
int ioFindSurface(int surfaceID, sqSurfaceDispatch *fn, sqIntptr_t *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
Expand All @@ -126,8 +126,8 @@ typedef struct sqSurfaceDispatch {
interpreterProxy->ioLoadFunctionFrom("ioRegisterSurface","SurfacePlugin");
The typedefs below are for easier casts.
*/
typedef long (*fn_ioRegisterSurface)(sqIntptr_t surfaceHandle, sqSurfaceDispatch *fn, long *surfaceID);
typedef long (*fn_ioUnregisterSurface)(long surfaceID);
typedef long (*fn_ioFindSurface)(long surfaceID, sqSurfaceDispatch *fn, sqIntptr_t *surfaceHandle);
typedef int (*fn_ioRegisterSurface)(sqIntptr_t surfaceHandle, sqSurfaceDispatch *fn, int *surfaceID);
typedef int (*fn_ioUnregisterSurface)(int surfaceID);
typedef int (*fn_ioFindSurface)(int surfaceID, sqSurfaceDispatch *fn, sqIntptr_t *surfaceHandle);

#endif /* __SQ_DRAW_SURFACE_H */
Expand Up @@ -64,7 +64,7 @@ sqInt sqQuicktimeShutdown() {
return true;
}

long stQuicktimeSetSurfacewidthheightrowBytesdepthmovie(char * buffer, int width, int height, int rowBytes, int depth, void *movie)
int stQuicktimeSetSurfacewidthheightrowBytesdepthmovie(char * buffer, int width, int height, int rowBytes, int depth, void *movie)
{
QuickTimeBitMapForSqueak *bitMap;
int sqHandle;
Expand All @@ -81,7 +81,7 @@ long stQuicktimeSetSurfacewidthheightrowBytesdepthmovie(char * buffer, int width
return sqHandle;
}

long stQuicktimeSetToExistingSurfacegworldwidthheightrowBytesdepthmovie
int stQuicktimeSetToExistingSurfacegworldwidthheightrowBytesdepthmovie
(int sqHandle, char * buffer, int width, int height, int rowBytes, int depth, void *movie)
{
QuickTimeBitMapForSqueak *bitMap;
Expand Down
Expand Up @@ -64,7 +64,7 @@ sqInt sqQuicktimeShutdown() {
return true;
}

long stQuicktimeSetSurfacewidthheightrowBytesdepthmovie(char * buffer, int width, int height, int rowBytes, int depth, void *movie)
int stQuicktimeSetSurfacewidthheightrowBytesdepthmovie(char * buffer, int width, int height, int rowBytes, int depth, void *movie)
{
QuickTimeBitMapForSqueak *bitMap;
int sqHandle;
Expand All @@ -81,7 +81,7 @@ long stQuicktimeSetSurfacewidthheightrowBytesdepthmovie(char * buffer, int width
return sqHandle;
}

long stQuicktimeSetToExistingSurfacegworldwidthheightrowBytesdepthmovie
int stQuicktimeSetToExistingSurfacegworldwidthheightrowBytesdepthmovie
(int sqHandle, char * buffer, int width, int height, int rowBytes, int depth, void *movie)
{
QuickTimeBitMapForSqueak *bitMap;
Expand Down

0 comments on commit 22385dc

Please sign in to comment.