Re: Random behavior using a wrapped C library

2012-02-29 Thread simendsjo

On Wed, 29 Feb 2012 07:44:23 +0100, James Miller ja...@aatch.net wrote:


On 29 February 2012 19:30, simendsjo simend...@gmail.com wrote:
On Wed, 29 Feb 2012 05:03:30 +0100, Mike Parker aldac...@gmail.com  
wrote:



On 2/29/2012 1:10 AM, simendsjo wrote:


On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r u...@known.com wrote:


http://d.puremagic.com/issues/show_bug.cgi?id=5570



Thanks. I've literally spent hours testing various things without any
luck - would have been simpler if I knew asm :/

A blocker for using x64 on linux then.



Have you tested on 32-bit yet? I had the exact same problem with one  
of my
wrappers when passing a struct by value, but on 32-bit Windows.  
Luckily, in
my case it was simple enough to implement the function in D to work  
around

it. I'm curious to know if it's related.



Yes. Tested on x32, and it works just fine. I'll use ia32libs and -m32  
for

the time being then.

A strange thing is that memory consumption went _up_ when everything was
compiled as x32.


I don't know much, but wouldn't bigger register sizes mean that less
data needs shuffled in and out of memory? Resulting in less
instructions and therefore less memory usage?

I'm just guessing though

--
James Miller


Probably. Almost everything is done using structs right now. Guess it will  
be quite different when I get a lot of classes bouncing around.


Random behavior using a wrapped C library

2012-02-28 Thread simendsjo
I'm getting some unexpected results (crashes or random behavior) when  
using a wrapped C struct in a library. I have no idea why this is  
happening as everything else (including other wrapped structs) seems to  
work just fine.

Could it be some alignment issues..?

extern(C):

//typedef unsigned char uint8;
alias ubyte uint8;

//typedef struct {
//  uint8 r,g,b;
//} TCOD_color_t;
struct TCOD_color_t {
uint8 r,g,b;
};

//typedef void * TCOD_console_t;
alias void* TCOD_console_t;

//TCODLIB_API void TCOD_console_set_default_background(TCOD_console_t  
con,TCOD_color_t col);
void TCOD_console_set_default_background(TCOD_console_t con,TCOD_color_t  
col);


Whenever I use I call this function using TCOD_color_t(255,255,255) it  
seems to set a random other value.
Also, when calling get_default_background (not shown here), I get random  
results back.
I know the library works fine from C, so it has to be somewhere in my  
wrapper.


Does anyone spot any obvious flaws in my wrapping above? Or has any other  
hints on what might have gone wrong?


I've only tested this on linux64.

Thanks.


Re: Random behavior using a wrapped C library

2012-02-28 Thread Trass3r

http://d.puremagic.com/issues/show_bug.cgi?id=5570


Re: Random behavior using a wrapped C library

2012-02-28 Thread simendsjo

On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r u...@known.com wrote:


http://d.puremagic.com/issues/show_bug.cgi?id=5570


Thanks. I've literally spent hours testing various things without any luck  
- would have been simpler if I knew asm :/


A blocker for using x64 on linux then.


Re: Random behavior using a wrapped C library

2012-02-28 Thread Trass3r

A blocker for using x64 on linux then.


Use gdc. Better codegen anyway.


Re: Random behavior using a wrapped C library

2012-02-28 Thread Mike Parker

On 2/29/2012 1:10 AM, simendsjo wrote:

On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r u...@known.com wrote:


http://d.puremagic.com/issues/show_bug.cgi?id=5570


Thanks. I've literally spent hours testing various things without any
luck - would have been simpler if I knew asm :/

A blocker for using x64 on linux then.


Have you tested on 32-bit yet? I had the exact same problem with one of 
my wrappers when passing a struct by value, but on 32-bit Windows. 
Luckily, in my case it was simple enough to implement the function in D 
to work around it. I'm curious to know if it's related.


Re: Random behavior using a wrapped C library

2012-02-28 Thread simendsjo

On Wed, 29 Feb 2012 05:03:30 +0100, Mike Parker aldac...@gmail.com wrote:


On 2/29/2012 1:10 AM, simendsjo wrote:

On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r u...@known.com wrote:


http://d.puremagic.com/issues/show_bug.cgi?id=5570


Thanks. I've literally spent hours testing various things without any
luck - would have been simpler if I knew asm :/

A blocker for using x64 on linux then.


Have you tested on 32-bit yet? I had the exact same problem with one of  
my wrappers when passing a struct by value, but on 32-bit Windows.  
Luckily, in my case it was simple enough to implement the function in D  
to work around it. I'm curious to know if it's related.


Yes. Tested on x32, and it works just fine. I'll use ia32libs and -m32 for  
the time being then.


A strange thing is that memory consumption went _up_ when everything was  
compiled as x32.


Re: Random behavior using a wrapped C library

2012-02-28 Thread James Miller
On 29 February 2012 19:30, simendsjo simend...@gmail.com wrote:
 On Wed, 29 Feb 2012 05:03:30 +0100, Mike Parker aldac...@gmail.com wrote:

 On 2/29/2012 1:10 AM, simendsjo wrote:

 On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r u...@known.com wrote:

 http://d.puremagic.com/issues/show_bug.cgi?id=5570


 Thanks. I've literally spent hours testing various things without any
 luck - would have been simpler if I knew asm :/

 A blocker for using x64 on linux then.


 Have you tested on 32-bit yet? I had the exact same problem with one of my
 wrappers when passing a struct by value, but on 32-bit Windows. Luckily, in
 my case it was simple enough to implement the function in D to work around
 it. I'm curious to know if it's related.


 Yes. Tested on x32, and it works just fine. I'll use ia32libs and -m32 for
 the time being then.

 A strange thing is that memory consumption went _up_ when everything was
 compiled as x32.

I don't know much, but wouldn't bigger register sizes mean that less
data needs shuffled in and out of memory? Resulting in less
instructions and therefore less memory usage?

I'm just guessing though

--
James Miller


Re: Random behavior using a wrapped C library

2012-02-28 Thread Kagamin

On Wednesday, 29 February 2012 at 06:30:27 UTC, simendsjo wrote:
A strange thing is that memory consumption went _up_ when 
everything was compiled as x32.


Data/code/symbols size?