OSDN Git Service

2002-01-04 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / bits / pthread_allocimpl.h
index dd99150..050b206 100644 (file)
@@ -1,3 +1,32 @@
+// POSIX thread-related memory allocation -*- C++ -*-
+
+// Copyright (C) 2001 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.
+
 /*
  * Copyright (c) 1996
  * Silicon Graphics Computer Systems, Inc.
  * purpose.  It is provided "as is" without express or implied warranty.
  */
 
+/** @file pthread_allocimpl.h
+ *  This is an internal header file, included by other library headers.
+ *  You should not attempt to use it directly.
+ */
+
 #ifndef _CPP_BITS_PTHREAD_ALLOCIMPL_H
 #define _CPP_BITS_PTHREAD_ALLOCIMPL_H 1
 
 // cache lines among processors, with potentially serious performance
 // consequences.
 
-#include <bits/std_cerrno.h>
-#include <bits/stl_config.h>
+#include <bits/c++config.h>
+#include <cerrno>
 #include <bits/stl_alloc.h>
 #ifndef __RESTRICT
 #  define __RESTRICT
 #endif
 
-#ifndef __STL_NO_BAD_ALLOC
-#  include <new>
-#endif
+#include <new>
 
-__STL_BEGIN_NAMESPACE
+namespace std
+{
 
 #define __STL_DATA_ALIGNMENT 8
 
@@ -213,7 +246,7 @@ _Pthread_alloc_template<_Max_size>::_S_get_per_thread_state()
     _Pthread_alloc_per_thread_state<_Max_size> * __result;
     if (!_S_key_initialized) {
         if (pthread_key_create(&_S_key, _S_destructor)) {
-           __THROW_BAD_ALLOC;  // defined in stl_alloc.h
+           std::__throw_bad_alloc();  // defined in funcexcept.h
         }
         _S_key_initialized = true;
     }
@@ -221,7 +254,7 @@ _Pthread_alloc_template<_Max_size>::_S_get_per_thread_state()
     __ret_code = pthread_setspecific(_S_key, __result);
     if (__ret_code) {
       if (__ret_code == ENOMEM) {
-       __THROW_BAD_ALLOC;
+       std::__throw_bad_alloc();
       } else {
        // EINVAL
        abort();
@@ -377,7 +410,6 @@ template <size_t _Max_size>
 size_t _Pthread_alloc_template<_Max_size>
 ::_S_heap_size = 0;
 
-#ifdef __STL_USE_STD_ALLOCATORS
 
 template <class _Tp>
 class pthread_allocator {
@@ -395,12 +427,12 @@ public:
     typedef pthread_allocator<_NewType> other;
   };
 
-  pthread_allocator() __STL_NOTHROW {}
-  pthread_allocator(const pthread_allocator& a) __STL_NOTHROW {}
+  pthread_allocator() throw() {}
+  pthread_allocator(const pthread_allocator& a) throw() {}
   template <class _OtherType>
        pthread_allocator(const pthread_allocator<_OtherType>&)
-               __STL_NOTHROW {}
-  ~pthread_allocator() __STL_NOTHROW {}
+               throw() {}
+  ~pthread_allocator() throw() {}
 
   pointer address(reference __x) const { return &__x; }
   const_pointer address(const_reference __x) const { return &__x; }
@@ -416,7 +448,7 @@ public:
   void deallocate(pointer __p, size_type __n)
     { _S_Alloc::deallocate(__p, __n * sizeof(_Tp)); }
 
-  size_type max_size() const __STL_NOTHROW 
+  size_type max_size() const throw() 
     { return size_t(-1) / sizeof(_Tp); }
 
   void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
@@ -484,9 +516,7 @@ struct _Alloc_traits<_Tp, pthread_allocator<_Atype> >
 };
 
 
-#endif /* __STL_USE_STD_ALLOCATORS */
-
-__STL_END_NAMESPACE
+} // namespace std
 
 #endif /* _CPP_BITS_PTHREAD_ALLOCIMPL_H */