[Vm-dev] [commit][3169] CogVM source as per VMMaker.oscog-eem.974

commits at squeakvm.org commits at squeakvm.org
Wed Dec 10 23:25:38 UTC 2014


Revision: 3169
Author:   eliot
Date:     2014-12-10 15:25:38 -0800 (Wed, 10 Dec 2014)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.974

Fix 64-bit issues in the AsynchFilePlugin.
Fix 64-bit issues with sqUnixMain.c, sqMemoryFence.h & sqVirtualMachine.c.

Modified Paths:
--------------
    branches/Cog/nscogsrc/plugins/AsynchFilePlugin/AsynchFilePlugin.c
    branches/Cog/platforms/Cross/vm/sqMemoryFence.h
    branches/Cog/platforms/Cross/vm/sqVirtualMachine.c
    branches/Cog/platforms/Mac OS/plugins/AsynchFilePlugin/sqMacAsyncFilePrims.c
    branches/Cog/platforms/unix/plugins/AsynchFilePlugin/sqUnixAsynchFile.c
    branches/Cog/platforms/unix/plugins/DropPlugin/sqUnixDragDrop.c
    branches/Cog/platforms/unix/vm/sqUnixMain.c
    branches/Cog/platforms/unix/vm/sqUnixMain.h
    branches/Cog/platforms/win32/vm/sqWin32Stubs.c
    branches/Cog/src/plugins/AsynchFilePlugin/AsynchFilePlugin.c

Property Changed:
----------------
    branches/Cog/platforms/Cross/vm/sqSCCSVersion.h

Modified: branches/Cog/nscogsrc/plugins/AsynchFilePlugin/AsynchFilePlugin.c
===================================================================
--- branches/Cog/nscogsrc/plugins/AsynchFilePlugin/AsynchFilePlugin.c	2014-12-10 23:23:27 UTC (rev 3168)
+++ branches/Cog/nscogsrc/plugins/AsynchFilePlugin/AsynchFilePlugin.c	2014-12-10 23:25:38 UTC (rev 3169)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.963 uuid: 9df56221-18fd-4dcd-b93f-ae000bef62e5
+	SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.974 uuid: 7ca9044b-c2d1-4605-b2b6-2b8ffc66c096
    from
-	AsynchFilePlugin VMMaker.oscog-eem.963 uuid: 9df56221-18fd-4dcd-b93f-ae000bef62e5
+	AsynchFilePlugin VMMaker.oscog-eem.974 uuid: 7ca9044b-c2d1-4605-b2b6-2b8ffc66c096
  */
-static char __buildInfo[] = "AsynchFilePlugin VMMaker.oscog-eem.963 uuid: 9df56221-18fd-4dcd-b93f-ae000bef62e5 " __DATE__ ;
+static char __buildInfo[] = "AsynchFilePlugin VMMaker.oscog-eem.974 uuid: 7ca9044b-c2d1-4605-b2b6-2b8ffc66c096 " __DATE__ ;
 
 
 
@@ -38,6 +38,7 @@
 
 
 /*** Constants ***/
+#define PrimErrBadArgument 3
 
 
 /*** Function Prototypes ***/
@@ -63,6 +64,7 @@
 
 #if !defined(SQUEAK_BUILTIN_PLUGIN)
 static sqInt (*booleanValueOf)(sqInt obj);
+static sqInt (*byteSizeOf)(sqInt oop);
 static sqInt (*classByteArray)(void);
 static sqInt (*failed)(void);
 static void * (*firstIndexableField)(sqInt oop);
@@ -74,12 +76,14 @@
 static sqInt (*pop)(sqInt nItems);
 static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
 static sqInt (*primitiveFail)(void);
+static sqInt (*primitiveFailFor)(sqInt reasonCode);
 static sqInt (*slotSizeOf)(sqInt oop);
 static sqInt (*stackIntegerValue)(sqInt offset);
 static sqInt (*stackValue)(sqInt offset);
 static sqInt (*success)(sqInt aBoolean);
 #else /* !defined(SQUEAK_BUILTIN_PLUGIN) */
 extern sqInt booleanValueOf(sqInt obj);
+extern sqInt byteSizeOf(sqInt oop);
 extern sqInt classByteArray(void);
 extern sqInt failed(void);
 extern void * firstIndexableField(sqInt oop);
@@ -91,6 +95,7 @@
 extern sqInt pop(sqInt nItems);
 extern sqInt popthenPush(sqInt nItems, sqInt oop);
 extern sqInt primitiveFail(void);
+extern sqInt primitiveFailFor(sqInt reasonCode);
 extern sqInt slotSizeOf(sqInt oop);
 extern sqInt stackIntegerValue(sqInt offset);
 extern sqInt stackValue(sqInt offset);
@@ -100,9 +105,9 @@
 struct VirtualMachine* interpreterProxy;
 static const char *moduleName =
 #ifdef SQUEAK_BUILTIN_PLUGIN
-	"AsynchFilePlugin VMMaker.oscog-eem.963 (i)"
+	"AsynchFilePlugin VMMaker.oscog-eem.974 (i)"
 #else
-	"AsynchFilePlugin VMMaker.oscog-eem.963 (e)"
+	"AsynchFilePlugin VMMaker.oscog-eem.974 (e)"
 #endif
 ;
 static void * sCOAFfn;
@@ -110,17 +115,18 @@
 
 
 /*	Answer a pointer to the first byte of the async file record within the
-	given Smalltalk bytes object, or nil if oop is not an async file record.
- */
+	given Smalltalk bytes object, or fail and answer nil if oop is not an
+	async file record. */
 
 static AsyncFile *
 asyncFileValueOf(sqInt oop)
 {
-	success((isBytes(oop))
-	 && ((slotSizeOf(oop)) == (sizeof(AsyncFile))));
-	return (!(failed())
-		? ((AsyncFile *) (firstIndexableField(oop)))
-		: 0);
+	if ((isBytes(oop))
+	 && ((byteSizeOf(oop)) == (sizeof(AsyncFile)))) {
+		return ((AsyncFile *) (firstIndexableField(oop)));
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	return null;
 }
 
 
@@ -193,7 +199,15 @@
 	if (failed()) {
 		return null;
 	}
-	f = asyncFileValueOf(fh);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fh))
+	 && ((byteSizeOf(fh)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fh)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	asyncFileClose(f);
 	if (failed()) {
 		return null;
@@ -224,18 +238,26 @@
 	/* If the security plugin can be loaded, use it to check for permission.
 	   If not, assume it's ok */
 
-	fileNameSize = slotSizeOf(((sqInt)((fileName) - BaseHeaderSize)));
+	fileNameSize = byteSizeOf(((sqInt)((fileName) - BaseHeaderSize)));
 	if (sCOAFfn != 0) {
-		okToOpen =  ((sqInt (*) (char *, sqInt, sqInt)) sCOAFfn)(fileName, fileNameSize, writeFlag);
+		okToOpen = ((sqInt (*) (char *, sqInt, sqInt)) sCOAFfn)(fileName, fileNameSize, writeFlag);
 		if (!okToOpen) {
 			primitiveFail();
 			return null;
 		}
 	}
 	fOop = instantiateClassindexableSize(classByteArray(), sizeof(AsyncFile));
-	f = asyncFileValueOf(fOop);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fOop))
+	 && ((byteSizeOf(fOop)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fOop)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	if (!(failed())) {
-		asyncFileOpen(f, (int)fileName, fileNameSize, writeFlag, semaIndex);
+		asyncFileOpen(f, fileName, fileNameSize, writeFlag, semaIndex);
 	}
 	if (failed()) {
 		return null;
@@ -266,7 +288,15 @@
 	if (failed()) {
 		return null;
 	}
-	f = asyncFileValueOf(fhandle);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fhandle))
+	 && ((byteSizeOf(fhandle)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fhandle)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	count = num;
 	startIndex = start;
 
@@ -286,7 +316,7 @@
 
 	/* adjust for zero-origin indexing */
 
-	bufferPtr = ((((int) (firstIndexableField(buffer)))) + startIndex) - 1;
+	bufferPtr = ((((sqInt) (firstIndexableField(buffer)))) + startIndex) - 1;
 	if (!(failed())) {
 		r = asyncFileReadResult(f, bufferPtr, count);
 	}
@@ -312,7 +342,15 @@
 	if (failed()) {
 		return null;
 	}
-	f = asyncFileValueOf(fHandle);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fHandle))
+	 && ((byteSizeOf(fHandle)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fHandle)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	asyncFileReadStart(f, fPosition, count);
 	if (failed()) {
 		return null;
@@ -333,7 +371,15 @@
 	if (failed()) {
 		return null;
 	}
-	f = asyncFileValueOf(fHandle);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fHandle))
+	 && ((byteSizeOf(fHandle)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fHandle)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	r =  asyncFileWriteResult(f);
 	_return_value = integerObjectOf(r);
 	if (failed()) {
@@ -365,7 +411,15 @@
 	if (failed()) {
 		return null;
 	}
-	f = asyncFileValueOf(fHandle);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fHandle))
+	 && ((byteSizeOf(fHandle)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fHandle)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	if (failed()) {
 		return null;
 	}
@@ -388,7 +442,7 @@
 
 	/* adjust for zero-origin indexing */
 
-	bufferPtr = ((((int) (firstIndexableField(buffer)))) + startIndex) - 1;
+	bufferPtr = ((((sqInt) (firstIndexableField(buffer)))) + startIndex) - 1;
 	if (!(failed())) {
 		asyncFileWriteStart(f, fPosition, bufferPtr, count);
 	}
@@ -414,6 +468,7 @@
 		
 #if !defined(SQUEAK_BUILTIN_PLUGIN)
 		booleanValueOf = interpreterProxy->booleanValueOf;
+		byteSizeOf = interpreterProxy->byteSizeOf;
 		classByteArray = interpreterProxy->classByteArray;
 		failed = interpreterProxy->failed;
 		firstIndexableField = interpreterProxy->firstIndexableField;
@@ -425,6 +480,7 @@
 		pop = interpreterProxy->pop;
 		popthenPush = interpreterProxy->popthenPush;
 		primitiveFail = interpreterProxy->primitiveFail;
+		primitiveFailFor = interpreterProxy->primitiveFailFor;
 		slotSizeOf = interpreterProxy->slotSizeOf;
 		stackIntegerValue = interpreterProxy->stackIntegerValue;
 		stackValue = interpreterProxy->stackValue;
@@ -456,11 +512,11 @@
 	{"AsynchFilePlugin", "getModuleName", (void*)getModuleName},
 	{"AsynchFilePlugin", "initialiseModule", (void*)initialiseModule},
 	{"AsynchFilePlugin", "moduleUnloaded", (void*)moduleUnloaded},
-	{"AsynchFilePlugin", "primitiveAsyncFileClose\000\001", (void*)primitiveAsyncFileClose},
+	{"AsynchFilePlugin", "primitiveAsyncFileClose\000\000", (void*)primitiveAsyncFileClose},
 	{"AsynchFilePlugin", "primitiveAsyncFileOpen\000\000", (void*)primitiveAsyncFileOpen},
 	{"AsynchFilePlugin", "primitiveAsyncFileReadResult\000\001", (void*)primitiveAsyncFileReadResult},
-	{"AsynchFilePlugin", "primitiveAsyncFileReadStart\000\001", (void*)primitiveAsyncFileReadStart},
-	{"AsynchFilePlugin", "primitiveAsyncFileWriteResult\000\001", (void*)primitiveAsyncFileWriteResult},
+	{"AsynchFilePlugin", "primitiveAsyncFileReadStart\000\000", (void*)primitiveAsyncFileReadStart},
+	{"AsynchFilePlugin", "primitiveAsyncFileWriteResult\000\000", (void*)primitiveAsyncFileWriteResult},
 	{"AsynchFilePlugin", "primitiveAsyncFileWriteStart\000\001", (void*)primitiveAsyncFileWriteStart},
 	{"AsynchFilePlugin", "setInterpreter", (void*)setInterpreter},
 	{"AsynchFilePlugin", "shutdownModule\000\377", (void*)shutdownModule},
@@ -469,11 +525,11 @@
 
 #else /* ifdef SQ_BUILTIN_PLUGIN */
 
-signed char primitiveAsyncFileCloseAccessorDepth = 1;
+signed char primitiveAsyncFileCloseAccessorDepth = 0;
 signed char primitiveAsyncFileOpenAccessorDepth = 0;
 signed char primitiveAsyncFileReadResultAccessorDepth = 1;
-signed char primitiveAsyncFileReadStartAccessorDepth = 1;
-signed char primitiveAsyncFileWriteResultAccessorDepth = 1;
+signed char primitiveAsyncFileReadStartAccessorDepth = 0;
+signed char primitiveAsyncFileWriteResultAccessorDepth = 0;
 signed char primitiveAsyncFileWriteStartAccessorDepth = 1;
 
 #endif /* ifdef SQ_BUILTIN_PLUGIN */

Modified: branches/Cog/platforms/Cross/vm/sqMemoryFence.h
===================================================================
--- branches/Cog/platforms/Cross/vm/sqMemoryFence.h	2014-12-10 23:23:27 UTC (rev 3168)
+++ branches/Cog/platforms/Cross/vm/sqMemoryFence.h	2014-12-10 23:25:38 UTC (rev 3169)
@@ -32,24 +32,28 @@
  * by other threads before a fence will be visible to the calling thread, and
  * vice versa.  Writers follow a write with a fence. Readers use a fence before
  * reading.  See e.g. http://en.wikipedia.org/wiki/Memory_barrier
- *
- * The only implementation directly uses mfence on x86.
- * Please add implementations for other ISAs as required.
  */
 
-#if defined(__GNUC__) && (defined(i386) || defined(__i386) || defined(__i386__) || defined(_X86_))
-# if defined(__MINGW32__) && !__SSE2__
+#if defined(__GNUC__)
+# define GCC_HAS_BUILTIN_SYNC \
+			(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
+# define GCC_HAS_BUILTIN_ATOMIC \
+			(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+# if GCC_HAS_BUILTIN_SYNC || defined(__clang__)
+#	define sqLowLevelMFence() __sync_synchronize()
+# elif defined(i386) || defined(__i386) || defined(__i386__) || defined(_X86_)
+#	if defined(__MINGW32__) && !__SSE2__
 	/* Andreas is fond of the gcc 2.95 MINGW but it lacks sse2 support */
-#	define sqLowLevelMFence() asm volatile (".byte 0x0f;.byte 0xae;.byte 0xf0")
-# elif defined(TARGET_OS_IS_IPHONE)
-#	define sqLowLevelMFence() __sync_synchronize()
-# else
-#	define sqLowLevelMFence() asm volatile ("mfence")
+#	 define sqLowLevelMFence() asm volatile (".byte 0x0f;.byte 0xae;.byte 0xf0")
+#	else
+#	 define sqLowLevelMFence() asm volatile ("mfence")
+#	endif
 # endif
-#else
-# if defined(TARGET_OS_IS_IPHONE) || (defined(__arm__) && (defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7A__)))
-#	define sqLowLevelMFence() __sync_synchronize()
-# elif !defined(sqLowLevelMFence)
+#endif
+
+#if !defined(sqLowLevelMFence)
 extern void sqLowLevelMFence(void);
-# endif
 #endif


Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
___________________________________________________________________
Modified: checkindate
   - Wed Dec 10 12:20:46 PST 2014
   + Wed Dec 10 15:24:58 PST 2014

Modified: branches/Cog/platforms/Cross/vm/sqVirtualMachine.c
===================================================================
--- branches/Cog/platforms/Cross/vm/sqVirtualMachine.c	2014-12-10 23:23:27 UTC (rev 3168)
+++ branches/Cog/platforms/Cross/vm/sqVirtualMachine.c	2014-12-10 23:25:38 UTC (rev 3169)
@@ -556,7 +556,7 @@
 		fprintf(stderr,"output file stack is full.\n");
 		return;
 	}
-	switch ((unsigned)filenameOrStdioIndex) {
+	switch ((unsigned long)filenameOrStdioIndex) {
 	case STDOUT_FILENO: output = stdout; break;
 	case STDERR_FILENO: output = stderr; break;
 	default:

Modified: branches/Cog/platforms/Mac OS/plugins/AsynchFilePlugin/sqMacAsyncFilePrims.c
===================================================================
--- branches/Cog/platforms/Mac OS/plugins/AsynchFilePlugin/sqMacAsyncFilePrims.c	2014-12-10 23:23:27 UTC (rev 3168)
+++ branches/Cog/platforms/Mac OS/plugins/AsynchFilePlugin/sqMacAsyncFilePrims.c	2014-12-10 23:25:38 UTC (rev 3169)
@@ -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, long fileNamePtr, int fileNameSize, int writeFlag, int semaIndex);
 int asyncFileRecordSize();
-int asyncFileReadResult(AsyncFile *f, int bufferPtr, int bufferSize);
+int asyncFileReadResult(AsyncFile *f, long 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, long 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, long 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, long 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:
@@ -340,7 +340,7 @@
 	return state->bytesTransferred;
 }
 
-int asyncFileWriteStart(AsyncFile *f, int fPosition, int bufferPtr, int bufferSize) {
+int asyncFileWriteStart(AsyncFile *f, int fPosition, long 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

Modified: branches/Cog/platforms/unix/plugins/AsynchFilePlugin/sqUnixAsynchFile.c
===================================================================
--- branches/Cog/platforms/unix/plugins/AsynchFilePlugin/sqUnixAsynchFile.c	2014-12-10 23:23:27 UTC (rev 3168)
+++ branches/Cog/platforms/unix/plugins/AsynchFilePlugin/sqUnixAsynchFile.c	2014-12-10 23:25:38 UTC (rev 3169)
@@ -182,7 +182,7 @@
 /*** public functions ***/
 
 
-int asyncFileOpen(AsyncFile *f, int fileNamePtr, int fileNameSize,
+int asyncFileOpen(AsyncFile *f, long fileNamePtr, int fileNameSize,
 		  int writeFlag, int semaIndex)
 {
   int fd= 0;
@@ -237,7 +237,7 @@
 }
 
 
-int asyncFileReadResult(AsyncFile *f, int bufferPtr, int bufferSize)
+int asyncFileReadResult(AsyncFile *f, long bufferPtr, int bufferSize)
 {
   FilePtr fp= 0;
   int n= 0;
@@ -331,7 +331,7 @@
 }
 
 
-int asyncFileWriteStart(AsyncFile *f, int fPosition, int bufferPtr, int count)
+int asyncFileWriteStart(AsyncFile *f, int fPosition, long bufferPtr, int count)
 {
   FilePtr fp= 0;
   validate(f);

Modified: branches/Cog/platforms/unix/plugins/DropPlugin/sqUnixDragDrop.c
===================================================================
--- branches/Cog/platforms/unix/plugins/DropPlugin/sqUnixDragDrop.c	2014-12-10 23:23:27 UTC (rev 3168)
+++ branches/Cog/platforms/unix/plugins/DropPlugin/sqUnixDragDrop.c	2014-12-10 23:25:38 UTC (rev 3169)
@@ -36,7 +36,6 @@
  * truth is very definitely not beauty today.  Sigh...
  */
 
-
 #include "sq.h"
 #include "sqVirtualMachine.h"
 #include "FilePlugin.h"
@@ -50,33 +49,31 @@
 extern char		     **uxDropFileNames;
 
 
-int dropInit(void)	{ return 1; }
-int dropShutdown(void)	{ return 1; }
+sqInt dropInit(void)     { return 1; }
+sqInt dropShutdown(void) { return 1; }
 
-char *dropRequestFileName(int dropIndex)	// in st coordinates
+char *dropRequestFileName(sqInt dropIndex)	// in st coordinates
 {
-  if ((dropIndex > 0) && (dropIndex <= uxDropFileCount))
-    {
-      assert(uxDropFileNames);
-      dndReceived(uxDropFileNames[dropIndex - 1]);
-      return uxDropFileNames[dropIndex - 1];
-    }
-  return 0;
+	if ((dropIndex > 0) && (dropIndex <= uxDropFileCount)) {
+		assert(uxDropFileNames);
+		dndReceived(uxDropFileNames[dropIndex - 1]);
+		return uxDropFileNames[dropIndex - 1];
+	}
+	return 0;
 }
 
-int dropRequestFileHandle(int dropIndex)
+sqInt dropRequestFileHandle(sqInt dropIndex)
 {
-  char *path= dropRequestFileName(dropIndex);
-  if (path)
-    {
-      // you cannot be serious?
-      int handle= instantiateClassindexableSize(classByteArray(), fileRecordSize());
-      sqFileOpen((SQFile *)fileValueOf(handle), (int)path, strlen(path), 0);
-      return handle;
-    }  
-  return interpreterProxy->nilObject();
+	char *path= dropRequestFileName(dropIndex);
+	if (path) {
+		// you cannot be serious?
+		sqInt handle = instantiateClassindexableSize(classByteArray(), fileRecordSize());
+		sqFileOpen((SQFile *)fileValueOf(handle), (int)path, strlen(path), 0);
+		return handle;
+	}  
+	return interpreterProxy->nilObject();
 }
 
-int  sqSecFileAccessCallback(void *callback)		 { return 0; }
-void sqSetNumberOfDropFiles(int numberOfFiles)		 { }
-void sqSetFileInformation(int dropIndex, void *dropFile) { }
+sqInt	sqSecFileAccessCallback(void *callback)               { return 0; }
+void	sqSetNumberOfDropFiles(sqInt numberOfFiles)           { }
+void	sqSetFileInformation(sqInt dropIndex, void *dropFile) { }

Modified: branches/Cog/platforms/unix/vm/sqUnixMain.c
===================================================================
--- branches/Cog/platforms/unix/vm/sqUnixMain.c	2014-12-10 23:23:27 UTC (rev 3168)
+++ branches/Cog/platforms/unix/vm/sqUnixMain.c	2014-12-10 23:25:38 UTC (rev 3169)
@@ -1957,7 +1957,7 @@
   return 0;
 }
 
-int ioExit(void) { return ioExitWithErrorCode(0); }
+sqInt ioExit(void) { return ioExitWithErrorCode(0); }
 
 sqInt
 ioExitWithErrorCode(int ec)

Modified: branches/Cog/platforms/unix/vm/sqUnixMain.h
===================================================================
--- branches/Cog/platforms/unix/vm/sqUnixMain.h	2014-12-10 23:23:27 UTC (rev 3168)
+++ branches/Cog/platforms/unix/vm/sqUnixMain.h	2014-12-10 23:25:38 UTC (rev 3169)
@@ -3,7 +3,7 @@
 
 extern char   imageName[];
 extern char   shortImageName[];
-extern int    inputEventSemaIndex;
+extern sqInt  inputEventSemaIndex;
 extern char   vmPath[];
 extern char  *exeName;
 extern char **argVec;

Modified: branches/Cog/platforms/win32/vm/sqWin32Stubs.c
===================================================================
--- branches/Cog/platforms/win32/vm/sqWin32Stubs.c	2014-12-10 23:23:27 UTC (rev 3168)
+++ branches/Cog/platforms/win32/vm/sqWin32Stubs.c	2014-12-10 23:25:38 UTC (rev 3169)
@@ -94,7 +94,7 @@
 
 #ifdef NO_ASYNC_FILES
 int asyncFileClose(AsyncFile *f) { return success(false); }
-int asyncFileOpen(AsyncFile *f, int fileNamePtr, int fileNameSize, int writeFlag, int semaIndex) { return success(false); }
+int asyncFileOpen(AsyncFile *f, long fileNamePtr, int fileNameSize, int writeFlag, int semaIndex) { return success(false); }
 int asyncFileRecordSize() { return success(false); }
 int asyncFileReadResult(AsyncFile *f, int bufferPtr, int bufferSize) { return success(false); }
 int asyncFileReadStart(AsyncFile *f, int fPosition, int count) { return success(false); }

Modified: branches/Cog/src/plugins/AsynchFilePlugin/AsynchFilePlugin.c
===================================================================
--- branches/Cog/src/plugins/AsynchFilePlugin/AsynchFilePlugin.c	2014-12-10 23:23:27 UTC (rev 3168)
+++ branches/Cog/src/plugins/AsynchFilePlugin/AsynchFilePlugin.c	2014-12-10 23:25:38 UTC (rev 3169)
@@ -1,9 +1,9 @@
 /* Automatically generated by
-	SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.963 uuid: 9df56221-18fd-4dcd-b93f-ae000bef62e5
+	SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.974 uuid: 7ca9044b-c2d1-4605-b2b6-2b8ffc66c096
    from
-	AsynchFilePlugin VMMaker.oscog-eem.963 uuid: 9df56221-18fd-4dcd-b93f-ae000bef62e5
+	AsynchFilePlugin VMMaker.oscog-eem.974 uuid: 7ca9044b-c2d1-4605-b2b6-2b8ffc66c096
  */
-static char __buildInfo[] = "AsynchFilePlugin VMMaker.oscog-eem.963 uuid: 9df56221-18fd-4dcd-b93f-ae000bef62e5 " __DATE__ ;
+static char __buildInfo[] = "AsynchFilePlugin VMMaker.oscog-eem.974 uuid: 7ca9044b-c2d1-4605-b2b6-2b8ffc66c096 " __DATE__ ;
 
 
 
@@ -38,6 +38,7 @@
 
 
 /*** Constants ***/
+#define PrimErrBadArgument 3
 
 
 /*** Function Prototypes ***/
@@ -63,6 +64,7 @@
 
 #if !defined(SQUEAK_BUILTIN_PLUGIN)
 static sqInt (*booleanValueOf)(sqInt obj);
+static sqInt (*byteSizeOf)(sqInt oop);
 static sqInt (*classByteArray)(void);
 static sqInt (*failed)(void);
 static void * (*firstIndexableField)(sqInt oop);
@@ -74,12 +76,14 @@
 static sqInt (*pop)(sqInt nItems);
 static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
 static sqInt (*primitiveFail)(void);
+static sqInt (*primitiveFailFor)(sqInt reasonCode);
 static sqInt (*slotSizeOf)(sqInt oop);
 static sqInt (*stackIntegerValue)(sqInt offset);
 static sqInt (*stackValue)(sqInt offset);
 static sqInt (*success)(sqInt aBoolean);
 #else /* !defined(SQUEAK_BUILTIN_PLUGIN) */
 extern sqInt booleanValueOf(sqInt obj);
+extern sqInt byteSizeOf(sqInt oop);
 extern sqInt classByteArray(void);
 extern sqInt failed(void);
 extern void * firstIndexableField(sqInt oop);
@@ -91,6 +95,7 @@
 extern sqInt pop(sqInt nItems);
 extern sqInt popthenPush(sqInt nItems, sqInt oop);
 extern sqInt primitiveFail(void);
+extern sqInt primitiveFailFor(sqInt reasonCode);
 extern sqInt slotSizeOf(sqInt oop);
 extern sqInt stackIntegerValue(sqInt offset);
 extern sqInt stackValue(sqInt offset);
@@ -100,9 +105,9 @@
 struct VirtualMachine* interpreterProxy;
 static const char *moduleName =
 #ifdef SQUEAK_BUILTIN_PLUGIN
-	"AsynchFilePlugin VMMaker.oscog-eem.963 (i)"
+	"AsynchFilePlugin VMMaker.oscog-eem.974 (i)"
 #else
-	"AsynchFilePlugin VMMaker.oscog-eem.963 (e)"
+	"AsynchFilePlugin VMMaker.oscog-eem.974 (e)"
 #endif
 ;
 static void * sCOAFfn;
@@ -110,17 +115,18 @@
 
 
 /*	Answer a pointer to the first byte of the async file record within the
-	given Smalltalk bytes object, or nil if oop is not an async file record.
- */
+	given Smalltalk bytes object, or fail and answer nil if oop is not an
+	async file record. */
 
 static AsyncFile *
 asyncFileValueOf(sqInt oop)
 {
-	success((isBytes(oop))
-	 && ((slotSizeOf(oop)) == (sizeof(AsyncFile))));
-	return (!(failed())
-		? ((AsyncFile *) (firstIndexableField(oop)))
-		: 0);
+	if ((isBytes(oop))
+	 && ((byteSizeOf(oop)) == (sizeof(AsyncFile)))) {
+		return ((AsyncFile *) (firstIndexableField(oop)));
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	return null;
 }
 
 
@@ -193,7 +199,15 @@
 	if (failed()) {
 		return null;
 	}
-	f = asyncFileValueOf(fh);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fh))
+	 && ((byteSizeOf(fh)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fh)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	asyncFileClose(f);
 	if (failed()) {
 		return null;
@@ -224,18 +238,26 @@
 	/* If the security plugin can be loaded, use it to check for permission.
 	   If not, assume it's ok */
 
-	fileNameSize = slotSizeOf(((sqInt)((fileName) - BaseHeaderSize)));
+	fileNameSize = byteSizeOf(((sqInt)((fileName) - BaseHeaderSize)));
 	if (sCOAFfn != 0) {
-		okToOpen =  ((sqInt (*) (char *, sqInt, sqInt)) sCOAFfn)(fileName, fileNameSize, writeFlag);
+		okToOpen = ((sqInt (*) (char *, sqInt, sqInt)) sCOAFfn)(fileName, fileNameSize, writeFlag);
 		if (!okToOpen) {
 			primitiveFail();
 			return null;
 		}
 	}
 	fOop = instantiateClassindexableSize(classByteArray(), sizeof(AsyncFile));
-	f = asyncFileValueOf(fOop);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fOop))
+	 && ((byteSizeOf(fOop)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fOop)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	if (!(failed())) {
-		asyncFileOpen(f, (int)fileName, fileNameSize, writeFlag, semaIndex);
+		asyncFileOpen(f, fileName, fileNameSize, writeFlag, semaIndex);
 	}
 	if (failed()) {
 		return null;
@@ -266,7 +288,15 @@
 	if (failed()) {
 		return null;
 	}
-	f = asyncFileValueOf(fhandle);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fhandle))
+	 && ((byteSizeOf(fhandle)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fhandle)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	count = num;
 	startIndex = start;
 
@@ -286,7 +316,7 @@
 
 	/* adjust for zero-origin indexing */
 
-	bufferPtr = ((((int) (firstIndexableField(buffer)))) + startIndex) - 1;
+	bufferPtr = ((((sqInt) (firstIndexableField(buffer)))) + startIndex) - 1;
 	if (!(failed())) {
 		r = asyncFileReadResult(f, bufferPtr, count);
 	}
@@ -312,7 +342,15 @@
 	if (failed()) {
 		return null;
 	}
-	f = asyncFileValueOf(fHandle);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fHandle))
+	 && ((byteSizeOf(fHandle)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fHandle)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	asyncFileReadStart(f, fPosition, count);
 	if (failed()) {
 		return null;
@@ -333,7 +371,15 @@
 	if (failed()) {
 		return null;
 	}
-	f = asyncFileValueOf(fHandle);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fHandle))
+	 && ((byteSizeOf(fHandle)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fHandle)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	r =  asyncFileWriteResult(f);
 	_return_value = integerObjectOf(r);
 	if (failed()) {
@@ -365,7 +411,15 @@
 	if (failed()) {
 		return null;
 	}
-	f = asyncFileValueOf(fHandle);
+	/* begin asyncFileValueOf: */
+	if ((isBytes(fHandle))
+	 && ((byteSizeOf(fHandle)) == (sizeof(AsyncFile)))) {
+		f = ((AsyncFile *) (firstIndexableField(fHandle)));
+		goto l1;
+	}
+	primitiveFailFor(PrimErrBadArgument);
+	f = null;
+l1:	/* end asyncFileValueOf: */;
 	if (failed()) {
 		return null;
 	}
@@ -388,7 +442,7 @@
 
 	/* adjust for zero-origin indexing */
 
-	bufferPtr = ((((int) (firstIndexableField(buffer)))) + startIndex) - 1;
+	bufferPtr = ((((sqInt) (firstIndexableField(buffer)))) + startIndex) - 1;
 	if (!(failed())) {
 		asyncFileWriteStart(f, fPosition, bufferPtr, count);
 	}
@@ -414,6 +468,7 @@
 		
 #if !defined(SQUEAK_BUILTIN_PLUGIN)
 		booleanValueOf = interpreterProxy->booleanValueOf;
+		byteSizeOf = interpreterProxy->byteSizeOf;
 		classByteArray = interpreterProxy->classByteArray;
 		failed = interpreterProxy->failed;
 		firstIndexableField = interpreterProxy->firstIndexableField;
@@ -425,6 +480,7 @@
 		pop = interpreterProxy->pop;
 		popthenPush = interpreterProxy->popthenPush;
 		primitiveFail = interpreterProxy->primitiveFail;
+		primitiveFailFor = interpreterProxy->primitiveFailFor;
 		slotSizeOf = interpreterProxy->slotSizeOf;
 		stackIntegerValue = interpreterProxy->stackIntegerValue;
 		stackValue = interpreterProxy->stackValue;
@@ -456,11 +512,11 @@
 	{"AsynchFilePlugin", "getModuleName", (void*)getModuleName},
 	{"AsynchFilePlugin", "initialiseModule", (void*)initialiseModule},
 	{"AsynchFilePlugin", "moduleUnloaded", (void*)moduleUnloaded},
-	{"AsynchFilePlugin", "primitiveAsyncFileClose\000\001", (void*)primitiveAsyncFileClose},
+	{"AsynchFilePlugin", "primitiveAsyncFileClose\000\000", (void*)primitiveAsyncFileClose},
 	{"AsynchFilePlugin", "primitiveAsyncFileOpen\000\000", (void*)primitiveAsyncFileOpen},
 	{"AsynchFilePlugin", "primitiveAsyncFileReadResult\000\001", (void*)primitiveAsyncFileReadResult},
-	{"AsynchFilePlugin", "primitiveAsyncFileReadStart\000\001", (void*)primitiveAsyncFileReadStart},
-	{"AsynchFilePlugin", "primitiveAsyncFileWriteResult\000\001", (void*)primitiveAsyncFileWriteResult},
+	{"AsynchFilePlugin", "primitiveAsyncFileReadStart\000\000", (void*)primitiveAsyncFileReadStart},
+	{"AsynchFilePlugin", "primitiveAsyncFileWriteResult\000\000", (void*)primitiveAsyncFileWriteResult},
 	{"AsynchFilePlugin", "primitiveAsyncFileWriteStart\000\001", (void*)primitiveAsyncFileWriteStart},
 	{"AsynchFilePlugin", "setInterpreter", (void*)setInterpreter},
 	{"AsynchFilePlugin", "shutdownModule\000\377", (void*)shutdownModule},
@@ -469,11 +525,11 @@
 
 #else /* ifdef SQ_BUILTIN_PLUGIN */
 
-signed char primitiveAsyncFileCloseAccessorDepth = 1;
+signed char primitiveAsyncFileCloseAccessorDepth = 0;
 signed char primitiveAsyncFileOpenAccessorDepth = 0;
 signed char primitiveAsyncFileReadResultAccessorDepth = 1;
-signed char primitiveAsyncFileReadStartAccessorDepth = 1;
-signed char primitiveAsyncFileWriteResultAccessorDepth = 1;
+signed char primitiveAsyncFileReadStartAccessorDepth = 0;
+signed char primitiveAsyncFileWriteResultAccessorDepth = 0;
 signed char primitiveAsyncFileWriteStartAccessorDepth = 1;
 
 #endif /* ifdef SQ_BUILTIN_PLUGIN */



More information about the Vm-dev mailing list