include file edits to make porting easier

Do you think it’s better to have QNX support software compiling by default, or have the software support QNX by default?

  • Software needs to be compatible with QNX
  • QNX needs to be compatible software
  • I know nobody is going to care what I vote here, but I like clicking buttons anyway

0 voters

So, I’ve started trying to update all the base libraries and programs installed with QNX 6.3 sp3… and as I run into problems and fixes I’ll post them here.

All edits listed are changes to files in the /usr/qnx630/target/qnx6/usr/include directory. I change these directly because it is easier for me to do it once for everything than once for every program that might need the functions.

I’m doing this out of boredom, so this isn’t me trying to offer support to anyone, I’m just posting this in the off chance that it helps someone else in any similar attempts. If you have questions or commments, however, feel free to chime in. Some of these are, I’m sure, elsewhere on this forum. The first I did not see in any forum searches, so I’m going to assume the rest need to be included any time I come across them.

So, the first couple things I’m working on are pretty simple, but they are base-lines (everything on the pre-requisite list for GCC 4.1.2, but newest versions rather than required)…

Here are the first two things that need fixing… and why.

1) unistd.h
There are a couple problems with QNX when trying to port programs… namely that QNX tries to be posix compliant, while the operating system the program was written for isn’t so worried about it.

The first problem to pop up for me is getpagesize(). Unfortunately, getpagesize does not seem to be a valid… well… anything. The problem is that Posix standards state that getpagesize() is an outdated method of getting the result you want… so I suppose they never implemented it. They did implement the proper way of doing it, however, so here’s how you make yourself a working getpagesize().

Edit unistd.h (in the above path) and add the following line:

#define getpagesize() sysconf(_SC_PAGESIZE)

This corrects any programs that try to use the outdated method, forcing them to use the new standard method (needed for tar-1.16 and others, but I stopped paying attention to what used it after it started working)

If you’ve been getting a getpagesize error on compile, this will most likely fix it.

2) sys/types.h

This one appears to be fairly well known but, well, after the search for #1 failed I’m not even going to bother searching anymore because I’m lazy.

The problem is that makedev, as implemented, requires 3 arguments… and the first argument always has to be 0 because they never got around to implementing it. That’s swell, isn’t it? Especially since every other program in existence seems to only use 2 arguments.

Now, the fix for this again comes from me being lazy… I make the system correspond with the programs I’m using and not the other way around, so you may like the second of the two options I’ll present, while I myself use the first.

open sys/types.h, find:
#define makedev(node,major,minor) [cut for brevity]
and change it to:
#define makedevorig(node,major,minor) [cut for brevity]
#define makedev(a,b) makedevorig(0,a,b)

this renames the original and means you won’t need to change any program code when you download it…

If you don’t like this (want to leave the function unchanged in the off chance it will break something else), you can instead do the following:

add this line to sys/types.h:
#define MAKEDEV(a,b) makedev(0,a,b)

Then, any time you get a compile error regardning makedev “only using 2 arguments” you can just replace all instances of makedev in the program source with MAKEDEV and be good to go… again, since this is more tedious crap than I care to do, I use the first way… but I’m like that.

At the moment I’m frustrated with the failures of gmp tests, mainly that I don’t care enough to fix the three tests, so I’ll continue this list when I get bored enough to fix whatever is breaking the locale test.