this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove old libstdc++darwin wrapper

-2694
-26
src/libstdc++darwin/CMakeLists.txt
··· 1 - project(libstdc++darwin) 2 - 3 - # clang doesn't support linker scripts (-T) 4 - #SET(CMAKE_CXX_COMPILER "/usr/bin/g++") 5 - #set(CMAKE_CXX_FLAGS "") 6 - 7 - if (SUFFIX STREQUAL "32") 8 - set(CMAKE_CXX_FLAGS "-m32") 9 - endif (SUFFIX STREQUAL "32") 10 - 11 - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version.map -Wl,-Bsymbolic") 12 - 13 - cmake_minimum_required(VERSION 2.4.0) 14 - 15 - add_definitions(-Bsymbolic) # -fno-weak 16 - add_library(stdc++darwin SHARED filebuf_abi_fix.cpp) 17 - 18 - #add_custom_target(stdc++_darwinx ALL COMMAND echo objcopy 19 - # --redefine-syms=${CMAKE_CURRENT_SOURCE_DIR}/renames.list 20 - # ${CMAKE_CURRENT_BINARY_DIR}/libstdc++_darwin.so) 21 - 22 - #add_dependencies(stdc++_darwinx stdc++_darwin) 23 - #target_link_libraries(stdc++-darwin -T${CMAKE_CURRENT_SOURCE_DIR}/renames.cmd) 24 - 25 - install(TARGETS stdc++darwin DESTINATION "lib${SUFFIX}/darling") 26 -
-401
src/libstdc++darwin/basic_file_stdio.cc
··· 1 - // Wrapper of C-language FILE struct -*- C++ -*- 2 - 3 - // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2009, 2010 4 - // Free Software Foundation, Inc. 5 - // 6 - // This file is part of the GNU ISO C++ Library. This library is free 7 - // software; you can redistribute it and/or modify it under the 8 - // terms of the GNU General Public License as published by the 9 - // Free Software Foundation; either version 3, or (at your option) 10 - // any later version. 11 - 12 - // This library is distributed in the hope that it will be useful, 13 - // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 - // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 - // GNU General Public License for more details. 16 - 17 - // Under Section 7 of GPL version 3, you are granted additional 18 - // permissions described in the GCC Runtime Library Exception, version 19 - // 3.1, as published by the Free Software Foundation. 20 - 21 - // You should have received a copy of the GNU General Public License and 22 - // a copy of the GCC Runtime Library Exception along with this program; 23 - // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 - // <http://www.gnu.org/licenses/>. 25 - 26 - // 27 - // ISO C++ 14882: 27.8 File-based streams 28 - // 29 - 30 - //#include <bits/basic_file.h> 31 - #define __c_file __sFILE 32 - #define _IO_FILE __sFILE 33 - #include "basic_file_stdio.h" 34 - #include <fcntl.h> 35 - #include <errno.h> 36 - 37 - #ifdef _GLIBCXX_HAVE_POLL 38 - #include <poll.h> 39 - #endif 40 - 41 - // Pick up ioctl on Solaris 2.8 42 - #ifdef _GLIBCXX_HAVE_UNISTD_H 43 - #include <unistd.h> 44 - #endif 45 - 46 - // Pick up FIONREAD on Solaris 2 47 - #ifdef _GLIBCXX_HAVE_SYS_IOCTL_H 48 - #define BSD_COMP 49 - #include <sys/ioctl.h> 50 - #endif 51 - 52 - // Pick up FIONREAD on Solaris 2.5. 53 - #ifdef _GLIBCXX_HAVE_SYS_FILIO_H 54 - #include <sys/filio.h> 55 - #endif 56 - 57 - #ifdef _GLIBCXX_HAVE_SYS_UIO_H 58 - #include <sys/uio.h> 59 - #endif 60 - 61 - struct __sFILE; 62 - 63 - extern "C" __sFILE* __darwin_fopen(const char* path, const char* mode); 64 - extern "C" __sFILE* __darwin_fdopen(int fd, const char* mode); 65 - extern "C" int __darwin_fclose(__sFILE* f); 66 - extern "C" int __darwin_fileno(__sFILE* f); 67 - 68 - #define fopen __darwin_fopen 69 - #define fopen64 __darwin_fopen 70 - #define fdopen __darwin_fdopen 71 - #define fclose __darwin_fclose 72 - #define fileno __darwin_fileno 73 - 74 - #if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG) 75 - # include <sys/stat.h> 76 - # ifdef _GLIBCXX_HAVE_S_ISREG 77 - # define _GLIBCXX_ISREG(x) S_ISREG(x) 78 - # else 79 - # define _GLIBCXX_ISREG(x) (((x) & S_IFMT) == S_IFREG) 80 - # endif 81 - #endif 82 - 83 - #include <limits> // For <off_t>::max() and min() and <streamsize>::max() 84 - 85 - namespace 86 - { 87 - // Map ios_base::openmode flags to a string for use in fopen(). 88 - // Table of valid combinations as given in [lib.filebuf.members]/2. 89 - static const char* 90 - fopen_mode(std::ios_base::openmode mode) 91 - { 92 - enum 93 - { 94 - in = std::ios_base::in, 95 - out = std::ios_base::out, 96 - trunc = std::ios_base::trunc, 97 - app = std::ios_base::app, 98 - binary = std::ios_base::binary 99 - }; 100 - 101 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 102 - // 596. 27.8.1.3 Table 112 omits "a+" and "a+b" modes. 103 - switch (mode & (in|out|trunc|app|binary)) 104 - { 105 - case ( out ): return "w"; 106 - case ( out |app ): return "a"; 107 - case ( app ): return "a"; 108 - case ( out|trunc ): return "w"; 109 - case (in ): return "r"; 110 - case (in|out ): return "r+"; 111 - case (in|out|trunc ): return "w+"; 112 - case (in|out |app ): return "a+"; 113 - case (in |app ): return "a+"; 114 - 115 - case ( out |binary): return "wb"; 116 - case ( out |app|binary): return "ab"; 117 - case ( app|binary): return "ab"; 118 - case ( out|trunc |binary): return "wb"; 119 - case (in |binary): return "rb"; 120 - case (in|out |binary): return "r+b"; 121 - case (in|out|trunc |binary): return "w+b"; 122 - case (in|out |app|binary): return "a+b"; 123 - case (in |app|binary): return "a+b"; 124 - 125 - default: return 0; // invalid 126 - } 127 - } 128 - 129 - // Wrapper handling partial write. 130 - static std::streamsize 131 - xwrite(int __fd, const char* __s, std::streamsize __n) 132 - { 133 - std::streamsize __nleft = __n; 134 - 135 - for (;;) 136 - { 137 - const std::streamsize __ret = write(__fd, __s, __nleft); 138 - if (__ret == -1L && errno == EINTR) 139 - continue; 140 - if (__ret == -1L) 141 - break; 142 - 143 - __nleft -= __ret; 144 - if (__nleft == 0) 145 - break; 146 - 147 - __s += __ret; 148 - } 149 - 150 - return __n - __nleft; 151 - } 152 - 153 - #ifdef _GLIBCXX_HAVE_WRITEV 154 - // Wrapper handling partial writev. 155 - static std::streamsize 156 - xwritev(int __fd, const char* __s1, std::streamsize __n1, 157 - const char* __s2, std::streamsize __n2) 158 - { 159 - std::streamsize __nleft = __n1 + __n2; 160 - std::streamsize __n1_left = __n1; 161 - 162 - struct iovec __iov[2]; 163 - __iov[1].iov_base = const_cast<char*>(__s2); 164 - __iov[1].iov_len = __n2; 165 - 166 - for (;;) 167 - { 168 - __iov[0].iov_base = const_cast<char*>(__s1); 169 - __iov[0].iov_len = __n1_left; 170 - 171 - const std::streamsize __ret = writev(__fd, __iov, 2); 172 - if (__ret == -1L && errno == EINTR) 173 - continue; 174 - if (__ret == -1L) 175 - break; 176 - 177 - __nleft -= __ret; 178 - if (__nleft == 0) 179 - break; 180 - 181 - const std::streamsize __off = __ret - __n1_left; 182 - if (__off >= 0) 183 - { 184 - __nleft -= xwrite(__fd, __s2 + __off, __n2 - __off); 185 - break; 186 - } 187 - 188 - __s1 += __ret; 189 - __n1_left -= __ret; 190 - } 191 - 192 - return __n1 + __n2 - __nleft; 193 - } 194 - #endif 195 - } // anonymous namespace 196 - 197 - 198 - namespace std _GLIBCXX_VISIBILITY(default) 199 - { 200 - _GLIBCXX_BEGIN_NAMESPACE_VERSION 201 - 202 - // Definitions for __basic_file<char>. 203 - __basic_file<char>::__basic_file(__c_lock* /*__lock*/) throw() 204 - : _M_cfile(NULL), _M_cfile_created(false) { } 205 - 206 - __basic_file<char>::~__basic_file() 207 - { this->close(); } 208 - 209 - __basic_file<char>* 210 - __basic_file<char>::sys_open(__c_file* __file, ios_base::openmode) 211 - { 212 - __basic_file* __ret = NULL; 213 - if (!this->is_open() && __file) 214 - { 215 - int __err; 216 - errno = 0; 217 - do 218 - __err = this->sync(); 219 - while (__err && errno == EINTR); 220 - if (!__err) 221 - { 222 - _M_cfile = __file; 223 - _M_cfile_created = false; 224 - __ret = this; 225 - } 226 - } 227 - return __ret; 228 - } 229 - 230 - __basic_file<char>* 231 - __basic_file<char>::sys_open(int __fd, ios_base::openmode __mode) throw () 232 - { 233 - __basic_file* __ret = NULL; 234 - const char* __c_mode = fopen_mode(__mode); 235 - if (__c_mode && !this->is_open() && (_M_cfile = fdopen(__fd, __c_mode))) 236 - { 237 - char* __buf = NULL; 238 - _M_cfile_created = true; 239 - if (__fd == 0) 240 - setvbuf(_M_cfile, __buf, _IONBF, 0); 241 - __ret = this; 242 - } 243 - return __ret; 244 - } 245 - 246 - __basic_file<char>* 247 - __basic_file<char>::open(const char* __name, ios_base::openmode __mode, 248 - int /*__prot*/) 249 - { 250 - __basic_file* __ret = NULL; 251 - const char* __c_mode = fopen_mode(__mode); 252 - if (__c_mode && !this->is_open()) 253 - { 254 - #ifdef _GLIBCXX_USE_LFS 255 - if ((_M_cfile = fopen64(__name, __c_mode))) 256 - #else 257 - if ((_M_cfile = fopen(__name, __c_mode))) 258 - #endif 259 - { 260 - _M_cfile_created = true; 261 - __ret = this; 262 - } 263 - } 264 - return __ret; 265 - } 266 - 267 - bool 268 - __basic_file<char>::is_open() const throw () 269 - { return _M_cfile != 0; } 270 - 271 - int 272 - __basic_file<char>::fd() throw () 273 - { return fileno(_M_cfile); } 274 - 275 - __c_file* 276 - __basic_file<char>::file() throw () 277 - { return _M_cfile; } 278 - 279 - __basic_file<char>* 280 - __basic_file<char>::close() 281 - { 282 - __basic_file* __ret = static_cast<__basic_file*>(NULL); 283 - if (this->is_open()) 284 - { 285 - int __err = 0; 286 - if (_M_cfile_created) 287 - { 288 - // In general, no need to zero errno in advance if checking 289 - // for error first. However, C89/C99 (at variance with IEEE 290 - // 1003.1, f.i.) do not mandate that fclose must set errno 291 - // upon error. 292 - errno = 0; 293 - do 294 - __err = fclose(_M_cfile); 295 - while (__err && errno == EINTR); 296 - } 297 - _M_cfile = 0; 298 - if (!__err) 299 - __ret = this; 300 - } 301 - return __ret; 302 - } 303 - 304 - streamsize 305 - __basic_file<char>::xsgetn(char* __s, streamsize __n) 306 - { 307 - streamsize __ret; 308 - do 309 - __ret = read(this->fd(), __s, __n); 310 - while (__ret == -1L && errno == EINTR); 311 - return __ret; 312 - } 313 - 314 - streamsize 315 - __basic_file<char>::xsputn(const char* __s, streamsize __n) 316 - { return xwrite(this->fd(), __s, __n); } 317 - 318 - streamsize 319 - __basic_file<char>::xsputn_2(const char* __s1, streamsize __n1, 320 - const char* __s2, streamsize __n2) 321 - { 322 - streamsize __ret = 0; 323 - #ifdef _GLIBCXX_HAVE_WRITEV 324 - __ret = xwritev(this->fd(), __s1, __n1, __s2, __n2); 325 - #else 326 - if (__n1) 327 - __ret = xwrite(this->fd(), __s1, __n1); 328 - 329 - if (__ret == __n1) 330 - __ret += xwrite(this->fd(), __s2, __n2); 331 - #endif 332 - return __ret; 333 - } 334 - 335 - streamoff 336 - __basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way) throw () 337 - { 338 - #ifdef _GLIBCXX_USE_LFS 339 - return lseek64(this->fd(), __off, __way); 340 - #else 341 - if (__off > numeric_limits<off_t>::max() 342 - || __off < numeric_limits<off_t>::min()) 343 - return -1L; 344 - return lseek(this->fd(), __off, __way); 345 - #endif 346 - } 347 - 348 - int 349 - __basic_file<char>::sync() 350 - { return fflush(_M_cfile); } 351 - 352 - streamsize 353 - __basic_file<char>::showmanyc() 354 - { 355 - #ifndef _GLIBCXX_NO_IOCTL 356 - #ifdef FIONREAD 357 - // Pipes and sockets. 358 - #ifdef _GLIBCXX_FIONREAD_TAKES_OFF_T 359 - off_t __num = 0; 360 - #else 361 - int __num = 0; 362 - #endif 363 - int __r = ioctl(this->fd(), FIONREAD, &__num); 364 - if (!__r && __num >= 0) 365 - return __num; 366 - #endif 367 - #endif 368 - 369 - #ifdef _GLIBCXX_HAVE_POLL 370 - // Cheap test. 371 - struct pollfd __pfd[1]; 372 - __pfd[0].fd = this->fd(); 373 - __pfd[0].events = POLLIN; 374 - if (poll(__pfd, 1, 0) <= 0) 375 - return 0; 376 - #endif 377 - 378 - #if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG) 379 - // Regular files. 380 - #ifdef _GLIBCXX_USE_LFS 381 - struct stat64 __buffer; 382 - const int __err = fstat64(this->fd(), &__buffer); 383 - if (!__err && _GLIBCXX_ISREG(__buffer.st_mode)) 384 - { 385 - const streamoff __off = __buffer.st_size - lseek64(this->fd(), 0, 386 - ios_base::cur); 387 - return std::min(__off, streamoff(numeric_limits<streamsize>::max())); 388 - } 389 - #else 390 - struct stat __buffer; 391 - const int __err = fstat(this->fd(), &__buffer); 392 - if (!__err && _GLIBCXX_ISREG(__buffer.st_mode)) 393 - return __buffer.st_size - lseek(this->fd(), 0, ios_base::cur); 394 - #endif 395 - #endif 396 - return 0; 397 - } 398 - 399 - _GLIBCXX_END_NAMESPACE_VERSION 400 - } // namespace 401 -
-115
src/libstdc++darwin/basic_file_stdio.h
··· 1 - // Wrapper of C-language FILE struct -*- C++ -*- 2 - 3 - // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 4 - // Free Software Foundation, Inc. 5 - // 6 - // This file is part of the GNU ISO C++ Library. This library is free 7 - // software; you can redistribute it and/or modify it under the 8 - // terms of the GNU General Public License as published by the 9 - // Free Software Foundation; either version 3, or (at your option) 10 - // any later version. 11 - 12 - // This library is distributed in the hope that it will be useful, 13 - // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 - // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 - // GNU General Public License for more details. 16 - 17 - // Under Section 7 of GPL version 3, you are granted additional 18 - // permissions described in the GCC Runtime Library Exception, version 19 - // 3.1, as published by the Free Software Foundation. 20 - 21 - // You should have received a copy of the GNU General Public License and 22 - // a copy of the GCC Runtime Library Exception along with this program; 23 - // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 - // <http://www.gnu.org/licenses/>. 25 - 26 - // 27 - // ISO C++ 14882: 27.8 File-based streams 28 - // 29 - 30 - /** @file bits/basic_file.h 31 - * This is an internal header file, included by other library headers. 32 - * Do not attempt to use it directly. @headername{ios} 33 - */ 34 - 35 - #ifndef _GLIBCXX_BASIC_FILE_STDIO_H 36 - #define _GLIBCXX_BASIC_FILE_STDIO_H 1 37 - #define __c_file __sFILE 38 - #define _IO_FILE __sFILE 39 - 40 - #pragma GCC system_header 41 - 42 - #include <bits/c++config.h> 43 - #include "c_io_stdio.h" 44 - //#include <bits/c++io.h> // for __c_lock and __c_file 45 - #include <ios> 46 - 47 - 48 - namespace std _GLIBCXX_VISIBILITY(default) 49 - { 50 - _GLIBCXX_BEGIN_NAMESPACE_VERSION 51 - 52 - // Generic declaration. 53 - template<typename _CharT> 54 - class __basic_file; 55 - 56 - // Specialization. 57 - template<> 58 - class __basic_file<char> 59 - { 60 - // Underlying data source/sink. 61 - __c_file* _M_cfile; 62 - 63 - // True iff we opened _M_cfile, and thus must close it ourselves. 64 - bool _M_cfile_created; 65 - 66 - public: 67 - __basic_file(__c_lock* __lock = 0) throw (); 68 - 69 - __basic_file* 70 - open(const char* __name, ios_base::openmode __mode, int __prot = 0664); 71 - 72 - __basic_file* 73 - sys_open(__c_file* __file, ios_base::openmode); 74 - 75 - __basic_file* 76 - sys_open(int __fd, ios_base::openmode __mode) throw (); 77 - 78 - __basic_file* 79 - close(); 80 - 81 - _GLIBCXX_PURE bool 82 - is_open() const throw (); 83 - 84 - _GLIBCXX_PURE int 85 - fd() throw (); 86 - 87 - _GLIBCXX_PURE __c_file* 88 - file() throw (); 89 - 90 - ~__basic_file(); 91 - 92 - streamsize 93 - xsputn(const char* __s, streamsize __n); 94 - 95 - streamsize 96 - xsputn_2(const char* __s1, streamsize __n1, 97 - const char* __s2, streamsize __n2); 98 - 99 - streamsize 100 - xsgetn(char* __s, streamsize __n); 101 - 102 - streamoff 103 - seekoff(streamoff __off, ios_base::seekdir __way) throw (); 104 - 105 - int 106 - sync(); 107 - 108 - streamsize 109 - showmanyc(); 110 - }; 111 - 112 - _GLIBCXX_END_NAMESPACE_VERSION 113 - } // namespace 114 - 115 - #endif
-53
src/libstdc++darwin/c_io_stdio.h
··· 1 - // Underlying io library details -*- C++ -*- 2 - 3 - // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010 4 - // Free Software Foundation, Inc. 5 - // 6 - // This file is part of the GNU ISO C++ Library. This library is free 7 - // software; you can redistribute it and/or modify it under the 8 - // terms of the GNU General Public License as published by the 9 - // Free Software Foundation; either version 3, or (at your option) 10 - // any later version. 11 - 12 - // This library is distributed in the hope that it will be useful, 13 - // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 - // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 - // GNU General Public License for more details. 16 - 17 - // Under Section 7 of GPL version 3, you are granted additional 18 - // permissions described in the GCC Runtime Library Exception, version 19 - // 3.1, as published by the Free Software Foundation. 20 - 21 - // You should have received a copy of the GNU General Public License and 22 - // a copy of the GCC Runtime Library Exception along with this program; 23 - // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 - // <http://www.gnu.org/licenses/>. 25 - 26 - /** @file bits/c++io.h 27 - * This is an internal header file, included by other library headers. 28 - * Do not attempt to use it directly. @headername{ios} 29 - */ 30 - 31 - // c_io_stdio.h - Defines for using "C" stdio.h 32 - 33 - #ifndef _GLIBCXX_CXX_IO_H 34 - #define _GLIBCXX_CXX_IO_H 1 35 - 36 - #include <cstdio> 37 - #include <bits/gthr.h> 38 - 39 - struct __sFILE; 40 - 41 - namespace std _GLIBCXX_VISIBILITY(default) 42 - { 43 - _GLIBCXX_BEGIN_NAMESPACE_VERSION 44 - 45 - typedef __gthread_mutex_t __c_lock; 46 - 47 - // for basic_file.h 48 - typedef __sFILE __c_file; 49 - 50 - _GLIBCXX_END_NAMESPACE_VERSION 51 - } // namespace 52 - 53 - #endif
-14
src/libstdc++darwin/filebuf_abi_fix.cpp
··· 1 - // http://stackoverflow.com/a/452955 2 - #define _GLIBCXX_VISIBILITY(x) __attribute((visibility(#x))) 3 - #define _GLIBCXX_BEGIN_NAMESPACE_VERSION 4 - #define _GLIBCXX_END_NAMESPACE_VERSION 5 - #include "basic_file_stdio.cc" 6 - #include "fstream" 7 - #include "fstream.tcc" 8 - 9 - template class std::__basic_file<char>; 10 - template class std::basic_filebuf<char, std::char_traits<char> >; 11 - template class std::basic_streambuf<char, std::char_traits<char> >; 12 - template class std::basic_ios<char, std::char_traits<char> >; 13 - template class std::basic_ostream<char, std::char_traits<char> >; 14 -
-950
src/libstdc++darwin/fstream
··· 1 - // File based streams -*- C++ -*- 2 - 3 - // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 4 - // 2006, 2007, 2008, 2009, 2010, 2011 5 - // Free Software Foundation, Inc. 6 - // 7 - // This file is part of the GNU ISO C++ Library. This library is free 8 - // software; you can redistribute it and/or modify it under the 9 - // terms of the GNU General Public License as published by the 10 - // Free Software Foundation; either version 3, or (at your option) 11 - // any later version. 12 - 13 - // This library is distributed in the hope that it will be useful, 14 - // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 - // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 - // GNU General Public License for more details. 17 - 18 - // Under Section 7 of GPL version 3, you are granted additional 19 - // permissions described in the GCC Runtime Library Exception, version 20 - // 3.1, as published by the Free Software Foundation. 21 - 22 - // You should have received a copy of the GNU General Public License and 23 - // a copy of the GCC Runtime Library Exception along with this program; 24 - // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 25 - // <http://www.gnu.org/licenses/>. 26 - 27 - /** @file include/fstream 28 - * This is a Standard C++ Library header. 29 - */ 30 - 31 - // 32 - // ISO C++ 14882: 27.8 File-based streams 33 - // 34 - 35 - #ifndef _GLIBCXX_FSTREAM 36 - #define _GLIBCXX_FSTREAM 1 37 - 38 - #pragma GCC system_header 39 - 40 - #include <istream> 41 - #include <ostream> 42 - #include <bits/codecvt.h> 43 - #include <cstdio> // For BUFSIZ 44 - #ifdef __GXX_EXPERIMENTAL_CXX0X__ 45 - #include <string> // For std::string overloads. 46 - #endif 47 - 48 - namespace std _GLIBCXX_VISIBILITY(default) 49 - { 50 - _GLIBCXX_BEGIN_NAMESPACE_VERSION 51 - 52 - // [27.8.1.1] template class basic_filebuf 53 - /** 54 - * @brief The actual work of input and output (for files). 55 - * @ingroup io 56 - * 57 - * This class associates both its input and output sequence with an 58 - * external disk file, and maintains a joint file position for both 59 - * sequences. Many of its semantics are described in terms of similar 60 - * behavior in the Standard C Library's @c FILE streams. 61 - */ 62 - // Requirements on traits_type, specific to this class: 63 - // traits_type::pos_type must be fpos<traits_type::state_type> 64 - // traits_type::off_type must be streamoff 65 - // traits_type::state_type must be Assignable and DefaultConstructible, 66 - // and traits_type::state_type() must be the initial state for codecvt. 67 - template<typename _CharT, typename _Traits> 68 - class basic_filebuf : public basic_streambuf<_CharT, _Traits> 69 - { 70 - public: 71 - // Types: 72 - typedef _CharT char_type; 73 - typedef _Traits traits_type; 74 - typedef typename traits_type::int_type int_type; 75 - typedef typename traits_type::pos_type pos_type; 76 - typedef typename traits_type::off_type off_type; 77 - 78 - typedef basic_streambuf<char_type, traits_type> __streambuf_type; 79 - typedef basic_filebuf<char_type, traits_type> __filebuf_type; 80 - typedef __basic_file<char> __file_type; 81 - typedef typename traits_type::state_type __state_type; 82 - typedef codecvt<char_type, char, __state_type> __codecvt_type; 83 - 84 - friend class ios_base; // For sync_with_stdio. 85 - 86 - protected: 87 - // Data Members: 88 - // MT lock inherited from libio or other low-level io library. 89 - 90 - // Darling MODIFICATION 91 - union 92 - { 93 - __c_lock _M_lock; 94 - // 64 on 64-bit 95 - // 44 on 32-bit 96 - struct 97 - { 98 - char __align0[24]; 99 - long __align0x[5]; 100 - }; 101 - }; 102 - 103 - // External buffer. 104 - __file_type _M_file; 105 - 106 - /// Place to stash in || out || in | out settings for current filebuf. 107 - ios_base::openmode _M_mode; 108 - 109 - // Beginning state type for codecvt. 110 - // Darling MODIFICATION 111 - union 112 - { 113 - __state_type _M_state_beg; 114 - char __align1[128]; 115 - }; 116 - 117 - // During output, the state that corresponds to pptr(), 118 - // during input, the state that corresponds to egptr() and 119 - // _M_ext_next. 120 - // Darling MODIFICATION 121 - union 122 - { 123 - __state_type _M_state_cur; 124 - char __align2[128]; 125 - }; 126 - 127 - // Not used for output. During input, the state that corresponds 128 - // to eback() and _M_ext_buf. 129 - // Darling MODIFICATION 130 - union 131 - { 132 - __state_type _M_state_last; 133 - char __align3[128]; 134 - }; 135 - 136 - /// Pointer to the beginning of internal buffer. 137 - char_type* _M_buf; 138 - 139 - /** 140 - * Actual size of internal buffer. This number is equal to the size 141 - * of the put area + 1 position, reserved for the overflow char of 142 - * a full area. 143 - */ 144 - size_t _M_buf_size; 145 - 146 - // Set iff _M_buf is allocated memory from _M_allocate_internal_buffer. 147 - bool _M_buf_allocated; 148 - 149 - /** 150 - * _M_reading == false && _M_writing == false for @b uncommitted mode; 151 - * _M_reading == true for @b read mode; 152 - * _M_writing == true for @b write mode; 153 - * 154 - * NB: _M_reading == true && _M_writing == true is unused. 155 - */ 156 - bool _M_reading; 157 - bool _M_writing; 158 - 159 - //@{ 160 - /** 161 - * Necessary bits for putback buffer management. 162 - * 163 - * @note pbacks of over one character are not currently supported. 164 - */ 165 - char_type _M_pback; 166 - char_type* _M_pback_cur_save; 167 - char_type* _M_pback_end_save; 168 - bool _M_pback_init; 169 - //@} 170 - 171 - // Cached codecvt facet. 172 - const __codecvt_type* _M_codecvt; 173 - 174 - /** 175 - * Buffer for external characters. Used for input when 176 - * codecvt::always_noconv() == false. When valid, this corresponds 177 - * to eback(). 178 - */ 179 - char* _M_ext_buf; 180 - 181 - /** 182 - * Size of buffer held by _M_ext_buf. 183 - */ 184 - streamsize _M_ext_buf_size; 185 - 186 - /** 187 - * Pointers into the buffer held by _M_ext_buf that delimit a 188 - * subsequence of bytes that have been read but not yet converted. 189 - * When valid, _M_ext_next corresponds to egptr(). 190 - */ 191 - const char* _M_ext_next; 192 - char* _M_ext_end; 193 - 194 - /** 195 - * Initializes pback buffers, and moves normal buffers to safety. 196 - * Assumptions: 197 - * _M_in_cur has already been moved back 198 - */ 199 - void 200 - _M_create_pback() 201 - { 202 - if (!_M_pback_init) 203 - { 204 - _M_pback_cur_save = this->gptr(); 205 - _M_pback_end_save = this->egptr(); 206 - this->setg(&_M_pback, &_M_pback, &_M_pback + 1); 207 - _M_pback_init = true; 208 - } 209 - } 210 - 211 - /** 212 - * Deactivates pback buffer contents, and restores normal buffer. 213 - * Assumptions: 214 - * The pback buffer has only moved forward. 215 - */ 216 - void 217 - _M_destroy_pback() throw() 218 - { 219 - if (_M_pback_init) 220 - { 221 - // Length _M_in_cur moved in the pback buffer. 222 - _M_pback_cur_save += this->gptr() != this->eback(); 223 - this->setg(_M_buf, _M_pback_cur_save, _M_pback_end_save); 224 - _M_pback_init = false; 225 - } 226 - } 227 - 228 - public: 229 - // Constructors/destructor: 230 - /** 231 - * @brief Does not open any files. 232 - * 233 - * The default constructor initializes the parent class using its 234 - * own default ctor. 235 - */ 236 - basic_filebuf(); 237 - 238 - /** 239 - * @brief The destructor closes the file first. 240 - */ 241 - virtual 242 - ~basic_filebuf() 243 - { this->close(); } 244 - 245 - // Members: 246 - /** 247 - * @brief Returns true if the external file is open. 248 - */ 249 - bool 250 - is_open() const throw() 251 - { return _M_file.is_open(); } 252 - 253 - /** 254 - * @brief Opens an external file. 255 - * @param s The name of the file. 256 - * @param mode The open mode flags. 257 - * @return @c this on success, NULL on failure 258 - * 259 - * If a file is already open, this function immediately fails. 260 - * Otherwise it tries to open the file named @a s using the flags 261 - * given in @a mode. 262 - * 263 - * Table 92, adapted here, gives the relation between openmode 264 - * combinations and the equivalent fopen() flags. 265 - * (NB: lines app, in|out|app, in|app, binary|app, binary|in|out|app, 266 - * and binary|in|app per DR 596) 267 - * +---------------------------------------------------------+ 268 - * | ios_base Flag combination stdio equivalent | 269 - * |binary in out trunc app | 270 - * +---------------------------------------------------------+ 271 - * | + w | 272 - * | + + a | 273 - * | + a | 274 - * | + + w | 275 - * | + r | 276 - * | + + r+ | 277 - * | + + + w+ | 278 - * | + + + a+ | 279 - * | + + a+ | 280 - * +---------------------------------------------------------+ 281 - * | + + wb | 282 - * | + + + ab | 283 - * | + + ab | 284 - * | + + + wb | 285 - * | + + rb | 286 - * | + + + r+b | 287 - * | + + + + w+b | 288 - * | + + + + a+b | 289 - * | + + + a+b | 290 - * +---------------------------------------------------------+ 291 - */ 292 - __filebuf_type* 293 - open(const char* __s, ios_base::openmode __mode); 294 - 295 - #ifdef __GXX_EXPERIMENTAL_CXX0X__ 296 - /** 297 - * @brief Opens an external file. 298 - * @param s The name of the file. 299 - * @param mode The open mode flags. 300 - * @return @c this on success, NULL on failure 301 - */ 302 - __filebuf_type* 303 - open(const std::string& __s, ios_base::openmode __mode) 304 - { return open(__s.c_str(), __mode); } 305 - #endif 306 - 307 - /** 308 - * @brief Closes the currently associated file. 309 - * @return @c this on success, NULL on failure 310 - * 311 - * If no file is currently open, this function immediately fails. 312 - * 313 - * If a <em>put buffer area</em> exists, @c overflow(eof) is 314 - * called to flush all the characters. The file is then 315 - * closed. 316 - * 317 - * If any operations fail, this function also fails. 318 - */ 319 - __filebuf_type* 320 - close(); 321 - 322 - protected: 323 - void 324 - _M_allocate_internal_buffer(); 325 - 326 - void 327 - _M_destroy_internal_buffer() throw(); 328 - 329 - // [27.8.1.4] overridden virtual functions 330 - virtual streamsize 331 - showmanyc(); 332 - 333 - // Stroustrup, 1998, p. 628 334 - // underflow() and uflow() functions are called to get the next 335 - // character from the real input source when the buffer is empty. 336 - // Buffered input uses underflow() 337 - 338 - virtual int_type 339 - underflow(); 340 - 341 - virtual int_type 342 - pbackfail(int_type __c = _Traits::eof()); 343 - 344 - // Stroustrup, 1998, p 648 345 - // The overflow() function is called to transfer characters to the 346 - // real output destination when the buffer is full. A call to 347 - // overflow(c) outputs the contents of the buffer plus the 348 - // character c. 349 - // 27.5.2.4.5 350 - // Consume some sequence of the characters in the pending sequence. 351 - virtual int_type 352 - overflow(int_type __c = _Traits::eof()); 353 - 354 - // Convert internal byte sequence to external, char-based 355 - // sequence via codecvt. 356 - bool 357 - _M_convert_to_external(char_type*, streamsize); 358 - 359 - /** 360 - * @brief Manipulates the buffer. 361 - * @param s Pointer to a buffer area. 362 - * @param n Size of @a s. 363 - * @return @c this 364 - * 365 - * If no file has been opened, and both @a s and @a n are zero, then 366 - * the stream becomes unbuffered. Otherwise, @c s is used as a 367 - * buffer; see 368 - * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html 369 - * for more. 370 - */ 371 - virtual __streambuf_type* 372 - setbuf(char_type* __s, streamsize __n); 373 - 374 - virtual pos_type 375 - seekoff(off_type __off, ios_base::seekdir __way, 376 - ios_base::openmode __mode = ios_base::in | ios_base::out); 377 - 378 - virtual pos_type 379 - seekpos(pos_type __pos, 380 - ios_base::openmode __mode = ios_base::in | ios_base::out); 381 - 382 - // Common code for seekoff, seekpos, and overflow 383 - pos_type 384 - _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state); 385 - 386 - int 387 - _M_get_ext_pos(__state_type &__state); 388 - 389 - virtual int 390 - sync(); 391 - 392 - virtual void 393 - imbue(const locale& __loc); 394 - 395 - virtual streamsize 396 - xsgetn(char_type* __s, streamsize __n); 397 - 398 - virtual streamsize 399 - xsputn(const char_type* __s, streamsize __n); 400 - 401 - // Flushes output buffer, then writes unshift sequence. 402 - bool 403 - _M_terminate_output(); 404 - 405 - /** 406 - * This function sets the pointers of the internal buffer, both get 407 - * and put areas. Typically: 408 - * 409 - * __off == egptr() - eback() upon underflow/uflow (@b read mode); 410 - * __off == 0 upon overflow (@b write mode); 411 - * __off == -1 upon open, setbuf, seekoff/pos (@b uncommitted mode). 412 - * 413 - * NB: epptr() - pbase() == _M_buf_size - 1, since _M_buf_size 414 - * reflects the actual allocated memory and the last cell is reserved 415 - * for the overflow char of a full put area. 416 - */ 417 - void 418 - _M_set_buffer(streamsize __off) 419 - { 420 - const bool __testin = _M_mode & ios_base::in; 421 - const bool __testout = _M_mode & ios_base::out; 422 - 423 - if (__testin && __off > 0) 424 - this->setg(_M_buf, _M_buf, _M_buf + __off); 425 - else 426 - this->setg(_M_buf, _M_buf, _M_buf); 427 - 428 - if (__testout && __off == 0 && _M_buf_size > 1 ) 429 - this->setp(_M_buf, _M_buf + _M_buf_size - 1); 430 - else 431 - this->setp(0, 0); 432 - } 433 - }; 434 - 435 - // [27.8.1.5] Template class basic_ifstream 436 - /** 437 - * @brief Controlling input for files. 438 - * @ingroup io 439 - * 440 - * This class supports reading from named files, using the inherited 441 - * functions from std::basic_istream. To control the associated 442 - * sequence, an instance of std::basic_filebuf is used, which this page 443 - * refers to as @c sb. 444 - */ 445 - template<typename _CharT, typename _Traits> 446 - class basic_ifstream : public basic_istream<_CharT, _Traits> 447 - { 448 - public: 449 - // Types: 450 - typedef _CharT char_type; 451 - typedef _Traits traits_type; 452 - typedef typename traits_type::int_type int_type; 453 - typedef typename traits_type::pos_type pos_type; 454 - typedef typename traits_type::off_type off_type; 455 - 456 - // Non-standard types: 457 - typedef basic_filebuf<char_type, traits_type> __filebuf_type; 458 - typedef basic_istream<char_type, traits_type> __istream_type; 459 - 460 - private: 461 - __filebuf_type _M_filebuf; 462 - 463 - public: 464 - // Constructors/Destructors: 465 - /** 466 - * @brief Default constructor. 467 - * 468 - * Initializes @c sb using its default constructor, and passes 469 - * @c &sb to the base class initializer. Does not open any files 470 - * (you haven't given it a filename to open). 471 - */ 472 - basic_ifstream() : __istream_type(), _M_filebuf() 473 - { this->init(&_M_filebuf); } 474 - 475 - /** 476 - * @brief Create an input file stream. 477 - * @param s Null terminated string specifying the filename. 478 - * @param mode Open file in specified mode (see std::ios_base). 479 - * 480 - * @c ios_base::in is automatically included in @a mode. 481 - * 482 - * Tip: When using std::string to hold the filename, you must use 483 - * .c_str() before passing it to this constructor. 484 - */ 485 - explicit 486 - basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in) 487 - : __istream_type(), _M_filebuf() 488 - { 489 - this->init(&_M_filebuf); 490 - this->open(__s, __mode); 491 - } 492 - 493 - #ifdef __GXX_EXPERIMENTAL_CXX0X__ 494 - /** 495 - * @brief Create an input file stream. 496 - * @param s std::string specifying the filename. 497 - * @param mode Open file in specified mode (see std::ios_base). 498 - * 499 - * @c ios_base::in is automatically included in @a mode. 500 - */ 501 - explicit 502 - basic_ifstream(const std::string& __s, 503 - ios_base::openmode __mode = ios_base::in) 504 - : __istream_type(), _M_filebuf() 505 - { 506 - this->init(&_M_filebuf); 507 - this->open(__s, __mode); 508 - } 509 - #endif 510 - 511 - /** 512 - * @brief The destructor does nothing. 513 - * 514 - * The file is closed by the filebuf object, not the formatting 515 - * stream. 516 - */ 517 - ~basic_ifstream() 518 - { } 519 - 520 - // Members: 521 - /** 522 - * @brief Accessing the underlying buffer. 523 - * @return The current basic_filebuf buffer. 524 - * 525 - * This hides both signatures of std::basic_ios::rdbuf(). 526 - */ 527 - __filebuf_type* 528 - rdbuf() const 529 - { return const_cast<__filebuf_type*>(&_M_filebuf); } 530 - 531 - /** 532 - * @brief Wrapper to test for an open file. 533 - * @return @c rdbuf()->is_open() 534 - */ 535 - bool 536 - is_open() 537 - { return _M_filebuf.is_open(); } 538 - 539 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 540 - // 365. Lack of const-qualification in clause 27 541 - bool 542 - is_open() const 543 - { return _M_filebuf.is_open(); } 544 - 545 - /** 546 - * @brief Opens an external file. 547 - * @param s The name of the file. 548 - * @param mode The open mode flags. 549 - * 550 - * Calls @c std::basic_filebuf::open(s,mode|in). If that function 551 - * fails, @c failbit is set in the stream's error state. 552 - * 553 - * Tip: When using std::string to hold the filename, you must use 554 - * .c_str() before passing it to this constructor. 555 - */ 556 - void 557 - open(const char* __s, ios_base::openmode __mode = ios_base::in) 558 - { 559 - if (!_M_filebuf.open(__s, __mode | ios_base::in)) 560 - this->setstate(ios_base::failbit); 561 - else 562 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 563 - // 409. Closing an fstream should clear error state 564 - this->clear(); 565 - } 566 - 567 - #ifdef __GXX_EXPERIMENTAL_CXX0X__ 568 - /** 569 - * @brief Opens an external file. 570 - * @param s The name of the file. 571 - * @param mode The open mode flags. 572 - * 573 - * Calls @c std::basic_filebuf::open(s,mode|in). If that function 574 - * fails, @c failbit is set in the stream's error state. 575 - */ 576 - void 577 - open(const std::string& __s, ios_base::openmode __mode = ios_base::in) 578 - { 579 - if (!_M_filebuf.open(__s, __mode | ios_base::in)) 580 - this->setstate(ios_base::failbit); 581 - else 582 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 583 - // 409. Closing an fstream should clear error state 584 - this->clear(); 585 - } 586 - #endif 587 - 588 - /** 589 - * @brief Close the file. 590 - * 591 - * Calls @c std::basic_filebuf::close(). If that function 592 - * fails, @c failbit is set in the stream's error state. 593 - */ 594 - void 595 - close() 596 - { 597 - if (!_M_filebuf.close()) 598 - this->setstate(ios_base::failbit); 599 - } 600 - }; 601 - 602 - 603 - // [27.8.1.8] Template class basic_ofstream 604 - /** 605 - * @brief Controlling output for files. 606 - * @ingroup io 607 - * 608 - * This class supports reading from named files, using the inherited 609 - * functions from std::basic_ostream. To control the associated 610 - * sequence, an instance of std::basic_filebuf is used, which this page 611 - * refers to as @c sb. 612 - */ 613 - template<typename _CharT, typename _Traits> 614 - class basic_ofstream : public basic_ostream<_CharT,_Traits> 615 - { 616 - public: 617 - // Types: 618 - typedef _CharT char_type; 619 - typedef _Traits traits_type; 620 - typedef typename traits_type::int_type int_type; 621 - typedef typename traits_type::pos_type pos_type; 622 - typedef typename traits_type::off_type off_type; 623 - 624 - // Non-standard types: 625 - typedef basic_filebuf<char_type, traits_type> __filebuf_type; 626 - typedef basic_ostream<char_type, traits_type> __ostream_type; 627 - 628 - private: 629 - __filebuf_type _M_filebuf; 630 - 631 - public: 632 - // Constructors: 633 - /** 634 - * @brief Default constructor. 635 - * 636 - * Initializes @c sb using its default constructor, and passes 637 - * @c &sb to the base class initializer. Does not open any files 638 - * (you haven't given it a filename to open). 639 - */ 640 - basic_ofstream(): __ostream_type(), _M_filebuf() 641 - { this->init(&_M_filebuf); } 642 - 643 - /** 644 - * @brief Create an output file stream. 645 - * @param s Null terminated string specifying the filename. 646 - * @param mode Open file in specified mode (see std::ios_base). 647 - * 648 - * @c ios_base::out|ios_base::trunc is automatically included in 649 - * @a mode. 650 - * 651 - * Tip: When using std::string to hold the filename, you must use 652 - * .c_str() before passing it to this constructor. 653 - */ 654 - explicit 655 - basic_ofstream(const char* __s, 656 - ios_base::openmode __mode = ios_base::out|ios_base::trunc) 657 - : __ostream_type(), _M_filebuf() 658 - { 659 - this->init(&_M_filebuf); 660 - this->open(__s, __mode); 661 - } 662 - 663 - #ifdef __GXX_EXPERIMENTAL_CXX0X__ 664 - /** 665 - * @brief Create an output file stream. 666 - * @param s std::string specifying the filename. 667 - * @param mode Open file in specified mode (see std::ios_base). 668 - * 669 - * @c ios_base::out|ios_base::trunc is automatically included in 670 - * @a mode. 671 - */ 672 - explicit 673 - basic_ofstream(const std::string& __s, 674 - ios_base::openmode __mode = ios_base::out|ios_base::trunc) 675 - : __ostream_type(), _M_filebuf() 676 - { 677 - this->init(&_M_filebuf); 678 - this->open(__s, __mode); 679 - } 680 - #endif 681 - 682 - /** 683 - * @brief The destructor does nothing. 684 - * 685 - * The file is closed by the filebuf object, not the formatting 686 - * stream. 687 - */ 688 - ~basic_ofstream() 689 - { } 690 - 691 - // Members: 692 - /** 693 - * @brief Accessing the underlying buffer. 694 - * @return The current basic_filebuf buffer. 695 - * 696 - * This hides both signatures of std::basic_ios::rdbuf(). 697 - */ 698 - __filebuf_type* 699 - rdbuf() const 700 - { return const_cast<__filebuf_type*>(&_M_filebuf); } 701 - 702 - /** 703 - * @brief Wrapper to test for an open file. 704 - * @return @c rdbuf()->is_open() 705 - */ 706 - bool 707 - is_open() 708 - { return _M_filebuf.is_open(); } 709 - 710 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 711 - // 365. Lack of const-qualification in clause 27 712 - bool 713 - is_open() const 714 - { return _M_filebuf.is_open(); } 715 - 716 - /** 717 - * @brief Opens an external file. 718 - * @param s The name of the file. 719 - * @param mode The open mode flags. 720 - * 721 - * Calls @c std::basic_filebuf::open(s,mode|out|trunc). If that 722 - * function fails, @c failbit is set in the stream's error state. 723 - * 724 - * Tip: When using std::string to hold the filename, you must use 725 - * .c_str() before passing it to this constructor. 726 - */ 727 - void 728 - open(const char* __s, 729 - ios_base::openmode __mode = ios_base::out | ios_base::trunc) 730 - { 731 - if (!_M_filebuf.open(__s, __mode | ios_base::out)) 732 - this->setstate(ios_base::failbit); 733 - else 734 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 735 - // 409. Closing an fstream should clear error state 736 - this->clear(); 737 - } 738 - 739 - #ifdef __GXX_EXPERIMENTAL_CXX0X__ 740 - /** 741 - * @brief Opens an external file. 742 - * @param s The name of the file. 743 - * @param mode The open mode flags. 744 - * 745 - * Calls @c std::basic_filebuf::open(s,mode|out|trunc). If that 746 - * function fails, @c failbit is set in the stream's error state. 747 - */ 748 - void 749 - open(const std::string& __s, 750 - ios_base::openmode __mode = ios_base::out | ios_base::trunc) 751 - { 752 - if (!_M_filebuf.open(__s, __mode | ios_base::out)) 753 - this->setstate(ios_base::failbit); 754 - else 755 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 756 - // 409. Closing an fstream should clear error state 757 - this->clear(); 758 - } 759 - #endif 760 - 761 - /** 762 - * @brief Close the file. 763 - * 764 - * Calls @c std::basic_filebuf::close(). If that function 765 - * fails, @c failbit is set in the stream's error state. 766 - */ 767 - void 768 - close() 769 - { 770 - if (!_M_filebuf.close()) 771 - this->setstate(ios_base::failbit); 772 - } 773 - }; 774 - 775 - 776 - // [27.8.1.11] Template class basic_fstream 777 - /** 778 - * @brief Controlling input and output for files. 779 - * @ingroup io 780 - * 781 - * This class supports reading from and writing to named files, using 782 - * the inherited functions from std::basic_iostream. To control the 783 - * associated sequence, an instance of std::basic_filebuf is used, which 784 - * this page refers to as @c sb. 785 - */ 786 - template<typename _CharT, typename _Traits> 787 - class basic_fstream : public basic_iostream<_CharT, _Traits> 788 - { 789 - public: 790 - // Types: 791 - typedef _CharT char_type; 792 - typedef _Traits traits_type; 793 - typedef typename traits_type::int_type int_type; 794 - typedef typename traits_type::pos_type pos_type; 795 - typedef typename traits_type::off_type off_type; 796 - 797 - // Non-standard types: 798 - typedef basic_filebuf<char_type, traits_type> __filebuf_type; 799 - typedef basic_ios<char_type, traits_type> __ios_type; 800 - typedef basic_iostream<char_type, traits_type> __iostream_type; 801 - 802 - private: 803 - __filebuf_type _M_filebuf; 804 - 805 - public: 806 - // Constructors/destructor: 807 - /** 808 - * @brief Default constructor. 809 - * 810 - * Initializes @c sb using its default constructor, and passes 811 - * @c &sb to the base class initializer. Does not open any files 812 - * (you haven't given it a filename to open). 813 - */ 814 - basic_fstream() 815 - : __iostream_type(), _M_filebuf() 816 - { this->init(&_M_filebuf); } 817 - 818 - /** 819 - * @brief Create an input/output file stream. 820 - * @param s Null terminated string specifying the filename. 821 - * @param mode Open file in specified mode (see std::ios_base). 822 - * 823 - * Tip: When using std::string to hold the filename, you must use 824 - * .c_str() before passing it to this constructor. 825 - */ 826 - explicit 827 - basic_fstream(const char* __s, 828 - ios_base::openmode __mode = ios_base::in | ios_base::out) 829 - : __iostream_type(0), _M_filebuf() 830 - { 831 - this->init(&_M_filebuf); 832 - this->open(__s, __mode); 833 - } 834 - 835 - #ifdef __GXX_EXPERIMENTAL_CXX0X__ 836 - /** 837 - * @brief Create an input/output file stream. 838 - * @param s Null terminated string specifying the filename. 839 - * @param mode Open file in specified mode (see std::ios_base). 840 - */ 841 - explicit 842 - basic_fstream(const std::string& __s, 843 - ios_base::openmode __mode = ios_base::in | ios_base::out) 844 - : __iostream_type(0), _M_filebuf() 845 - { 846 - this->init(&_M_filebuf); 847 - this->open(__s, __mode); 848 - } 849 - #endif 850 - 851 - /** 852 - * @brief The destructor does nothing. 853 - * 854 - * The file is closed by the filebuf object, not the formatting 855 - * stream. 856 - */ 857 - ~basic_fstream() 858 - { } 859 - 860 - // Members: 861 - /** 862 - * @brief Accessing the underlying buffer. 863 - * @return The current basic_filebuf buffer. 864 - * 865 - * This hides both signatures of std::basic_ios::rdbuf(). 866 - */ 867 - __filebuf_type* 868 - rdbuf() const 869 - { return const_cast<__filebuf_type*>(&_M_filebuf); } 870 - 871 - /** 872 - * @brief Wrapper to test for an open file. 873 - * @return @c rdbuf()->is_open() 874 - */ 875 - bool 876 - is_open() 877 - { return _M_filebuf.is_open(); } 878 - 879 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 880 - // 365. Lack of const-qualification in clause 27 881 - bool 882 - is_open() const 883 - { return _M_filebuf.is_open(); } 884 - 885 - /** 886 - * @brief Opens an external file. 887 - * @param s The name of the file. 888 - * @param mode The open mode flags. 889 - * 890 - * Calls @c std::basic_filebuf::open(s,mode). If that 891 - * function fails, @c failbit is set in the stream's error state. 892 - * 893 - * Tip: When using std::string to hold the filename, you must use 894 - * .c_str() before passing it to this constructor. 895 - */ 896 - void 897 - open(const char* __s, 898 - ios_base::openmode __mode = ios_base::in | ios_base::out) 899 - { 900 - if (!_M_filebuf.open(__s, __mode)) 901 - this->setstate(ios_base::failbit); 902 - else 903 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 904 - // 409. Closing an fstream should clear error state 905 - this->clear(); 906 - } 907 - 908 - #ifdef __GXX_EXPERIMENTAL_CXX0X__ 909 - /** 910 - * @brief Opens an external file. 911 - * @param s The name of the file. 912 - * @param mode The open mode flags. 913 - * 914 - * Calls @c std::basic_filebuf::open(s,mode). If that 915 - * function fails, @c failbit is set in the stream's error state. 916 - */ 917 - void 918 - open(const std::string& __s, 919 - ios_base::openmode __mode = ios_base::in | ios_base::out) 920 - { 921 - if (!_M_filebuf.open(__s, __mode)) 922 - this->setstate(ios_base::failbit); 923 - else 924 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 925 - // 409. Closing an fstream should clear error state 926 - this->clear(); 927 - } 928 - #endif 929 - 930 - /** 931 - * @brief Close the file. 932 - * 933 - * Calls @c std::basic_filebuf::close(). If that function 934 - * fails, @c failbit is set in the stream's error state. 935 - */ 936 - void 937 - close() 938 - { 939 - if (!_M_filebuf.close()) 940 - this->setstate(ios_base::failbit); 941 - } 942 - }; 943 - 944 - _GLIBCXX_END_NAMESPACE_VERSION 945 - } // namespace 946 - 947 - // Darling MODIFICATION 948 - #include "fstream.tcc" 949 - 950 - #endif /* _GLIBCXX_FSTREAM */
-984
src/libstdc++darwin/fstream.tcc
··· 1 - // File based streams -*- C++ -*- 2 - 3 - // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 4 - // 2007, 2008, 2009, 2010, 2011 5 - // Free Software Foundation, Inc. 6 - // 7 - // This file is part of the GNU ISO C++ Library. This library is free 8 - // software; you can redistribute it and/or modify it under the 9 - // terms of the GNU General Public License as published by the 10 - // Free Software Foundation; either version 3, or (at your option) 11 - // any later version. 12 - 13 - // This library is distributed in the hope that it will be useful, 14 - // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 - // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 - // GNU General Public License for more details. 17 - 18 - // Under Section 7 of GPL version 3, you are granted additional 19 - // permissions described in the GCC Runtime Library Exception, version 20 - // 3.1, as published by the Free Software Foundation. 21 - 22 - // You should have received a copy of the GNU General Public License and 23 - // a copy of the GCC Runtime Library Exception along with this program; 24 - // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 25 - // <http://www.gnu.org/licenses/>. 26 - 27 - /** @file bits/fstream.tcc 28 - * This is an internal header file, included by other library headers. 29 - * Do not attempt to use it directly. @headername{fstream} 30 - */ 31 - 32 - // 33 - // ISO C++ 14882: 27.8 File-based streams 34 - // 35 - 36 - #ifndef _FSTREAM_TCC 37 - #define _FSTREAM_TCC 1 38 - 39 - #pragma GCC system_header 40 - 41 - #include <bits/cxxabi_forced.h> 42 - 43 - namespace std _GLIBCXX_VISIBILITY(default) 44 - { 45 - _GLIBCXX_BEGIN_NAMESPACE_VERSION 46 - 47 - template<typename _CharT, typename _Traits> 48 - void 49 - basic_filebuf<_CharT, _Traits>:: 50 - _M_allocate_internal_buffer() 51 - { 52 - // Allocate internal buffer only if one doesn't already exist 53 - // (either allocated or provided by the user via setbuf). 54 - if (!_M_buf_allocated && !_M_buf) 55 - { 56 - _M_buf = new char_type[_M_buf_size]; 57 - _M_buf_allocated = true; 58 - } 59 - } 60 - 61 - template<typename _CharT, typename _Traits> 62 - void 63 - basic_filebuf<_CharT, _Traits>:: 64 - _M_destroy_internal_buffer() throw() 65 - { 66 - if (_M_buf_allocated) 67 - { 68 - delete [] _M_buf; 69 - _M_buf = 0; 70 - _M_buf_allocated = false; 71 - } 72 - delete [] _M_ext_buf; 73 - _M_ext_buf = 0; 74 - _M_ext_buf_size = 0; 75 - _M_ext_next = 0; 76 - _M_ext_end = 0; 77 - } 78 - 79 - template<typename _CharT, typename _Traits> 80 - basic_filebuf<_CharT, _Traits>:: 81 - basic_filebuf() : __streambuf_type(), _M_lock(), _M_file(&_M_lock), 82 - _M_mode(ios_base::openmode(0)), _M_state_beg(), _M_state_cur(), 83 - _M_state_last(), _M_buf(0), _M_buf_size(BUFSIZ), 84 - _M_buf_allocated(false), _M_reading(false), _M_writing(false), _M_pback(), 85 - _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false), 86 - _M_codecvt(0), _M_ext_buf(0), _M_ext_buf_size(0), _M_ext_next(0), 87 - _M_ext_end(0) 88 - { 89 - if (has_facet<__codecvt_type>(this->_M_buf_locale)) 90 - _M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale); 91 - } 92 - 93 - template<typename _CharT, typename _Traits> 94 - typename basic_filebuf<_CharT, _Traits>::__filebuf_type* 95 - basic_filebuf<_CharT, _Traits>:: 96 - open(const char* __s, ios_base::openmode __mode) 97 - { 98 - __filebuf_type *__ret = 0; 99 - if (!this->is_open()) 100 - { 101 - _M_file.open(__s, __mode); 102 - if (this->is_open()) 103 - { 104 - _M_allocate_internal_buffer(); 105 - _M_mode = __mode; 106 - 107 - // Setup initial buffer to 'uncommitted' mode. 108 - _M_reading = false; 109 - _M_writing = false; 110 - _M_set_buffer(-1); 111 - 112 - // Reset to initial state. 113 - _M_state_last = _M_state_cur = _M_state_beg; 114 - 115 - // 27.8.1.3,4 116 - if ((__mode & ios_base::ate) 117 - && this->seekoff(0, ios_base::end, __mode) 118 - == pos_type(off_type(-1))) 119 - this->close(); 120 - else 121 - __ret = this; 122 - } 123 - } 124 - return __ret; 125 - } 126 - 127 - template<typename _CharT, typename _Traits> 128 - typename basic_filebuf<_CharT, _Traits>::__filebuf_type* 129 - basic_filebuf<_CharT, _Traits>:: 130 - close() 131 - { 132 - if (!this->is_open()) 133 - return 0; 134 - 135 - bool __testfail = false; 136 - { 137 - // NB: Do this here so that re-opened filebufs will be cool... 138 - struct __close_sentry 139 - { 140 - basic_filebuf *__fb; 141 - __close_sentry (basic_filebuf *__fbi): __fb(__fbi) { } 142 - ~__close_sentry () 143 - { 144 - __fb->_M_mode = ios_base::openmode(0); 145 - __fb->_M_pback_init = false; 146 - __fb->_M_destroy_internal_buffer(); 147 - __fb->_M_reading = false; 148 - __fb->_M_writing = false; 149 - __fb->_M_set_buffer(-1); 150 - __fb->_M_state_last = __fb->_M_state_cur = __fb->_M_state_beg; 151 - } 152 - } __cs (this); 153 - 154 - __try 155 - { 156 - if (!_M_terminate_output()) 157 - __testfail = true; 158 - } 159 - __catch(__cxxabiv1::__forced_unwind&) 160 - { 161 - _M_file.close(); 162 - __throw_exception_again; 163 - } 164 - __catch(...) 165 - { __testfail = true; } 166 - } 167 - 168 - if (!_M_file.close()) 169 - __testfail = true; 170 - 171 - if (__testfail) 172 - return 0; 173 - else 174 - return this; 175 - } 176 - 177 - template<typename _CharT, typename _Traits> 178 - streamsize 179 - basic_filebuf<_CharT, _Traits>:: 180 - showmanyc() 181 - { 182 - streamsize __ret = -1; 183 - const bool __testin = _M_mode & ios_base::in; 184 - if (__testin && this->is_open()) 185 - { 186 - // For a stateful encoding (-1) the pending sequence might be just 187 - // shift and unshift prefixes with no actual character. 188 - __ret = this->egptr() - this->gptr(); 189 - 190 - #if _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 191 - // About this workaround, see libstdc++/20806. 192 - const bool __testbinary = _M_mode & ios_base::binary; 193 - if (__check_facet(_M_codecvt).encoding() >= 0 194 - && __testbinary) 195 - #else 196 - if (__check_facet(_M_codecvt).encoding() >= 0) 197 - #endif 198 - __ret += _M_file.showmanyc() / _M_codecvt->max_length(); 199 - } 200 - return __ret; 201 - } 202 - 203 - template<typename _CharT, typename _Traits> 204 - typename basic_filebuf<_CharT, _Traits>::int_type 205 - basic_filebuf<_CharT, _Traits>:: 206 - underflow() 207 - { 208 - int_type __ret = traits_type::eof(); 209 - const bool __testin = _M_mode & ios_base::in; 210 - if (__testin) 211 - { 212 - if (_M_writing) 213 - { 214 - if (overflow() == traits_type::eof()) 215 - return __ret; 216 - _M_set_buffer(-1); 217 - _M_writing = false; 218 - } 219 - // Check for pback madness, and if so switch back to the 220 - // normal buffers and jet outta here before expensive 221 - // fileops happen... 222 - _M_destroy_pback(); 223 - 224 - if (this->gptr() < this->egptr()) 225 - return traits_type::to_int_type(*this->gptr()); 226 - 227 - // Get and convert input sequence. 228 - const size_t __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1; 229 - 230 - // Will be set to true if ::read() returns 0 indicating EOF. 231 - bool __got_eof = false; 232 - // Number of internal characters produced. 233 - streamsize __ilen = 0; 234 - codecvt_base::result __r = codecvt_base::ok; 235 - if (__check_facet(_M_codecvt).always_noconv()) 236 - { 237 - __ilen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()), 238 - __buflen); 239 - if (__ilen == 0) 240 - __got_eof = true; 241 - } 242 - else 243 - { 244 - // Worst-case number of external bytes. 245 - // XXX Not done encoding() == -1. 246 - const int __enc = _M_codecvt->encoding(); 247 - streamsize __blen; // Minimum buffer size. 248 - streamsize __rlen; // Number of chars to read. 249 - if (__enc > 0) 250 - __blen = __rlen = __buflen * __enc; 251 - else 252 - { 253 - __blen = __buflen + _M_codecvt->max_length() - 1; 254 - __rlen = __buflen; 255 - } 256 - const streamsize __remainder = _M_ext_end - _M_ext_next; 257 - __rlen = __rlen > __remainder ? __rlen - __remainder : 0; 258 - 259 - // An imbue in 'read' mode implies first converting the external 260 - // chars already present. 261 - if (_M_reading && this->egptr() == this->eback() && __remainder) 262 - __rlen = 0; 263 - 264 - // Allocate buffer if necessary and move unconverted 265 - // bytes to front. 266 - if (_M_ext_buf_size < __blen) 267 - { 268 - char* __buf = new char[__blen]; 269 - if (__remainder) 270 - __builtin_memcpy(__buf, _M_ext_next, __remainder); 271 - 272 - delete [] _M_ext_buf; 273 - _M_ext_buf = __buf; 274 - _M_ext_buf_size = __blen; 275 - } 276 - else if (__remainder) 277 - __builtin_memmove(_M_ext_buf, _M_ext_next, __remainder); 278 - 279 - _M_ext_next = _M_ext_buf; 280 - _M_ext_end = _M_ext_buf + __remainder; 281 - _M_state_last = _M_state_cur; 282 - 283 - do 284 - { 285 - if (__rlen > 0) 286 - { 287 - // Sanity check! 288 - // This may fail if the return value of 289 - // codecvt::max_length() is bogus. 290 - if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size) 291 - { 292 - __throw_ios_failure(__N("basic_filebuf::underflow " 293 - "codecvt::max_length() " 294 - "is not valid")); 295 - } 296 - streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen); 297 - if (__elen == 0) 298 - __got_eof = true; 299 - else if (__elen == -1) 300 - break; 301 - _M_ext_end += __elen; 302 - } 303 - 304 - char_type* __iend = this->eback(); 305 - if (_M_ext_next < _M_ext_end) 306 - __r = _M_codecvt->in(_M_state_cur, _M_ext_next, 307 - _M_ext_end, _M_ext_next, 308 - this->eback(), 309 - this->eback() + __buflen, __iend); 310 - if (__r == codecvt_base::noconv) 311 - { 312 - size_t __avail = _M_ext_end - _M_ext_buf; 313 - __ilen = std::min(__avail, __buflen); 314 - traits_type::copy(this->eback(), 315 - reinterpret_cast<char_type*> 316 - (_M_ext_buf), __ilen); 317 - _M_ext_next = _M_ext_buf + __ilen; 318 - } 319 - else 320 - __ilen = __iend - this->eback(); 321 - 322 - // _M_codecvt->in may return error while __ilen > 0: this is 323 - // ok, and actually occurs in case of mixed encodings (e.g., 324 - // XML files). 325 - if (__r == codecvt_base::error) 326 - break; 327 - 328 - __rlen = 1; 329 - } 330 - while (__ilen == 0 && !__got_eof); 331 - } 332 - 333 - if (__ilen > 0) 334 - { 335 - _M_set_buffer(__ilen); 336 - _M_reading = true; 337 - __ret = traits_type::to_int_type(*this->gptr()); 338 - } 339 - else if (__got_eof) 340 - { 341 - // If the actual end of file is reached, set 'uncommitted' 342 - // mode, thus allowing an immediate write without an 343 - // intervening seek. 344 - _M_set_buffer(-1); 345 - _M_reading = false; 346 - // However, reaching it while looping on partial means that 347 - // the file has got an incomplete character. 348 - if (__r == codecvt_base::partial) 349 - __throw_ios_failure(__N("basic_filebuf::underflow " 350 - "incomplete character in file")); 351 - } 352 - else if (__r == codecvt_base::error) 353 - __throw_ios_failure(__N("basic_filebuf::underflow " 354 - "invalid byte sequence in file")); 355 - else 356 - __throw_ios_failure(__N("basic_filebuf::underflow " 357 - "error reading the file")); 358 - } 359 - return __ret; 360 - } 361 - 362 - template<typename _CharT, typename _Traits> 363 - typename basic_filebuf<_CharT, _Traits>::int_type 364 - basic_filebuf<_CharT, _Traits>:: 365 - pbackfail(int_type __i) 366 - { 367 - int_type __ret = traits_type::eof(); 368 - const bool __testin = _M_mode & ios_base::in; 369 - if (__testin) 370 - { 371 - if (_M_writing) 372 - { 373 - if (overflow() == traits_type::eof()) 374 - return __ret; 375 - _M_set_buffer(-1); 376 - _M_writing = false; 377 - } 378 - // Remember whether the pback buffer is active, otherwise below 379 - // we may try to store in it a second char (libstdc++/9761). 380 - const bool __testpb = _M_pback_init; 381 - const bool __testeof = traits_type::eq_int_type(__i, __ret); 382 - int_type __tmp; 383 - if (this->eback() < this->gptr()) 384 - { 385 - this->gbump(-1); 386 - __tmp = traits_type::to_int_type(*this->gptr()); 387 - } 388 - else if (this->seekoff(-1, ios_base::cur) != pos_type(off_type(-1))) 389 - { 390 - __tmp = this->underflow(); 391 - if (traits_type::eq_int_type(__tmp, __ret)) 392 - return __ret; 393 - } 394 - else 395 - { 396 - // At the beginning of the buffer, need to make a 397 - // putback position available. But the seek may fail 398 - // (f.i., at the beginning of a file, see 399 - // libstdc++/9439) and in that case we return 400 - // traits_type::eof(). 401 - return __ret; 402 - } 403 - 404 - // Try to put back __i into input sequence in one of three ways. 405 - // Order these tests done in is unspecified by the standard. 406 - if (!__testeof && traits_type::eq_int_type(__i, __tmp)) 407 - __ret = __i; 408 - else if (__testeof) 409 - __ret = traits_type::not_eof(__i); 410 - else if (!__testpb) 411 - { 412 - _M_create_pback(); 413 - _M_reading = true; 414 - *this->gptr() = traits_type::to_char_type(__i); 415 - __ret = __i; 416 - } 417 - } 418 - return __ret; 419 - } 420 - 421 - template<typename _CharT, typename _Traits> 422 - typename basic_filebuf<_CharT, _Traits>::int_type 423 - basic_filebuf<_CharT, _Traits>:: 424 - overflow(int_type __c) 425 - { 426 - int_type __ret = traits_type::eof(); 427 - const bool __testeof = traits_type::eq_int_type(__c, __ret); 428 - const bool __testout = _M_mode & ios_base::out; 429 - if (__testout) 430 - { 431 - if (_M_reading) 432 - { 433 - _M_destroy_pback(); 434 - const int __gptr_off = _M_get_ext_pos(_M_state_last); 435 - if (_M_seek(__gptr_off, ios_base::cur, _M_state_last) 436 - == pos_type(off_type(-1))) 437 - return __ret; 438 - } 439 - if (this->pbase() < this->pptr()) 440 - { 441 - // If appropriate, append the overflow char. 442 - if (!__testeof) 443 - { 444 - *this->pptr() = traits_type::to_char_type(__c); 445 - this->pbump(1); 446 - } 447 - 448 - // Convert pending sequence to external representation, 449 - // and output. 450 - if (_M_convert_to_external(this->pbase(), 451 - this->pptr() - this->pbase())) 452 - { 453 - _M_set_buffer(0); 454 - __ret = traits_type::not_eof(__c); 455 - } 456 - } 457 - else if (_M_buf_size > 1) 458 - { 459 - // Overflow in 'uncommitted' mode: set _M_writing, set 460 - // the buffer to the initial 'write' mode, and put __c 461 - // into the buffer. 462 - _M_set_buffer(0); 463 - _M_writing = true; 464 - if (!__testeof) 465 - { 466 - *this->pptr() = traits_type::to_char_type(__c); 467 - this->pbump(1); 468 - } 469 - __ret = traits_type::not_eof(__c); 470 - } 471 - else 472 - { 473 - // Unbuffered. 474 - char_type __conv = traits_type::to_char_type(__c); 475 - if (__testeof || _M_convert_to_external(&__conv, 1)) 476 - { 477 - _M_writing = true; 478 - __ret = traits_type::not_eof(__c); 479 - } 480 - } 481 - } 482 - return __ret; 483 - } 484 - 485 - template<typename _CharT, typename _Traits> 486 - bool 487 - basic_filebuf<_CharT, _Traits>:: 488 - _M_convert_to_external(_CharT* __ibuf, streamsize __ilen) 489 - { 490 - // Sizes of external and pending output. 491 - streamsize __elen; 492 - streamsize __plen; 493 - if (__check_facet(_M_codecvt).always_noconv()) 494 - { 495 - __elen = _M_file.xsputn(reinterpret_cast<char*>(__ibuf), __ilen); 496 - __plen = __ilen; 497 - } 498 - else 499 - { 500 - // Worst-case number of external bytes needed. 501 - // XXX Not done encoding() == -1. 502 - streamsize __blen = __ilen * _M_codecvt->max_length(); 503 - char* __buf = static_cast<char*>(__builtin_alloca(__blen)); 504 - 505 - char* __bend; 506 - const char_type* __iend; 507 - codecvt_base::result __r; 508 - __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, 509 - __iend, __buf, __buf + __blen, __bend); 510 - 511 - if (__r == codecvt_base::ok || __r == codecvt_base::partial) 512 - __blen = __bend - __buf; 513 - else if (__r == codecvt_base::noconv) 514 - { 515 - // Same as the always_noconv case above. 516 - __buf = reinterpret_cast<char*>(__ibuf); 517 - __blen = __ilen; 518 - } 519 - else 520 - __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " 521 - "conversion error")); 522 - 523 - __elen = _M_file.xsputn(__buf, __blen); 524 - __plen = __blen; 525 - 526 - // Try once more for partial conversions. 527 - if (__r == codecvt_base::partial && __elen == __plen) 528 - { 529 - const char_type* __iresume = __iend; 530 - streamsize __rlen = this->pptr() - __iend; 531 - __r = _M_codecvt->out(_M_state_cur, __iresume, 532 - __iresume + __rlen, __iend, __buf, 533 - __buf + __blen, __bend); 534 - if (__r != codecvt_base::error) 535 - { 536 - __rlen = __bend - __buf; 537 - __elen = _M_file.xsputn(__buf, __rlen); 538 - __plen = __rlen; 539 - } 540 - else 541 - __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " 542 - "conversion error")); 543 - } 544 - } 545 - return __elen == __plen; 546 - } 547 - 548 - template<typename _CharT, typename _Traits> 549 - streamsize 550 - basic_filebuf<_CharT, _Traits>:: 551 - xsgetn(_CharT* __s, streamsize __n) 552 - { 553 - // Clear out pback buffer before going on to the real deal... 554 - streamsize __ret = 0; 555 - if (_M_pback_init) 556 - { 557 - if (__n > 0 && this->gptr() == this->eback()) 558 - { 559 - *__s++ = *this->gptr(); // emulate non-underflowing sbumpc 560 - this->gbump(1); 561 - __ret = 1; 562 - --__n; 563 - } 564 - _M_destroy_pback(); 565 - } 566 - else if (_M_writing) 567 - { 568 - if (overflow() == traits_type::eof()) 569 - return __ret; 570 - _M_set_buffer(-1); 571 - _M_writing = false; 572 - } 573 - 574 - // Optimization in the always_noconv() case, to be generalized in the 575 - // future: when __n > __buflen we read directly instead of using the 576 - // buffer repeatedly. 577 - const bool __testin = _M_mode & ios_base::in; 578 - const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1; 579 - 580 - if (__n > __buflen && __check_facet(_M_codecvt).always_noconv() 581 - && __testin) 582 - { 583 - // First, copy the chars already present in the buffer. 584 - const streamsize __avail = this->egptr() - this->gptr(); 585 - if (__avail != 0) 586 - { 587 - traits_type::copy(__s, this->gptr(), __avail); 588 - __s += __avail; 589 - this->setg(this->eback(), this->gptr() + __avail, 590 - this->egptr()); 591 - __ret += __avail; 592 - __n -= __avail; 593 - } 594 - 595 - // Need to loop in case of short reads (relatively common 596 - // with pipes). 597 - streamsize __len; 598 - for (;;) 599 - { 600 - __len = _M_file.xsgetn(reinterpret_cast<char*>(__s), 601 - __n); 602 - if (__len == -1) 603 - __throw_ios_failure(__N("basic_filebuf::xsgetn " 604 - "error reading the file")); 605 - if (__len == 0) 606 - break; 607 - 608 - __n -= __len; 609 - __ret += __len; 610 - if (__n == 0) 611 - break; 612 - 613 - __s += __len; 614 - } 615 - 616 - if (__n == 0) 617 - { 618 - _M_set_buffer(0); 619 - _M_reading = true; 620 - } 621 - else if (__len == 0) 622 - { 623 - // If end of file is reached, set 'uncommitted' 624 - // mode, thus allowing an immediate write without 625 - // an intervening seek. 626 - _M_set_buffer(-1); 627 - _M_reading = false; 628 - } 629 - } 630 - else 631 - __ret += __streambuf_type::xsgetn(__s, __n); 632 - 633 - return __ret; 634 - } 635 - 636 - template<typename _CharT, typename _Traits> 637 - streamsize 638 - basic_filebuf<_CharT, _Traits>:: 639 - xsputn(const _CharT* __s, streamsize __n) 640 - { 641 - streamsize __ret = 0; 642 - // Optimization in the always_noconv() case, to be generalized in the 643 - // future: when __n is sufficiently large we write directly instead of 644 - // using the buffer. 645 - const bool __testout = _M_mode & ios_base::out; 646 - if (__check_facet(_M_codecvt).always_noconv() 647 - && __testout && !_M_reading) 648 - { 649 - // Measurement would reveal the best choice. 650 - const streamsize __chunk = 1ul << 10; 651 - streamsize __bufavail = this->epptr() - this->pptr(); 652 - 653 - // Don't mistake 'uncommitted' mode buffered with unbuffered. 654 - if (!_M_writing && _M_buf_size > 1) 655 - __bufavail = _M_buf_size - 1; 656 - 657 - const streamsize __limit = std::min(__chunk, __bufavail); 658 - if (__n >= __limit) 659 - { 660 - const streamsize __buffill = this->pptr() - this->pbase(); 661 - const char* __buf = reinterpret_cast<const char*>(this->pbase()); 662 - __ret = _M_file.xsputn_2(__buf, __buffill, 663 - reinterpret_cast<const char*>(__s), 664 - __n); 665 - if (__ret == __buffill + __n) 666 - { 667 - _M_set_buffer(0); 668 - _M_writing = true; 669 - } 670 - if (__ret > __buffill) 671 - __ret -= __buffill; 672 - else 673 - __ret = 0; 674 - } 675 - else 676 - __ret = __streambuf_type::xsputn(__s, __n); 677 - } 678 - else 679 - __ret = __streambuf_type::xsputn(__s, __n); 680 - return __ret; 681 - } 682 - 683 - template<typename _CharT, typename _Traits> 684 - typename basic_filebuf<_CharT, _Traits>::__streambuf_type* 685 - basic_filebuf<_CharT, _Traits>:: 686 - setbuf(char_type* __s, streamsize __n) 687 - { 688 - if (!this->is_open()) 689 - { 690 - if (__s == 0 && __n == 0) 691 - _M_buf_size = 1; 692 - else if (__s && __n > 0) 693 - { 694 - // This is implementation-defined behavior, and assumes that 695 - // an external char_type array of length __n exists and has 696 - // been pre-allocated. If this is not the case, things will 697 - // quickly blow up. When __n > 1, __n - 1 positions will be 698 - // used for the get area, __n - 1 for the put area and 1 699 - // position to host the overflow char of a full put area. 700 - // When __n == 1, 1 position will be used for the get area 701 - // and 0 for the put area, as in the unbuffered case above. 702 - _M_buf = __s; 703 - _M_buf_size = __n; 704 - } 705 - } 706 - return this; 707 - } 708 - 709 - 710 - // According to 27.8.1.4 p11 - 13, seekoff should ignore the last 711 - // argument (of type openmode). 712 - template<typename _CharT, typename _Traits> 713 - typename basic_filebuf<_CharT, _Traits>::pos_type 714 - basic_filebuf<_CharT, _Traits>:: 715 - seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode) 716 - { 717 - int __width = 0; 718 - if (_M_codecvt) 719 - __width = _M_codecvt->encoding(); 720 - if (__width < 0) 721 - __width = 0; 722 - 723 - pos_type __ret = pos_type(off_type(-1)); 724 - const bool __testfail = __off != 0 && __width <= 0; 725 - if (this->is_open() && !__testfail) 726 - { 727 - // tellg and tellp queries do not affect any state, unless 728 - // ! always_noconv and the put sequence is not empty. 729 - // In that case, determining the position requires converting the 730 - // put sequence. That doesn't use ext_buf, so requires a flush. 731 - bool __no_movement = __way == ios_base::cur && __off == 0 732 - && (!_M_writing || _M_codecvt->always_noconv()); 733 - 734 - // Ditch any pback buffers to avoid confusion. 735 - if (!__no_movement) 736 - _M_destroy_pback(); 737 - 738 - // Correct state at destination. Note that this is the correct 739 - // state for the current position during output, because 740 - // codecvt::unshift() returns the state to the initial state. 741 - // This is also the correct state at the end of the file because 742 - // an unshift sequence should have been written at the end. 743 - __state_type __state = _M_state_beg; 744 - off_type __computed_off = __off * __width; 745 - if (_M_reading && __way == ios_base::cur) 746 - { 747 - __state = _M_state_last; 748 - __computed_off += _M_get_ext_pos(__state); 749 - } 750 - if (!__no_movement) 751 - __ret = _M_seek(__computed_off, __way, __state); 752 - else 753 - { 754 - if (_M_writing) 755 - __computed_off = this->pptr() - this->pbase(); 756 - 757 - off_type __file_off = _M_file.seekoff(0, ios_base::cur); 758 - if (__file_off != off_type(-1)) 759 - { 760 - __ret = __file_off + __computed_off; 761 - __ret.state(__state); 762 - } 763 - } 764 - } 765 - return __ret; 766 - } 767 - 768 - // _GLIBCXX_RESOLVE_LIB_DEFECTS 769 - // 171. Strange seekpos() semantics due to joint position 770 - // According to the resolution of DR 171, seekpos should ignore the last 771 - // argument (of type openmode). 772 - template<typename _CharT, typename _Traits> 773 - typename basic_filebuf<_CharT, _Traits>::pos_type 774 - basic_filebuf<_CharT, _Traits>:: 775 - seekpos(pos_type __pos, ios_base::openmode) 776 - { 777 - pos_type __ret = pos_type(off_type(-1)); 778 - if (this->is_open()) 779 - { 780 - // Ditch any pback buffers to avoid confusion. 781 - _M_destroy_pback(); 782 - __ret = _M_seek(off_type(__pos), ios_base::beg, __pos.state()); 783 - } 784 - return __ret; 785 - } 786 - 787 - template<typename _CharT, typename _Traits> 788 - typename basic_filebuf<_CharT, _Traits>::pos_type 789 - basic_filebuf<_CharT, _Traits>:: 790 - _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state) 791 - { 792 - pos_type __ret = pos_type(off_type(-1)); 793 - if (_M_terminate_output()) 794 - { 795 - off_type __file_off = _M_file.seekoff(__off, __way); 796 - if (__file_off != off_type(-1)) 797 - { 798 - _M_reading = false; 799 - _M_writing = false; 800 - _M_ext_next = _M_ext_end = _M_ext_buf; 801 - _M_set_buffer(-1); 802 - _M_state_cur = __state; 803 - __ret = __file_off; 804 - __ret.state(_M_state_cur); 805 - } 806 - } 807 - return __ret; 808 - } 809 - 810 - // Returns the distance from the end of the ext buffer to the point 811 - // corresponding to gptr(). This is a negative value. Updates __state 812 - // from eback() correspondence to gptr(). 813 - template<typename _CharT, typename _Traits> 814 - int basic_filebuf<_CharT, _Traits>:: 815 - _M_get_ext_pos(__state_type& __state) 816 - { 817 - if (_M_codecvt->always_noconv()) 818 - return this->gptr() - this->egptr(); 819 - else 820 - { 821 - // Calculate offset from _M_ext_buf that corresponds to 822 - // gptr(). Precondition: __state == _M_state_last, which 823 - // corresponds to eback(). 824 - const int __gptr_off = 825 - _M_codecvt->length(__state, _M_ext_buf, _M_ext_next, 826 - this->gptr() - this->eback()); 827 - return _M_ext_buf + __gptr_off - _M_ext_end; 828 - } 829 - } 830 - 831 - template<typename _CharT, typename _Traits> 832 - bool 833 - basic_filebuf<_CharT, _Traits>:: 834 - _M_terminate_output() 835 - { 836 - // Part one: update the output sequence. 837 - bool __testvalid = true; 838 - if (this->pbase() < this->pptr()) 839 - { 840 - const int_type __tmp = this->overflow(); 841 - if (traits_type::eq_int_type(__tmp, traits_type::eof())) 842 - __testvalid = false; 843 - } 844 - 845 - // Part two: output unshift sequence. 846 - if (_M_writing && !__check_facet(_M_codecvt).always_noconv() 847 - && __testvalid) 848 - { 849 - // Note: this value is arbitrary, since there is no way to 850 - // get the length of the unshift sequence from codecvt, 851 - // without calling unshift. 852 - const size_t __blen = 128; 853 - char __buf[__blen]; 854 - codecvt_base::result __r; 855 - streamsize __ilen = 0; 856 - 857 - do 858 - { 859 - char* __next; 860 - __r = _M_codecvt->unshift(_M_state_cur, __buf, 861 - __buf + __blen, __next); 862 - if (__r == codecvt_base::error) 863 - __testvalid = false; 864 - else if (__r == codecvt_base::ok || 865 - __r == codecvt_base::partial) 866 - { 867 - __ilen = __next - __buf; 868 - if (__ilen > 0) 869 - { 870 - const streamsize __elen = _M_file.xsputn(__buf, __ilen); 871 - if (__elen != __ilen) 872 - __testvalid = false; 873 - } 874 - } 875 - } 876 - while (__r == codecvt_base::partial && __ilen > 0 && __testvalid); 877 - 878 - if (__testvalid) 879 - { 880 - // This second call to overflow() is required by the standard, 881 - // but it's not clear why it's needed, since the output buffer 882 - // should be empty by this point (it should have been emptied 883 - // in the first call to overflow()). 884 - const int_type __tmp = this->overflow(); 885 - if (traits_type::eq_int_type(__tmp, traits_type::eof())) 886 - __testvalid = false; 887 - } 888 - } 889 - return __testvalid; 890 - } 891 - 892 - template<typename _CharT, typename _Traits> 893 - int 894 - basic_filebuf<_CharT, _Traits>:: 895 - sync() 896 - { 897 - // Make sure that the internal buffer resyncs its idea of 898 - // the file position with the external file. 899 - int __ret = 0; 900 - if (this->pbase() < this->pptr()) 901 - { 902 - const int_type __tmp = this->overflow(); 903 - if (traits_type::eq_int_type(__tmp, traits_type::eof())) 904 - __ret = -1; 905 - } 906 - return __ret; 907 - } 908 - 909 - template<typename _CharT, typename _Traits> 910 - void 911 - basic_filebuf<_CharT, _Traits>:: 912 - imbue(const locale& __loc) 913 - { 914 - bool __testvalid = true; 915 - 916 - const __codecvt_type* _M_codecvt_tmp = 0; 917 - if (__builtin_expect(has_facet<__codecvt_type>(__loc), true)) 918 - _M_codecvt_tmp = &use_facet<__codecvt_type>(__loc); 919 - 920 - if (this->is_open()) 921 - { 922 - // encoding() == -1 is ok only at the beginning. 923 - if ((_M_reading || _M_writing) 924 - && __check_facet(_M_codecvt).encoding() == -1) 925 - __testvalid = false; 926 - else 927 - { 928 - if (_M_reading) 929 - { 930 - if (__check_facet(_M_codecvt).always_noconv()) 931 - { 932 - if (_M_codecvt_tmp 933 - && !__check_facet(_M_codecvt_tmp).always_noconv()) 934 - __testvalid = this->seekoff(0, ios_base::cur, _M_mode) 935 - != pos_type(off_type(-1)); 936 - } 937 - else 938 - { 939 - // External position corresponding to gptr(). 940 - _M_ext_next = _M_ext_buf 941 - + _M_codecvt->length(_M_state_last, _M_ext_buf, 942 - _M_ext_next, 943 - this->gptr() - this->eback()); 944 - const streamsize __remainder = _M_ext_end - _M_ext_next; 945 - if (__remainder) 946 - __builtin_memmove(_M_ext_buf, _M_ext_next, __remainder); 947 - 948 - _M_ext_next = _M_ext_buf; 949 - _M_ext_end = _M_ext_buf + __remainder; 950 - _M_set_buffer(-1); 951 - _M_state_last = _M_state_cur = _M_state_beg; 952 - } 953 - } 954 - else if (_M_writing && (__testvalid = _M_terminate_output())) 955 - _M_set_buffer(-1); 956 - } 957 - } 958 - 959 - if (__testvalid) 960 - _M_codecvt = _M_codecvt_tmp; 961 - else 962 - _M_codecvt = 0; 963 - } 964 - 965 - // Inhibit implicit instantiations for required instantiations, 966 - // which are defined via explicit instantiations elsewhere. 967 - #if _GLIBCXX_EXTERN_TEMPLATE 968 - extern template class basic_filebuf<char>; 969 - extern template class basic_ifstream<char>; 970 - extern template class basic_ofstream<char>; 971 - extern template class basic_fstream<char>; 972 - 973 - #ifdef _GLIBCXX_USE_WCHAR_T 974 - extern template class basic_filebuf<wchar_t>; 975 - extern template class basic_ifstream<wchar_t>; 976 - extern template class basic_ofstream<wchar_t>; 977 - extern template class basic_fstream<wchar_t>; 978 - #endif 979 - #endif 980 - 981 - _GLIBCXX_END_NAMESPACE_VERSION 982 - } // namespace std 983 - 984 - #endif
-151
src/libstdc++darwin/version.map
··· 1 - DARLING { 2 - 3 - global: 4 - 5 - _ZZNSt13basic_filebufIcSt11char_traitsIcEE5closeEvEN14__close_sentryC1EPS2_; 6 - _ZZNSt13basic_filebufIcSt11char_traitsIcEE5closeEvEN14__close_sentryD1Ev; 7 - _ZZNSt13basic_filebufIcSt11char_traitsIcEE5closeEvEN14__close_sentryC2EPS2_; 8 - _ZZNSt13basic_filebufIcSt11char_traitsIcEE5closeEvEN14__close_sentryD2Ev; 9 - _ZNSt13basic_filebufIcSt11char_traitsIcEE15_M_create_pbackEv; 10 - _ZNKSt15basic_streambufIcSt11char_traitsIcEE4gptrEv; 11 - _ZNKSt15basic_streambufIcSt11char_traitsIcEE5egptrEv; 12 - _ZNSt15basic_streambufIcSt11char_traitsIcEE4setgEPcS3_S3_; 13 - _ZNSt13basic_filebufIcSt11char_traitsIcEE16_M_destroy_pbackEv; 14 - _ZNKSt15basic_streambufIcSt11char_traitsIcEE5ebackEv; 15 - _ZNSt13basic_filebufIcSt11char_traitsIcEEC2Ev; 16 - _ZNSt15basic_streambufIcSt11char_traitsIcEEC2Ev; 17 - _ZTVSt13basic_filebufIcSt11char_traitsIcEE; 18 - _ZNSt15basic_streambufIcSt11char_traitsIcEED2Ev; 19 - _ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev; 20 - _ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv; 21 - _ZNSt13basic_filebufIcSt11char_traitsIcEED0Ev; 22 - _ZNSt13basic_filebufIcSt11char_traitsIcEED1Ev; 23 - _ZNKSt13basic_filebufIcSt11char_traitsIcEE7is_openEv; 24 - _ZNSt13basic_filebufIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode; 25 - _ZNSt13basic_filebufIcSt11char_traitsIcEE27_M_allocate_internal_bufferEv; 26 - _ZNSt13basic_filebufIcSt11char_traitsIcEE13_M_set_bufferEl; 27 - _ZNSt13basic_filebufIcSt11char_traitsIcEE19_M_terminate_outputEv; 28 - _ZNSt13basic_filebufIcSt11char_traitsIcEE26_M_destroy_internal_bufferEv; 29 - _ZNSt13basic_filebufIcSt11char_traitsIcEE9showmanycEv; 30 - _ZNSt13basic_filebufIcSt11char_traitsIcEE9underflowEv; 31 - _ZNSt13basic_filebufIcSt11char_traitsIcEE9pbackfailEi; 32 - _ZNSt15basic_streambufIcSt11char_traitsIcEE5gbumpEi; 33 - _ZNSt13basic_filebufIcSt11char_traitsIcEE8overflowEi; 34 - _ZNSt13basic_filebufIcSt11char_traitsIcEE14_M_get_ext_posER11__mbstate_t; 35 - _ZNSt13basic_filebufIcSt11char_traitsIcEE7_M_seekElSt12_Ios_Seekdir11__mbstate_t; 36 - _ZNKSt15basic_streambufIcSt11char_traitsIcEE5pbaseEv; 37 - _ZNKSt15basic_streambufIcSt11char_traitsIcEE4pptrEv; 38 - _ZNSt15basic_streambufIcSt11char_traitsIcEE5pbumpEi; 39 - _ZNSt13basic_filebufIcSt11char_traitsIcEE22_M_convert_to_externalEPcl; 40 - _ZNSt13basic_filebufIcSt11char_traitsIcEE6setbufEPcl; 41 - _ZNSt13basic_filebufIcSt11char_traitsIcEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode; 42 - _ZNSt13basic_filebufIcSt11char_traitsIcEE7seekposESt4fposI11__mbstate_tESt13_Ios_Openmode; 43 - _ZNSt13basic_filebufIcSt11char_traitsIcEE4syncEv; 44 - _ZNSt13basic_filebufIcSt11char_traitsIcEE5imbueERKSt6locale; 45 - _ZNSt13basic_filebufIcSt11char_traitsIcEE6xsgetnEPcl; 46 - _ZNSt15basic_streambufIcSt11char_traitsIcEE6xsgetnEPcl; 47 - _ZNSt13basic_filebufIcSt11char_traitsIcEE6xsputnEPKcl; 48 - _ZNKSt15basic_streambufIcSt11char_traitsIcEE5epptrEv; 49 - _ZNSt15basic_streambufIcSt11char_traitsIcEE6xsputnEPKcl; 50 - _ZNSt15basic_streambufIcSt11char_traitsIcEE4setpEPcS3_; 51 - _ZTVSt15basic_streambufIcSt11char_traitsIcEE; 52 - _ZNSt15basic_streambufIcSt11char_traitsIcEED0Ev; 53 - _ZNSt15basic_streambufIcSt11char_traitsIcEED1Ev; 54 - _ZNSt15basic_streambufIcSt11char_traitsIcEE8pubimbueERKSt6locale; 55 - _ZNKSt15basic_streambufIcSt11char_traitsIcEE6getlocEv; 56 - _ZNSt15basic_streambufIcSt11char_traitsIcEE9pubsetbufEPcl; 57 - _ZNSt15basic_streambufIcSt11char_traitsIcEE10pubseekoffElSt12_Ios_SeekdirSt13_Ios_Openmode; 58 - _ZNSt15basic_streambufIcSt11char_traitsIcEE10pubseekposESt4fposI11__mbstate_tESt13_Ios_Openmode; 59 - _ZNSt15basic_streambufIcSt11char_traitsIcEE7pubsyncEv; 60 - _ZNSt15basic_streambufIcSt11char_traitsIcEE8in_availEv; 61 - _ZNSt15basic_streambufIcSt11char_traitsIcEE6snextcEv; 62 - _ZNSt15basic_streambufIcSt11char_traitsIcEE6sbumpcEv; 63 - _ZNSt15basic_streambufIcSt11char_traitsIcEE5sgetcEv; 64 - _ZNSt15basic_streambufIcSt11char_traitsIcEE5sgetnEPcl; 65 - _ZNSt15basic_streambufIcSt11char_traitsIcEE9sputbackcEc; 66 - _ZNSt15basic_streambufIcSt11char_traitsIcEE7sungetcEv; 67 - _ZNSt15basic_streambufIcSt11char_traitsIcEE5sputcEc; 68 - _ZNSt15basic_streambufIcSt11char_traitsIcEE5sputnEPKcl; 69 - _ZNSt15basic_streambufIcSt11char_traitsIcEE5imbueERKSt6locale; 70 - _ZNSt15basic_streambufIcSt11char_traitsIcEE6setbufEPcl; 71 - _ZNSt15basic_streambufIcSt11char_traitsIcEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode; 72 - _ZNSt15basic_streambufIcSt11char_traitsIcEE7seekposESt4fposI11__mbstate_tESt13_Ios_Openmode; 73 - _ZNSt15basic_streambufIcSt11char_traitsIcEE4syncEv; 74 - _ZNSt15basic_streambufIcSt11char_traitsIcEE9showmanycEv; 75 - _ZNSt15basic_streambufIcSt11char_traitsIcEE12__safe_gbumpEl; 76 - _ZNSt15basic_streambufIcSt11char_traitsIcEE9underflowEv; 77 - _ZNSt15basic_streambufIcSt11char_traitsIcEE5uflowEv; 78 - _ZNSt15basic_streambufIcSt11char_traitsIcEE9pbackfailEi; 79 - _ZNSt15basic_streambufIcSt11char_traitsIcEE12__safe_pbumpEl; 80 - _ZNSt15basic_streambufIcSt11char_traitsIcEE8overflowEi; 81 - _ZNSt15basic_streambufIcSt11char_traitsIcEE6stosscEv; 82 - _ZNSt15basic_streambufIcSt11char_traitsIcEEC2ERKS2_; 83 - _ZNSt15basic_streambufIcSt11char_traitsIcEEaSERKS2_; 84 - _ZNKSt9basic_iosIcSt11char_traitsIcEEcvPvEv; 85 - _ZNKSt9basic_iosIcSt11char_traitsIcEE4failEv; 86 - _ZNKSt9basic_iosIcSt11char_traitsIcEEntEv; 87 - _ZNKSt9basic_iosIcSt11char_traitsIcEE7rdstateEv; 88 - _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate; 89 - _ZNKSt9basic_iosIcSt11char_traitsIcEE5rdbufEv; 90 - _ZNKSt9basic_iosIcSt11char_traitsIcEE10exceptionsEv; 91 - _ZNSt9basic_iosIcSt11char_traitsIcEE8setstateESt12_Ios_Iostate; 92 - _ZNSt9basic_iosIcSt11char_traitsIcEE11_M_setstateESt12_Ios_Iostate; 93 - _ZNKSt9basic_iosIcSt11char_traitsIcEE4goodEv; 94 - _ZNKSt9basic_iosIcSt11char_traitsIcEE3eofEv; 95 - _ZNKSt9basic_iosIcSt11char_traitsIcEE3badEv; 96 - _ZNSt9basic_iosIcSt11char_traitsIcEE10exceptionsESt12_Ios_Iostate; 97 - _ZNSt9basic_iosIcSt11char_traitsIcEEC2EPSt15basic_streambufIcS1_E; 98 - _ZTVSt9basic_iosIcSt11char_traitsIcEE; 99 - _ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E; 100 - _ZNSt9basic_iosIcSt11char_traitsIcEED2Ev; 101 - _ZNSt9basic_iosIcSt11char_traitsIcEED0Ev; 102 - _ZNSt9basic_iosIcSt11char_traitsIcEED1Ev; 103 - _ZNKSt9basic_iosIcSt11char_traitsIcEE3tieEv; 104 - _ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo; 105 - _ZNSt9basic_iosIcSt11char_traitsIcEE5rdbufEPSt15basic_streambufIcS1_E; 106 - _ZNSt9basic_iosIcSt11char_traitsIcEE7copyfmtERKS2_; 107 - _ZNKSt9basic_iosIcSt11char_traitsIcEE4fillEv; 108 - _ZNSt9basic_iosIcSt11char_traitsIcEE4fillEc; 109 - _ZNSt9basic_iosIcSt11char_traitsIcEE15_M_cache_localeERKSt6locale; 110 - _ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc; 111 - _ZNSt9basic_iosIcSt11char_traitsIcEE5imbueERKSt6locale; 112 - _ZNKSt9basic_iosIcSt11char_traitsIcEE6narrowEcc; 113 - _ZNSt9basic_iosIcSt11char_traitsIcEEC2Ev; 114 - _ZNSoC2EPSt15basic_streambufIcSt11char_traitsIcEE; 115 - _ZNSoC1EPSt15basic_streambufIcSt11char_traitsIcEE; 116 - _ZNSolsEPFRSt9basic_iosIcSt11char_traitsIcEES3_E; 117 - _ZNSolsEPSt15basic_streambufIcSt11char_traitsIcEE; 118 - _ZTISt13basic_filebufIcSt11char_traitsIcEE; 119 - _ZTISt9basic_iosIcSt11char_traitsIcEE; 120 - _ZTISt15basic_streambufIcSt11char_traitsIcEE; 121 - _ZTSSt13basic_filebufIcSt11char_traitsIcEE; 122 - _ZTSSt9basic_iosIcSt11char_traitsIcEE; 123 - _ZTSSt15basic_streambufIcSt11char_traitsIcEE; 124 - _ZNSt13basic_filebufIcSt11char_traitsIcEEC1Ev; 125 - _ZNSt15basic_streambufIcSt11char_traitsIcEEC1Ev; 126 - _ZNSt15basic_streambufIcSt11char_traitsIcEEC1ERKS2_; 127 - _ZNSt9basic_iosIcSt11char_traitsIcEEC1EPSt15basic_streambufIcS1_E; 128 - _ZNSt9basic_iosIcSt11char_traitsIcEEC1Ev; 129 - _ZNSt12__basic_fileIcEC2EP15pthread_mutex_t; 130 - _ZNSt12__basic_fileIcED2Ev; 131 - _ZNSt12__basic_fileIcE5closeEv; 132 - _ZNSt12__basic_fileIcE8sys_openEP7__sFILESt13_Ios_Openmode; 133 - _ZNKSt12__basic_fileIcE7is_openEv; 134 - _ZNSt12__basic_fileIcE4syncEv; 135 - _ZNSt12__basic_fileIcE8sys_openEiSt13_Ios_Openmode; 136 - _ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei; 137 - _ZNSt12__basic_fileIcE2fdEv; 138 - _ZNSt12__basic_fileIcE4fileEv; 139 - _ZNSt12__basic_fileIcE6xsgetnEPcl; 140 - _ZNSt12__basic_fileIcE6xsputnEPKcl; 141 - _ZNSt12__basic_fileIcE8xsputn_2EPKclS2_l; 142 - _ZNSt12__basic_fileIcE7seekoffElSt12_Ios_Seekdir; 143 - _ZNSt12__basic_fileIcE9showmanycEv; 144 - _ZNSt12__basic_fileIcEC1EP15pthread_mutex_t; 145 - _ZNSt12__basic_fileIcED1Ev; 146 - 147 - 148 - local: 149 - *; 150 - }; 151 -