Commit 2f9f6cef by Benjamin Kosnik

[multiple changes]


2005-09-11  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/19265
	PR libstdc++/22309
	* include/ext/mt_allocator.h
	(__gnu_cxx::__create_handler): Remove.
	(__pool<true>::_M_destroy_thread_key): Compatibility only.
	(__pool<true>::_M_initialize(__destroy): Same.
	(__pool<true>::_M_initialize): New.
	(__pool<true>::_M_initialize_once): Nothing fancy.
	(__pool<true>::_M_once): Remove.
	(__common_pool): New.
	(__common_pool_base): New.
	(__per_type_pool): New.
	(__per_type_pool_base): New.
	* src/mt_allocator.cc: Same.
	* config/linker-map.gnu (__pool<true>::_M_initialize()): Add.

2005-09-11  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/19265
	PR libstdc++/22309
	* src/mt_allocator.cc (__gnu_internal::freelist_mutex): Make static.
	(__gnu_internal::__freelist): New type.
	(__gnu_internal::freelist): New variable.
	(__gnu_internal::_M_destroy_thread_key): New function.
	(__gnu_cxx::__pool<true>::_M_destroy): Don't delete
	_M_thread_freelist_initial.
	(__gnu_cxx::__pool<true>::_M_initialize): Make argument nameless.
	Don't use _M_thread_freelist and _M_thread_freelist_initial
	__pool<true> fields, instead use __gnu_internal::freelist fields, call
	gthread_key_create just once.  Use
	__gnu_internal::_M_destroy_thread_key as key destructor.
	(__gnu_cxx::__pool<true>::_M_get_thread_id): Store size_t id
	rather than _Thread_record* in the thread specific value.  Don't
	use _M_thread_freelist __pool<true> field, instead use
	__gnu_internal::freelist fields.
	(__gnu_cxx::__pool<true>::_M_destroy_thread_key): Do nothing.

2005-09-11  Benjamin Kosnik  <bkoz@redhat.com>
            Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/19265
	PR libstdc++/22309
	* testsuite/testsuite_shared.cc: New.
	* testsuite/lib/dg-options.exp (dg-require-sharedlib): New.
	* testsuite/lib/libstdc++.exp (libstdc++_init): Look for shared
	library, and set v3-sharedlib based on this.
	(check_v3_target_sharedlib): New.
	(proc v3-build_support): Build shared objects.
	* testsuite/ext/mt_allocator/22309_thread.cc: New, use above.

From-SVN: r104161
parent 56b4ea3d
2005-09-11 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/19265
PR libstdc++/22309
* include/ext/mt_allocator.h
(__gnu_cxx::__create_handler): Remove.
(__pool<true>::_M_destroy_thread_key): Compatibility only.
(__pool<true>::_M_initialize(__destroy): Same.
(__pool<true>::_M_initialize): New.
(__pool<true>::_M_initialize_once): Nothing fancy.
(__pool<true>::_M_once): Remove.
(__common_pool): New.
(__common_pool_base): New.
(__per_type_pool): New.
(__per_type_pool_base): New.
* src/mt_allocator.cc: Same.
* config/linker-map.gnu (__pool<true>::_M_initialize()): Add.
2005-09-11 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/19265
PR libstdc++/22309
* src/mt_allocator.cc (__gnu_internal::freelist_mutex): Make static.
(__gnu_internal::__freelist): New type.
(__gnu_internal::freelist): New variable.
(__gnu_internal::_M_destroy_thread_key): New function.
(__gnu_cxx::__pool<true>::_M_destroy): Don't delete
_M_thread_freelist_initial.
(__gnu_cxx::__pool<true>::_M_initialize): Make argument nameless.
Don't use _M_thread_freelist and _M_thread_freelist_initial
__pool<true> fields, instead use __gnu_internal::freelist fields, call
gthread_key_create just once. Use
__gnu_internal::_M_destroy_thread_key as key destructor.
(__gnu_cxx::__pool<true>::_M_get_thread_id): Store size_t id
rather than _Thread_record* in the thread specific value. Don't
use _M_thread_freelist __pool<true> field, instead use
__gnu_internal::freelist fields.
(__gnu_cxx::__pool<true>::_M_destroy_thread_key): Do nothing.
2005-09-11 Benjamin Kosnik <bkoz@redhat.com>
Jakub Jelinek <jakub@redhat.com>
PR libstdc++/19265
PR libstdc++/22309
* testsuite/testsuite_shared.cc: New.
* testsuite/lib/dg-options.exp (dg-require-sharedlib): New.
* testsuite/lib/libstdc++.exp (libstdc++_init): Look for shared
library, and set v3-sharedlib based on this.
(check_v3_target_sharedlib): New.
(proc v3-build_support): Build shared objects.
* testsuite/ext/mt_allocator/22309_thread.cc: New, use above.
2005-09-11 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/23781
......
......@@ -515,8 +515,8 @@ GLIBCXX_3.4.3 {
} GLIBCXX_3.4.2;
GLIBCXX_3.4.4 {
_ZN9__gnu_cxx6__poolILb0EE13_M_initializeEv;
_ZN9__gnu_cxx6__poolILb0EE13_M_initializeEv;
_ZN9__gnu_cxx6__poolILb1EE13_M_initializeEPFvPvE;
_ZN9__gnu_cxx6__poolILb1EE21_M_destroy_thread_keyEPv;
_ZN9__gnu_cxx6__poolILb1EE16_M_get_thread_idEv;
......@@ -571,6 +571,8 @@ GLIBCXX_3.4.6 {
_ZNKSt15basic_stringbufIwSt11char_traitsIwESaIwEE3strEv;
_ZN9__gnu_cxx6__poolILb1EE13_M_initializeEv;
} GLIBCXX_3.4.5;
# Symbols in the support library (libsupc++) have their own tag.
......
// { dg-require-sharedlib "" }
// { dg-do run { target *-*-linux* } }
// { dg-options "-g -O2 -pthread -ldl" { target *-*-linux* } }
// Copyright (C) 2004, 2005 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <dlfcn.h>
#include <pthread.h>
#include <cstdlib>
#include <stdexcept>
void
check_dlopen(void*& h)
{
dlerror();
void* tmp = dlopen("./testsuite_shared.so", RTLD_LAZY);
if (!tmp)
{
try
{
// Throws std::logic_error on NULL string.
std::string error(dlerror());
throw std::runtime_error(error);
}
catch (const std::logic_error&)
{ }
}
h = tmp;
}
void
check_dlsym(void*& h)
{
dlerror();
typedef void (*function_type) (void);
function_type fn;
fn = reinterpret_cast<function_type>(dlsym(h, "foo"));
try
{
std::string error(dlerror());
throw std::runtime_error(error);
}
catch (const std::logic_error&)
{ }
fn();
}
void
check_dlclose(void*& h)
{
dlerror();
if (dlclose(h) != 0)
{
try
{
std::string error(dlerror());
throw std::runtime_error(error);
}
catch (const std::logic_error&)
{ }
}
}
void*
tf(void* arg)
{
void* h;
check_dlopen(h);
check_dlsym(h);
check_dlclose(h);
return 0;
}
// libstdc++/22309
int
main (void)
{
pthread_t th;
pthread_create(&th, NULL, tf, NULL);
pthread_join(th, NULL);
return 0;
}
......@@ -44,3 +44,12 @@ proc dg-require-cxa-atexit { args } {
}
return
}
proc dg-require-sharedlib { args } {
if { ![ check_v3_target_sharedlib ] } {
upvar dg-do-what dg-do-what
set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
return
}
return
}
......@@ -14,7 +14,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# Define callbacks and load other libraries. This file is loaded relatively
......@@ -79,6 +80,7 @@ proc v3-copy-files {srcfiles} {
# Called once, during runtest.exp setup.
proc libstdc++_init { testfile } {
global env
global v3-sharedlib
global srcdir blddir objdir tool_root_dir
global cxx cxxflags
global includes
......@@ -127,6 +129,15 @@ proc libstdc++_init { testfile } {
}
v3track gccdir 3
# Look for shared library. (ie libstdc++.so.)
set v3-sharedlib 0
set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.so]
if {$sharedlibdir != ""} {
set v3-sharedlib 1
verbose -log "shared library support detected"
}
v3track v3-sharedlib 3
# Compute what needs to be added to the existing LD_LIBRARY_PATH.
if {$gccdir != ""} {
set ld_library_path ""
......@@ -324,6 +335,7 @@ proc v3-build_support {} {
global v3-threads
global v3-test_objs
global v3-symver
global v3-sharedlib
# Figure out whether or not the library supports certain features.
set v3-wchar_t 0
......@@ -353,7 +365,7 @@ proc v3-build_support {} {
# Build the support objects.
set source_files \
[list testsuite_abi.cc testsuite_allocator.cc testsuite_character.cc testsuite_hooks.cc]
[list testsuite_abi.cc testsuite_allocator.cc testsuite_character.cc testsuite_hooks.cc ]
foreach f $source_files {
set object_file [file rootname $f].o
# Compile with "-w" so that warnings issued by the compiler
......@@ -365,6 +377,27 @@ proc v3-build_support {} {
}
append v3-test_objs "$object_file "
}
# Build the shared support objects.
if { ${v3-sharedlib} == 1 } {
set source_files \
[list testsuite_shared.cc]
foreach f $source_files {
set object_file [file rootname $f].so
# Compile with "-w" so that warnings issued by the compiler
# do not prevent compilation.
if { [v3_target_compile $srcdir/$f $object_file "executable" \
[list "incdir=$srcdir" "additional_flags=-w -shared -fPIC -DPIC"]]
!= "" } {
error "could not compile $f"
}
}
}
}
proc check_v3_target_sharedlib { } {
global v3-sharedlib
return ${v3-sharedlib}
}
proc check_v3_target_namedlocale { } {
......@@ -491,27 +524,27 @@ proc check_v3_target_cxa_atexit { } {
puts $f "static unsigned int count;"
puts $f "struct X"
puts $f "{"
puts $f "X() { count = 1; }"
puts $f "~X()"
puts $f "{"
puts $f " if (count != 3)"
puts $f " exit(1);"
puts $f " count = 4;"
puts $f "}"
puts $f " X() { count = 1; }"
puts $f " ~X()"
puts $f " {"
puts $f " if (count != 3)"
puts $f " exit(1);"
puts $f " count = 4;"
puts $f " }"
puts $f "};"
puts $f "void f()"
puts $f "{"
puts $f "static X x;"
puts $f " static X x;"
puts $f "}"
puts $f "struct Y"
puts $f "{"
puts $f "Y() { f(); count = 2; }"
puts $f "~Y()"
puts $f "{"
puts $f "if (count != 2)"
puts $f " exit(1);"
puts $f "count = 3;"
puts $f "}"
puts $f " Y() { f(); count = 2; }"
puts $f " ~Y()"
puts $f " {"
puts $f " if (count != 2)"
puts $f " exit(1);"
puts $f " count = 3;"
puts $f " }"
puts $f "};"
puts $f "Y y;"
puts $f "int main()"
......
// Copyright (C) 2004, 2005 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
#include <string>
#include <ext/mt_allocator.h>
// libstdc++/22309
extern "C" void
foo()
{
typedef char value_t;
typedef __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true> policy_t;
typedef __gnu_cxx::__mt_alloc<value_t, policy_t> allocator_t;
typedef std::char_traits<value_t> traits_t;
typedef std::basic_string<value_t, traits_t, allocator_t> string_t;
string_t s;
s += "west beach, indiana dunes";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment