mingw 64bit fixes (xxLL in constants - sigh)
authorClaus Gittinger <cg@exept.de>
Fri, 11 Mar 2016 15:24:01 +0100
changeset 19341 2ab29dd7ec1a
parent 19340 2e2523f386df
child 19342 3afa63c8dcae
mingw 64bit fixes (xxLL in constants - sigh)
AbstractOperatingSystem.st
ExternalLibraryFunction.st
--- a/AbstractOperatingSystem.st	Fri Mar 11 14:52:48 2016 +0100
+++ b/AbstractOperatingSystem.st	Fri Mar 11 15:24:01 2016 +0100
@@ -909,15 +909,15 @@
 shuffleAllFrom:anInStream to:anOutStream lineWise:lineWise lockWith:aLock
 
     lineWise ifFalse:[
-        ^ anInStream copyToEndInto:anOutStream.
+	^ anInStream copyToEndInto:anOutStream.
     ].
     [anInStream isOpen and:[anInStream atEnd not]] whileTrue:[
-        aLock critical:[
-            self
-                shuffleFrom:anInStream
-                to:anOutStream
-                lineWise:lineWise
-        ]
+	aLock critical:[
+	    self
+		shuffleFrom:anInStream
+		to:anOutStream
+		lineWise:lineWise
+	]
     ]
 !
 
@@ -1339,244 +1339,244 @@
     terminateLock := Semaphore forMutualExclusion.
     ((externalInStream := anInStream) notNil
      and:[externalInStream isExternalStream not]) ifTrue:[
-        pIn := NonPositionableExternalStream makePipe.
-        inStreamToClose := externalInStream := pIn at:1.
-        shuffledInStream := pIn at:2.
-        anInStream isBinary ifTrue:[
-            shuffledInStream binary
-        ].
-        lineWise ifFalse:[
-            shuffledInStream blocking:false.
-        ].
-
-        "/ start a reader process, shuffling data from the given
-        "/ inStream to the pipe (which is connected to the commands input)
-        inputShufflerProcess :=
-            [
-                [
-                    [anInStream atEnd] whileFalse:[
-                        self shuffleFrom:anInStream to:shuffledInStream lineWise:lineWise.
-                        shuffledInStream flush
-                    ]
-                ] ensure:[
-                    shuffledInStream close
-                ]
-            ] newProcess
-                name:'cmd input shuffler';
+	pIn := NonPositionableExternalStream makePipe.
+	inStreamToClose := externalInStream := pIn at:1.
+	shuffledInStream := pIn at:2.
+	anInStream isBinary ifTrue:[
+	    shuffledInStream binary
+	].
+	lineWise ifFalse:[
+	    shuffledInStream blocking:false.
+	].
+
+	"/ start a reader process, shuffling data from the given
+	"/ inStream to the pipe (which is connected to the commands input)
+	inputShufflerProcess :=
+	    [
+		[
+		    [anInStream atEnd] whileFalse:[
+			self shuffleFrom:anInStream to:shuffledInStream lineWise:lineWise.
+			shuffledInStream flush
+		    ]
+		] ensure:[
+		    shuffledInStream close
+		]
+	    ] newProcess
+		name:'cmd input shuffler';
 "/                beSystemProcess;
-                resume.
+		resume.
     ].
     ((externalOutStream := anOutStream) notNil
      and:[externalOutStream isExternalStream not]) ifTrue:[
-        pOut := NonPositionableExternalStream makePipe.
-        shuffledOutStream := (pOut at:1).
-        anOutStream isBinary ifTrue:[
-            shuffledOutStream binary
-        ].
-        outStreamToClose := externalOutStream := pOut at:2.
-        outputShufflerProcess :=
-            [
-                WriteError handle:[:ex |
-                    "/ ignored
-                ] do:[
-                    self shuffleAllFrom:shuffledOutStream to:anOutStream lineWise:lineWise lockWith:terminateLock.
-                ].
-            ] newProcess
-                priority:(Processor userSchedulingPriority "+ 1");
-                name:'cmd output shuffler';
+	pOut := NonPositionableExternalStream makePipe.
+	shuffledOutStream := (pOut at:1).
+	anOutStream isBinary ifTrue:[
+	    shuffledOutStream binary
+	].
+	outStreamToClose := externalOutStream := pOut at:2.
+	outputShufflerProcess :=
+	    [
+		WriteError handle:[:ex |
+		    "/ ignored
+		] do:[
+		    self shuffleAllFrom:shuffledOutStream to:anOutStream lineWise:lineWise lockWith:terminateLock.
+		].
+	    ] newProcess
+		priority:(Processor userSchedulingPriority "+ 1");
+		name:'cmd output shuffler';
 "/                beSystemProcess;
-                resume.
+		resume.
     ].
     (externalErrStream := anErrStream) notNil ifTrue:[
-        anErrStream == anOutStream ifTrue:[
-            externalErrStream := externalOutStream
-        ] ifFalse:[
-            anErrStream isExternalStream ifFalse:[
-                pErr := NonPositionableExternalStream makePipe.
-                shuffledErrStream := (pErr at:1).
-                anErrStream isBinary ifTrue:[
-                    shuffledErrStream binary
-                ].
-                errStreamToClose := externalErrStream := pErr at:2.
-                errorShufflerProcess :=
-                    [
-                        self shuffleAllFrom:shuffledErrStream to:anErrStream lineWise:lineWise lockWith:terminateLock.
-                    ] newProcess
-                        priority:(Processor userSchedulingPriority + 1);
-                        name:'cmd err-output shuffler';
+	anErrStream == anOutStream ifTrue:[
+	    externalErrStream := externalOutStream
+	] ifFalse:[
+	    anErrStream isExternalStream ifFalse:[
+		pErr := NonPositionableExternalStream makePipe.
+		shuffledErrStream := (pErr at:1).
+		anErrStream isBinary ifTrue:[
+		    shuffledErrStream binary
+		].
+		errStreamToClose := externalErrStream := pErr at:2.
+		errorShufflerProcess :=
+		    [
+			self shuffleAllFrom:shuffledErrStream to:anErrStream lineWise:lineWise lockWith:terminateLock.
+		    ] newProcess
+			priority:(Processor userSchedulingPriority + 1);
+			name:'cmd err-output shuffler';
 "/                        beSystemProcess;
-                        resume.
-            ]
-        ]
+			resume.
+	    ]
+	]
     ].
     ((externalAuxStream := anAuxStream) notNil
      and:[externalAuxStream isExternalStream not]) ifTrue:[
-        pAux := NonPositionableExternalStream makePipe.
-        auxStreamToClose := externalAuxStream := pAux at:1.
-        shuffledAuxStream := pAux at:2.
-        shuffledAuxStream blocking:false.
-        anAuxStream isBinary ifTrue:[
-            shuffledAuxStream binary
-        ].
-
-        "/ start a reader process, shuffling data from the given
-        "/ auxStream to the pipe (which is connected to the commands aux)
-        auxShufflerProcess :=
-            [
-                [
-                    [anAuxStream atEnd] whileFalse:[
-                        self shuffleFrom:anAuxStream to:shuffledAuxStream lineWise:false.
-                        shuffledAuxStream flush
-                    ]
-                ] ensure:[
-                    shuffledAuxStream close
-                ]
-            ] newProcess
-                name:'cmd aux shuffler';
+	pAux := NonPositionableExternalStream makePipe.
+	auxStreamToClose := externalAuxStream := pAux at:1.
+	shuffledAuxStream := pAux at:2.
+	shuffledAuxStream blocking:false.
+	anAuxStream isBinary ifTrue:[
+	    shuffledAuxStream binary
+	].
+
+	"/ start a reader process, shuffling data from the given
+	"/ auxStream to the pipe (which is connected to the commands aux)
+	auxShufflerProcess :=
+	    [
+		[
+		    [anAuxStream atEnd] whileFalse:[
+			self shuffleFrom:anAuxStream to:shuffledAuxStream lineWise:false.
+			shuffledAuxStream flush
+		    ]
+		] ensure:[
+		    shuffledAuxStream close
+		]
+	    ] newProcess
+		name:'cmd aux shuffler';
 "/                beSystemProcess;
-                resume.
+		resume.
     ].
 
     stopShufflers := [:shuffleRest |
-            inputShufflerProcess notNil ifTrue:[
-                terminateLock critical:[inputShufflerProcess terminate].
-                inputShufflerProcess waitUntilTerminated
-            ].
-            auxShufflerProcess notNil ifTrue:[
-                terminateLock critical:[auxShufflerProcess terminate].
-                auxShufflerProcess waitUntilTerminated
-            ].
-            outputShufflerProcess notNil ifTrue:[
-                terminateLock critical:[outputShufflerProcess terminate].
-                outputShufflerProcess waitUntilTerminated.
-                shuffleRest ifTrue:[ self shuffleRestFrom:shuffledOutStream to:anOutStream lineWise:lineWise ].
-                shuffledOutStream close.
-            ].
-            errorShufflerProcess notNil ifTrue:[
-                terminateLock critical:[errorShufflerProcess terminate].
-                errorShufflerProcess waitUntilTerminated.
-                shuffleRest ifTrue:[ self shuffleRestFrom:shuffledErrStream to:anErrStream lineWise:lineWise ].
-                shuffledErrStream close.
-            ].
-        ].
+	    inputShufflerProcess notNil ifTrue:[
+		terminateLock critical:[inputShufflerProcess terminate].
+		inputShufflerProcess waitUntilTerminated
+	    ].
+	    auxShufflerProcess notNil ifTrue:[
+		terminateLock critical:[auxShufflerProcess terminate].
+		auxShufflerProcess waitUntilTerminated
+	    ].
+	    outputShufflerProcess notNil ifTrue:[
+		terminateLock critical:[outputShufflerProcess terminate].
+		outputShufflerProcess waitUntilTerminated.
+		shuffleRest ifTrue:[ self shuffleRestFrom:shuffledOutStream to:anOutStream lineWise:lineWise ].
+		shuffledOutStream close.
+	    ].
+	    errorShufflerProcess notNil ifTrue:[
+		terminateLock critical:[errorShufflerProcess terminate].
+		errorShufflerProcess waitUntilTerminated.
+		shuffleRest ifTrue:[ self shuffleRestFrom:shuffledErrStream to:anErrStream lineWise:lineWise ].
+		shuffledErrStream close.
+	    ].
+	].
 
     closeStreams := [
-            inStreamToClose notNil ifTrue:[
-                inStreamToClose close
-            ].
-            errStreamToClose notNil ifTrue:[
-                errStreamToClose close
-            ].
-            outStreamToClose notNil ifTrue:[
-                outStreamToClose close
-            ].
-            auxStreamToClose notNil ifTrue:[
-                auxStreamToClose close
-            ].
-            nullStream notNil ifTrue:[
-                nullStream close
-            ].
-        ].
+	    inStreamToClose notNil ifTrue:[
+		inStreamToClose close
+	    ].
+	    errStreamToClose notNil ifTrue:[
+		errStreamToClose close
+	    ].
+	    outStreamToClose notNil ifTrue:[
+		outStreamToClose close
+	    ].
+	    auxStreamToClose notNil ifTrue:[
+		auxStreamToClose close
+	    ].
+	    nullStream notNil ifTrue:[
+		nullStream close
+	    ].
+	].
 
 
     sema := Semaphore new name:'OS command wait'.
     [
-        externalInStream isNil ifTrue:[
-            externalInStream := nullStream := Filename nullDevice readWriteStream.
-        ].
-        externalOutStream isNil ifTrue:[
-            nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
-            externalOutStream := nullStream.
-        ].
-        externalErrStream isNil ifTrue:[
-            externalErrStream := externalOutStream
-        ].
-
-        pid := Processor
-                    monitor:[
-                        self
-                            startProcess:aCommandStringOrArray
-                            inputFrom:externalInStream
-                            outputTo:externalOutStream
-                            errorTo:externalErrStream
-                            auxFrom:externalAuxStream
-                            environment:environmentDictionary
-                            inDirectory:dirOrNil
-                    ]
-                    action:[:status |
-                        status stillAlive ifFalse:[
-                            exitStatus := status.
-                            sema signal.
-                            self closePid:pid
-                        ]
-                    ].
-
-        pid isNil ifTrue:[
-            exitStatus := self osProcessStatusClass processCreationFailure
-        ] ifFalse:[
-            sema wait.
-        ].
+	externalInStream isNil ifTrue:[
+	    externalInStream := nullStream := Filename nullDevice readWriteStream.
+	].
+	externalOutStream isNil ifTrue:[
+	    nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
+	    externalOutStream := nullStream.
+	].
+	externalErrStream isNil ifTrue:[
+	    externalErrStream := externalOutStream
+	].
+
+	pid := Processor
+		    monitor:[
+			self
+			    startProcess:aCommandStringOrArray
+			    inputFrom:externalInStream
+			    outputTo:externalOutStream
+			    errorTo:externalErrStream
+			    auxFrom:externalAuxStream
+			    environment:environmentDictionary
+			    inDirectory:dirOrNil
+		    ]
+		    action:[:status |
+			status stillAlive ifFalse:[
+			    exitStatus := status.
+			    sema signal.
+			    self closePid:pid
+			]
+		    ].
+
+	pid isNil ifTrue:[
+	    exitStatus := self osProcessStatusClass processCreationFailure
+	] ifFalse:[
+	    sema wait.
+	].
     ] ifCurtailed:[
-        closeStreams value.
-        pid notNil ifTrue:[
-            "/ terminate the os-command (and all of its forked commands)
-            self terminateProcessGroup:pid.
-            self terminateProcess:pid.
-            self closePid:pid.
-        ].
-        stopShufflers value:false.
+	closeStreams value.
+	pid notNil ifTrue:[
+	    "/ terminate the os-command (and all of its forked commands)
+	    self terminateProcessGroup:pid.
+	    self terminateProcess:pid.
+	    self closePid:pid.
+	].
+	stopShufflers value:false.
     ].
 
     closeStreams value.
     stopShufflers value:true.
     (exitStatus isNil or:[exitStatus success]) ifFalse:[
-        ^ aBlock value:exitStatus
+	^ aBlock value:exitStatus
     ].
     ^ true
 
     "
-        |outStream errStream|
-
-        outStream := '' writeStream.
-
-        OperatingSystem executeCommand:'ls -l'
-                        inputFrom:'abc' readStream
-                        outputTo:outStream
-                        errorTo:nil
-                        inDirectory:nil
-                        lineWise:true
-                        onError:[:exitStatus | ^ false].
-        outStream contents
-    "
-
-    "
-        |outStream errStream|
-
-        outStream := #[] writeStream.
-
-        OperatingSystem executeCommand:'cat'
-                        inputFrom:(ByteArray new:5000000) readStream
-                        outputTo:outStream
-                        errorTo:nil
-                        inDirectory:nil
-                        lineWise:false
-                        onError:[:exitStatus | ^ false].
-        outStream size
-    "
-
-    "
-        |outStream errStream|
-
-        outStream := '' writeStream.
-
-        OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd'
-                        inputFrom:'bla' readStream
-                        outputTo:outStream
-                        errorTo:nil
-                        inDirectory:nil
-                        lineWise:true
-                        onError:[:exitStatus |  false].
-        outStream contents
+	|outStream errStream|
+
+	outStream := '' writeStream.
+
+	OperatingSystem executeCommand:'ls -l'
+			inputFrom:'abc' readStream
+			outputTo:outStream
+			errorTo:nil
+			inDirectory:nil
+			lineWise:true
+			onError:[:exitStatus | ^ false].
+	outStream contents
+    "
+
+    "
+	|outStream errStream|
+
+	outStream := #[] writeStream.
+
+	OperatingSystem executeCommand:'cat'
+			inputFrom:(ByteArray new:5000000) readStream
+			outputTo:outStream
+			errorTo:nil
+			inDirectory:nil
+			lineWise:false
+			onError:[:exitStatus | ^ false].
+	outStream size
+    "
+
+    "
+	|outStream errStream|
+
+	outStream := '' writeStream.
+
+	OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd'
+			inputFrom:'bla' readStream
+			outputTo:outStream
+			errorTo:nil
+			inDirectory:nil
+			lineWise:true
+			onError:[:exitStatus |  false].
+	outStream contents
     "
 
     "Modified: / 11-02-2007 / 20:54:39 / cg"
@@ -6037,7 +6037,7 @@
     unsigned INT low, high;
 
 #ifdef __x86_64__
-# if defined(__GCC__)
+# if defined(__GCC__) || defined(__CLANG__) || defined(__MINGW64__)
     asm volatile("rdtsc" : "=a"(low), "=d"(high));
     RETURN ( __MKUINT(low + (high << 32)) );
 # endif
@@ -6053,7 +6053,7 @@
     _asm { mov high,edx };
     _asm { pop edx };
 # else
-#  if defined(__MINGW_H) || defined(__GNUC__)
+#  if defined(__MINGW_H) || defined(__MINGW32__) || defined(__GNUC__)
     asm volatile("rdtsc" : "=a"(low), "=d"(high));
 #  else
     goto unsupported;
@@ -6783,18 +6783,18 @@
     |result fdArray|
 
     self supportsSelect ifFalse:[
-        "/ mhmh - what should we do then ?
-        "/ For now, return true as if data was present,
-        "/ and let the thread fall into the write.
-        "/ It will then (hopefully) be desceduled there and
-        "/ effectively polling for output.
-        ^ true
+	"/ mhmh - what should we do then ?
+	"/ For now, return true as if data was present,
+	"/ and let the thread fall into the write.
+	"/ It will then (hopefully) be desceduled there and
+	"/ effectively polling for output.
+	^ true
     ].
 
     result := self
-                selectOnAnyReadable:nil writable:(fdArray := Array with:fd) exception:fdArray
-                readableInto:nil writableInto:nil exceptionInto:nil
-                withTimeOut:0.
+		selectOnAnyReadable:nil writable:(fdArray := Array with:fd) exception:fdArray
+		readableInto:nil writableInto:nil exceptionInto:nil
+		withTimeOut:0.
 
     "on select error, a read will immediately return, so answer true"
     ^ result > 0.
--- a/ExternalLibraryFunction.st	Fri Mar 11 14:52:48 2016 +0100
+++ b/ExternalLibraryFunction.st	Fri Mar 11 15:24:01 2016 +0100
@@ -873,7 +873,7 @@
      For cplusplus, aReceiverOrNil is required to be an externalStructure like object;
      for objectiveC, it must be an ObjectiveC object"
 
-    |argTypeSymbols returnTypeSymbol failureCode failureInfo returnValue stClass vtOffset
+    |argTypeSymbols returnTypeSymbol failureCode failureArgNr failureInfo returnValue stClass vtOffset
      virtual objectiveC async unlimitedStack callTypeNumber returnValueClass argValueClass
      oldReturnType oldArgumentTypes|
 
@@ -959,14 +959,14 @@
     void *__returnValuePointer;
     int __numArgs, __numArgsIncludingThis;
     static INT null = 0;
-    int i;
+    int i = -1;
     ffi_abi __callType = FFI_DEFAULT_ABI;
     VOIDFUNC codeAddress = (VOIDFUNC)__INST(code_);
     int __numArgsWanted;
 
 #   define __FAIL__(fcode) \
     { \
-	failureCode = fcode; goto getOutOfHere; \
+	failureCode = fcode; failureArgNr = __mkSmallInteger(i+1); goto getOutOfHere; \
     }
 
     if (argumentsOrNil == nil) {
@@ -1178,6 +1178,11 @@
 	    } else {
 		__argValues[i].iVal = __signedLongIntVal(arg);
 		if (__argValues[i].iVal == 0) {
+# ifdef VERBOSE
+			if (@global(Verbose) == true) {
+			    printf("invalidArgument: arg%d sint value out of range [%d]\n", i+1, __LINE__);
+			}
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
@@ -1191,6 +1196,11 @@
 	    } else {
 		__argValues[i].iVal = __unsignedLongIntVal(arg);
 		if (__argValues[i].iVal == 0) {
+# ifdef VERBOSE
+			if (@global(Verbose) == true) {
+			    printf("invalidArgument: arg%d uint value out of range [%d]\n", i+1, __LINE__);
+			}
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
@@ -1199,10 +1209,20 @@
 	} else if (typeSymbol == @symbol(uint8)) {
 	    thisType = __get_ffi_type_uint8();
 	    if (! __isSmallInteger(arg)) {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    __argValues[i].iVal = __intVal(arg);
 	    if (((unsigned)(__argValues[i].iVal)) > 0xFF) {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    argValuePtr = &(__argValues[i].iVal);
@@ -1210,10 +1230,20 @@
 	} else if (typeSymbol == @symbol(sint8)) {
 	    thisType = __get_ffi_type_sint8();
 	    if (! __isSmallInteger(arg)) {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    __argValues[i].iVal = __intVal(arg);
 	    if (((__argValues[i].iVal) < -0x80) || ((__argValues[i].iVal) > 0x7F))  {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    argValuePtr = &(__argValues[i].iVal);
@@ -1221,10 +1251,20 @@
 	} else if (typeSymbol == @symbol(uint16)) {
 	    thisType = __get_ffi_type_uint16();
 	    if (! __isSmallInteger(arg)) {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    __argValues[i].iVal = __intVal(arg);
 	    if (((unsigned)(__argValues[i].iVal)) > 0xFFFF) {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    argValuePtr = &(__argValues[i].iVal);
@@ -1232,10 +1272,20 @@
 	} else if (typeSymbol == @symbol(sint16)) {
 	    thisType = __get_ffi_type_sint16();
 	    if (! __isSmallInteger(arg)) {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    __argValues[i].iVal = __intVal(arg);
 	    if (((__argValues[i].iVal) < -0x8000) || ((__argValues[i].iVal) > 0x7FFF))  {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    argValuePtr = &(__argValues[i].iVal);
@@ -1247,11 +1297,21 @@
 	    } else {
 		__argValues[i].iVal = __unsignedLongIntVal(arg);
 		if (__argValues[i].iVal == 0) {
+# ifdef VERBOSE
+		    if (@global(Verbose) == true) {
+			printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__);
+		    }
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
 # if __POINTER_SIZE__ == 8
 	    if ((__argValues[i].iVal) < 0)  {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 # endif
@@ -1264,11 +1324,21 @@
 	    } else {
 		__argValues[i].iVal = __signedLongIntVal(arg);
 		if (__argValues[i].iVal == 0) {
+# ifdef VERBOSE
+		    if (@global(Verbose) == true) {
+			printf("invalidArgument: arg%d sint32 value out of range [%d]\n", i+1, __LINE__);
+		    }
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
 # if __POINTER_SIZE__ == 8
-	    if (((__argValues[i].iVal) < -0x80000000) || ((__argValues[i].iVal) > 0x7FFFFFFF))  {
+	    if (((__argValues[i].iVal) < -0x80000000LL) || ((__argValues[i].iVal) > 0x7FFFFFFFLL))  {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d sint32 value (%"_lx_") out of range [%d]\n", i+1, __argValues[i].iVal, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 # endif
@@ -1281,23 +1351,28 @@
 	    } else {
 		__argValues[i].iVal = __unsignedLongIntVal(arg);
 		if (__argValues[i].iVal == 0) {
+# ifdef VERBOSE
+		    if (@global(Verbose) == true) {
+			printf("invalidArgument: arg%d uint64 value out of range [%d]\n", i+1, __LINE__);
+		    }
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
-# if __POINTER_SIZE__ == 8
-	    if ((__argValues[i].iVal) < 0)  {
-		__FAIL__(@symbol(InvalidArgument))
-	    }
-# endif
 	    argValuePtr = &(__argValues[i].iVal);
 
 	 } else if (typeSymbol == @symbol(sint64)) {
-	    thisType = __get_ffi_type_uint64();
+	    thisType = __get_ffi_type_sint64();
 	    if (__isSmallInteger(arg)) {
 		__argValues[i].iVal = __intVal(arg);
 	    } else {
 		__argValues[i].iVal = __signedLongIntVal(arg);
 		if (__argValues[i].iVal == 0) {
+# ifdef VERBOSE
+		    if (@global(Verbose) == true) {
+			printf("invalidArgument: arg%d sint64 value out of range [%d]\n", i+1, __LINE__);
+		    }
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
@@ -1312,6 +1387,11 @@
 	    } else if (__isShortFloat(arg)) {
 		__argValues[i].fVal = (float)(__shortFloatVal(arg));
 	    } else {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d non float value [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    argValuePtr = &(__argValues[i].fVal);
@@ -1325,6 +1405,11 @@
 	    } else if (__isShortFloat(arg)) {
 		__argValues[i].dVal = (double)(__shortFloatVal(arg));
 	    } else {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d non double value [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    argValuePtr = &(__argValues[i].dVal);
@@ -1349,6 +1434,11 @@
 		if (arg == nil) {
 		    __argValues[i].pointerVal = (void *)0;
 		} else {
+# ifdef VERBOSE
+		    if (@global(Verbose) == true) {
+			printf("invalidArgument: arg%d non charPointer value [%d]\n", i+1, __LINE__);
+		    }
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
@@ -1370,6 +1460,11 @@
 		if (arg == nil) {
 		    __argValues[i].pointerVal = (void *)0;
 		} else {
+# ifdef VERBOSE
+		    if (@global(Verbose) == true) {
+			printf("invalidArgument: arg%d non wcharPointer value [%d]\n", i+1, __LINE__);
+		    }
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
@@ -1398,6 +1493,11 @@
 		if (arg == nil) {
 		    __argValues[i].pointerVal = (void *)0;
 		} else {
+# ifdef VERBOSE
+		    if (@global(Verbose) == true) {
+			printf("invalidArgument: arg%d non floatPointer value [%d]\n", i+1, __LINE__);
+		    }
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
@@ -1433,6 +1533,11 @@
 		if (arg == nil) {
 		    __argValues[i].pointerVal = (void *)0;
 		} else {
+# ifdef VERBOSE
+		    if (@global(Verbose) == true) {
+			printf("invalidArgument: arg%d non doublePointer value [%d]\n", i+1, __LINE__);
+		    }
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
@@ -1463,6 +1568,11 @@
 	    } else if (__isStringLike(arg)) {
 		if (async == true) {
 badArgForAsyncCall: ;
+# ifdef VERBOSE
+		    if (@global(Verbose) == true) {
+			printf("invalidArgument: arg%d not allowed for async call [%d]\n", i+1, __LINE__);
+		    }
+# endif
 		    __FAIL__(@symbol(BadArgForAsyncCall))
 		}
 		__argValues[i].pointerVal = (void *)(__stringVal(arg));
@@ -1476,6 +1586,11 @@
 		nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
 		__argValues[i].pointerVal = p + nInstBytes;
 	    } else {
+# ifdef VERBOSE
+		if (@global(Verbose) == true) {
+		    printf("invalidArgument: arg%d non pointer value [%d]\n", i+1, __LINE__);
+		}
+# endif
 		__FAIL__(@symbol(InvalidArgument))
 	    }
 	    argValuePtr = &(__argValues[i].pointerVal);;
@@ -1492,6 +1607,11 @@
 	    } else {
 		__argValues[i].iVal = __unsignedLongIntVal(arg);
 		if (__argValues[i].iVal == 0) {
+# ifdef VERBOSE
+		    if (@global(Verbose) == true) {
+			printf("invalidArgument: arg%d non bool value [%d]\n", i+1, __LINE__);
+		    }
+# endif
 		    __FAIL__(@symbol(InvalidArgument))
 		}
 	    }
@@ -1516,7 +1636,7 @@
 
 # ifdef VERBOSE
 	if (@global(Verbose) == true) {
-	    printf("arg%d: %"_lx_" type:%d\n", i, (INT)(__argValues[i].iVal), thisType);
+	    printf("arg%d: %"_lx_" type:%"_lx_"\n", i+1, (INT)(__argValues[i].iVal), (INT)thisType);
 	}
 # endif
     }