Wireshark-dev: Re: [Wireshark-dev] Use of MAP_ANON in epan/emem.c
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Fri, 16 Jun 2006 18:11:14 -0700

On Jun 16, 2006, at 3:25 PM, Albert Chin wrote:

On Fri, Jun 16, 2006 at 11:32:32PM +0200, Jaap Keuter wrote:
Checked in.

Thanks. What do we do for IRIX which has neither MAP_ANONYMOUS or
MAP_ANON? #define MAP_ANONYMOUS to 0 in this case?

The goal here is to get anonymous pages.

One of the earliest implementations of mmap() that could map a region of the address space to a vendor of anonymous pages was SunOS 4.0; the way you did it in 4.0 was to open "/dev/zero" and mmap that. (You can also read from "/dev/zero" if you want an infinite stream of zeroes....)

The IRIX 6.5 man page for /dev/zero indicates you can mmap it to get anonymous pages. Are there any UN*Xes we support that *don't* allow you to mmap /dev/zero to get anonymous pages? If not, we might just want to open /dev/zero and hold it open, and use that for anonymous pages; if so, we might want to use MAP_ANONYMOUS on systems that define it, otherwise use MAP_ANON on systems that define it (OS X 10.4 defines MAP_ANON but *NOT* MAP_ANONYMOUS, and that seems to be a general BSD characteristic - I don't find any definitions of MAP_ANONYMOUS in the sys/sys source directory of fairly recent {Free,Net,Open}BSD), otherwise use "/dev/zero".