Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!snorkelwacker!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!aplcen!haven!adm!news From: Kemp@dockmaster.ncsc.mil Newsgroups: comp.unix.wizards Subject: Re: mmap (was What new system calls do you want in BSD?) Message-ID: <22368@adm.BRL.MIL> Date: 6 Feb 90 23:17:00 GMT Sender: news@adm.BRL.MIL Lines: 35 Doug Gwyn writes: > Larry McVoy writes: >> Anyway, it's tough to do this otherwise. Protection is implemented >> via the MMU. I can't think of any other reasonable (performance) >> way to do it. > > I appreciate that, but you do see the point, I hope. > A user-mode application has no reasonable handle on the notion of > "page alignment"; . . . > > . . . lacking a system-provided function like > void *PageAlign( void *base_pointer, size_t extent ); > . . . there is no way I can see to use mmap() portably even among > systems on which it exists. I fail to understand why mmap(2) can't be used portably. caddr_t mmap( caddr_t addr, int len, int prot, int flags, int fd, off_t off ); " mmap() establishes a mapping between the process's address space at an address paddr for len bytes to the memory object represented by fd at off for len bytes. The value of paddr is an implementation dependent function of the parameter addr and the values of flags, . . . A successful mmap() returns paddr as its result." In other words, a user mode application should have *no* handle at all on the notion of "page alignment". It should just regard the value returned by mmap as a pointer to memory that is valid for the particular hardware on which it is running. In fact, page alignment alone may not be a sufficient condition for validity. What's non-portable about that? Dave Kemp