You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2005/09/15 22:28:30 UTC

svn commit: r289307 - /incubator/stdcxx/trunk/src/memattr.cpp

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  <se...@roguewave.com>

	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 <errno.h>    // for errno
 #include <string.h>   // 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 <unistd.h>     // for sysconf
 #  include <sys/mman.h>   // for mincore
 #  include <sys/types.h>
+
+#  ifndef _SC_PAGE_SIZE
+     // fall back on the alternative
+#    define _SC_PAGE_SIZE _SC_PAGESIZE
+#  endif
+
 #else
 #  include <windows.h>    // 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;
     }