re PR libstdc++/14775 ([3.4 only] LFS tests missing)

2004-04-01  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/14775
	* acconfig.h: Rename _GLIBCXX_MEM_LIMITS to _GLIBCXX_RES_LIMITS.
	* acinclude.m4 (GLIBCXX_CHECK_SETRLIMIT): Call
	GLIBCXX_CHECK_SETRLIMIT_ancilliary for FSIZE too, adjust define
	to _GLIBCXX_RES_LIMITS.
	(GLIBCXX_CHECK_SETRLIMIT_ancilliary): Rename HAVE_MEMLIMIT_* to
	HAVE_LIMIT_*.
	* testsuite/testsuite_hooks.h: Declare set_file_limit.
	* testsuite/testsuite_hooks.cc: Define it, using getrlimit
	and setrlimit(RLIMIT_FSIZE).
	* testsuite/27_io/fpos/14775.cc: New.
	* config.h.in: Regenerate.
	* configure: Likewise.

From-SVN: r80289
This commit is contained in:
Paolo Carlini 2004-04-01 09:16:36 +00:00 committed by Paolo Carlini
parent 8df83eae1e
commit 2ae6e9823a
8 changed files with 196 additions and 46 deletions

View File

@ -1,3 +1,19 @@
2004-04-01 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/14775
* acconfig.h: Rename _GLIBCXX_MEM_LIMITS to _GLIBCXX_RES_LIMITS.
* acinclude.m4 (GLIBCXX_CHECK_SETRLIMIT): Call
GLIBCXX_CHECK_SETRLIMIT_ancilliary for FSIZE too, adjust define
to _GLIBCXX_RES_LIMITS.
(GLIBCXX_CHECK_SETRLIMIT_ancilliary): Rename HAVE_MEMLIMIT_* to
HAVE_LIMIT_*.
* testsuite/testsuite_hooks.h: Declare set_file_limit.
* testsuite/testsuite_hooks.cc: Define it, using getrlimit
and setrlimit(RLIMIT_FSIZE).
* testsuite/27_io/fpos/14775.cc: New.
* config.h.in: Regenerate.
* configure: Likewise.
2004-03-31 Paolo Carlini <pcarlini@suse.de>
* config/locale/generic/c_locale.cc (__convert_to_v(long double&)):

View File

@ -25,8 +25,8 @@
// Define if code specialized for wchar_t should be used.
#undef _GLIBCXX_USE_WCHAR_T
// Define if using setrlimit to limit memory usage during 'make check'.
#undef _GLIBCXX_MEM_LIMITS
// Define if using setrlimit to set resource limits during 'make check'.
#undef _GLIBCXX_RES_LIMITS
// Define to use concept checking code from the boost libraries.
#undef _GLIBCXX_CONCEPT_CHECKS

View File

@ -454,8 +454,8 @@ dnl Check for headers for, and arguments to, the setrlimit() function.
dnl Used only in testsuite_hooks.h. Called from GLIBCXX_CONFIGURE_TESTSUITE.
dnl
dnl Defines:
dnl _GLIBCXX_MEM_LIMITS if we can set artificial limits on memory
dnl various HAVE_MEMLIMIT_* for individual limit names
dnl _GLIBCXX_RES_LIMITS if we can set artificial resource limits
dnl various HAVE_LIMIT_* for individual limit names
dnl
AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT_ancilliary], [
AC_TRY_COMPILE(
@ -465,7 +465,7 @@ AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT_ancilliary], [
],
[ int f = RLIMIT_$1 ; ],
[glibcxx_mresult=1], [glibcxx_mresult=0])
AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcxx_mresult,
AC_DEFINE_UNQUOTED(HAVE_LIMIT_$1, $glibcxx_mresult,
[Only used in build directory testsuite_hooks.h.])
])
@ -482,6 +482,7 @@ AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT], [
GLIBCXX_CHECK_SETRLIMIT_ancilliary(RSS)
GLIBCXX_CHECK_SETRLIMIT_ancilliary(VMEM)
GLIBCXX_CHECK_SETRLIMIT_ancilliary(AS)
GLIBCXX_CHECK_SETRLIMIT_ancilliary(FSIZE)
# Check for rlimit, setrlimit.
AC_CACHE_VAL(ac_setrlimit, [
@ -496,14 +497,14 @@ AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT], [
])
fi
AC_MSG_CHECKING([for testsuite memory limit support])
AC_MSG_CHECKING([for testsuite resource limits support])
if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
ac_mem_limits=yes
AC_DEFINE(_GLIBCXX_MEM_LIMITS)
ac_res_limits=yes
AC_DEFINE(_GLIBCXX_RES_LIMITS)
else
ac_mem_limits=no
ac_res_limits=no
fi
AC_MSG_RESULT($ac_mem_limits)
AC_MSG_RESULT($ac_res_limits)
])
@ -634,7 +635,7 @@ dnl baseline_dir
dnl
AC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [
if $GLIBCXX_IS_NATIVE && test $is_hosted = yes; then
# Do checks for memory limit functions.
# Do checks for resource limit functions.
GLIBCXX_CHECK_SETRLIMIT
# Look for setenv, so that extended locale tests can be performed.

View File

@ -26,8 +26,8 @@
// Define if code specialized for wchar_t should be used.
#undef _GLIBCXX_USE_WCHAR_T
// Define if using setrlimit to limit memory usage during 'make check'.
#undef _GLIBCXX_MEM_LIMITS
// Define if using setrlimit to set resource limits during 'make check'.
#undef _GLIBCXX_RES_LIMITS
// Define to use concept checking code from the boost libraries.
#undef _GLIBCXX_CONCEPT_CHECKS
@ -362,6 +362,21 @@
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Only used in build directory testsuite_hooks.h. */
#undef HAVE_LIMIT_AS
/* Only used in build directory testsuite_hooks.h. */
#undef HAVE_LIMIT_DATA
/* Only used in build directory testsuite_hooks.h. */
#undef HAVE_LIMIT_FSIZE
/* Only used in build directory testsuite_hooks.h. */
#undef HAVE_LIMIT_RSS
/* Only used in build directory testsuite_hooks.h. */
#undef HAVE_LIMIT_VMEM
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
@ -395,18 +410,6 @@
/* Define to 1 if you have the `mbsrtowcs' function. */
#undef HAVE_MBSRTOWCS
/* Only used in build directory testsuite_hooks.h. */
#undef HAVE_MEMLIMIT_AS
/* Only used in build directory testsuite_hooks.h. */
#undef HAVE_MEMLIMIT_DATA
/* Only used in build directory testsuite_hooks.h. */
#undef HAVE_MEMLIMIT_RSS
/* Only used in build directory testsuite_hooks.h. */
#undef HAVE_MEMLIMIT_VMEM
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

View File

@ -72046,7 +72046,7 @@ echo "$as_me: versioning on shared library symbols is $enable_symvers" >&6;}
# This depends on GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE.
if $GLIBCXX_IS_NATIVE && test $is_hosted = yes; then
# Do checks for memory limit functions.
# Do checks for resource limit functions.
setrlimit_have_headers=yes
@ -72258,7 +72258,7 @@ fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
cat >>confdefs.h <<_ACEOF
#define HAVE_MEMLIMIT_DATA $glibcxx_mresult
#define HAVE_LIMIT_DATA $glibcxx_mresult
_ACEOF
@ -72313,7 +72313,7 @@ fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
cat >>confdefs.h <<_ACEOF
#define HAVE_MEMLIMIT_RSS $glibcxx_mresult
#define HAVE_LIMIT_RSS $glibcxx_mresult
_ACEOF
@ -72368,7 +72368,7 @@ fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
cat >>confdefs.h <<_ACEOF
#define HAVE_MEMLIMIT_VMEM $glibcxx_mresult
#define HAVE_LIMIT_VMEM $glibcxx_mresult
_ACEOF
@ -72423,7 +72423,62 @@ fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
cat >>confdefs.h <<_ACEOF
#define HAVE_MEMLIMIT_AS $glibcxx_mresult
#define HAVE_LIMIT_AS $glibcxx_mresult
_ACEOF
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>
int
main ()
{
int f = RLIMIT_FSIZE ;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
glibcxx_mresult=1
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
glibcxx_mresult=0
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
cat >>confdefs.h <<_ACEOF
#define HAVE_LIMIT_FSIZE $glibcxx_mresult
_ACEOF
@ -72487,19 +72542,19 @@ fi
fi
echo "$as_me:$LINENO: checking for testsuite memory limit support" >&5
echo $ECHO_N "checking for testsuite memory limit support... $ECHO_C" >&6
echo "$as_me:$LINENO: checking for testsuite resource limits support" >&5
echo $ECHO_N "checking for testsuite resource limits support... $ECHO_C" >&6
if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
ac_mem_limits=yes
ac_res_limits=yes
cat >>confdefs.h <<\_ACEOF
#define _GLIBCXX_MEM_LIMITS 1
#define _GLIBCXX_RES_LIMITS 1
_ACEOF
else
ac_mem_limits=no
ac_res_limits=no
fi
echo "$as_me:$LINENO: result: $ac_mem_limits" >&5
echo "${ECHO_T}$ac_mem_limits" >&6
echo "$as_me:$LINENO: result: $ac_res_limits" >&5
echo "${ECHO_T}$ac_res_limits" >&6
# Look for setenv, so that extended locale tests can be performed.

View File

@ -0,0 +1,55 @@
// 2004-03-31 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2004 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.4.3 fpos
#include <fstream>
#include <testsuite_hooks.h>
#define TWO_GB 2147483648UL
// Basic test for LFS support.
void test01()
{
#ifdef _GLIBCXX_USE_LFS
using namespace std;
bool test __attribute__((unused)) = true;
typedef filebuf::pos_type pos_type;
typedef filebuf::off_type off_type;
__gnu_test::set_file_limit(TWO_GB + 200);
basic_filebuf<char> fb;
fb.open("14775_tmp", ios_base::out | ios_base::in | ios_base::trunc);
pos_type ret = fb.pubseekoff(TWO_GB + 100, ios_base::beg);
VERIFY( ret != pos_type(off_type(-1)) );
fb.close();
#endif
}
int main()
{
test01();
return 0;
}

View File

@ -30,7 +30,7 @@
#include <testsuite_hooks.h>
#ifdef _GLIBCXX_MEM_LIMITS
#ifdef _GLIBCXX_RES_LIMITS
#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>
@ -44,7 +44,7 @@
namespace __gnu_test
{
#ifdef _GLIBCXX_MEM_LIMITS
#ifdef _GLIBCXX_RES_LIMITS
void
set_memory_limits(float size)
{
@ -53,21 +53,21 @@ namespace __gnu_test
__typeof__ (r.rlim_cur) limit = (__typeof__ (r.rlim_cur))(size * 1048576);
// Heap size, seems to be common.
#if _GLIBCXX_HAVE_MEMLIMIT_DATA
#if _GLIBCXX_HAVE_LIMIT_DATA
getrlimit(RLIMIT_DATA, &r);
r.rlim_cur = limit;
setrlimit(RLIMIT_DATA, &r);
#endif
// Resident set size.
#if _GLIBCXX_HAVE_MEMLIMIT_RSS
#if _GLIBCXX_HAVE_LIMIT_RSS
getrlimit(RLIMIT_RSS, &r);
r.rlim_cur = limit;
setrlimit(RLIMIT_RSS, &r);
#endif
// Mapped memory (brk + mmap).
#if _GLIBCXX_HAVE_MEMLIMIT_VMEM
#if _GLIBCXX_HAVE_LIMIT_VMEM
getrlimit(RLIMIT_VMEM, &r);
r.rlim_cur = limit;
setrlimit(RLIMIT_VMEM, &r);
@ -77,7 +77,7 @@ namespace __gnu_test
// On HP-UX 11.23, a trivial C++ program that sets RLIMIT_AS to
// anything less than 128MB cannot "malloc" even 1K of memory.
// Therefore, we skip RLIMIT_AS on HP-UX.
#if _GLIBCXX_HAVE_MEMLIMIT_AS && !defined(__hpux__)
#if _GLIBCXX_HAVE_LIMIT_AS && !defined(__hpux__)
getrlimit(RLIMIT_AS, &r);
r.rlim_cur = limit;
setrlimit(RLIMIT_AS, &r);
@ -89,6 +89,25 @@ namespace __gnu_test
set_memory_limits(float) { }
#endif
#ifdef _GLIBCXX_RES_LIMITS
void
set_file_limit(unsigned long size)
{
#if _GLIBCXX_HAVE_LIMIT_FSIZE
struct rlimit r;
// Cater to the absence of rlim_t.
__typeof__ (r.rlim_cur) limit = (__typeof__ (r.rlim_cur))(size);
getrlimit(RLIMIT_FSIZE, &r);
r.rlim_cur = limit;
setrlimit(RLIMIT_FSIZE, &r);
#endif
}
#else
void
set_file_limit(unsigned long) { }
#endif
void
verify_demangle(const char* mangled, const char* wanted)

View File

@ -39,7 +39,7 @@
// set_memory_limits() uses setrlimit() to restrict dynamic memory
// allocation. We provide a default memory limit if none is passed by the
// calling application. The argument to set_memory_limits() is the
// limit in megabytes (a floating-point number). If _GLIBCXX_MEM_LIMITS is
// limit in megabytes (a floating-point number). If _GLIBCXX_RES_LIMITS is
// not #defined before including this header, then no limiting is attempted.
//
// 3) counter
@ -86,7 +86,7 @@ namespace __gnu_test
// from c++config.h
// Set memory limits if possible, if not set to 0.
#ifndef _GLIBCXX_MEM_LIMITS
#ifndef _GLIBCXX_RES_LIMITS
# define MEMLIMIT_MB 0
#else
# ifndef MEMLIMIT_MB
@ -96,12 +96,13 @@ namespace __gnu_test
extern void
set_memory_limits(float __size = MEMLIMIT_MB);
extern void
set_file_limit(unsigned long __size);
// Check mangled name demangles (using __cxa_demangle) as expected.
void
verify_demangle(const char* mangled, const char* wanted);
// Simple callback structure for variable numbers of tests (all with
// same signature). Assume all unit tests are of the signature
// void test01();