Re: Bug with callbacks returning a signed long long
Gary Byers <[email protected]> Fri, 4 Nov 2005 09:55:44 -0700 (MST)
| Newsgroups | gmane.lisp.openmcl.bugs |
|---|---|
| Message-ID | <[email protected]> |
Thanks.
The bug seems to be in the LAP function CCL::%%SET-SIGNED-LONGLONG;
the 32-bit version of that function is trying to insist that its
first argument (the pointer) has a type that'd be appropriate for
a pointer in the 64-bit implementation. This means that storing
a signed 64-bit integer in memory will fail in other contexts as
well.
On Wed, 2 Nov 2005, Luis Oliveira wrote:
> Hello,
>
> While writing tests for CFFI's long long support, I came across the
> following bug when returning signed long long types from callbacks:
>
> $ cat testlib.c
> #include <stdio.h>
> #include <limits.h>
>
> void expect_long_long(long long (*f)(long long))
> {
> printf("f(-42LL) => %lld\n", f(-42LL));
> }
> $ gcc -o testlib.dylib -bundle -lm -Wall -std=c99 -pedantic testlib.c
> $ openmcl
> Welcome to OpenMCL Version 1.0 (DarwinPPC32)!
> ? (open-shared-library "testlib.dylib")
> #<SHLIB testlib.dylib #x83DB606>
> ? (defcallback return-llong (:signed-doubleword n :signed-doubleword)
> (format t "Lisp side got: ~A~%" n)
> -42)
> RETURN-LLONG
> ? (external-call "_expect_long_long" :address return-llong)
> Lisp side got: -42
>> Error in process listener(1): value #<A Mac Pointer #xF0135B88> is not
>> of the expected type CCL::UVECTOR.
>> While executing: CCL::%%SET-SIGNED-LONGLONG
>> Type :POP to abort.
> Type :? for other options.
> 1 >
>
> The same test using "unsigned long long" works as expected.
>
> BTW, is there any particular reason why the :long-long,
> :signed-long-long and :unsigned-long-long are undefined?
No good reason that I can think of. They'd be aliases for
(:SIGNED 64) and (:UNSIGNED 64), and perhaps a little easier
to type and/or more meaningful to read.
:SIGNED-DOUBLEWORD and :UNSIGNED-DOUBLEWORD -are- defined.
I sometimes convince myself that type names involving :*WORD and
:*DOUBLE-WORD should be phased out in favor of things like
:SIGNED32 or :UNSIGNED64; terms like "word" and "doubleword"
tend to be CPU-specific.
>
> --
> Luís Oliveira
> luismbo (@) gmail (.) com
> Equipa Portuguesa do Translation Project
> http://www.iro.umontreal.ca/translation/registry.cgi?team=pt
>
> _______________________________________________
> Bug-openmcl mailing list
> [email protected]
> http://clozure.com/mailman/listinfo/bug-openmcl
>
>
_______________________________________________
Bug-openmcl mailing list
[email protected]
http://clozure.com/mailman/listinfo/bug-openmcl