Re: Controlling allocation in 64-bit space
Basile STARYNKEVITCH <email@example.com> writes:
> Le Fri, Mar 24, 2006 at 10:44:43PM +0100, Goswin von Brederlow écrivait/wrote:
>> Basile STARYNKEVITCH <firstname.lastname@example.org> writes:
>> > I suggest more precisely to
>> > mmap((void*)0, (size_t)size, PROT_READ|PROT_WRITE,
>> > MAP_PRIVATE|MAP_ANONYMOUS, (int)-1 /*no fd*/, (off_t)0)
>> > with MAP_ANONYMOUS you don't need to open /dev/zero (but internally it is
>> > the same)
>> > Regards
>> Is that protable or just a linux speciality?
> It exists in recent Solaris, Linux, BSD. And should be conformant to SUSv3 but not SUSv2. the UNIX (from SCO) has it
> I tend to believe that you can test #ifdef MAP_ANONYMOUS; if it is not
> defined, you'll need to open /dev/zero.
I was more thinking about mmaping -1. But I see from the manpage that
the fd is ignored anyway on MAP_ANONYMOUS so anything should do.