Commit ec9c42c9 by Jason Merrill

we dont use these bits of SGI STL

From-SVN: r22184
parent ff51efd5
/*
* Copyright (c) 1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
#ifndef __SGI_STL_CHAR_TRAITS_H
#define __SGI_STL_CHAR_TRAITS_H
#include <string.h>
#include <wchar.h>
__STL_BEGIN_NAMESPACE
// Class __char_traits_base.
template <class _CharT, class _IntT> struct __char_traits_base {
typedef _CharT char_type;
typedef _IntT int_type;
// typedef streamoff off_type;
// typedef streampos pos_type;
// typedef mbstate_t state_type;
static void assign(char_type& __c1, const char_type& __c2) { __c1 = __c2; }
static bool eq(const _CharT& __c1, const _CharT& __c2)
{ return __c1 == __c2; }
static bool lt(const _CharT& __c1, const _CharT& __c2)
{ return __c1 < __c2; }
static int compare(const _CharT* __s1, const _CharT* __s2, size_t __n) {
for (size_t __i = 0; __i < __n; ++__i)
if (!eq(__s1[__i], __s2[__i]))
return __s1[__i] < __s2[__i] ? -1 : 1;
return 0;
}
static size_t length(const _CharT* __s) {
const _CharT __null = _CharT();
size_t __i;
for (__i = 0; !eq(__s[__i], __null); ++__i)
{}
return __i;
}
static const _CharT* find(const _CharT* __s, size_t __n, const _CharT& __c)
{
for ( ; __n > 0 ; ++__s, --__n)
if (eq(*__s, __c))
return __s;
return 0;
}
static _CharT* move(_CharT* __s1, const _CharT* __s2, size_t __n) {
memmove(__s1, __s2, __n * sizeof(_CharT));
return __s1;
}
static _CharT* copy(_CharT* __s1, const _CharT* __s2, size_t __n) {
memcpy(__s1, __s2, __n * sizeof(_CharT));
return __s1;
}
static _CharT* assign(_CharT* __s, size_t __n, _CharT __c) {
for (size_t __i = 0; __i < __n; ++__i)
__s[__i] = __c;
return __s;
}
static int_type not_eof(const int_type& __c) {
return !eq(__c, eof()) ? __c : 0;
}
static char_type to_char_type(const int_type& __c) {
return static_cast<char_type>(__c);
}
static int_type to_int_type(const char_type& __c) {
return static_cast<int_type>(__c);
}
static bool eq_int_type(const int_type& __c1, const int_type& __c2) {
return __c1 == __c2;
}
static int_type eof() {
return static_cast<int_type>(-1);
}
};
// Generic char_traits class. Note that this class is provided only
// as a base for explicit specialization; it is unlikely to be useful
// as is for any particular user-defined type. In particular, it
// *will not work* for a non-POD type.
template <class _CharT> struct char_traits
: public __char_traits_base<_CharT, _CharT>
{};
// Specialization for char.
template<> struct char_traits<char>
: public __char_traits_base<char, int>
{
static int compare(const char* __s1, const char* __s2, size_t __n)
{ return memcmp(__s1, __s2, __n); }
static size_t length(const char* __s) { return strlen(__s); }
static void assign(char& __c1, const char& __c2) { __c1 = __c2; }
static char* assign(char* __s, size_t __n, char __c)
{ memset(__s, __c, __n); return __s; }
};
// Specialization for wchar_t.
template<> struct char_traits<wchar_t>
: public __char_traits_base<wchar_t, wint_t>
{};
__STL_END_NAMESPACE
#endif /* __SGI_STL_CHAR_TRAITS_H */
// Local Variables:
// mode:C++
// End:
/*
* Copyright (c) 1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
#ifndef __SGI_STDEXCEPT
#define __SGI_STDEXCEPT
#include <stl_exception.h>
#if !(defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32)
#include <stl_string_fwd.h>
__STL_BEGIN_NAMESPACE
class logic_error : public __STL_EXCEPTION_BASE {
public:
logic_error(const string& __s)
{ _S_string_copy(__s, _M_name, _S_bufsize); }
virtual const char* what() const __STL_NOTHROW { return _M_name; }
private:
enum { _S_bufsize = 256 };
char _M_name[_S_bufsize];
};
class runtime_error : public __STL_EXCEPTION_BASE {
public:
runtime_error(const string& __s)
{ _S_string_copy(__s, _M_name, _S_bufsize); }
virtual const char* what() const __STL_NOTHROW { return _M_name; }
private:
enum { _S_bufsize = 256 };
char _M_name[_S_bufsize];
};
class domain_error : public logic_error {
public:
domain_error(const string& __arg) : logic_error(__arg) {}
};
class invalid_argument : public logic_error {
public:
invalid_argument(const string& __arg) : logic_error(__arg) {}
};
class length_error : public logic_error {
public:
length_error(const string& __arg) : logic_error(__arg) {}
};
class out_of_range : public logic_error {
public:
out_of_range(const string& __arg) : logic_error(__arg) {}
};
class range_error : public runtime_error {
public:
range_error(const string& __arg) : runtime_error(__arg) {}
};
class overflow_error : public runtime_error {
public:
overflow_error(const string& __arg) : runtime_error(__arg) {}
};
class underflow_error : public runtime_error {
public:
underflow_error(const string& __arg) : runtime_error(__arg) {}
};
__STL_END_NAMESPACE
#ifndef __SGI_STL_STRING
#include <string>
#endif
#endif /* Not o32 */
#endif /* __SGI_STDEXCEPT */
// Local Variables:
// mode:C++
// End:
......@@ -118,6 +118,10 @@
It should be upgraded to glibc 2.0 or later. */
# if !defined(_NOTHREADS) && __GLIBC__ >= 2 && defined(_G_USING_THUNKS)
# define __STL_PTHREADS
# ifdef __STRICT_ANSI__
/* Work around a bug in the glibc 2.0.x pthread.h. */
# define sigset_t __sigset_t
# endif
# endif
# ifdef __EXCEPTIONS
# define __STL_USE_EXCEPTIONS
......
/*
* Copyright (c) 1998
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
#ifndef __SGI_STL_EXCEPTION_H
#define __SGI_STL_EXCEPTION_H
// This header exists solely for portability. Normally it just includes
// the header <exception>.
// The header <exception> contains low-level functions that interact
// with a compiler's exception-handling mechanism. It is assumed to
// be supplied with the compiler, rather than with the library, because
// it is inherently tied very closely to the compiler itself.
// On platforms where <exception> does not exist, this header defines
// an exception base class. This is *not* a substitute for everything
// in <exception>, but it suffices to support a bare minimum of STL
// functionality.
#include <stl_config.h>
#ifndef __STL_NO_EXCEPTION_HEADER
#include <exception>
#define __STL_EXCEPTION_BASE exception
#else /* __STL_NO_EXCEPTION_HEADER */
__STL_BEGIN_NAMESPACE
class _Exception {
public:
virtual ~_Exception() __STL_NOTHROW {}
virtual const char* what() const __STL_NOTHROW { return ""; }
};
#define __STL_EXCEPTION_BASE _Exception
__STL_END_NAMESPACE
#endif /* __STL_NO_EXCEPTION_HEADER */
#endif /* __SGI_STL_EXCEPTION_H */
// Local Variables:
// mode:C++
// End:
/*
* Copyright (c) 1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
#ifndef __SGI_STL_STRING_FWD_H
#define __SGI_STL_STRING_FWD_H
#include <stddef.h>
__STL_BEGIN_NAMESPACE
#ifdef __STL_USE_STD_ALLOCATORS
template <class _Tp> class allocator;
#else /* __STL_USE_STD_ALLOCATORS */
template <bool __threads, int __inst> class _Default_alloc_template;
typedef _Default_alloc_template<true, 0> _Alloc;
#endif /* __STL_USE_STD_ALLOCATORS */
template <class _CharT> struct char_traits;
template <class _CharT,
class _Traits = char_traits<_CharT>,
class _Alloc = __STL_DEFAULT_ALLOCATOR(_CharT) >
class basic_string;
typedef basic_string<char> string;
typedef basic_string<wchar_t> wstring;
template <class _CharT, class _Traits, class _Alloc>
void _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>&, _CharT*,
size_t);
__STL_END_NAMESPACE
#endif /* __SGI_STL_STRING_FWD_H */
// Local Variables:
// mode:C++
// End:
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