Interfacing C library with dllcc, long long typedef not working

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Interfacing C library with dllcc, long long typedef not working

Vincent Lesbros-2

Hi, 
I am interfacing libsoundfile from Smalltalk (Cincom Smalltalk VisualWorks® Personal Use Edition, 7.9.1 of 18 octobre 2012) 

It is now working,  but I have to do some modifications in header file in order to get a working interface.

For example the definition of sf_count_t is :


#if (defined (_MSCVER) || defined (_MSC_VER))
typedef __int64 sf_count_t ;
#define SF_COUNT_MAX 0x7fffffffffffffffi64
#else
typedef __int64 sf_count_t ;
#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL
#endif

and gives : 

sf_count_t
<C: typedef long long sf_count_t>


and the function

sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) ;

became : 

sf_write_float: sndfile with: ptr with: items
<C: long long sf_write_float(SNDFILE * sndfile, const float * ptr, long long items)>
^self externalAccessFailedWith: _errorCode

note : the "normal" definition should read : 

sf_write_float: sndfile with: ptr with: items
<C: sf_count_t sf_write_float(SNDFILE * sndfile, const float * ptr, sf_count_t items)>
^self externalAccessFailedWith: _errorCode

But with this last definition, I get a null result and no data is writen.

Where is the mistake ?
I am using a 32 bit image.
will this code work in a 64 bit image ? 
in 32 bit a long long is 64 bit integer, what is a long long in 64 bit env ?





_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Interfacing C library with dllcc, long long typedef not working

Ralf Propach
Hi  Vincent,

to find out the of a C data type, you can use the method #dataSize, like
this:

CIntegerType.SignedLongLong dataSize

YourLibrary new sf_count_t dataSize

What is the dataSize for your sf_count_t type?
It should be the same as CIntegerType.SignedLongLong dataSize, i.e. 8.

Ralf


Am 28.08.2013 16:31, schrieb Vincent Lesbros:

>
> Hi,
> I am interfacing libsoundfile from Smalltalk (Cincom Smalltalk
> VisualWorks® Personal Use Edition, 7.9.1 of 18 octobre 2012)
>
> It is now working,  but I have to do some modifications in header file
> in order to get a working interface.
>
> For example the definition of sf_count_t is :
>
>
> #if (defined (_MSCVER) || defined (_MSC_VER))
> typedef __int64 sf_count_t ;
> #define SF_COUNT_MAX0x7fffffffffffffffi64
> #else
> typedef __int64 sf_count_t ;
> #define SF_COUNT_MAX0x7FFFFFFFFFFFFFFFLL
> #endif
>
> and gives :
>
> sf_count_t
> <C: typedef long long sf_count_t>
>
>
> and the function
>
> sf_count_tsf_write_float(SNDFILE *sndfile, const float *ptr, sf_count_t
> items) ;
>
> became :
>
> sf_write_float: sndfile with: ptr with: items
> <C: long long sf_write_float(SNDFILE * sndfile, const float * ptr, long
> long items)>
> ^self externalAccessFailedWith: _errorCode
>
> note : the "normal" definition should read :
>
> sf_write_float: sndfile with: ptr with: items
> <C: sf_count_t sf_write_float(SNDFILE * sndfile, const float *
> ptr, sf_count_t items)>
> ^self externalAccessFailedWith: _errorCode
>
> But with this last definition, I get a null result and no data is writen.
>
> Where is the mistake ?
> I am using a 32 bit image.
> will this code work in a 64 bit image ?
> in 32 bit a long long is 64 bit integer, what is a long long in 64 bit env ?
>
>
>
>
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Interfacing C library with dllcc, long long typedef not working

Vincent Lesbros-2
Yes Ralf,

the response is 8.

But if I use sf_count_t type instead of long long in declaration, the call return 0, and no data is writen.
I find it strange.




2013/8/28 Ralf Propach <[hidden email]>
Hi  Vincent,

to find out the of a C data type, you can use the method #dataSize, like this:

CIntegerType.SignedLongLong dataSize

YourLibrary new sf_count_t dataSize

What is the dataSize for your sf_count_t type?
It should be the same as CIntegerType.SignedLongLong dataSize, i.e. 8.

Ralf


Am 28.08.2013 16:31, schrieb Vincent Lesbros:

Hi,
I am interfacing libsoundfile from Smalltalk (Cincom Smalltalk
VisualWorks® Personal Use Edition, 7.9.1 of 18 octobre 2012)

It is now working,  but I have to do some modifications in header file
in order to get a working interface.

For example the definition of sf_count_t is :


#if (defined (_MSCVER) || defined (_MSC_VER))
typedef __int64 sf_count_t ;
#define SF_COUNT_MAX0x7fffffffffffffffi64
#else
typedef __int64 sf_count_t ;
#define SF_COUNT_MAX0x7FFFFFFFFFFFFFFFLL
#endif

and gives :

sf_count_t
<C: typedef long long sf_count_t>


and the function

sf_count_tsf_write_float(SNDFILE *sndfile, const float *ptr, sf_count_t

items) ;

became :

sf_write_float: sndfile with: ptr with: items
<C: long long sf_write_float(SNDFILE * sndfile, const float * ptr, long
long items)>
^self externalAccessFailedWith: _errorCode

note : the "normal" definition should read :

sf_write_float: sndfile with: ptr with: items
<C: sf_count_t sf_write_float(SNDFILE * sndfile, const float *
ptr, sf_count_t items)>
^self externalAccessFailedWith: _errorCode

But with this last definition, I get a null result and no data is writen.

Where is the mistake ?
I am using a 32 bit image.
will this code work in a 64 bit image ?
in 32 bit a long long is 64 bit integer, what is a long long in 64 bit env ?






_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Interfacing C library with dllcc, long long typedef not working

Ralf Propach
Hi Vincent,

you can inspect the method sf_write_float: sndfile with: ptr with: items
with the method menu from the browser.
What is the value for argumentKinds and resultType
a) if you use sf_count_t and
b) if you use long long ?

Ralf

Am 28.08.2013 17:15, schrieb Vincent Lesbros:

> Yes Ralf,
>
> the response is 8.
>
> But if I use sf_count_t type instead of long long in declaration, the
> call return 0, and no data is writen.
> I find it strange.
>
>
>
>
> 2013/8/28 Ralf Propach <[hidden email] <mailto:[hidden email]>>
>
>     Hi  Vincent,
>
>     to find out the of a C data type, you can use the method #dataSize,
>     like this:
>
>     CIntegerType.SignedLongLong dataSize
>
>     YourLibrary new sf_count_t dataSize
>
>     What is the dataSize for your sf_count_t type?
>     It should be the same as CIntegerType.SignedLongLong dataSize, i.e. 8.
>
>     Ralf
>
>
>     Am 28.08.2013 16:31, schrieb Vincent Lesbros:
>
>
>         Hi,
>         I am interfacing libsoundfile from Smalltalk (Cincom Smalltalk
>         VisualWorks® Personal Use Edition, 7.9.1 of 18 octobre 2012)
>
>         It is now working,  but I have to do some modifications in
>         header file
>         in order to get a working interface.
>
>         For example the definition of sf_count_t is :
>
>
>         #if (defined (_MSCVER) || defined (_MSC_VER))
>         typedef __int64 sf_count_t ;
>         #define SF_COUNT___MAX0x7fffffffffffffffi64
>         #else
>         typedef __int64 sf_count_t ;
>         #define SF_COUNT___MAX0x7FFFFFFFFFFFFFFFLL
>         #endif
>
>         and gives :
>
>         sf_count_t
>         <C: typedef long long sf_count_t>
>
>
>         and the function
>
>         sf_count_tsf_write_float(__SNDFILE *sndfile, const float *ptr,
>         sf_count_t
>
>         items) ;
>
>         became :
>
>         sf_write_float: sndfile with: ptr with: items
>         <C: long long sf_write_float(SNDFILE * sndfile, const float *
>         ptr, long
>         long items)>
>         ^self externalAccessFailedWith: _errorCode
>
>         note : the "normal" definition should read :
>
>         sf_write_float: sndfile with: ptr with: items
>         <C: sf_count_t sf_write_float(SNDFILE * sndfile, const float *
>         ptr, sf_count_t items)>
>         ^self externalAccessFailedWith: _errorCode
>
>         But with this last definition, I get a null result and no data
>         is writen.
>
>         Where is the mistake ?
>         I am using a 32 bit image.
>         will this code work in a 64 bit image ?
>         in 32 bit a long long is 64 bit integer, what is a long long in
>         64 bit env ?
>
>
>
>
>
>
>         _________________________________________________
>         vwnc mailing list
>         [hidden email] <mailto:[hidden email]>
>         http://lists.cs.uiuc.edu/__mailman/listinfo/vwnc
>         <http://lists.cs.uiuc.edu/mailman/listinfo/vwnc>
>
>
>     _________________________________________________
>     vwnc mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://lists.cs.uiuc.edu/__mailman/listinfo/vwnc
>     <http://lists.cs.uiuc.edu/mailman/listinfo/vwnc>
>
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc