delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/01/12/06:15:50

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Wed, 12 Jan 2011 12:15:20 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Adding madvise function in cygwin with a #define
Message-ID: <20110112111520.GJ6353@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <AANLkTimioT4OZ7CfW1Kh7R1nWv7uKz6v_3w=Hcgv-J6D AT mail DOT gmail DOT com> <4D2C6AE0 DOT 1000703 AT redhat DOT com> <AANLkTin_qu-uidFWgas31-v4MwWqLbi75svwtO-cUKoZ AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <AANLkTin_qu-uidFWgas31-v4MwWqLbi75svwtO-cUKoZ@mail.gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
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 11 20:12, jdzstz - gmail dot com wrote:
> I have read cygwin "posix_madvise" code, that is in "mmap.cc" file and
> "madvise" linux code and posix especification:
>   *  CYGWIN => mmap.cc file:
> http://cygwin.com/cgi-bin/cvsweb.cgi/~checkout~/src/winsup/cygwin/mmap.cc?cvsroot=src
>   *  LINUX => madvise man:
> http://www.kernel.org/doc/man-pages/online/pages/man2/madvise.2.html
>                   => madvise source:
> http://lxr.linux.no/linux+v2.6.37/mm/madvise.c
>   *  POSIX => posix_madvise specification:
> http://pubs.opengroup.org/onlinepubs/009695399/functions/posix_madvise.html
> 
> Your argument "madvise is more powerful than posix_madvise" in linux
> is correct, the diference about standard "posix_madvise" and linux
> "madvise" are the number of advices that admit in "int advice"
> parameters, Linux implementation admits 10 options but standard Posix
> only defines 5.

For a start, please note that the Windows MM does not support any 
advises.  So the posix_madvise function behaves exactly as specified.
It checks the validity of its parameters and then just ignores the
advice since the OS doesn't support it anyway.

There are two big differences between posix_madvise and madvise.

Madvise doesn't handle the advice as advice, but as a command.  In
contrast to posix_madvise, it returns with an error if it can't support
the given advice.

Madvise supports flags which affect the memory mapping behaviour on fork.
Given that madvise returns an error if something can't be supported,
an application which relies on this behaviour will be dis-functional
on Cygwin, or at least would have a potentially serious security
problem.

Consequentially, *iff* Cygwin implements madvise, it would have to
be implemented along the lines of:

  int
  madvise (void *addr, size_t length, int advice)
  {
    set_errno (EINVAL);
    return -1;
  }

I'm wondering if that's really feasible.


Corinna

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

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

- Raw text -


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