[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Controlling allocation in 64-bit space



Basile STARYNKEVITCH <basile@starynkevitch.net> writes:

> Le Fri, Mar 24, 2006 at 10:44:43PM +0100, Goswin von Brederlow écrivait/wrote:
>> Basile STARYNKEVITCH <basile@starynkevitch.net> 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
> http://uw713doc.sco.com/en/man/html.2/mmap.2.html
>
> 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.

MfG
        Goswin



Reply to: