Re: do_brk() error return
From: David Schwartz (davids_at_webmaster.com)
Date: 07/30/04
- Next message: phil-news-nospam_at_ipal.net: "Re: troubles patching kernel source"
- Previous message: Nix: "Re: How to aviod a process from deleting an opened file"
- In reply to: sean larsson: "do_brk() error return"
- Next in thread: sean larsson: "Re: do_brk() error return"
- Reply: sean larsson: "Re: do_brk() error return"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Jul 2004 23:18:59 -0700
"sean larsson" <infamous42md@ERASEMEhotpop.com> wrote in message
news:20040729225306.2af2214c.infamous42md@ERASEMEhotpop.com...
> 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?
None of these error values could ever be page aligned addresses. It's
ugly, but it's safe.
They don't return a negative value in a function that returns an
unsigned long. They return a value that will compare equivalent to a
particular negative number. Many functions work this way. For example,
'time' returns a 'time_t', which may or may not be signed, however it
returns something that will compare equivalent to '(time_t) -1' on error.
DS
- Next message: phil-news-nospam_at_ipal.net: "Re: troubles patching kernel source"
- Previous message: Nix: "Re: How to aviod a process from deleting an opened file"
- In reply to: sean larsson: "do_brk() error return"
- Next in thread: sean larsson: "Re: do_brk() error return"
- Reply: sean larsson: "Re: do_brk() error return"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|