[libcxx-commits] [libcxx] c7d46f2 - [libcxx] Use the allocating form of getcwd() on Glibc and Apple platforms
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 25 14:16:12 PST 2021
Author: Martin Storsjö
Date: 2021-02-26T00:14:12+02:00
New Revision: c7d46f221e829411b0f0dec41409ed626646cdd2
URL: https://github.com/llvm/llvm-project/commit/c7d46f221e829411b0f0dec41409ed626646cdd2
DIFF: https://github.com/llvm/llvm-project/commit/c7d46f221e829411b0f0dec41409ed626646cdd2.diff
LOG: [libcxx] Use the allocating form of getcwd() on Glibc and Apple platforms
This avoids having to query pathconf for a max size for
preallocating a buffer for the return value.
This is an extension to the POSIX getcwd() spec.
Differential Revision: https://reviews.llvm.org/D97460
Added:
Modified:
libcxx/src/filesystem/operations.cpp
Removed:
################################################################################
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index d0f0d5b99159..06efb722e054 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -1095,7 +1095,7 @@ void __create_symlink(path const& from, path const& to, error_code* ec) {
path __current_path(error_code* ec) {
ErrorHandler<path> err("current_path", ec);
-#if defined(_LIBCPP_WIN32API)
+#if defined(_LIBCPP_WIN32API) || defined(__GLIBC__) || defined(__APPLE__)
// Common extension outside of POSIX getcwd() spec, without needing to
// preallocate a buffer. Also supported by a number of other POSIX libcs.
int size = 0;
More information about the libcxx-commits
mailing list