[Vm-dev] [commit][3178] Update platforms/* with Eliot' s fixes for 64-bit clean AsyncPlugin.

commits at squeakvm.org commits at squeakvm.org
Sat Dec 13 00:42:57 UTC 2014


Revision: 3178
Author:   lewis
Date:     2014-12-12 16:42:55 -0800 (Fri, 12 Dec 2014)
Log Message:
-----------
Update platforms/* with Eliot's fixes for 64-bit clean AsyncPlugin.

The platforms/unix changes are tested. The win32 and Mac OS changes are not tested but I believe them to be correct.
Not applicable to RiscOS.
Updates not applied to iOS.

@eliot - I changed the declarations in Cross to (void *) rather than long to reduce type casts in platforms/[unix|win32|Mac OS].

@esteban - I did not update platforms/iOS in SVN trunk. Please update declarations as needed.

@tim - no change required for RiscOS.

Modified Paths:
--------------
    trunk/platforms/Cross/plugins/AsynchFilePlugin/AsynchFilePlugin.h
    trunk/platforms/Mac OS/plugins/AsynchFilePlugin/sqMacAsyncFilePrims.c
    trunk/platforms/unix/plugins/AsynchFilePlugin/sqUnixAsynchFile.c
    trunk/platforms/win32/plugins/AsynchFilePlugin/sqWin32AsyncFilePrims.c

Modified: trunk/platforms/Cross/plugins/AsynchFilePlugin/AsynchFilePlugin.h
===================================================================
--- trunk/platforms/Cross/plugins/AsynchFilePlugin/AsynchFilePlugin.h	2014-12-12 19:56:33 UTC (rev 3177)
+++ trunk/platforms/Cross/plugins/AsynchFilePlugin/AsynchFilePlugin.h	2014-12-13 00:42:55 UTC (rev 3178)
@@ -10,9 +10,9 @@
 } AsyncFile;
 
 int asyncFileClose(AsyncFile *f);
-int asyncFileOpen(AsyncFile *f, long fileNamePtr, int fileNameSize, int writeFlag, int semaIndex);
+int asyncFileOpen(AsyncFile *f, char *fileNamePtr, int fileNameSize, int writeFlag, int semaIndex);
 int asyncFileRecordSize();
-int asyncFileReadResult(AsyncFile *f, long bufferPtr, int bufferSize);
+int asyncFileReadResult(AsyncFile *f, void *bufferPtr, int bufferSize);
 int asyncFileReadStart(AsyncFile *f, int fPosition, int count);
 int asyncFileWriteResult(AsyncFile *f);
-int asyncFileWriteStart(AsyncFile *f, int fPosition, long bufferPtr, int bufferSize);
+int asyncFileWriteStart(AsyncFile *f, int fPosition, void *bufferPtr, int bufferSize);

Modified: trunk/platforms/Mac OS/plugins/AsynchFilePlugin/sqMacAsyncFilePrims.c
===================================================================
--- trunk/platforms/Mac OS/plugins/AsynchFilePlugin/sqMacAsyncFilePrims.c	2014-12-12 19:56:33 UTC (rev 3177)
+++ trunk/platforms/Mac OS/plugins/AsynchFilePlugin/sqMacAsyncFilePrims.c	2014-12-13 00:42:55 UTC (rev 3178)
@@ -85,12 +85,12 @@
 
 /*** Exported Functions ***/
 int asyncFileClose(AsyncFile *f);
-int asyncFileOpen(AsyncFile *f, int fileNamePtr, int fileNameSize, int writeFlag, int semaIndex);
+int asyncFileOpen(AsyncFile *f, char *fileNamePtr, int fileNameSize, int writeFlag, int semaIndex);
 int asyncFileRecordSize();
-int asyncFileReadResult(AsyncFile *f, int bufferPtr, int bufferSize);
+int asyncFileReadResult(AsyncFile *f, void *bufferPtr, int bufferSize);
 int asyncFileReadStart(AsyncFile *f, int fPosition, int count);
 int asyncFileWriteResult(AsyncFile *f);
-int asyncFileWriteStart(AsyncFile *f, int fPosition, int bufferPtr, int bufferSize);
+int asyncFileWriteStart(AsyncFile *f, int fPosition, void *bufferPtr, int bufferSize);
 
 /*** Local Functions ***/
 void asyncFileAllocateBuffer(AsyncFileState *state, int byteCount);
@@ -203,7 +203,7 @@
 	return 0;
 }
 
-int asyncFileOpen(AsyncFile *f, int fileNamePtr, int fileNameSize, int writeFlag, int semaIndex) {
+int asyncFileOpen(AsyncFile *f, char *fileNamePtr, int fileNameSize, int writeFlag, int semaIndex) {
   /* Opens the given file using the supplied AsyncFile structure to record
 	 its state. Fails with no side effects if f is already open. Files are
 	 always opened in binary mode. */
@@ -270,7 +270,7 @@
 	return 0;
 }
 
-int asyncFileReadResult(AsyncFile *f, int bufferPtr, int bufferSize) {
+int asyncFileReadResult(AsyncFile *f, void *bufferPtr, int bufferSize) {
   /* Copy up to bufferSize bytes from the buffer of the last read operation
 	 into the given Squeak buffer, and return the number of bytes copied.
 	 Negative values indicate:
@@ -290,7 +290,7 @@
 
 	/* copy the file buffer into the squeak buffer */
 	bytesRead = (bufferSize < state->bytesTransferred) ? bufferSize : state->bytesTransferred;
-	memcpy((char *) bufferPtr, state->bufferPtr, bytesRead);
+	memcpy(bufferPtr, state->bufferPtr, bytesRead);
 	return bytesRead;
 }
 
@@ -340,7 +340,7 @@
 	return state->bytesTransferred;
 }
 
-int asyncFileWriteStart(AsyncFile *f, int fPosition, int bufferPtr, int bufferSize) {
+int asyncFileWriteStart(AsyncFile *f, int fPosition, void *bufferPtr, int bufferSize) {
   /* Start an asynchronous operation to write bufferSize bytes to the given file
 	 starting at the given file position. The file's semaphore will be signalled when
 	 the operation is complete. The client may then use asyncFileWriteResult() to
@@ -359,7 +359,7 @@
 	if (state->bufferPtr == nil) return success(false);  /* could not allocate buffer */
 
 	/* copy the squeak buffer into the file buffer */
-	memcpy(state->bufferPtr, (char *) bufferPtr, bufferSize);
+	memcpy(state->bufferPtr, bufferPtr, bufferSize);
 
 	asyncFileInitPB(state, fPosition);
 	err = PBWriteAsync(&state->pb);

Modified: trunk/platforms/unix/plugins/AsynchFilePlugin/sqUnixAsynchFile.c
===================================================================
--- trunk/platforms/unix/plugins/AsynchFilePlugin/sqUnixAsynchFile.c	2014-12-12 19:56:33 UTC (rev 3177)
+++ trunk/platforms/unix/plugins/AsynchFilePlugin/sqUnixAsynchFile.c	2014-12-13 00:42:55 UTC (rev 3178)
@@ -184,7 +184,7 @@
 /*** public functions ***/
 
 
-int asyncFileOpen(AsyncFile *f, int fileNamePtr, int fileNameSize,
+int asyncFileOpen(AsyncFile *f, char *fileNamePtr, int fileNameSize,
 		  int writeFlag, int semaIndex)
 {
   int fd= 0;
@@ -239,13 +239,13 @@
 }
 
 
-int asyncFileReadResult(AsyncFile *f, int bufferPtr, int bufferSize)
+int asyncFileReadResult(AsyncFile *f, void *bufferPtr, int bufferSize)
 {
   FilePtr fp= 0;
   int n= 0;
   validate(f);
   fp= (FilePtr)f->state;
-  n= read(fp->fd, (void *)bufferPtr, bufferSize);
+  n= read(fp->fd, bufferPtr, bufferSize);
   if      ((n < 0) && (errno == EWOULDBLOCK))
     return fp->rd.status= Busy;
   else if (n <= 0)
@@ -333,7 +333,7 @@
 }
 
 
-int asyncFileWriteStart(AsyncFile *f, int fPosition, int bufferPtr, int count)
+int asyncFileWriteStart(AsyncFile *f, int fPosition, void *bufferPtr, int count)
 {
   FilePtr fp= 0;
   validate(f);
@@ -363,7 +363,7 @@
       goto fail;
     }
 
-  memcpy((void *)fp->buf.bytes, (void *)bufferPtr, count);
+  memcpy((void *)fp->buf.bytes, bufferPtr, count);
   fp->buf.pos= 0;	/* current output pointer */
   fp->buf.size= count;	/* bytes to transfer */
   fp->wr.status= Busy;	/* transfer in progress */

Modified: trunk/platforms/win32/plugins/AsynchFilePlugin/sqWin32AsyncFilePrims.c
===================================================================
--- trunk/platforms/win32/plugins/AsynchFilePlugin/sqWin32AsyncFilePrims.c	2014-12-12 19:56:33 UTC (rev 3177)
+++ trunk/platforms/win32/plugins/AsynchFilePlugin/sqWin32AsyncFilePrims.c	2014-12-13 00:42:55 UTC (rev 3178)
@@ -87,12 +87,12 @@
 
 /*** Exported Functions ***/
 int asyncFileClose(AsyncFile *f);
-int asyncFileOpen(AsyncFile *f, long fileNamePtr, int fileNameSize, int writeFlag, int semaIndex);
+int asyncFileOpen(AsyncFile *f, char *fileNamePtr, int fileNameSize, int writeFlag, int semaIndex);
 int asyncFileRecordSize();
-int asyncFileReadResult(AsyncFile *f, long bufferPtr, int bufferSize);
+int asyncFileReadResult(AsyncFile *f, void *bufferPtr, int bufferSize);
 int asyncFileReadStart(AsyncFile *f, int fPosition, int count);
 int asyncFileWriteResult(AsyncFile *f);
-int asyncFileWriteStart(AsyncFile *f, int fPosition, long bufferPtr, int bufferSize);
+int asyncFileWriteStart(AsyncFile *f, int fPosition, void *bufferPtr, int bufferSize);
 
 
 /*****************************************************************************
@@ -205,7 +205,7 @@
   return 1;
 }
 
-int asyncFileOpen(AsyncFile *f, long fileNamePtr, int fileNameSize, 
+int asyncFileOpen(AsyncFile *f, char *fileNamePtr, int fileNameSize, 
 		  int writeFlag, int semaIndex) {
   /* Opens the given file using the supplied AsyncFile structure to record
      its state. Fails with no side effects if f is already open. Files are
@@ -224,7 +224,7 @@
   /* copy the file name into a null-terminated C string */
   if (fileNameSize > 255) return success(false);
   for (i = 0; i < fileNameSize; i++) {
-    cFileName[i] = *((char *) (fileNamePtr + i));
+    cFileName[i] = *(fileNamePtr + i);
   }
   cFileName[fileNameSize] = 0;
 
@@ -278,7 +278,7 @@
   return 1;
 }
 
-int asyncFileReadResult(AsyncFile *f, long bufferPtr, int bufferSize) {
+int asyncFileReadResult(AsyncFile *f, void *bufferPtr, int bufferSize) {
   /* Copy up to bufferSize bytes from the buffer of the last read operation
      into the given Squeak buffer, and return the number of bytes copied.
      Negative values indicate:
@@ -297,7 +297,7 @@
   
   /* copy the file buffer into the squeak buffer */
   bytesRead = (bufferSize < state->bytesTransferred) ? bufferSize : state->bytesTransferred;
-  MoveMemory((void *) bufferPtr, (void *)state->bufferPtr, bytesRead);
+  MoveMemory(bufferPtr, (void *)state->bufferPtr, bytesRead);
   return bytesRead;
 }
 
@@ -341,7 +341,7 @@
   return state->bytesTransferred;
 }
 
-int asyncFileWriteStart(AsyncFile *f, int fPosition, long bufferPtr, int bufferSize) {
+int asyncFileWriteStart(AsyncFile *f, int fPosition, void *bufferPtr, int bufferSize) {
   /* Start an asynchronous operation to write bufferSize bytes to the given file
      starting at the given file position. The file''s semaphore will be signalled when
      the operation is complete. The client may then use asyncFileWriteResult() to
@@ -357,7 +357,7 @@
   if (state->bufferPtr == NULL) return success(false);  /* could not allocate buffer */
 
   /* copy the squeak buffer into the file buffer */
-  MoveMemory((void*)state->bufferPtr, (void*) bufferPtr, bufferSize);
+  MoveMemory((void*)state->bufferPtr, bufferPtr, bufferSize);
 
   state->dwPosition = fPosition;
   state->dwSize = bufferSize;



More information about the Vm-dev mailing list