delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/01/16/07:42:58

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Fri, 16 Jan 2009 13:42:09 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: how to get mmap page size?
Message-ID: <20090116124209.GS400@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <ee2e06e90901160424j63c9a2b0u8d6e76bd8bb352c1 AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <ee2e06e90901160424j63c9a2b0u8d6e76bd8bb352c1@mail.gmail.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Jan 16 12:24, Jay Foad wrote:
> I have an application that wants to use mmap() to read a file, but
> only if it can guarantee that this will leave one or more zero bytes
> after the end of the contents of the file in memory:
> 
>   if ((filesize & (pagesize - 1) != 0)
>     use_mmap();
>   else
>     use_read();
> 
> How do I get the appropriate page size on cygwin?
> 
> If I call getpagesize() it returns 64k, the "allocation granularity".

That's what you want.  mmap always allocates in 64K chunks.

> Internally cygwin has a getsystempagesize() (introduced here:
> http://cygwin.com/ml/cygwin-cvs/2005-q4/msg00099.html) that returns
> the appropriate page size, 4k, but that doesn't seem to be exposed to
> applications.

And it's not required.  The system pagesize is really only used
internally.  Applications should rely on getpagesize().


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019