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 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: <4D2C6AE0 DOT 1000703 AT redhat DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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