digitalmars.D.learn - Random behavior using a wrapped C library
- simendsjo (30/30) Feb 28 2012 I'm getting some unexpected results (crashes or random behavior) when
- Trass3r (1/1) Feb 28 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5570
- simendsjo (4/5) Feb 28 2012 Thanks. I've literally spent hours testing various things without any lu...
- Trass3r (1/2) Feb 28 2012 Use gdc. Better codegen anyway.
- Mike Parker (5/10) Feb 28 2012 Have you tested on 32-bit yet? I had the exact same problem with one of
- simendsjo (5/18) Feb 28 2012 Yes. Tested on x32, and it works just fine. I'll use ia32libs and -m32 f...
- James Miller (7/29) Feb 28 2012 I don't know much, but wouldn't bigger register sizes mean that less
- simendsjo (3/41) Feb 29 2012 Probably. Almost everything is done using structs right now. Guess it wi...
- Kagamin (2/4) Feb 28 2012 Data/code/symbols size?
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.
Feb 28 2012
On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r <un known.com> wrote:http://d.puremagic.com/issues/show_bug.cgi?id=5570Thanks. 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.
Feb 28 2012
A blocker for using x64 on linux then.Use gdc. Better codegen anyway.
Feb 28 2012
On 2/29/2012 1:10 AM, simendsjo wrote:On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r <un known.com> wrote: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.http://d.puremagic.com/issues/show_bug.cgi?id=5570Thanks. 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.
Feb 28 2012
On Wed, 29 Feb 2012 05:03:30 +0100, Mike Parker <aldacron gmail.com> wrote:On 2/29/2012 1:10 AM, simendsjo wrote: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.On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r <un known.com> wrote: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.http://d.puremagic.com/issues/show_bug.cgi?id=5570Thanks. 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.
Feb 28 2012
On 29 February 2012 19:30, simendsjo <simendsjo gmail.com> wrote:On Wed, 29 Feb 2012 05:03:30 +0100, Mike Parker <aldacron gmail.com> wrote: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 MillerOn 2/29/2012 1:10 AM, simendsjo wrote: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.On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r <un known.com> wrote: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.http://d.puremagic.com/issues/show_bug.cgi?id=5570Thanks. 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.
Feb 28 2012
On Wed, 29 Feb 2012 07:44:23 +0100, James Miller <james aatch.net> wrote:On 29 February 2012 19:30, simendsjo <simendsjo gmail.com> wrote:Probably. Almost everything is done using structs right now. Guess it will be quite different when I get a lot of classes bouncing around.On Wed, 29 Feb 2012 05:03:30 +0100, Mike Parker <aldacron gmail.com> wrote: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 MillerOn 2/29/2012 1:10 AM, simendsjo wrote: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.On Tue, 28 Feb 2012 16:58:13 +0100, Trass3r <un known.com> wrote: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.http://d.puremagic.com/issues/show_bug.cgi?id=5570Thanks. 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.
Feb 29 2012
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?
Feb 28 2012