mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-24 19:33:59 +08:00
threads-no.h: Remove file.
* config/threads-no.h: Remove file. * config/threads-posix.h: Remove file. * acconfig.h (_GLIBCPP_USE_THREADS): Remove. (_GLIBCPP_SUPPORTS_WEAK): Add (required by namespace-clean gthr*.h). (_GLIBCPP_HAVE_GTHR_DEFAULT): Likewise. * config.h.in: Regenerate. * acinclude.m4 (GLIBCPP_ENABLE_THREADS): Completely rework to setup and use gthr*.h files. In particular, make gthr.h files namespace-clean in the staging area (they don't have to be for libgcc.a). * aclocal.m4: Regenerate. * configure: Regenerate. * src/Makefile.am (build_headers): Remove bits/c++threads.h and add bits/gthr.h bits/gthr-single.h bits/gthr-default.h. * src/Makefile.in: Regenerate. * include/bits/c++config: Cleanup threading configuration macros. In particular, define __STL_GTHREADS macro which controls... * include/bits/stl_threads.h: ...a brand new gthr.h-based configuration here. * config/c_io_stdio.h: Include staged gthr.h instead of local thread configuration file. Always use __gthread_mutex_t instead of __mutext_type (or int). * include/bits/std_fstream.h: Likewise. * docs/html/17_intro/howto.html: Remove placeholder comment in case this configuration patch didn't make it. Add advice that section only applies if configured with --enable-threads. * docs/html/23_containers/howto.html: Reword to make clear that _PTHREADS is no longer required for any port to be correctly using STL with threads. Add advice that section only applies if configured with --enable-threads. Co-Authored-By: John David Anglin <dave@hiauly1.hia.nrc.ca> From-SVN: r42998
This commit is contained in:
parent
e9a8af1067
commit
5e21803304
@ -1,3 +1,43 @@
|
|||||||
|
2001-06-07 Loren J. Rittle <ljrittle@acm.org>
|
||||||
|
John David Anglin <dave@hiauly1.hia.nrc.ca>
|
||||||
|
|
||||||
|
* config/threads-no.h: Remove file.
|
||||||
|
* config/threads-posix.h: Remove file.
|
||||||
|
|
||||||
|
* acconfig.h (_GLIBCPP_USE_THREADS): Remove.
|
||||||
|
(_GLIBCPP_SUPPORTS_WEAK): Add (required by namespace-clean gthr*.h).
|
||||||
|
(_GLIBCPP_HAVE_GTHR_DEFAULT): Likewise.
|
||||||
|
* config.h.in: Regenerate.
|
||||||
|
|
||||||
|
* acinclude.m4 (GLIBCPP_ENABLE_THREADS): Completely rework to
|
||||||
|
setup and use gthr*.h files. In particular, make gthr.h files
|
||||||
|
namespace-clean in the staging area (they don't have to be for
|
||||||
|
libgcc.a).
|
||||||
|
* aclocal.m4: Regenerate.
|
||||||
|
* configure: Regenerate.
|
||||||
|
|
||||||
|
* src/Makefile.am (build_headers): Remove bits/c++threads.h
|
||||||
|
and add bits/gthr.h bits/gthr-single.h bits/gthr-default.h.
|
||||||
|
* src/Makefile.in: Regenerate.
|
||||||
|
|
||||||
|
* include/bits/c++config: Cleanup threading configuration macros.
|
||||||
|
In particular, define __STL_GTHREADS macro which controls...
|
||||||
|
* include/bits/stl_threads.h: ...a brand new gthr.h-based
|
||||||
|
configuration here.
|
||||||
|
|
||||||
|
* config/c_io_stdio.h: Include staged gthr.h instead of local
|
||||||
|
thread configuration file. Always use __gthread_mutex_t
|
||||||
|
instead of __mutext_type (or int).
|
||||||
|
* include/bits/std_fstream.h: Likewise.
|
||||||
|
|
||||||
|
* docs/html/17_intro/howto.html: Remove placeholder comment in
|
||||||
|
case this configuration patch didn't make it. Add advice that
|
||||||
|
section only applies if configured with --enable-threads.
|
||||||
|
* docs/html/23_containers/howto.html: Reword to make clear
|
||||||
|
that _PTHREADS is no longer required for any port to be
|
||||||
|
correctly using STL with threads. Add advice that section
|
||||||
|
only applies if configured with --enable-threads.
|
||||||
|
|
||||||
2001-06-06 Benjamin Kosnik <bkoz@redhat.com>
|
2001-06-06 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
* src/string-inst.cc (_Rep::_S_max_size): Add instantiation.
|
* src/string-inst.cc (_Rep::_S_max_size): Add instantiation.
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
// acconfig.h symbols and macros for libstdc++ v3 -*- C++ -*-
|
// acconfig.h symbols and macros for libstdc++ v3 -*- C++ -*-
|
||||||
|
|
||||||
// Include support for multiple threads, e.g., in the I/O package.
|
// Define if GCC supports weak symbols
|
||||||
#undef _GLIBCPP_USE_THREADS
|
#undef _GLIBCPP_SUPPORTS_WEAK
|
||||||
|
|
||||||
|
// Define if gthr-default.h exists (meaning that threading support is enabled)
|
||||||
|
#undef HAVE_GTHR_DEFAULT
|
||||||
|
|
||||||
// Include support for 'long long' and 'unsigned long long'.
|
// Include support for 'long long' and 'unsigned long long'.
|
||||||
#undef _GLIBCPP_USE_LONG_LONG
|
#undef _GLIBCPP_USE_LONG_LONG
|
||||||
|
@ -1118,41 +1118,37 @@ AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
|
|||||||
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Check for which threading library to use.
|
dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
|
||||||
dnl
|
dnl We must stage the required headers so that they will be installed
|
||||||
dnl GLIBCPP_ENABLE_THREADS
|
dnl with the library (unlike libgcc, the STL implementation is provided
|
||||||
dnl --enable-threads=posix sets config/threads-posix.h et. al.
|
dnl solely within headers). Since we must not inject random user-space
|
||||||
dnl
|
dnl macro names into user-provided C++ code, we first stage into <file>-in
|
||||||
dnl Default is no threads, which also disables _IO_MTSAFE_IO in
|
dnl and process to <file> with an output command. The reason for a two-
|
||||||
dnl libio. Any actual thread package will enable it.
|
dnl stage process here is to correctly handle $srcdir!=$objdir without
|
||||||
|
dnl having to write complex code (the sed commands to clean the macro
|
||||||
|
dnl namespace are complex and fragile enough as it is).
|
||||||
dnl
|
dnl
|
||||||
AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
|
AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
|
||||||
AC_MSG_CHECKING([for thread model used by GCC])
|
AC_MSG_CHECKING([for thread model used by GCC])
|
||||||
target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
|
target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
|
||||||
AC_MSG_RESULT([$target_thread_file])
|
AC_MSG_RESULT([$target_thread_file])
|
||||||
|
|
||||||
dnl Check for thread package actually supported in libstdc++
|
AC_LINK_FILES(../gcc/gthr.h, include/bits/gthr.h-in)
|
||||||
THREADH=
|
AC_LINK_FILES(../gcc/gthr-single.h, include/bits/gthr-single.h-in)
|
||||||
case "$target_thread_file" in
|
AC_LINK_FILES(../gcc/gthr-$target_thread_file.h,
|
||||||
no | none | single)
|
include/bits/gthr-default.h-in)
|
||||||
THREADH=threads-no.h
|
if test $target_thread_file != single; then
|
||||||
;;
|
AC_DEFINE(HAVE_GTHR_DEFAULT)
|
||||||
posix | pthreads)
|
AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
|
||||||
THREADH=threads-posix.h
|
|
||||||
;;
|
|
||||||
decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
|
|
||||||
AC_MSG_WARN(disabling unsupported thread package $target_thread_file)
|
|
||||||
THREADH=threads-no.h
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
AC_MSG_ERROR($target_thread_file: unsupported/unknown thread package)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
AC_LINK_FILES(config/$THREADH, include/bits/c++threads.h)
|
|
||||||
if test $THREADH != threads-no.h; then
|
|
||||||
AC_DEFINE(_GLIBCPP_USE_THREADS)
|
|
||||||
fi
|
fi
|
||||||
|
AC_OUTPUT_COMMANDS([d=include/bits
|
||||||
|
rm -f $d/gthr.h $d/gthr-single.h $d/gthr-default.h
|
||||||
|
sed '/^#/s/\([A-Z_][A-Z_]*\)/_GLIBCPP_\1/g' <$d/gthr.h-in >$d/gthr.h
|
||||||
|
sed 's/\(UNUSED\)/_GLIBCPP_\1/g' <$d/gthr-single.h-in \
|
||||||
|
| sed 's/\(GCC[A-Z_]*_H\)/_GLIBCPP_\1/g' >$d/gthr-single.h
|
||||||
|
sed 's/\(UNUSED\)/_GLIBCPP_\1/g' <$d/gthr-default.h-in \
|
||||||
|
| sed 's/\(GCC[A-Z_]*_H\)/_GLIBCPP_\1/g' \
|
||||||
|
| sed 's/\([A-Z_]*WEAK\)/_GLIBCPP_\1/g' >$d/gthr-default.h])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
52
libstdc++-v3/aclocal.m4
vendored
52
libstdc++-v3/aclocal.m4
vendored
@ -1130,41 +1130,37 @@ AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
|
|||||||
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Check for which threading library to use.
|
dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
|
||||||
dnl
|
dnl We must stage the required headers so that they will be installed
|
||||||
dnl GLIBCPP_ENABLE_THREADS
|
dnl with the library (unlike libgcc, the STL implementation is provided
|
||||||
dnl --enable-threads=posix sets config/threads-posix.h et. al.
|
dnl solely within headers). Since we must not inject random user-space
|
||||||
dnl
|
dnl macro names into user-provided C++ code, we first stage into <file>-in
|
||||||
dnl Default is no threads, which also disables _IO_MTSAFE_IO in
|
dnl and process to <file> with an output command. The reason for a two-
|
||||||
dnl libio. Any actual thread package will enable it.
|
dnl stage process here is to correctly handle $srcdir!=$objdir without
|
||||||
|
dnl having to write complex code (the sed commands to clean the macro
|
||||||
|
dnl namespace are complex and fragile enough as it is).
|
||||||
dnl
|
dnl
|
||||||
AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
|
AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
|
||||||
AC_MSG_CHECKING([for thread model used by GCC])
|
AC_MSG_CHECKING([for thread model used by GCC])
|
||||||
target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
|
target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
|
||||||
AC_MSG_RESULT([$target_thread_file])
|
AC_MSG_RESULT([$target_thread_file])
|
||||||
|
|
||||||
dnl Check for thread package actually supported in libstdc++
|
AC_LINK_FILES(../gcc/gthr.h, include/bits/gthr.h-in)
|
||||||
THREADH=
|
AC_LINK_FILES(../gcc/gthr-single.h, include/bits/gthr-single.h-in)
|
||||||
case "$target_thread_file" in
|
AC_LINK_FILES(../gcc/gthr-$target_thread_file.h,
|
||||||
no | none | single)
|
include/bits/gthr-default.h-in)
|
||||||
THREADH=threads-no.h
|
if test $target_thread_file != single; then
|
||||||
;;
|
AC_DEFINE(HAVE_GTHR_DEFAULT)
|
||||||
posix | pthreads)
|
AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
|
||||||
THREADH=threads-posix.h
|
|
||||||
;;
|
|
||||||
decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
|
|
||||||
AC_MSG_WARN(disabling unsupported thread package $target_thread_file)
|
|
||||||
THREADH=threads-no.h
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
AC_MSG_ERROR($target_thread_file: unsupported/unknown thread package)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
AC_LINK_FILES(config/$THREADH, include/bits/c++threads.h)
|
|
||||||
if test $THREADH != threads-no.h; then
|
|
||||||
AC_DEFINE(_GLIBCPP_USE_THREADS)
|
|
||||||
fi
|
fi
|
||||||
|
AC_OUTPUT_COMMANDS([d=include/bits
|
||||||
|
rm -f $d/gthr.h $d/gthr-single.h $d/gthr-default.h
|
||||||
|
sed '/^#/s/\([A-Z_][A-Z_]*\)/_GLIBCPP_\1/g' <$d/gthr.h-in >$d/gthr.h
|
||||||
|
sed 's/\(UNUSED\)/_GLIBCPP_\1/g' <$d/gthr-single.h-in \
|
||||||
|
| sed 's/\(GCC[A-Z_]*_H\)/_GLIBCPP_\1/g' >$d/gthr-single.h
|
||||||
|
sed 's/\(UNUSED\)/_GLIBCPP_\1/g' <$d/gthr-default.h-in \
|
||||||
|
| sed 's/\(GCC[A-Z_]*_H\)/_GLIBCPP_\1/g' \
|
||||||
|
| sed 's/\([A-Z_]*WEAK\)/_GLIBCPP_\1/g' >$d/gthr-default.h])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,11 @@
|
|||||||
/* Define if you have a working `mmap' system call. */
|
/* Define if you have a working `mmap' system call. */
|
||||||
#undef HAVE_MMAP
|
#undef HAVE_MMAP
|
||||||
|
|
||||||
// Include support for multiple threads, e.g., in the I/O package.
|
// Define if GCC supports weak symbols
|
||||||
#undef _GLIBCPP_USE_THREADS
|
#undef _GLIBCPP_SUPPORTS_WEAK
|
||||||
|
|
||||||
|
// Define if gthr-default.h exists (meaning that threading support is enabled)
|
||||||
|
#undef HAVE_GTHR_DEFAULT
|
||||||
|
|
||||||
// Include support for 'long long' and 'unsigned long long'.
|
// Include support for 'long long' and 'unsigned long long'.
|
||||||
#undef _GLIBCPP_USE_LONG_LONG
|
#undef _GLIBCPP_USE_LONG_LONG
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <bits/c++threads.h>
|
#include <bits/gthr.h>
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
@ -46,12 +46,7 @@ namespace std
|
|||||||
#endif
|
#endif
|
||||||
typedef fpos_t __c_streampos;
|
typedef fpos_t __c_streampos;
|
||||||
|
|
||||||
#ifdef _GLIBCPP_USE_THREADS
|
typedef __gthread_mutex_t __c_lock;
|
||||||
typedef __mutext_type __c_lock;
|
|
||||||
#else
|
|
||||||
typedef int __c_lock;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// from basic_file.h
|
// from basic_file.h
|
||||||
#define _GLIBCPP_BASIC_FILE_ENCAPSULATION 1
|
#define _GLIBCPP_BASIC_FILE_ENCAPSULATION 1
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
// thread support (null case) -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2000 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.
|
|
||||||
|
|
||||||
// As a special exception, you may use this file as part of a free software
|
|
||||||
// library without restriction. Specifically, if other files instantiate
|
|
||||||
// templates or use macros or inline functions from this file, or you compile
|
|
||||||
// this file and link it with other files to produce an executable, this
|
|
||||||
// file does not by itself cause the resulting executable to be covered by
|
|
||||||
// the GNU General Public License. This exception does not however
|
|
||||||
// invalidate any other reasons why the executable file might be covered by
|
|
||||||
// the GNU General Public License.
|
|
||||||
|
|
||||||
// threads-no.h - Defines for using no threads.
|
|
||||||
|
|
||||||
#ifndef _CPP_THREADS_NO
|
|
||||||
#define _CPP_THREADS_NO
|
|
||||||
|
|
||||||
//
|
|
||||||
// Includes
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Defines
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Typedefs.
|
|
||||||
//
|
|
||||||
namespace std {
|
|
||||||
|
|
||||||
struct __null_mutext { };
|
|
||||||
typedef __null_mutext __mutext_type;
|
|
||||||
|
|
||||||
} // std
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Condition variables.
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Mutexes.
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Thread creation and manipulation.
|
|
||||||
//
|
|
||||||
|
|
||||||
#endif // _CPP_THREADS_NO
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
|||||||
// thread support (posix case) -*- C++ -*-
|
|
||||||
|
|
||||||
// Copyright (C) 2000 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.
|
|
||||||
|
|
||||||
// As a special exception, you may use this file as part of a free software
|
|
||||||
// library without restriction. Specifically, if other files instantiate
|
|
||||||
// templates or use macros or inline functions from this file, or you compile
|
|
||||||
// this file and link it with other files to produce an executable, this
|
|
||||||
// file does not by itself cause the resulting executable to be covered by
|
|
||||||
// the GNU General Public License. This exception does not however
|
|
||||||
// invalidate any other reasons why the executable file might be covered by
|
|
||||||
// the GNU General Public License.
|
|
||||||
|
|
||||||
// threads-posix.h - Defines for using posix threads.
|
|
||||||
|
|
||||||
// People trying to implement this should look at
|
|
||||||
// libjava/include/posix-threads.h for more info on the interface that
|
|
||||||
// java is using. It's one worth looking at.
|
|
||||||
|
|
||||||
#ifndef _CPP_THREADS_POSIX
|
|
||||||
#define _CPP_THREADS_POSIX
|
|
||||||
|
|
||||||
#include <bits/c++config.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
// Includes
|
|
||||||
//
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Defines
|
|
||||||
//
|
|
||||||
|
|
||||||
// Currently needed for stl/bits/stl_config.h
|
|
||||||
# define _PTHREADS
|
|
||||||
|
|
||||||
// Currently libio expects this macro
|
|
||||||
#define _IO_MTSAFE_IO
|
|
||||||
|
|
||||||
// May be needed on solaris.
|
|
||||||
//#define PTHREAD_MUTEX_INITIALIZER {{{0},0},{{{0}}},{0}}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Typedefs.
|
|
||||||
//
|
|
||||||
namespace std {
|
|
||||||
typedef pthread_mutex_t __mutext_type;
|
|
||||||
} // std
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Condition variables.
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Mutexes.
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Thread creation and manipulation.
|
|
||||||
//
|
|
||||||
|
|
||||||
#endif // _CPP_THREADS_POSIX
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1445
libstdc++-v3/configure
vendored
1445
libstdc++-v3/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@
|
|||||||
<META NAME="GENERATOR" CONTENT="vi and eight fingers">
|
<META NAME="GENERATOR" CONTENT="vi and eight fingers">
|
||||||
<TITLE>libstdc++-v3 HOWTO: Chapter 17</TITLE>
|
<TITLE>libstdc++-v3 HOWTO: Chapter 17</TITLE>
|
||||||
<LINK REL=StyleSheet HREF="../lib3styles.css">
|
<LINK REL=StyleSheet HREF="../lib3styles.css">
|
||||||
<!-- $Id: howto.html,v 1.4 2001/05/30 21:54:57 pme Exp $ -->
|
<!-- $Id: howto.html,v 1.5 2001/05/31 02:45:03 ljrittle Exp $ -->
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<BODY>
|
<BODY>
|
||||||
|
|
||||||
@ -57,7 +57,8 @@
|
|||||||
This entry will mention a very little bit about the general MT
|
This entry will mention a very little bit about the general MT
|
||||||
issues with libstdc++. The latest status and quick notes will be
|
issues with libstdc++. The latest status and quick notes will be
|
||||||
in FAQ 5.6. Some discussion about thread-safe containers will be
|
in FAQ 5.6. Some discussion about thread-safe containers will be
|
||||||
in section 6.8 (the HOWTOs on containers).
|
in section 6.8 (the HOWTOs on containers). This section only applies
|
||||||
|
when gcc and libstdc++-v3 were configured with --enable-threads.
|
||||||
</P>
|
</P>
|
||||||
<P>The libstdc++ code (all of it, not just the containers) has been
|
<P>The libstdc++ code (all of it, not just the containers) has been
|
||||||
designed so that thread-safety will be easily possible. The first
|
designed so that thread-safety will be easily possible. The first
|
||||||
@ -79,19 +80,7 @@
|
|||||||
in include/bits/c++config and the HOWTOs on containers. Be
|
in include/bits/c++config and the HOWTOs on containers. Be
|
||||||
fully aware that you may change the external or internal ABI of
|
fully aware that you may change the external or internal ABI of
|
||||||
libstdc++-v3 when you provide -D__USE_MALLOC on the command line
|
libstdc++-v3 when you provide -D__USE_MALLOC on the command line
|
||||||
or make a change to that configuration file. [Placeholder in
|
or make a change to that configuration file.
|
||||||
case other patches don't make it before the 3.0 release: That
|
|
||||||
memory allocator can appear buggy in multithreaded C++ programs
|
|
||||||
(and has been reported to leak memory), if STL is misconfigured
|
|
||||||
for your platform. You may need to provide -D_PTHREADS on the
|
|
||||||
command line in this case to ensure the memory allocator for
|
|
||||||
containers is really protected by a mutex. Also, be aware that
|
|
||||||
you just changed the ABI of libstdc++-v3 when you did that thus
|
|
||||||
your entire application and all libraries must be compiled with
|
|
||||||
compatible flags. The STL implementation doesn't currently
|
|
||||||
protect you from changing the mutex locking implementation to
|
|
||||||
one that doesn't really play together with the implementation
|
|
||||||
you may have compiled other application code with.]
|
|
||||||
</P>
|
</P>
|
||||||
<P>
|
<P>
|
||||||
If you don't like caches of objects being retained inside the
|
If you don't like caches of objects being retained inside the
|
||||||
@ -192,7 +181,7 @@
|
|||||||
<P CLASS="fineprint"><EM>
|
<P CLASS="fineprint"><EM>
|
||||||
Comments and suggestions are welcome, and may be sent to
|
Comments and suggestions are welcome, and may be sent to
|
||||||
<A HREF="mailto:libstdc++@gcc.gnu.org">the mailing list</A>.
|
<A HREF="mailto:libstdc++@gcc.gnu.org">the mailing list</A>.
|
||||||
<BR> $Id: howto.html,v 1.4 2001/05/30 21:54:57 pme Exp $
|
<BR> $Id: howto.html,v 1.5 2001/05/31 02:45:03 ljrittle Exp $
|
||||||
</EM></P>
|
</EM></P>
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<META NAME="GENERATOR" CONTENT="vi and eight fingers">
|
<META NAME="GENERATOR" CONTENT="vi and eight fingers">
|
||||||
<TITLE>libstdc++-v3 HOWTO: Chapter 23</TITLE>
|
<TITLE>libstdc++-v3 HOWTO: Chapter 23</TITLE>
|
||||||
<LINK REL=StyleSheet HREF="../lib3styles.css">
|
<LINK REL=StyleSheet HREF="../lib3styles.css">
|
||||||
<!-- $Id: howto.html,v 1.4 2001/05/30 21:55:01 pme Exp $ -->
|
<!-- $Id: howto.html,v 1.5 2001/05/31 02:45:02 ljrittle Exp $ -->
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<BODY>
|
<BODY>
|
||||||
|
|
||||||
@ -185,7 +185,8 @@
|
|||||||
<P>This section will mention some of the problems in designing MT
|
<P>This section will mention some of the problems in designing MT
|
||||||
programs that use Standard containers. For information on other
|
programs that use Standard containers. For information on other
|
||||||
aspects of multithreading (e.g., the library as a whole), see
|
aspects of multithreading (e.g., the library as a whole), see
|
||||||
the Received Wisdom on Chapter 17.
|
the Received Wisdom on Chapter 17. This section only applies
|
||||||
|
when gcc and libstdc++-v3 were configured with --enable-threads.
|
||||||
</P>
|
</P>
|
||||||
<P>Two excellent pages to read when working with templatized containers
|
<P>Two excellent pages to read when working with templatized containers
|
||||||
and threads are
|
and threads are
|
||||||
@ -207,7 +208,7 @@
|
|||||||
the mutex lock as is best for your platform. In particular,
|
the mutex lock as is best for your platform. In particular,
|
||||||
past advice was for people using g++ to explicitly define
|
past advice was for people using g++ to explicitly define
|
||||||
_PTHREADS on the command line to get a thread-safe STL. This
|
_PTHREADS on the command line to get a thread-safe STL. This
|
||||||
may or may not be required for your port. It may or may not be
|
is no longer required for your port. It may or may not be
|
||||||
a good idea for your port. Extremely big caution: if you
|
a good idea for your port. Extremely big caution: if you
|
||||||
compile some of your application code against the STL with one
|
compile some of your application code against the STL with one
|
||||||
set of threading flags and macros and another portion of the
|
set of threading flags and macros and another portion of the
|
||||||
@ -258,7 +259,7 @@
|
|||||||
<P CLASS="fineprint"><EM>
|
<P CLASS="fineprint"><EM>
|
||||||
Comments and suggestions are welcome, and may be sent to
|
Comments and suggestions are welcome, and may be sent to
|
||||||
<A HREF="mailto:libstdc++@gcc.gnu.org">the mailing list</A>.
|
<A HREF="mailto:libstdc++@gcc.gnu.org">the mailing list</A>.
|
||||||
<BR> $Id: howto.html,v 1.4 2001/05/30 21:55:01 pme Exp $
|
<BR> $Id: howto.html,v 1.5 2001/05/31 02:45:02 ljrittle Exp $
|
||||||
</EM></P>
|
</EM></P>
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,26 +62,17 @@
|
|||||||
// Enable concept checking code from the boost libraries.
|
// Enable concept checking code from the boost libraries.
|
||||||
//#define _GLIBCPP_CONCEPT_CHECKS 1
|
//#define _GLIBCPP_CONCEPT_CHECKS 1
|
||||||
|
|
||||||
// From SGI's stl_config.h; generic settings and user hooks (_NOTHREADS).
|
// Map gthr.h abstraction to that required for STL. Do not key off of
|
||||||
#ifdef _REENTRANT
|
// __GTHREADS at this point since we haven't seen the correct symbol
|
||||||
# define __STL_THREADS
|
// yet, instead setup so that include/bits/stl_threads.h will know to
|
||||||
#endif
|
// include gthr.h instead of any other type of thread support. Note:
|
||||||
|
// that gthr.h may well map to gthr-single.h which is a correct way to
|
||||||
#if defined(_PTHREADS) && !defined(_NOTHREADS)
|
// express no threads support in gcc. As a user, do not define
|
||||||
# define __STL_PTHREADS
|
// _NOTHREADS without consideration of the consequences (e.g. it is an
|
||||||
#endif
|
// internal ABI change).
|
||||||
|
#define __STL_GTHREADS
|
||||||
#if defined(_UITHREADS) && !defined(_PTHREADS) && !defined(_NOTHREADS)
|
#define __STL_THREADS
|
||||||
# define __STL_UITHREADS
|
#define __STL_VOLATILE volatile
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__STL_WIN32THREADS) || defined(__STL_SGI_THREADS) \
|
|
||||||
|| defined(__STL_PTHREADS) || defined(__STL_UITHREADS)
|
|
||||||
# define __STL_THREADS
|
|
||||||
# define __STL_VOLATILE volatile
|
|
||||||
#else
|
|
||||||
# define __STL_VOLATILE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This is also a user hook, but via -f[no-]exceptions, not direct #defines.
|
// This is also a user hook, but via -f[no-]exceptions, not direct #defines.
|
||||||
#ifdef __EXCEPTIONS
|
#ifdef __EXCEPTIONS
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include <bits/std_ostream.h>
|
#include <bits/std_ostream.h>
|
||||||
#include <bits/basic_file.h>
|
#include <bits/basic_file.h>
|
||||||
#include <bits/std_locale.h> // For codecvt
|
#include <bits/std_locale.h> // For codecvt
|
||||||
#include <bits/c++threads.h> // For __mutext_type
|
#include <bits/gthr.h>
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,15 @@
|
|||||||
// threads standard), and Win32 threads. Uithread support by Jochen
|
// threads standard), and Win32 threads. Uithread support by Jochen
|
||||||
// Schlick, 1999.
|
// Schlick, 1999.
|
||||||
|
|
||||||
|
// GCC extension begin
|
||||||
|
// In order to present a stable threading configuration, in all cases,
|
||||||
|
// gcc looks for it's own abstraction layer before all others. All
|
||||||
|
// modifications to this file are marked to allow easier importation of
|
||||||
|
// STL upgrades.
|
||||||
|
#if defined(__STL_GTHREADS)
|
||||||
|
#include "bits/gthr.h"
|
||||||
|
#else
|
||||||
|
// GCC extension end
|
||||||
#if defined(__STL_SGI_THREADS)
|
#if defined(__STL_SGI_THREADS)
|
||||||
#include <mutex.h>
|
#include <mutex.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -35,6 +44,9 @@
|
|||||||
#elif defined(__STL_WIN32THREADS)
|
#elif defined(__STL_WIN32THREADS)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
// GCC extension begin
|
||||||
|
#endif
|
||||||
|
// GCC extension end
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
@ -64,6 +76,22 @@ struct _Refcount_Base
|
|||||||
volatile _RC_t _M_ref_count;
|
volatile _RC_t _M_ref_count;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
|
// GCC extension begin
|
||||||
|
#ifdef __STL_GTHREADS
|
||||||
|
__gthread_mutex_t _M_ref_count_lock;
|
||||||
|
_Refcount_Base(_RC_t __n) : _M_ref_count(__n)
|
||||||
|
{
|
||||||
|
#ifdef __GTHREAD_MUTEX_INIT
|
||||||
|
__gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
|
||||||
|
_M_ref_count_lock = __tmp;
|
||||||
|
#elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
|
||||||
|
__GTHREAD_MUTEX_INIT_FUNCTION (&_M_ref_count_lock);
|
||||||
|
#else
|
||||||
|
#error __GTHREAD_MUTEX_INIT or __GTHREAD_MUTEX_INIT_FUNCTION should be defined by gthr.h abstraction layer, report problem to libstdc++@gcc.gnu.org.
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// GCC extension end
|
||||||
# ifdef __STL_PTHREADS
|
# ifdef __STL_PTHREADS
|
||||||
pthread_mutex_t _M_ref_count_lock;
|
pthread_mutex_t _M_ref_count_lock;
|
||||||
_Refcount_Base(_RC_t __n) : _M_ref_count(__n)
|
_Refcount_Base(_RC_t __n) : _M_ref_count(__n)
|
||||||
@ -75,7 +103,25 @@ struct _Refcount_Base
|
|||||||
# else
|
# else
|
||||||
_Refcount_Base(_RC_t __n) : _M_ref_count(__n) {}
|
_Refcount_Base(_RC_t __n) : _M_ref_count(__n) {}
|
||||||
# endif
|
# endif
|
||||||
|
// GCC extension begin
|
||||||
|
#endif
|
||||||
|
// GCC extension end
|
||||||
|
|
||||||
|
// GCC extension begin
|
||||||
|
#ifdef __STL_GTHREADS
|
||||||
|
void _M_incr() {
|
||||||
|
__gthread_mutex_lock(&_M_ref_count_lock);
|
||||||
|
++_M_ref_count;
|
||||||
|
__gthread_mutex_unlock(&_M_ref_count_lock);
|
||||||
|
}
|
||||||
|
_RC_t _M_decr() {
|
||||||
|
__gthread_mutex_lock(&_M_ref_count_lock);
|
||||||
|
volatile _RC_t __tmp = --_M_ref_count;
|
||||||
|
__gthread_mutex_unlock(&_M_ref_count_lock);
|
||||||
|
return __tmp;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// GCC extension end
|
||||||
// _M_incr and _M_decr
|
// _M_incr and _M_decr
|
||||||
# ifdef __STL_SGI_THREADS
|
# ifdef __STL_SGI_THREADS
|
||||||
void _M_incr() { __add_and_fetch(&_M_ref_count, 1); }
|
void _M_incr() { __add_and_fetch(&_M_ref_count, 1); }
|
||||||
@ -111,12 +157,24 @@ struct _Refcount_Base
|
|||||||
void _M_incr() { ++_M_ref_count; }
|
void _M_incr() { ++_M_ref_count; }
|
||||||
_RC_t _M_decr() { return --_M_ref_count; }
|
_RC_t _M_decr() { return --_M_ref_count; }
|
||||||
# endif
|
# endif
|
||||||
|
// GCC extension begin
|
||||||
|
#endif
|
||||||
|
// GCC extension end
|
||||||
};
|
};
|
||||||
|
|
||||||
// Atomic swap on unsigned long
|
// Atomic swap on unsigned long
|
||||||
// This is guaranteed to behave as though it were atomic only if all
|
// This is guaranteed to behave as though it were atomic only if all
|
||||||
// possibly concurrent updates use _Atomic_swap.
|
// possibly concurrent updates use _Atomic_swap.
|
||||||
// In some cases the operation is emulated with a lock.
|
// In some cases the operation is emulated with a lock.
|
||||||
|
// GCC extension begin
|
||||||
|
#ifdef __STL_GTHREADS
|
||||||
|
// We don't provide an _Atomic_swap in this configuration. This only
|
||||||
|
// affects the use of ext/rope with threads. Someone could add this
|
||||||
|
// later, if required. You can start by cloning the __STL_PTHREADS
|
||||||
|
// path while making the obvious changes. Later it could be optimized
|
||||||
|
// to use the atomicity.h abstraction layer from libstdc++-v3.
|
||||||
|
#else
|
||||||
|
// GCC extension end
|
||||||
# ifdef __STL_SGI_THREADS
|
# ifdef __STL_SGI_THREADS
|
||||||
inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {
|
inline unsigned long _Atomic_swap(unsigned long * __p, unsigned long __q) {
|
||||||
# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64))
|
# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64))
|
||||||
@ -205,6 +263,9 @@ struct _Refcount_Base
|
|||||||
return __result;
|
return __result;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
// GCC extension begin
|
||||||
|
#endif
|
||||||
|
// GCC extension end
|
||||||
|
|
||||||
// Locking class. Note that this class *does not have a constructor*.
|
// Locking class. Note that this class *does not have a constructor*.
|
||||||
// It must be initialized either statically, with __STL_MUTEX_INITIALIZER,
|
// It must be initialized either statically, with __STL_MUTEX_INITIALIZER,
|
||||||
@ -237,6 +298,21 @@ unsigned _STL_mutex_spin<__inst>::__last = 0;
|
|||||||
|
|
||||||
struct _STL_mutex_lock
|
struct _STL_mutex_lock
|
||||||
{
|
{
|
||||||
|
// GCC extension begin
|
||||||
|
#if defined(__STL_GTHREADS)
|
||||||
|
__gthread_mutex_t _M_lock;
|
||||||
|
void _M_initialize()
|
||||||
|
{
|
||||||
|
#ifdef __GTHREAD_MUTEX_INIT
|
||||||
|
// There should be no code in this path given the usage rules above.
|
||||||
|
#elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
|
||||||
|
__GTHREAD_MUTEX_INIT_FUNCTION (&_M_lock);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void _M_acquire_lock() { __gthread_mutex_lock(&_M_lock); }
|
||||||
|
void _M_release_lock() { __gthread_mutex_unlock(&_M_lock); }
|
||||||
|
#else
|
||||||
|
// GCC extension end
|
||||||
#if defined(__STL_SGI_THREADS) || defined(__STL_WIN32THREADS)
|
#if defined(__STL_SGI_THREADS) || defined(__STL_WIN32THREADS)
|
||||||
// It should be relatively easy to get this to work on any modern Unix.
|
// It should be relatively easy to get this to work on any modern Unix.
|
||||||
volatile unsigned long _M_lock;
|
volatile unsigned long _M_lock;
|
||||||
@ -330,8 +406,20 @@ struct _STL_mutex_lock
|
|||||||
void _M_acquire_lock() {}
|
void _M_acquire_lock() {}
|
||||||
void _M_release_lock() {}
|
void _M_release_lock() {}
|
||||||
#endif
|
#endif
|
||||||
|
// GCC extension begin
|
||||||
|
#endif
|
||||||
|
// GCC extension end
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// GCC extension begin
|
||||||
|
#if defined(__STL_GTHREADS)
|
||||||
|
#ifdef __GTHREAD_MUTEX_INIT
|
||||||
|
#define __STL_MUTEX_INITIALIZER = { __GTHREAD_MUTEX_INIT }
|
||||||
|
#else
|
||||||
|
#define __STL_MUTEX_INITIALIZER
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
// GCC extension end
|
||||||
#ifdef __STL_PTHREADS
|
#ifdef __STL_PTHREADS
|
||||||
// Pthreads locks must be statically initialized to something other than
|
// Pthreads locks must be statically initialized to something other than
|
||||||
// the default value of zero.
|
// the default value of zero.
|
||||||
@ -345,6 +433,9 @@ struct _STL_mutex_lock
|
|||||||
#else
|
#else
|
||||||
# define __STL_MUTEX_INITIALIZER
|
# define __STL_MUTEX_INITIALIZER
|
||||||
#endif
|
#endif
|
||||||
|
// GCC extension begin
|
||||||
|
#endif
|
||||||
|
// GCC extension end
|
||||||
|
|
||||||
|
|
||||||
// A locking class that uses _STL_mutex_lock. The constructor takes a
|
// A locking class that uses _STL_mutex_lock. The constructor takes a
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
## USA.
|
## USA.
|
||||||
|
|
||||||
## $Id: Makefile.am,v 1.85 2001/05/19 03:42:53 bkoz Exp $
|
## $Id: Makefile.am,v 1.86 2001/06/01 09:22:05 hp Exp $
|
||||||
|
|
||||||
AUTOMAKE_OPTIONS = 1.3 gnits
|
AUTOMAKE_OPTIONS = 1.3 gnits
|
||||||
MAINT_CHARSET = latin1
|
MAINT_CHARSET = latin1
|
||||||
@ -158,7 +158,8 @@ endif
|
|||||||
|
|
||||||
build_headers = \
|
build_headers = \
|
||||||
bits/std_limits.h \
|
bits/std_limits.h \
|
||||||
bits/c++config.h bits/c++io.h bits/c++locale.h bits/c++threads.h \
|
bits/c++config.h bits/c++io.h bits/c++locale.h \
|
||||||
|
bits/gthr.h bits/gthr-single.h bits/gthr-default.h \
|
||||||
bits/basic_file_model.h \
|
bits/basic_file_model.h \
|
||||||
bits/atomicity.h bits/os_defines.h \
|
bits/atomicity.h bits/os_defines.h \
|
||||||
bits/ctype_base.h bits/ctype_noninline.h bits/ctype_inline.h
|
bits/ctype_base.h bits/ctype_noninline.h bits/ctype_inline.h
|
||||||
|
@ -162,12 +162,13 @@ std_headers = algorithm bitset complex deque fstream functional iomanip ios i
|
|||||||
@GLIBCPP_NEED_LIBIO_TRUE@libio_headers = $(top_srcdir)/libio/_G_config.h $(top_srcdir)/libio/libio.h
|
@GLIBCPP_NEED_LIBIO_TRUE@libio_headers = $(top_srcdir)/libio/_G_config.h $(top_srcdir)/libio/libio.h
|
||||||
@GLIBCPP_NEED_LIBIO_FALSE@libio_headers =
|
@GLIBCPP_NEED_LIBIO_FALSE@libio_headers =
|
||||||
|
|
||||||
build_headers = bits/std_limits.h bits/c++config.h bits/c++io.h bits/c++locale.h bits/c++threads.h bits/basic_file_model.h bits/atomicity.h bits/os_defines.h bits/ctype_base.h bits/ctype_noninline.h bits/ctype_inline.h
|
build_headers = bits/std_limits.h bits/c++config.h bits/c++io.h bits/c++locale.h bits/gthr.h bits/gthr-single.h bits/gthr-default.h bits/basic_file_model.h bits/atomicity.h bits/os_defines.h bits/ctype_base.h bits/ctype_noninline.h bits/ctype_inline.h
|
||||||
|
|
||||||
|
|
||||||
sources = limitsMEMBERS.cc stdexcept.cc functexcept.cc bitset.cc globals.cc basic_file.cc ios.cc complex_io.cc strstream.cc c++locale.cc locale.cc localename.cc codecvt.cc locale-inst.cc stl-inst.cc misc-inst.cc valarray-inst.cc string-inst.cc wstring-inst.cc
|
sources = limitsMEMBERS.cc stdexcept.cc functexcept.cc bitset.cc globals.cc basic_file.cc ios.cc complex_io.cc strstream.cc c++locale.cc locale.cc localename.cc codecvt.cc locale-inst.cc stl-inst.cc misc-inst.cc valarray-inst.cc string-inst.cc wstring-inst.cc
|
||||||
|
|
||||||
VPATH = $(top_srcdir):$(top_srcdir)/src:$(GLIBCPP_INCLUDE_DIR):$(GLIBCPP_INCLUDE_DIR)/std:$(C_INCLUDE_DIR)
|
|
||||||
|
VPATH = $(top_srcdir):$(top_srcdir)/src:$(GLIBCPP_INCLUDE_DIR):$(GLIBCPP_INCLUDE_DIR)/std:$(C_INCLUDE_DIR)
|
||||||
|
|
||||||
libstdc___la_SOURCES = $(sources)
|
libstdc___la_SOURCES = $(sources)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user