Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 11485 invoked from network); 15 Sep 2005 20:28:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Sep 2005 20:28:32 -0000 Received: (qmail 69840 invoked by uid 500); 15 Sep 2005 20:28:32 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 69821 invoked by uid 500); 15 Sep 2005 20:28:31 -0000 Mailing-List: contact stdcxx-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-commits@incubator.apache.org Received: (qmail 69808 invoked by uid 500); 15 Sep 2005 20:28:31 -0000 Delivered-To: apmail-incubator-stdcxx-cvs@incubator.apache.org Received: (qmail 69805 invoked by uid 99); 15 Sep 2005 20:28:31 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 15 Sep 2005 13:28:30 -0700 Received: (qmail 11479 invoked by uid 65534); 15 Sep 2005 20:28:30 -0000 Message-ID: <20050915202830.11478.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r289307 - /incubator/stdcxx/trunk/src/memattr.cpp Date: Thu, 15 Sep 2005 20:28:30 -0000 To: stdcxx-cvs@incubator.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: sebor Date: Thu Sep 15 13:28:27 2005 New Revision: 289307 URL: http://svn.apache.org/viewcvs?rev=289307&view=rev Log: 2005-09-15 Martin Sebor STDCXX-19 * memattr.cpp: #defined _SC_PAGE_SIZE to _SC_PAGESIZE when the former is not #defined (such as Cygwin). STDCXX-20 * memattr.cpp: #defined _WIN32 when __CYGWIN__ is #defined to take advantage of the Windows Memory Management API and to work aound the lack of madvise(). Modified: incubator/stdcxx/trunk/src/memattr.cpp Modified: incubator/stdcxx/trunk/src/memattr.cpp URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/src/memattr.cpp?rev=289307&r1=289306&r2=289307&view=diff ============================================================================== --- incubator/stdcxx/trunk/src/memattr.cpp (original) +++ incubator/stdcxx/trunk/src/memattr.cpp Thu Sep 15 13:28:27 2005 @@ -3,7 +3,7 @@ * memattr.cpp - source for C++ Standard Library helper functions * to determine the attributes of regions of memory * - * $Id: //stdlib/dev/source/stdlib/memattr.cpp#6 $ + * $Id$ * *************************************************************************** * @@ -25,6 +25,11 @@ #include // for errno #include // for memchr +#ifdef __CYGWIN__ + // use the Windows API on Cygwin +# define _WIN32 +#endif + #if !defined (_WIN32) && !defined (_WIN64) # ifdef __SUNPRO_CC // working around SunOS bug #568 @@ -33,6 +38,12 @@ # include // for sysconf # include // for mincore # include + +# ifndef _SC_PAGE_SIZE + // fall back on the alternative +# define _SC_PAGE_SIZE _SC_PAGESIZE +# endif + #else # include // for everything (ugh) #endif // _WIN{32,64} @@ -139,11 +150,15 @@ LPVOID const ptr = _RWSTD_CONST_CAST (LPVOID, addr); if (_RWSTD_SIZE_MAX == nbytes) { + + // treat the address as a pointer to a NUL-terminated string if (IsBadStringPtr (_RWSTD_STATIC_CAST (LPCSTR, ptr), nbytes)) return -1; + // compute the length of the string nbytes = strlen (_RWSTD_STATIC_CAST (const char*, addr)); + // disable read checking below (since it was done above) attr &= ~_RWSTD_PROT_READ; }