diff options
author | kan <kan@FreeBSD.org> | 2007-05-19 01:25:07 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2007-05-19 01:25:07 +0000 |
commit | 7865836f4b0f698454c31b4593effcb032c22c1e (patch) | |
tree | ea6c2718dc1e45ed535d194df808ef31f0ebac92 /contrib/libstdc++/config/io | |
parent | 1f9ea4d0a40cca64d60cf4dab152349da7b9dddf (diff) | |
download | FreeBSD-src-7865836f4b0f698454c31b4593effcb032c22c1e.zip FreeBSD-src-7865836f4b0f698454c31b4593effcb032c22c1e.tar.gz |
GCC 4.2.0 release C++ standard library and runtime support code.
Diffstat (limited to 'contrib/libstdc++/config/io')
-rw-r--r-- | contrib/libstdc++/config/io/basic_file_stdio.cc | 57 | ||||
-rw-r--r-- | contrib/libstdc++/config/io/basic_file_stdio.h | 12 | ||||
-rw-r--r-- | contrib/libstdc++/config/io/c_io_stdio.h | 56 |
3 files changed, 57 insertions, 68 deletions
diff --git a/contrib/libstdc++/config/io/basic_file_stdio.cc b/contrib/libstdc++/config/io/basic_file_stdio.cc index 0a4e154..41d914a 100644 --- a/contrib/libstdc++/config/io/basic_file_stdio.cc +++ b/contrib/libstdc++/config/io/basic_file_stdio.cc @@ -1,6 +1,7 @@ // Wrapper of C-language FILE struct -*- C++ -*- -// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 +// 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 @@ -15,7 +16,7 @@ // 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, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -68,9 +69,9 @@ # endif #endif -#include <limits> // For <off_t>::max() and min() +#include <limits> // For <off_t>::max() and min() and <streamsize>::max() -namespace __gnu_internal +namespace { // Map ios_base::openmode flags to a string for use in fopen(). // Table of valid combinations as given in [lib.filebuf.members]/2. @@ -94,6 +95,8 @@ namespace __gnu_internal case (in ): return "r"; case (in|out ): return "r+"; case (in|out|trunc ): return "w+"; + // Extension to Table 92. + case (in|out |app ): return "a+"; case ( out |binary): return "wb"; case ( out |app|binary): return "ab"; @@ -101,6 +104,8 @@ namespace __gnu_internal case (in |binary): return "rb"; case (in|out |binary): return "r+b"; case (in|out|trunc |binary): return "w+b"; + // Extension to Table 92. + case (in|out |app|binary): return "a+b"; default: return 0; // invalid } @@ -172,10 +177,11 @@ namespace __gnu_internal return __n1 + __n2 - __nleft; } #endif -} // namespace __gnu_internal +} // anonymous namespace + + +_GLIBCXX_BEGIN_NAMESPACE(std) -namespace std -{ // Definitions for __basic_file<char>. __basic_file<char>::__basic_file(__c_lock* /*__lock*/) : _M_cfile(NULL), _M_cfile_created(false) { } @@ -208,7 +214,7 @@ namespace std __basic_file<char>::sys_open(int __fd, ios_base::openmode __mode) { __basic_file* __ret = NULL; - const char* __c_mode = __gnu_internal::fopen_mode(__mode); + const char* __c_mode = fopen_mode(__mode); if (__c_mode && !this->is_open() && (_M_cfile = fdopen(__fd, __c_mode))) { char* __buf = NULL; @@ -225,7 +231,7 @@ namespace std int /*__prot*/) { __basic_file* __ret = NULL; - const char* __c_mode = __gnu_internal::fopen_mode(__mode); + const char* __c_mode = fopen_mode(__mode); if (__c_mode && !this->is_open()) { #ifdef _GLIBCXX_USE_LFS @@ -290,7 +296,7 @@ namespace std streamsize __basic_file<char>::xsputn(const char* __s, streamsize __n) - { return __gnu_internal::xwrite(this->fd(), __s, __n); } + { return xwrite(this->fd(), __s, __n); } streamsize __basic_file<char>::xsputn_2(const char* __s1, streamsize __n1, @@ -298,13 +304,13 @@ namespace std { streamsize __ret = 0; #ifdef _GLIBCXX_HAVE_WRITEV - __ret = __gnu_internal::xwritev(this->fd(), __s1, __n1, __s2, __n2); + __ret = xwritev(this->fd(), __s1, __n1, __s2, __n2); #else if (__n1) - __ret = __gnu_internal::xwrite(this->fd(), __s1, __n1); + __ret = xwrite(this->fd(), __s1, __n1); if (__ret == __n1) - __ret += __gnu_internal::xwrite(this->fd(), __s2, __n2); + __ret += xwrite(this->fd(), __s2, __n2); #endif return __ret; } @@ -315,8 +321,8 @@ namespace std #ifdef _GLIBCXX_USE_LFS return lseek64(this->fd(), __off, __way); #else - if (__off > std::numeric_limits<off_t>::max() - || __off < std::numeric_limits<off_t>::min()) + if (__off > numeric_limits<off_t>::max() + || __off < numeric_limits<off_t>::min()) return -1L; return lseek(this->fd(), __off, __way); #endif @@ -352,11 +358,24 @@ namespace std #if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG) // Regular files. +#ifdef _GLIBCXX_USE_LFS + struct stat64 __buffer; + const int __err = fstat64(this->fd(), &__buffer); + if (!__err && _GLIBCXX_ISREG(__buffer.st_mode)) + { + const streamoff __off = __buffer.st_size - lseek64(this->fd(), 0, + ios_base::cur); + return std::min(__off, streamoff(numeric_limits<streamsize>::max())); + } +#else struct stat __buffer; - int __ret = fstat(this->fd(), &__buffer); - if (!__ret && _GLIBCXX_ISREG(__buffer.st_mode)) - return __buffer.st_size - lseek(this->fd(), 0, ios_base::cur); + const int __err = fstat(this->fd(), &__buffer); + if (!__err && _GLIBCXX_ISREG(__buffer.st_mode)) + return __buffer.st_size - lseek(this->fd(), 0, ios_base::cur); +#endif #endif return 0; } -} // namespace std + +_GLIBCXX_END_NAMESPACE + diff --git a/contrib/libstdc++/config/io/basic_file_stdio.h b/contrib/libstdc++/config/io/basic_file_stdio.h index 6aa031b..75468e0 100644 --- a/contrib/libstdc++/config/io/basic_file_stdio.h +++ b/contrib/libstdc++/config/io/basic_file_stdio.h @@ -1,6 +1,7 @@ // Wrapper of C-language FILE struct -*- C++ -*- -// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 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 @@ -15,7 +16,7 @@ // 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, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -44,8 +45,8 @@ #include <bits/c++config.h> #include <ios> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // Generic declaration. template<typename _CharT> class __basic_file; @@ -105,6 +106,7 @@ namespace std streamsize showmanyc(); }; -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/config/io/c_io_stdio.h b/contrib/libstdc++/config/io/c_io_stdio.h index 5659c13..69b8205 100644 --- a/contrib/libstdc++/config/io/c_io_stdio.h +++ b/contrib/libstdc++/config/io/c_io_stdio.h @@ -1,6 +1,7 @@ -// underlying io library -*- C++ -*- +// Underlying io library details -*- C++ -*- -// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // 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, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,6 +28,11 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file c++io.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + // c_io_stdio.h - Defines for using "C" stdio.h #ifndef _C_IO_STDIO_H @@ -36,51 +42,13 @@ #include <cstddef> #include <bits/gthr.h> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + typedef __gthread_mutex_t __c_lock; // for basic_file.h typedef FILE __c_file; - // XXX GLIBCXX_ABI Deprecated - // for ios_base.h - struct __ios_flags - { - typedef short __int_type; - - static const __int_type _S_boolalpha = 0x0001; - static const __int_type _S_dec = 0x0002; - static const __int_type _S_fixed = 0x0004; - static const __int_type _S_hex = 0x0008; - static const __int_type _S_internal = 0x0010; - static const __int_type _S_left = 0x0020; - static const __int_type _S_oct = 0x0040; - static const __int_type _S_right = 0x0080; - static const __int_type _S_scientific = 0x0100; - static const __int_type _S_showbase = 0x0200; - static const __int_type _S_showpoint = 0x0400; - static const __int_type _S_showpos = 0x0800; - static const __int_type _S_skipws = 0x1000; - static const __int_type _S_unitbuf = 0x2000; - static const __int_type _S_uppercase = 0x4000; - static const __int_type _S_adjustfield = 0x0020 | 0x0080 | 0x0010; - static const __int_type _S_basefield = 0x0002 | 0x0040 | 0x0008; - static const __int_type _S_floatfield = 0x0100 | 0x0004; - - // 27.4.2.1.3 Type ios_base::iostate - static const __int_type _S_badbit = 0x01; - static const __int_type _S_eofbit = 0x02; - static const __int_type _S_failbit = 0x04; - - // 27.4.2.1.4 Type openmode - static const __int_type _S_app = 0x01; - static const __int_type _S_ate = 0x02; - static const __int_type _S_bin = 0x04; - static const __int_type _S_in = 0x08; - static const __int_type _S_out = 0x10; - static const __int_type _S_trunc = 0x20; - }; -} +_GLIBCXX_END_NAMESPACE #endif |