From commits-return-3644-apmail-stdcxx-commits-archive=stdcxx.apache.org@stdcxx.apache.org Mon Jan 18 01:21:49 2010 Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 63125 invoked from network); 18 Jan 2010 01:21:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Jan 2010 01:21:49 -0000 Received: (qmail 33686 invoked by uid 500); 18 Jan 2010 01:21:49 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 33647 invoked by uid 500); 18 Jan 2010 01:21:49 -0000 Mailing-List: contact commits-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list commits@stdcxx.apache.org Received: (qmail 33638 invoked by uid 99); 18 Jan 2010 01:21:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jan 2010 01:21:49 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jan 2010 01:21:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id EF6AF238888F; Mon, 18 Jan 2010 01:21:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r900262 - in /stdcxx/branches/4.2.x: etc/config/src/POSIX_MADVISE.cpp src/memattr.cpp Date: Mon, 18 Jan 2010 01:21:27 -0000 To: commits@stdcxx.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100118012127.EF6AF238888F@eris.apache.org> Author: sebor Date: Mon Jan 18 01:21:27 2010 New Revision: 900262 URL: http://svn.apache.org/viewvc?rev=900262&view=rev Log: 2010-01-17 John Taylor STDCXX-1045 * etc/config/src/POSIX_MADVISE.cpp: New config test. * src/memattr.cpp [_RWSTD_OS_SUNOS && !_RWSTD_NO_POSIX_MADVISE] (__rw_memattr): Used posix_madvise() instead of madvise(). Added: stdcxx/branches/4.2.x/etc/config/src/POSIX_MADVISE.cpp (with props) Modified: stdcxx/branches/4.2.x/src/memattr.cpp Added: stdcxx/branches/4.2.x/etc/config/src/POSIX_MADVISE.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/etc/config/src/POSIX_MADVISE.cpp?rev=900262&view=auto ============================================================================== --- stdcxx/branches/4.2.x/etc/config/src/POSIX_MADVISE.cpp (added) +++ stdcxx/branches/4.2.x/etc/config/src/POSIX_MADVISE.cpp Mon Jan 18 01:21:27 2010 @@ -0,0 +1,40 @@ +// checking for posix_madvise() in + +/*************************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the License); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + * + **************************************************************************/ + +#include // for posix_madvise(), POSIX_MADV_WILLNEED +#include // for size_t + + +int main (int argc, char *argv[]) +{ + size_t len = (size_t)argc; + + const int result = posix_madvise (argv, len, POSIX_MADV_WILLNEED); + + if (1 < argc) { + // invoke with any command line arguments to test + return result; + } + + // always succeed when invoked without arguments + return 0; +} Propchange: stdcxx/branches/4.2.x/etc/config/src/POSIX_MADVISE.cpp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: stdcxx/branches/4.2.x/etc/config/src/POSIX_MADVISE.cpp ------------------------------------------------------------------------------ svn:keywords = Id Modified: stdcxx/branches/4.2.x/src/memattr.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/memattr.cpp?rev=900262&r1=900261&r2=900262&view=diff ============================================================================== --- stdcxx/branches/4.2.x/src/memattr.cpp (original) +++ stdcxx/branches/4.2.x/src/memattr.cpp Mon Jan 18 01:21:27 2010 @@ -29,6 +29,8 @@ #define _RWSTD_LIB_SRC +#include + #include // for ENOMEM, errno #include // for memchr(), size_t @@ -55,6 +57,11 @@ # include // for mincore() # include +# if defined (_RWSTD_OS_SUNOS) && defined (_RWSTD_NO_POSIX_MADVISE) + // can't get a proper prototype for madvise with C++ defines in Solaris 10 + extern "C" int madvise(caddr_t, size_t, int); +# endif + # ifndef _SC_PAGE_SIZE // fall back on the alternative macro if it exists, @@ -93,7 +100,6 @@ ( _RWSTD_REINTERPRET_CAST (const char*, addr1) \ - _RWSTD_REINTERPRET_CAST (const char*, addr2)) - _RWSTD_NAMESPACE (__rw) { _RWSTD_EXPORT _RWSTD_SSIZE_T @@ -129,11 +135,21 @@ # ifdef _RWSTD_OS_SUNOS - char dummy = '\0'; +# ifndef _RWSTD_NO_POSIX_MADVISE + + const int advice = POSIX_MADV_WILLNEED; + + // on Solaris use posix_madvise if available + if (-1 == posix_madvise (next, 1, advice)) { + +# else + + const int advice = MADV_WILLNEED; + + // on Solaris use madvise if available + if (-1 == madvise (next, 1, advice)) { - // on Solaris use mincore() instead of madvise() since - // the latter is unreliable - if (-1 == mincore (next, 1, &dummy)) { +# endif // _RWSTD_NO_POSIX_MADVISE const int err = errno; errno = errno_save;