Matthew Dempsky
2014-06-24 17:49:21 UTC
Every system I've looked at (Solaris, HPUX, AIX, UnixWare, Linux, OS
X, *BSD) supports an mmap() flag to allocate anonymous memory without
needing an open file descriptor. Is there anything keeping POSIX from
standardizing this now ubiquitous feature?
Some notes from trolling through online man pages:
1. Most systems call it MAP_ANON, but HPUX, AIX, and UnixWare call it
MAP_ANONYMOUS. (Some systems provide both; e.g., FreeBSD.)
2. Mac OS X allows Mach VM flags to be passed via the "fd" parameter,
but recognizes "-1" as "no flags". Other OSes reject MAP_ANON(YMOUS)?
with fd != -1. Common practice seems to be EINVAL, but at least AIX
specifies EBADF instead.
3. FreeBSD requires offset==0 when using MAP_ANON; Linux and Mac OS X
explicitly document that it's ignored, and other OSes don't seem to
care.
So it seems fair for POSIX to standardize that MAP_ANON with fd==-1
and offset==0 shall allocate anonymous memory without requiring a file
descriptor to be passed, and leave MAP_ANON with fd!=-1 or offset!=0
unspecified?
X, *BSD) supports an mmap() flag to allocate anonymous memory without
needing an open file descriptor. Is there anything keeping POSIX from
standardizing this now ubiquitous feature?
Some notes from trolling through online man pages:
1. Most systems call it MAP_ANON, but HPUX, AIX, and UnixWare call it
MAP_ANONYMOUS. (Some systems provide both; e.g., FreeBSD.)
2. Mac OS X allows Mach VM flags to be passed via the "fd" parameter,
but recognizes "-1" as "no flags". Other OSes reject MAP_ANON(YMOUS)?
with fd != -1. Common practice seems to be EINVAL, but at least AIX
specifies EBADF instead.
3. FreeBSD requires offset==0 when using MAP_ANON; Linux and Mac OS X
explicitly document that it's ignored, and other OSes don't seem to
care.
So it seems fair for POSIX to standardize that MAP_ANON with fd==-1
and offset==0 shall allocate anonymous memory without requiring a file
descriptor to be passed, and leave MAP_ANON with fd!=-1 or offset!=0
unspecified?