From 7c88b0095279958ef0e03b4116fbc8d858e720ee Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Sat, 10 Aug 2019 17:36:34 +0000 Subject: [PATCH] enhanced LONGLONG argument handling in mod/ffi.c --- moo/kernel/FFI.moo | 8 ++++---- moo/mod/ffi.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/moo/kernel/FFI.moo b/moo/kernel/FFI.moo index 62705a5..90bbeb0 100644 --- a/moo/kernel/FFI.moo +++ b/moo/kernel/FFI.moo @@ -35,7 +35,7 @@ class FFI(Object) x := self.ffi open(name). //(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. } @@ -51,7 +51,7 @@ class FFI(Object) /* f := self.funcs at: name ifAbsent: [ 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. f. // need this as at:put: returns an association ]. */ @@ -60,12 +60,12 @@ class FFI(Object) if (f isNil) { 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. }. 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. } diff --git a/moo/mod/ffi.c b/moo/mod/ffi.c index 81d26a0..38ccf57 100644 --- a/moo/mod/ffi.c +++ b/moo/mod/ffi.c @@ -390,14 +390,14 @@ static MOO_INLINE int add_ffi_arg (moo_t* moo, ffi_t* ffi, moo_ooch_t fmtc, int break; case FMTC_LONGLONG: - #if (MOO_SIZEOF_LONG_LONG <= 0) + #if (MOO_SIZEOF_LONG_LONG <= MOO_SIZEOF_LONG) goto arg_as_long; #else 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 */ - if (moo_inttooow(moo, arg, &v) == 0) goto oops; + if (moo_inttouintmax(moo, arg, &v) == 0) goto oops; #if defined(USE_DYNCALL) dcArgLongLong (ffi->dc, v); #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 { - moo_ooi_t v; - if (moo_inttoooi(moo, arg, &v) == 0) goto oops; + moo_intmax_t v; + if (moo_inttointmax(moo, arg, &v) == 0) goto oops; #if defined(USE_DYNCALL) dcArgLongLong (ffi->dc, v); #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: { - #if (MOO_SIZEOF_LONG_LONG <= 0) + #if (MOO_SIZEOF_LONG_LONG <= MOO_SIZEOF_LONG) goto ret_as_long; #else moo_oop_t r;