enhanced LONGLONG argument handling in mod/ffi.c

This commit is contained in:
hyunghwan.chung 2019-08-10 17:36:34 +00:00
parent 3f2e39cf44
commit 7c88b00952
2 changed files with 10 additions and 10 deletions

View File

@ -35,7 +35,7 @@ class FFI(Object)
x := self.ffi open(name). x := self.ffi open(name).
//(x isError) ifTrue: [^x]. //(x isError) ifTrue: [^x].
if (x isError) { FFIException signal: ('Unable to open %s' strfmt(name)) }. if (x isError) { FFIException signal: ('Unable to open %O' strfmt(name)) }.
^self. ^self.
} }
@ -51,7 +51,7 @@ class FFI(Object)
/* f := self.funcs at: name ifAbsent: [ /* f := self.funcs at: name ifAbsent: [
f := self.ffi getsym(name). f := self.ffi getsym(name).
if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }. if (f isError) { FFIException signal: ('Unable to find %O' strfmt(name)) }.
self.funcs at: name put: f. self.funcs at: name put: f.
f. // need this as at:put: returns an association f. // need this as at:put: returns an association
]. */ ]. */
@ -60,12 +60,12 @@ class FFI(Object)
if (f isNil) if (f isNil)
{ {
f := self.ffi getsym(name). f := self.ffi getsym(name).
if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }. if (f isError) { FFIException signal: ('Unable to find %O' strfmt(name)) }.
self.funcs at: name put: f. self.funcs at: name put: f.
}. }.
rc := self.ffi call(f, sig, args). rc := self.ffi call(f, sig, args).
if (rc isError) { FFIException signal: ('Unable to call %s' strfmt(name)) }. if (rc isError) { FFIException signal: ('Unable to call %O' strfmt(name)) }.
^rc. ^rc.
} }

View File

@ -390,14 +390,14 @@ static MOO_INLINE int add_ffi_arg (moo_t* moo, ffi_t* ffi, moo_ooch_t fmtc, int
break; break;
case FMTC_LONGLONG: case FMTC_LONGLONG:
#if (MOO_SIZEOF_LONG_LONG <= 0) #if (MOO_SIZEOF_LONG_LONG <= MOO_SIZEOF_LONG)
goto arg_as_long; goto arg_as_long;
#else #else
if (_unsigned) if (_unsigned)
{ {
moo_oow_t v; moo_uintmax_t v;
/* TODO: if (MOO_SIZEOF_LONG_LONG > MOO_SIZEOF_OOI_T) use moo_inttointmax() or something */ /* TODO: if (MOO_SIZEOF_LONG_LONG > MOO_SIZEOF_OOI_T) use moo_inttointmax() or something */
if (moo_inttooow(moo, arg, &v) == 0) goto oops; if (moo_inttouintmax(moo, arg, &v) == 0) goto oops;
#if defined(USE_DYNCALL) #if defined(USE_DYNCALL)
dcArgLongLong (ffi->dc, v); dcArgLongLong (ffi->dc, v);
#elif defined(USE_LIBFFI) #elif defined(USE_LIBFFI)
@ -407,8 +407,8 @@ static MOO_INLINE int add_ffi_arg (moo_t* moo, ffi_t* ffi, moo_ooch_t fmtc, int
} }
else else
{ {
moo_ooi_t v; moo_intmax_t v;
if (moo_inttoooi(moo, arg, &v) == 0) goto oops; if (moo_inttointmax(moo, arg, &v) == 0) goto oops;
#if defined(USE_DYNCALL) #if defined(USE_DYNCALL)
dcArgLongLong (ffi->dc, v); dcArgLongLong (ffi->dc, v);
#elif defined(USE_LIBFFI) #elif defined(USE_LIBFFI)
@ -671,7 +671,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
case FMTC_LONGLONG: case FMTC_LONGLONG:
{ {
#if (MOO_SIZEOF_LONG_LONG <= 0) #if (MOO_SIZEOF_LONG_LONG <= MOO_SIZEOF_LONG)
goto ret_as_long; goto ret_as_long;
#else #else
moo_oop_t r; moo_oop_t r;