Thread overview
Re: Porting GDC to QNX
Mar 30, 2007
Sheff
Mar 30, 2007
Frits van Bommel
March 30, 2007
I think I understood what's the problem, the values of POSIX constants are different in linux and QNX (i.e O_CREAT, MAP_ANON, etc ), but in phobos they're defined like in linux, for example:
In phobos O_CREAT defined like:
const int O_CREAT = 0100; //0x64
In linux fcntl.h header:
#define  O_CREAT 0100 //0x64
but in QNX fcntl.h header it's defined like this:
#define  O_CREAT 0400 //0x100
0x64 != 0x100, so file creation always fails, so do other system calls.
What shall I do about it ? I don't want to manually redefine all POSIX constants...
March 30, 2007
Sheff wrote:
> I think I understood what's the problem, the values of POSIX constants are different in linux and QNX (i.e O_CREAT, MAP_ANON, etc ), but in phobos they're defined like in linux, for example:
> In phobos O_CREAT defined like:
> const int O_CREAT = 0100; //0x64
> In linux fcntl.h header:
> #define  O_CREAT 0100 //0x64
> but in QNX fcntl.h header it's defined like this:
> #define  O_CREAT 0400 //0x100
> 0x64 != 0x100, so file creation always fails, so do other system calls.
> What shall I do about it ? I don't want to manually redefine all POSIX constants...

That only applies to DMD's (which only supports Linux anyway) Phobos,
but not to GDC - it uses autoconf to generate those gPhobos constants.

For instance, on Mac OS X we have:
#define        O_CREAT         0x0200

Take a look at the programs in d/phobos/config, for all the details.
You need to create the frag-gen, frag-math and frag-unix configs...

--anders
March 30, 2007
Sheff wrote:
> I think I understood what's the problem, the values of POSIX constants are different in linux and QNX (i.e O_CREAT, MAP_ANON, etc ), but in phobos they're defined like in linux, for example:
> In phobos O_CREAT defined like:
> const int O_CREAT = 0100; //0x64
> In linux fcntl.h header:
> #define  O_CREAT 0100 //0x64
> but in QNX fcntl.h header it's defined like this:
> #define  O_CREAT 0400 //0x100
> 0x64 != 0x100, so file creation always fails, so do other system calls.
> What shall I do about it ? I don't want to manually redefine all POSIX constants...

There should be a file called gen_unix.c in the GDC tree (specifically, gcc/d/phobos/config/gen_unix.c) that generates data for std/c/unix/unix.d when compiled and ran on the target platform. This should be automatic for a native build, but IIRC for a cross-build you need to do this manually.
(This is mentioned in gcc/d/INSTALL).

You'll want to do the same for gen_config1.c and gen_math.c, and then put the output in a directory like gcc/d/phobos/config/qnx (with filenames frag-unix, frag-gen and frag-math) and pass --enable-phobos-config-dir=<dir> to GDC's ./configure command.

Note: I've never done this myself, this is just from what I remember reading in these newsgroups and from looking at the GDC source tree.