Messages in this thread | | | Date | Fri, 31 May 2002 14:10:00 -0400 (EDT) | From | "Richard B. Johnson" <> | Subject | Re: do_mmap |
| |
On Fri, 31 May 2002, Thomas 'Dent' Mirlacher wrote:
> --snip/snip > > > >> is it possible to have 0 as a valid address? - if not, this should > > >> be the return on errors. > > > > > >SuS explicitly says that 0 is not a valid mmap return address. > > > > But if so, SuS is _very_ _very_ wrong. > > > > The fact is, if you use something like vm86 mode, you absolutely _need_ > > to be able to explicitly mmap at address 0. > > > > So it is correct (and in fact there is no other sane way to do it) to > > say > > > > addr = mmap(NULL, 1024*1024, > > PROT_READ | PROT_WRITE , > > MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, > > -1, 0); > > > > and if SuS says that mmap must not return NULL for this case, then SuS > > is so full of sh*t that it's not worth worrying about. > > > > In short, under Linux 0 _is_, and will always be (at least on x86) a > > perfectly valid return address from mmap() and friends. It's only going > > to be returned when you explicitly ask for it with MAP_FIXED, but it > > absolutely is a valid return. > > ok. so 0 or (NULL) is not an option, and also unnneccessary once someone > know how the error retun is used. - wouldn't it be much more cleaner > to convert this _ugly_ unsigned long vals into void * wherever these vals > are carrying an address? (well at least for do_mmap*) and use ERR_PTR > for returning, and IS_ERR for checking for an error? > > btw, is err should (according to alans explaination be): > > return (unsigned long)ptr > (unsigned long)-1024UL; > > tm >
At the user-mode API, we get to (void *) -1, defined in sys/mman.h (actually (__ptr_t) -1); so whatever you do, the 'C' runtime library has to 'know' about your return values if this propagates to sys-calls.
Cheers, Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Windows-2000/Professional isn't.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |