OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libstdc++-v3/] [src/] [ios.cc] - Diff between revs 816 and 826

Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 826
// Iostreams base classes -*- C++ -*-
// Iostreams base classes -*- C++ -*-
 
 
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
// 2006, 2007, 2008, 2009, 2010
// 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
// Free Software Foundation, Inc.
//
//
// This file is part of the GNU ISO C++ Library.  This library is free
// 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
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// any later version.
 
 
// This library is distributed in the hope that it will be useful,
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// GNU General Public License for more details.
 
 
// Under Section 7 of GPL version 3, you are granted additional
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// 3.1, as published by the Free Software Foundation.
 
 
// You should have received a copy of the GNU General Public License and
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.
// <http://www.gnu.org/licenses/>.
 
 
//
//
// ISO C++ 14882: 27.4  Iostreams base classes
// ISO C++ 14882: 27.4  Iostreams base classes
//
//
 
 
#include <ios>
#include <ios>
#include <limits>
#include <limits>
 
 
_GLIBCXX_BEGIN_NAMESPACE(std)
_GLIBCXX_BEGIN_NAMESPACE(std)
 
 
  // Definitions for static const members of ios_base.
  // Definitions for static const members of ios_base.
  const ios_base::fmtflags ios_base::boolalpha;
  const ios_base::fmtflags ios_base::boolalpha;
  const ios_base::fmtflags ios_base::dec;
  const ios_base::fmtflags ios_base::dec;
  const ios_base::fmtflags ios_base::fixed;
  const ios_base::fmtflags ios_base::fixed;
  const ios_base::fmtflags ios_base::hex;
  const ios_base::fmtflags ios_base::hex;
  const ios_base::fmtflags ios_base::internal;
  const ios_base::fmtflags ios_base::internal;
  const ios_base::fmtflags ios_base::left;
  const ios_base::fmtflags ios_base::left;
  const ios_base::fmtflags ios_base::oct;
  const ios_base::fmtflags ios_base::oct;
  const ios_base::fmtflags ios_base::right;
  const ios_base::fmtflags ios_base::right;
  const ios_base::fmtflags ios_base::scientific;
  const ios_base::fmtflags ios_base::scientific;
  const ios_base::fmtflags ios_base::showbase;
  const ios_base::fmtflags ios_base::showbase;
  const ios_base::fmtflags ios_base::showpoint;
  const ios_base::fmtflags ios_base::showpoint;
  const ios_base::fmtflags ios_base::showpos;
  const ios_base::fmtflags ios_base::showpos;
  const ios_base::fmtflags ios_base::skipws;
  const ios_base::fmtflags ios_base::skipws;
  const ios_base::fmtflags ios_base::unitbuf;
  const ios_base::fmtflags ios_base::unitbuf;
  const ios_base::fmtflags ios_base::uppercase;
  const ios_base::fmtflags ios_base::uppercase;
  const ios_base::fmtflags ios_base::adjustfield;
  const ios_base::fmtflags ios_base::adjustfield;
  const ios_base::fmtflags ios_base::basefield;
  const ios_base::fmtflags ios_base::basefield;
  const ios_base::fmtflags ios_base::floatfield;
  const ios_base::fmtflags ios_base::floatfield;
 
 
  const ios_base::iostate ios_base::badbit;
  const ios_base::iostate ios_base::badbit;
  const ios_base::iostate ios_base::eofbit;
  const ios_base::iostate ios_base::eofbit;
  const ios_base::iostate ios_base::failbit;
  const ios_base::iostate ios_base::failbit;
  const ios_base::iostate ios_base::goodbit;
  const ios_base::iostate ios_base::goodbit;
 
 
  const ios_base::openmode ios_base::app;
  const ios_base::openmode ios_base::app;
  const ios_base::openmode ios_base::ate;
  const ios_base::openmode ios_base::ate;
  const ios_base::openmode ios_base::binary;
  const ios_base::openmode ios_base::binary;
  const ios_base::openmode ios_base::in;
  const ios_base::openmode ios_base::in;
  const ios_base::openmode ios_base::out;
  const ios_base::openmode ios_base::out;
  const ios_base::openmode ios_base::trunc;
  const ios_base::openmode ios_base::trunc;
 
 
  const ios_base::seekdir ios_base::beg;
  const ios_base::seekdir ios_base::beg;
  const ios_base::seekdir ios_base::cur;
  const ios_base::seekdir ios_base::cur;
  const ios_base::seekdir ios_base::end;
  const ios_base::seekdir ios_base::end;
 
 
  _Atomic_word ios_base::Init::_S_refcount;
  _Atomic_word ios_base::Init::_S_refcount;
 
 
  bool ios_base::Init::_S_synced_with_stdio = true;
  bool ios_base::Init::_S_synced_with_stdio = true;
 
 
  ios_base::ios_base() throw()
  ios_base::ios_base() throw()
  : _M_precision(), _M_width(), _M_flags(), _M_exception(),
  : _M_precision(), _M_width(), _M_flags(), _M_exception(),
  _M_streambuf_state(), _M_callbacks(0), _M_word_zero(),
  _M_streambuf_state(), _M_callbacks(0), _M_word_zero(),
  _M_word_size(_S_local_word_size), _M_word(_M_local_word), _M_ios_locale()
  _M_word_size(_S_local_word_size), _M_word(_M_local_word), _M_ios_locale()
  {
  {
    // Do nothing: basic_ios::init() does it.  
    // Do nothing: basic_ios::init() does it.  
    // NB: _M_callbacks and _M_word must be zero for non-initialized
    // NB: _M_callbacks and _M_word must be zero for non-initialized
    // ios_base to go through ~ios_base gracefully.
    // ios_base to go through ~ios_base gracefully.
  }
  }
 
 
  // 27.4.2.7  ios_base constructors/destructors
  // 27.4.2.7  ios_base constructors/destructors
  ios_base::~ios_base()
  ios_base::~ios_base()
  {
  {
    _M_call_callbacks(erase_event);
    _M_call_callbacks(erase_event);
    _M_dispose_callbacks();
    _M_dispose_callbacks();
    if (_M_word != _M_local_word)
    if (_M_word != _M_local_word)
      {
      {
        delete [] _M_word;
        delete [] _M_word;
        _M_word = 0;
        _M_word = 0;
      }
      }
  }
  }
 
 
  // 27.4.2.5  ios_base storage functions
  // 27.4.2.5  ios_base storage functions
  int
  int
  ios_base::xalloc() throw()
  ios_base::xalloc() throw()
  {
  {
    // Implementation note: Initialize top to zero to ensure that
    // Implementation note: Initialize top to zero to ensure that
    // initialization occurs before main() is started.
    // initialization occurs before main() is started.
    static _Atomic_word _S_top = 0;
    static _Atomic_word _S_top = 0;
    return __gnu_cxx::__exchange_and_add_dispatch(&_S_top, 1) + 4;
    return __gnu_cxx::__exchange_and_add_dispatch(&_S_top, 1) + 4;
  }
  }
 
 
  void
  void
  ios_base::register_callback(event_callback __fn, int __index)
  ios_base::register_callback(event_callback __fn, int __index)
  { _M_callbacks = new _Callback_list(__fn, __index, _M_callbacks); }
  { _M_callbacks = new _Callback_list(__fn, __index, _M_callbacks); }
 
 
  // 27.4.2.5  iword/pword storage
  // 27.4.2.5  iword/pword storage
  ios_base::_Words&
  ios_base::_Words&
  ios_base::_M_grow_words(int __ix, bool __iword)
  ios_base::_M_grow_words(int __ix, bool __iword)
  {
  {
    // Precondition: _M_word_size <= __ix
    // Precondition: _M_word_size <= __ix
    int __newsize = _S_local_word_size;
    int __newsize = _S_local_word_size;
    _Words* __words = _M_local_word;
    _Words* __words = _M_local_word;
    if (__ix > _S_local_word_size - 1)
    if (__ix > _S_local_word_size - 1)
      {
      {
        if (__ix < numeric_limits<int>::max())
        if (__ix < numeric_limits<int>::max())
          {
          {
            __newsize = __ix + 1;
            __newsize = __ix + 1;
            __try
            __try
              { __words = new _Words[__newsize]; }
              { __words = new _Words[__newsize]; }
            __catch(const std::bad_alloc&)
            __catch(const std::bad_alloc&)
              {
              {
                _M_streambuf_state |= badbit;
                _M_streambuf_state |= badbit;
                if (_M_streambuf_state & _M_exception)
                if (_M_streambuf_state & _M_exception)
                  __throw_ios_failure(__N("ios_base::_M_grow_words "
                  __throw_ios_failure(__N("ios_base::_M_grow_words "
                                          "allocation failed"));
                                          "allocation failed"));
                if (__iword)
                if (__iword)
                  _M_word_zero._M_iword = 0;
                  _M_word_zero._M_iword = 0;
                else
                else
                  _M_word_zero._M_pword = 0;
                  _M_word_zero._M_pword = 0;
                return _M_word_zero;
                return _M_word_zero;
              }
              }
            for (int __i = 0; __i < _M_word_size; __i++)
            for (int __i = 0; __i < _M_word_size; __i++)
              __words[__i] = _M_word[__i];
              __words[__i] = _M_word[__i];
            if (_M_word && _M_word != _M_local_word)
            if (_M_word && _M_word != _M_local_word)
              {
              {
                delete [] _M_word;
                delete [] _M_word;
                _M_word = 0;
                _M_word = 0;
              }
              }
          }
          }
        else
        else
          {
          {
            _M_streambuf_state |= badbit;
            _M_streambuf_state |= badbit;
            if (_M_streambuf_state & _M_exception)
            if (_M_streambuf_state & _M_exception)
              __throw_ios_failure(__N("ios_base::_M_grow_words is not valid"));
              __throw_ios_failure(__N("ios_base::_M_grow_words is not valid"));
            if (__iword)
            if (__iword)
              _M_word_zero._M_iword = 0;
              _M_word_zero._M_iword = 0;
            else
            else
              _M_word_zero._M_pword = 0;
              _M_word_zero._M_pword = 0;
            return _M_word_zero;
            return _M_word_zero;
          }
          }
      }
      }
    _M_word = __words;
    _M_word = __words;
    _M_word_size = __newsize;
    _M_word_size = __newsize;
    return _M_word[__ix];
    return _M_word[__ix];
  }
  }
 
 
  void
  void
  ios_base::_M_call_callbacks(event __e) throw()
  ios_base::_M_call_callbacks(event __e) throw()
  {
  {
    _Callback_list* __p = _M_callbacks;
    _Callback_list* __p = _M_callbacks;
    while (__p)
    while (__p)
      {
      {
        __try
        __try
          { (*__p->_M_fn) (__e, *this, __p->_M_index); }
          { (*__p->_M_fn) (__e, *this, __p->_M_index); }
        __catch(...)
        __catch(...)
          { }
          { }
        __p = __p->_M_next;
        __p = __p->_M_next;
      }
      }
  }
  }
 
 
  void
  void
  ios_base::_M_dispose_callbacks(void) throw()
  ios_base::_M_dispose_callbacks(void) throw()
  {
  {
    _Callback_list* __p = _M_callbacks;
    _Callback_list* __p = _M_callbacks;
    while (__p && __p->_M_remove_reference() == 0)
    while (__p && __p->_M_remove_reference() == 0)
      {
      {
        _Callback_list* __next = __p->_M_next;
        _Callback_list* __next = __p->_M_next;
        delete __p;
        delete __p;
        __p = __next;
        __p = __next;
      }
      }
    _M_callbacks = 0;
    _M_callbacks = 0;
  }
  }
 
 
_GLIBCXX_END_NAMESPACE
_GLIBCXX_END_NAMESPACE
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.