Discussion:
Can POSIX standardize MAP_ANON?
Matthew Dempsky
2014-06-24 17:49:21 UTC
Permalink
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?
Nick Stoughton
2014-06-24 20:44:57 UTC
Permalink
Personally, I don't see any problem with this proposal. You should submit
it to austingroupbugs.net as an enhancement request, with fully formed
edits to add it. Since this is not a totally new feature as such, I don't
believe it needs a sponsor in Austin Group, but the other ORs should weigh
in on this.
Post by Matthew Dempsky
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?
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?
Don Cragun
2014-06-24 21:06:28 UTC
Permalink
Hi Nick,
As IEEE PASC OR, I agree.

Cheers,
Don
Personally, I don't see any problem with this proposal. You should submit it to austingroupbugs.net as an enhancement request, with fully formed edits to add it. Since this is not a totally new feature as such, I don't believe it needs a sponsor in Austin Group, but the other ORs should weigh in on this.
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?
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?
Loading...