do_brk() error return

From: sean larsson (infamous42md_at_ERASEMEhotpop.com)
Date: 07/30/04


Date: Fri, 30 Jul 2004 02:49:46 GMT

the do_brk() function returns an unsigned long. usually this value is
the new address of the top of the heap. however, when it encounters an
error, it will return a negative error code, ie -EAGAIN or w/e. so, i'm
wondering: what if the top of the heap address has the high order bit
set? i know that the heap usually starts at a low address on my x86
computers, but i haven't run linux on other platforms so i'm not sure if
that holds true. and also, why would the developers return a negative
value in a function that returns an unsigned long? you'd need to cast
the return to signed type, or test high order bit to check for an error,
which seems like a dumb thing to do imho. comments?

-- 
-sean


Relevant Pages

  • Re: do_brk() error return
    ... "David Schwartz" wrote: ... >> is the new address of the top of the heap. ... >> encounters an error, it will return a negative error code, ie ... >> address has the high order bit set? ...
    (comp.os.linux.development.system)
  • Re: do_brk() error return
    ... sean larsson wrote: ... > the new address of the top of the heap. ... > the return to signed type, or test high order bit to check for an error, ... Error codes are from the interval -1 to -124. ...
    (comp.os.linux.development.system)
  • Re: do_brk() error return
    ... > the new address of the top of the heap. ... > the return to signed type, or test high order bit to check for an error, ... returns something that will compare equivalent to '-1' on error. ...
    (comp.os.linux.development.system)