[libcxx-commits] [PATCH] D97460: [libcxx] Use the allocating form of getcwd() on Glibc and Apple platforms

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 25 04:19:20 PST 2021

mstorsjo created this revision.
mstorsjo added a reviewer: libc++.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added 1 blocking reviewer(s): libc++.

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.

  rG LLVM Github Monorepo



Index: libcxx/src/filesystem/operations.cpp
--- libcxx/src/filesystem/operations.cpp
+++ libcxx/src/filesystem/operations.cpp
@@ -1110,7 +1110,7 @@
 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;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97460.326353.patch
Type: text/x-patch
Size: 578 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210225/e6f52249/attachment.bin>

More information about the libcxx-commits mailing list