[haiku-development] Re: replacing runtime_loader

  • From: François Revol <revol@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 17 Mar 2016 01:18:19 +0100

Hi,

On 17/03/2016 01:07, Tim Kelly wrote:


/* Minimum and maximum values a `signed int' can hold.  */
#ifndef __INT_MAX__
#define __INT_MAX__ 2147483647
#endif
#undef INT_MIN
#define INT_MIN (-INT_MAX-1)
#undef INT_MAX
#define INT_MAX __INT_MAX__

which means, if I understand correctly, errors can be positive or
negative, depending on the compiler.  Since 0x80000000 is the most

That's because historically BeOS error codes are negative (which makes
much more sense than using "return -EINVAL" (which is both errorprone et
ugly) (but POSIX or ISO C doesn't care about making sense).

But some software are so badly written and full of those -EFOO that we
have to resort to this madness to redefine errors as positive integers
to abide by ISO C and POSIX (although POSIX did change its mind at one
point from "non 0" to "positive"), and link to a posix_error_mapper
static library.

negative 32-bit number (smallest != most negative), I was able to figure
out that 0x80000005 was the error being returned by
_kern_reserve_address_space, but the runtime_loader images.cpp code was
walking over it and returning B_NO_MEMORY (0x80000000) instead and the
actual error was occurring deep in the VM code.

So, no, I didn't realize I was seeing the actual return value. It took a
while.  :-)

There's an "error" command in the shell for that :)

François.


Other related posts: