--- a/ExternalLibraryFunction.st Mon Mar 14 08:45:36 2016 +0000
+++ b/ExternalLibraryFunction.st Tue Mar 15 07:14:51 2016 +0000
@@ -653,45 +653,45 @@
|handle moduleNameUsed functionName|
name isNumber ifTrue:[
- self isCPPFunction ifTrue:[
- "/ no need to load a dll.
- ^ self
- ]
+ self isCPPFunction ifTrue:[
+ "/ no need to load a dll.
+ ^ self
+ ]
].
"/ in some other smalltalks, there is no moduleName in the ffi-spec;
"/ instead, the class provides the libraryName...
(moduleNameUsed := moduleName) isNil ifTrue:[
- owningClass isNil ifTrue:[
- self error:'Missing moduleName'.
- ].
- moduleNameUsed := owningClass theNonMetaclass libraryName asSymbol.
+ owningClass isNil ifTrue:[
+ self error:'Missing moduleName'.
+ ].
+ moduleNameUsed := owningClass theNonMetaclass libraryName asSymbol.
].
moduleHandle isNil ifTrue:[
- "/ speedup. in 95% of all calls, the same moduleName is resolved here
- (LastModuleHandleHolder isNil
- or:[ (handle := LastModuleHandleHolder at:1) isNil
- or:[ LastModuleHandleName ~= moduleNameUsed ]]) ifTrue:[
+ "/ speedup. in 95% of all calls, the same moduleName is resolved here
+ (LastModuleHandleHolder isNil
+ or:[ (handle := LastModuleHandleHolder at:1) isNil
+ or:[ LastModuleHandleName ~= moduleNameUsed ]]) ifTrue:[
- handle := self loadLibrary:moduleNameUsed.
- handle isNil ifTrue:[
- self error:('Cannot find or load dll/module: "%1"' bindWith: moduleNameUsed).
- ].
- LastModuleHandleHolder := WeakArray with:handle.
- LastModuleHandleName := moduleNameUsed.
- ].
- moduleHandle := handle.
+ handle := self loadLibrary:moduleNameUsed.
+ handle isNil ifTrue:[
+ self error:('Cannot find or load dll/module: "%1"' bindWith: moduleNameUsed).
+ ].
+ LastModuleHandleHolder := WeakArray with:handle.
+ LastModuleHandleName := moduleNameUsed.
+ ].
+ moduleHandle := handle.
].
name isNumber ifFalse:[
- functionName := name.
- (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
- functionName := ('_', functionName) asSymbol.
+ functionName := name.
+ (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
+ functionName := ('_', functionName) asSymbol.
- (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
- moduleHandle := nil.
- self error:'Missing function: ', name, ' in module: ', moduleNameUsed.
- ].
- ].
+ (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
+ moduleHandle := nil.
+ self error:'Missing function: ', name, ' in module: ', moduleNameUsed.
+ ].
+ ].
].
"Modified: / 10-04-2012 / 12:12:44 / cg"
@@ -950,6 +950,10 @@
# endif
# if defined(__BORLANDC__) || defined(__VISUALC__)
# define HAS_INT64
+# ifndef __LO32
+# define __LO32(ll) ((ll) & 0xFFFFFFFFL)
+# define __HI32(ll) (((ll)>>32) & 0xFFFFFFFFL)
+# endif
# endif
ffi_cif __cif;
@@ -968,7 +972,11 @@
# ifdef HAS_INT64
__int64__ longLongVal;
# else
- struct ll { long low; long hi; } longLongVal;
+ struct ll { long lo; long hi; } longLongVal;
+# ifndef __LO32
+# define __LO32(ll) (ll.lo)
+# define __HI32(ll) (ll.hi)
+# endif
# endif
# endif
};
@@ -1736,7 +1744,7 @@
printf("UNLIMITEDSTACKCALL call 0x%"_lx_"\n", (INT)codeAddress);
}
# endif
- __UNLIMITEDSTACKCALL4__(ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
+ __UNLIMITEDSTACKCALL4__((OBJFUNC)ffi_call, (INT)(&__cif), (INT)codeAddress, (INT)__returnValuePointer, (INT)__argValuePointersIncludingThis);
} else {
# ifdef VERBOSE
if (@global(Verbose) == true) {
@@ -1794,26 +1802,37 @@
RETURN ( __MKUCHARACTER(__returnValue.iVal & 0xFFFF) );
}
if (returnTypeSymbol == @symbol(sint64)) {
-# ifdef VERBOSE
+# if (__POINTER_SIZE__ == 8)
+
+# ifdef VERBOSE
if (@global(Verbose) == true) {
printf("return sint64: %"_lx_"\n", (INT)(__returnValue.longLongVal));
}
-# endif
-# if __POINTER_SIZE__ == 8
+# endif
RETURN ( __MKINT(__returnValue.longLongVal) );
# else
+# ifdef VERBOSE
+ if (@global(Verbose) == true) {
+ printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal));
+ }
+# endif
RETURN ( __MKINT64(&__returnValue.longLongVal) );
# endif
}
if (returnTypeSymbol == @symbol(uint64)) {
+# if (__POINTER_SIZE__ == 8)
# ifdef VERBOSE
if (@global(Verbose) == true) {
printf("return uint64: %"_lx_"\n", (unsigned INT)(__returnValue.longLongVal));
}
# endif
-# if __POINTER_SIZE__ == 8
RETURN ( __MKUINT(__returnValue.longLongVal) );
# else
+# ifdef VERBOSE
+ if (@global(Verbose) == true) {
+ printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal));
+ }
+# endif
RETURN ( __MKUINT64(&__returnValue.longLongVal) );
# endif
}