summaryrefslogtreecommitdiffstats
path: root/libcxx/include/fstream
Commit message (Collapse)AuthorAgeFilesLines
* Open fstream files in O_CLOEXEC mode when possible.Dan Albert2019-09-161-12/+12
| | | | | | | | | | | | | | Reviewers: EricWF, mclow.lists, ldionne Reviewed By: ldionne Subscribers: smeenai, dexonsmith, christof, ldionne, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D59839 llvm-svn: 372027
* [libc++] Set __file_ to 0 in basic_filebuf::close() even if fclose failsPetr Hosek2019-07-221-3/+2
| | | | | | | | | | | | | | | | | | | | This issue was detected by ASan in one of our tests. This test manually invokes basic_filebuf::cloe(). fclose(__h.release() returned a non-zero exit status, so __file_ wasn't set to 0. Later when basic_filebuf destructor ran, we would enter the if (__file_) block again leading to heap-use-after-free error. The POSIX specification for fclose says that independently of the return value, fclose closes the underlying file descriptor and any further access (including another call to fclose()) to the stream results in undefined behavior. This is exactly what happened in our test case. To avoid this issue, we have to always set __file_ to 0 independently of the fclose return value. Differential Revision: https://reviews.llvm.org/D64979 llvm-svn: 366730
* [libc++] Mark <filesystem> tests as failing when the dylib doesn't support ↵Louis Dionne2019-03-201-8/+8
| | | | | | | | | | | | filesystem This fixes CI for back-deployment testers on platforms that don't have <filesystem> support in the dylib. This is effectively half of https://reviews.llvm.org/D59224. The other half requires fixes in Clang. llvm-svn: 356558
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* Set the buffer of an fstream to empty when the underlying file is closed. ↵Marshall Clow2019-01-081-0/+1
| | | | | | This 'fixes' PR#38052 - std::fstream still good after closing and updating content. llvm-svn: 350603
* Implement <filesystem>Eric Fiselier2018-07-271-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements the <filesystem> header and uses that to provide <experimental/filesystem>. Unlike other standard headers, the symbols needed for <filesystem> have not yet been placed in libc++.so. Instead they live in the new libc++fs.a library. Users of filesystem are required to link this library. (Also note that libc++experimental no longer contains the definition of <experimental/filesystem>, which now requires linking libc++fs). The reason for keeping <filesystem> out of the dylib for now is that it's still somewhat experimental, and the possibility of requiring an ABI breaking change is very real. In the future the symbols will likely be moved into the dylib, or the dylib will be made to link libc++fs automagically). Note that moving the symbols out of libc++experimental may break user builds until they update to -lc++fs. This should be OK, because the experimental library provides no stability guarantees. However, I plan on looking into ways we can force libc++experimental to automagically link libc++fs. In order to use a single implementation and set of tests for <filesystem>, it has been placed in a special `__fs` namespace. This namespace is inline in C++17 onward, but not before that. As such implementation is available in C++11 onward, but no filesystem namespace is present "directly", and as such name conflicts shouldn't occur in C++11 or C++14. llvm-svn: 338093
* Implement a better copy_file.Eric Fiselier2018-07-221-87/+129
| | | | | | | | | | | | | | | | | | | | This patch improves both the performance, and the safety of the copy_file implementation. The performance improvements are achieved by using sendfile on Linux and copyfile on OS X when available. The TOCTOU hardening is achieved by opening the source and destination files and then using fstat to check their attributes to see if we can copy them. Unfortunately for the destination file, there is no way to open it without accidentally creating it, so we first have to use stat to determine if it exists, and if we should copy to it. Then, once we're sure we should try to copy, we open the dest file and ensure it names the same entity we previously stat'ed. llvm-svn: 337649
* libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* ↵Peter Collingbourne2018-01-231-0/+177
| | | | | | | | | | | | filenames on Windows. This is an MSVC standard library extension. It seems like a reasonable enough extension to me because wchar_t* is the native format for filenames on that platform. Differential Revision: https://reviews.llvm.org/D42225 llvm-svn: 323170
* Make pbump (internally) handle sizes bigger than MAX_INT. Fixes PR#33725 - ↵Marshall Clow2017-09-121-4/+4
| | | | | | thanks to Jonathan Wakely for the report llvm-svn: 313031
* Add some const_casts in places where we were implicitly casting away ↵Marshall Clow2017-06-141-3/+4
| | | | | | constness. No functional change, but now they're explicit llvm-svn: 305410
* [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on WindowsEric Fiselier2017-05-311-2/+6
| | | | | | | | | | | | | | | | Summary: This patch improves how libc++ handles min/max macros within the headers. Previously libc++ would undef them and emit a warning. This patch changes libc++ to use `#pragma push_macro` to save the macro before undefining it, and `#pragma pop_macro` to restore the macros and the end of the header. Reviewers: mclow.lists, bcraig, compnerd, EricWF Reviewed By: EricWF Subscribers: cfe-commits, krytarowski Differential Revision: https://reviews.llvm.org/D33080 llvm-svn: 304357
* Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the input.output libraryEric Fiselier2017-04-181-19/+13
| | | | llvm-svn: 300626
* [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VISEric Fiselier2017-01-041-4/+4
| | | | | | | | | | | | | The name _LIBCPP_TYPE_VIS_ONLY is no longer accurate because both _LIBCPP_TYPE_VIS and _LIBCPP_TYPE_VIS_ONLY expand to __attribute__((__type_visibility__)) with Clang. The only remaining difference is that _LIBCPP_TYPE_VIS_ONLY can be applied to templates whereas _LIBCPP_TYPE_VIS cannot (due to dllimport/dllexport not being allowed on templates). This patch renames _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS. llvm-svn: 291035
* [libc++] Add configuration define for off_t functionsShoaib Meenai2016-10-311-3/+3
| | | | | | | | | | Create this define in __config and use it elsewhere, instead of checking the operating system/library defines in other files. The aim is to reduce the usage of _WIN32 outside __config. No functional change. Differential Revision: https://reviews.llvm.org/D25741 llvm-svn: 285582
* Add an _LIBCPP_NORETURN inline function named __throw_XXX for each exception ↵Marshall Clow2016-08-251-12/+8
| | | | | | type we define. They either construct and throw the exception, or abort() (if exceptions are disabled). Use these functions everywhere instead of assert()ing when exceptions are disabled. WARNING: This is a behavior change - but only with exceptions disabled. Reviewed as: https://reviews.llvm.org/D23855. llvm-svn: 279744
* Don't call memmove when there's nothing to move. Fixes PR#27978.Marshall Clow2016-06-041-1/+3
| | | | llvm-svn: 271794
* Cleanup: move visibility/linkage attributes to the first declaration.Evgeniy Stepanov2016-04-221-30/+60
| | | | | | http://reviews.llvm.org/D15404 llvm-svn: 267093
* Add option to disable access to the global filesystem namespace.Ed Schouten2015-03-121-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Systems like FreeBSD's Capsicum and Nuxi CloudABI apply the concept of capability-based security on the way processes can interact with the filesystem API. It is no longer possible to interact with the VFS through calls like open(), unlink(), rename(), etc. Instead, processes are only allowed to interact with files and directories to which they have been granted access. The *at() functions can be used for this purpose. This change adds a new config switch called _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE. If set, all functionality that requires the global filesystem namespace will be disabled. More concretely: - fstream's open() function will be removed. - cstdio will no longer pull in fopen(), rename(), etc. - The test suite's get_temp_file_name() will be removed. This will cause all tests that use the global filesystem namespace to break, but will at least make all the other tests run (as get_temp_file_name will not build anyway). It is important to mention that this change will make fstream rather useless on those systems for now. Still, I'd rather not have fstream disabled entirely, as it is of course possible to come up with an extension for fstream that would allow access to local filesystem namespaces (e.g., by adding an openat() member function). Differential revision: http://reviews.llvm.org/D8194 Reviewed by: jroelofs (thanks!) llvm-svn: 232049
* Revert: Revert r227804: Use fseek/ftell instead of fseeko/ftello when Newlib ↵Jonathan Roelofs2015-02-031-3/+3
| | | | | | | | is the libc EricWF has updated the compilers on his buildbots. Hopefully they won't crash now. llvm-svn: 227971
* Revert r227804: Use fseek/ftell instead of fseeko/ftello when Newlib is the libcJonathan Roelofs2015-02-021-3/+3
| | | | | | This change is causing a driver crash on libcxx-libcxxabi-x86_64-linux-ubuntu-msan llvm-svn: 227806
* Use fseek/ftell instead of fseeko/ftello when Newlib is the libcJonathan Roelofs2015-02-021-3/+3
| | | | | | http://reviews.llvm.org/D6626 llvm-svn: 227804
* Nico Rieck: this patch series fixes visibility issues on Windows as ↵Howard Hinnant2013-08-121-4/+4
| | | | | | explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>. llvm-svn: 188192
* Reference: ↵Howard Hinnant2013-04-021-0/+16
| | | | | | http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130325/077133.html llvm-svn: 178581
* No functionality change at this time. I've split _LIBCPP_VISIBLE up into ↵Howard Hinnant2013-03-061-4/+4
| | | | | | two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute. llvm-svn: 176593
* Don't neglect to "return *this".Argyrios Kyrtzidis2012-10-131-0/+1
| | | | llvm-svn: 165860
* Hyeon-Bin Jeong: 1. sync() should reset it’s external buffer pointers. Howard Hinnant2012-08-241-23/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remaining characters should be discarded once sync() called. If don’t, garbage characters can be inserted to the front of external buffer in underflow(). Because underflow() copies remaining characters in external buffer to it’s front. This results wrong characters insertion when seekpos() or seekoff() is called. this line should be inserted in sync() just before return: __extbufnext_ = __extbufend_ = __extbuf_; 2. sync() should use length() rather than out() to calculate offset. Reversing iterators and calling out() to calculate offset from behind is working fine in stateless character encoding. However, in stateful encoding, escape sequences could differ in length. As a result, out() could return wrong length. For example, if we have internal buffer converted from this external sequence: (capital letters mean escape sequence) … a a a a B b b b b out() produces this sequence. b b b b A a a a a Because out() inserts escape sequence A rather than B, result sequence doesn't match to external sequence. A and B could have different lengths, result offset could be wrong value too. length() method in codecvt is right for calculating offset, but it counts offset from the beginning of buffer. So it requires another state member variable to hold state before conversion. Fixes http://llvm.org/bugs/show_bug.cgi?id=13667 llvm-svn: 162601
* Fix basic_filebuf's internal buffer is shrinking when using with some ↵Howard Hinnant2012-08-241-2/+3
| | | | | | codecvt. http://llvm.org/bugs/show_bug.cgi?id=13602 llvm-svn: 162585
* Fixed order of calling use_facet vs setbuf in basic_filebuf default constructor.Howard Hinnant2012-08-241-1/+1
| | | | llvm-svn: 162571
* basic_filebuf needs to delay obtaining a codecvt facet from the global ↵Howard Hinnant2012-08-241-2/+23
| | | | | | locale to give the client a chance to imbue the proper locale. Fixes http://llvm.org/bugs/show_bug.cgi?id=13663. llvm-svn: 162567
* Fix http://llvm.org/bugs/show_bug.cgi?id=11752Howard Hinnant2012-01-121-1/+1
| | | | llvm-svn: 148069
* Add protection from min/max macrosHoward Hinnant2011-11-291-0/+2
| | | | llvm-svn: 145407
* Windows support by Ruben Van Boxem.Howard Hinnant2011-10-171-0/+2
| | | | llvm-svn: 142235
* _STD -> _VSTD to avoid macro clash on windowsHoward Hinnant2011-06-301-27/+27
| | | | llvm-svn: 134190
* Chris Jefferson noted many places where function calls needed to be ↵Howard Hinnant2011-02-141-1/+1
| | | | | | qualified (thanks Chris). llvm-svn: 125510
* Missing traits::to_int_type in fstreamHoward Hinnant2011-02-021-4/+4
| | | | llvm-svn: 124727
* license changeHoward Hinnant2010-11-161-2/+2
| | | | llvm-svn: 119395
* visibility-decoration.Howard Hinnant2010-09-211-4/+4
| | | | llvm-svn: 114496
* Changed __config to react to all of clang's currently documented has_feature ↵Howard Hinnant2010-09-041-16/+16
| | | | | | flags, and renamed _LIBCPP_MOVE to _LIBCPP_HAS_NO_RVALUE_REFERENCES to be more consistent with the rest of the libc++'s flags, and with clang's nomenclature. llvm-svn: 113086
* Fixing whitespace problemsHoward Hinnant2010-08-221-7/+7
| | | | llvm-svn: 111750
* Tests for basic posix regex templated on wchar_tHoward Hinnant2010-07-151-1/+1
| | | | llvm-svn: 108435
* Wiped out some non-ascii characters that snuck into the copyright.Howard Hinnant2010-05-111-1/+1
| | | | llvm-svn: 103516
* libcxx initial importHoward Hinnant2010-05-111-0/+1394
llvm-svn: 103490
OpenPOWER on IntegriCloud