summaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Unix/Process.inc
AgeCommit message (Collapse)Author
2025-06-17[LLVM] [Support] Disable `ioctl()` terminal size check on Solaris (#144600)Sirraide
#143514 broke the `clang-solaris11-sparcv9` bot; from what I can tell that’s Solaris and according to `SolarisTargetInfo::getOSDefines`, the macro `__sun__` should be defined on Solaris, so check for that and don’t try to query the terminal size if it is defined. Not sure this is the best solution but hopefully it fixes the bot.
2025-06-17[LLVM] [Support] Query the terminal width using `ioctl()` (#143514)Sirraide
On unix systems, we were trying to determine the terminal width using the `COULMNS` environment variable. Unfortunately, `COLUMNS` is not exported by all shells and thus not available on some systems. We were previously using `ioctl()` for this; fall back to doing so if `COLUMNS` does not exist or does not store a positive integer. This essentially reverts a3eb3d3d92d037fe3c9deaad87f6fc42fe9ea766 and parts of https://reviews.llvm.org/D61326. For more information, see #139499. Fixes #139499.
2025-02-12[Support] Fix building on FreeBSD and OpenBSD (#127005)Brad Smith
Fix building after a6f7cb54d3c268ea4748a0ff783b4b030c3195d9. Check for the function getauxval() instead of just the sys/auxv.h header.
2025-02-13[Support] Prefer AUX vector for page size (#126863)Tristan Ross
Prefers the page size to come from the AUX vector, `getpagesize` is removed from POSIX.1-2001. Also throws in a couple asserts to ensure the page size is a valid value.
2025-01-16[CMake] Remove HAVE_SYS_RESOURCE_H/HAVE_SETRLIMIT/HAVE_GETRLIMITFangrui Song
Only used by Unix/Program.inc and seem always available. Pull Request: https://github.com/llvm/llvm-project/pull/123288
2025-01-16[CMake] Remove HAVE_SYS_IOCTL_HFangrui Song
2025-01-16[CMake] Remove HAVE_TERMIOS_HFangrui Song
The code path has been dead since 2019. See a3eb3d3d92d037fe3c9deaad87f6fc42fe9ea766
2025-01-16[CMake] Remove some unneeded HAVE_*_HFangrui Song
Pull Request: https://github.com/llvm/llvm-project/pull/123282
2025-01-15[CMake] Remove some always-true HAVE_XXX_HFangrui Song
These are unneeded even on AIX, PURE_WINDOWS, and ZOS (per #104706) * HAVE_ERRNO_H: introduced by 1a93330ffa2ae2aa0b49461f05e6f0d51e8443f8 (2009) but unneeded. The guarded ABI is unconditionally used by lldb. * HAVE_FCNTL_H * HAVE_FENV_H * HAVE_SYS_STAT_H Pull Request: https://github.com/llvm/llvm-project/pull/123087
2024-08-30[NFC] Add explicit #include llvm-config.h where its macros are used. (#106621)Daniil Fukalov
Without these explicit includes, removing other headers, who implicitly include llvm-config.h, may have non-trivial side effects.
2024-05-31Reapply "[Support] Remove terminfo dependency (#92865)" (#93889)Aaron Siddhartha Mondal
This reverts commit fe82a3da36196157c0caa1ef2505186782f750d1. This broke LLDB on MacOS due to a missing symbol during linking. The fix has been applied in c6c08eee37bada190bd1aa4593c88a5e2c8cdaac. Original commit message: The terminfo dependency introduces a significant nonhermeticity into the build. It doesn't respect `--no-undefined-version` meaning that it's not a dependency that can be built with Clang 17+. This forces maintainers of source-based distributions to implement patches or ignore linker errors. Remove it to reduce the closure size and improve portability of LLVM-based tools. Users can still use command line arguments to toggle color support expliticly. Fixes #75490 Closes #53294 #23355
2024-05-29Revert "[Support] Remove terminfo dependency (#92865)"Michael Buch
This reverts commit 6bf450c7a60fa62c642e39836566da94bb9bbc91. It breaks LLDB CI: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/4762/execution/node/97/log/ ``` /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=14.1 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip -Wl,-no_warn_duplicate_libraries tools/lldb/unittests/Editline/CMakeFiles/EditlineTests.dir/EditlineTest.cpp.o -o tools/lldb/unittests/Editline/EditlineTests lib/libLLVMSupport.a lib/libllvm_gtest_main.a lib/libllvm_gtest.a lib/liblldbHost.a lib/liblldbUtility.a lib/libLLVMTestingSupport.a /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libxml2.tbd /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd lib/liblldbHostMacOSXObjCXX.a lib/liblldbUtility.a -framework Foundation -framework CoreFoundation -framework CoreServices -framework Security lib/libLLVMObject.a lib/libLLVMIRReader.a lib/libLLVMBitReader.a lib/libLLVMAsmParser.a lib/libLLVMCore.a lib/libLLVMRemarks.a lib/libLLVMBitstreamReader.a lib/libLLVMMCParser.a lib/libLLVMMC.a lib/libLLVMDebugInfoCodeView.a lib/libLLVMTextAPI.a lib/libLLVMBinaryFormat.a lib/libLLVMTargetParser.a lib/libllvm_gtest.a lib/libLLVMSupport.a -lm /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libz.tbd /opt/homebrew/lib/libzstd.dylib lib/libLLVMDemangle.a -lpthread && cd /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/unittests/Editline && /opt/homebrew/Cellar/cmake/3.28.3/bin/cmake -E make_directory /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/unittests/Editline/./Inputs ld: Undefined symbols: _setupterm, referenced from: lldb_private::Editline::Editline(char const*, __sFILE*, __sFILE*, __sFILE*, std::__1::recursive_mutex&) in liblldbHost.a[35](Editline.cpp.o) clang: error: linker command failed with exit code 1 (use -v to see invocation) ```
2024-05-24[Support] Remove terminfo dependency (#92865)Aaron Siddhartha Mondal
The terminfo dependency introduces a significant nonhermeticity into the build. It doesn't respect `--no-undefined-version` meaning that it's not a dependency that can be built with Clang 17+. This forces maintainers of source-based distributions to implement patches or ignore linker errors. Remove it to reduce the closure size and improve portability of LLVM-based tools. Users can still use command line arguments to toggle color support expliticly. Fixes #75490 Closes #53294 #23355
2024-03-08[llvm][Support] Add and use errnoAsErrorCode (#84423)Michael Spencer
LLVM is inconsistent about how it converts `errno` to `std::error_code`. This can cause problems because values outside of `std::errc` compare differently if one is system and one is generic on POSIX systems. This is even more of a problem on Windows where use of the system category is just wrong, as that is for Windows errors, which have a completely different mapping than POSIX/generic errors. This patch fixes one instance of this mistake in `JSONTransport.cpp`. This patch adds `errnoAsErrorCode()` which makes it so people do not need to think about this issue in the future. It also cleans up a lot of usage of `errno` in LLVM and Clang.
2024-03-08[Support] Fix Process::PreventCoreFiles() when coredumps are pipedAlexander Richardson
On many current Linux systems, coredumps are no longer dumped in the CWD but instead piped to a utility such as systemd-coredumpd that stores them in a deterministic location. This can be done by setting the kernel.core_pattern sysctl to start with a '|'. However, when using such a setup the kernel ignores a coredump limit of 0 (since there is no file being written) and we can end up piping many gigabytes of data to systemd-coredumpd which causes the test suite to freeze for a long time. While most piped coredump handlers do respect the crashing processes' RLIMIT_CORE, this is notable not the case for Debian's systemd-coredump due to a local patch that changes sysctl.d/50-coredump.conf to ignore the specified limit and instead use RLIM_INFINITY (https://salsa.debian.org/systemd-team/systemd/-/commit/64599ffe44f0d). Fortunately there is a workaround: the kernel recognizes the magic value of 1 for RLIMIT_CORE to disable coredumps when piping. One byte is also too small to generate any coredump, so it effectively behaves as if we had set the value to zero. The alternative to using RLIMIT_CORE=1 would be to use prctl() with the PR_SET_DUMPABLE flag, however that also prevents ptrace(), so makes it impossible to attach a debugger. See https://github.com/llvm/llvm-project/pull/83701 and https://github.com/llvm/llvm-project/issues/45797 Reviewed By: MaskRay Pull Request: https://github.com/llvm/llvm-project/pull/83703
2024-01-31[llvm][Support] Support bright colors in raw_ostream (#80017)Timm Baeder
2023-12-12[SystemZ][z/OS] Fix build errors on z/OS in the Unix .inc files (#74758)Abhina Sree
This patch resolves the following errors on z/OS: error: no member named 'wait4' in the global namespace error: no member named 'ru_maxrss' in 'rusage' error: use of undeclared identifier 'strsignal' error: Cannot get usage times on this platform error: Cannot get malloc info on this platform
2022-12-06Process: convert Optional to std::optionalKrzysztof Parzyszek
This applies to GetEnv and FindInEnvPath.
2022-12-02[llvm] Use std::nullopt instead of None (NFC)Kazu Hirata
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26[Support] Apply clang-format on .inc files. NFC.Alexandre Ganea
Apply clang-format on llvm/lib/Support/Windows/ and llvm/lib/Support/Unix/ since .inc files in these folders aren't picked up by default. Eventually we need to add this extension in the monorepo .clang-format file. Differential Revision: https://reviews.llvm.org/D138714
2022-07-10ManagedStatic: remove many straightforward uses in llvmNicolai Hähnle
(Reapply after revert in e9ce1a588030d8d4004f5d7e443afe46245e9a92 due to Fuchsia test failures. Removed changes in lib/ExecutionEngine/ other than error categories, to be checked in more detail and reapplied separately.) Bulk remove many of the more trivial uses of ManagedStatic in the llvm directory, either by defining a new getter function or, in many cases, moving the static variable directly into the only function that uses it. Differential Revision: https://reviews.llvm.org/D129120
2022-07-10Revert "ManagedStatic: remove many straightforward uses in llvm"Nicolai Hähnle
This reverts commit e6f1f062457c928c18a88c612f39d9e168f65a85. Reverting due to a failure on the fuchsia-x86_64-linux buildbot.
2022-07-10ManagedStatic: remove many straightforward uses in llvmNicolai Hähnle
Bulk remove many of the more trivial uses of ManagedStatic in the llvm directory, either by defining a new getter function or, in many cases, moving the static variable directly into the only function that uses it. Differential Revision: https://reviews.llvm.org/D129120
2022-05-18[llvm/Support] Fallback to $TERM if terminfo has no "colors" capabilityMed Ismail Bennani
It can happen on macOS that terminal doesn't report the "colors" capability in the terminfo database, in which case `tigetnum` returns -1. This doesn't mean however that the terminal doesn't supports color, it just means that the capability is absent from the terminal description. In that case, we should still fallback to the checking the $TERM environment variable to see if it supports ANSI escapes codes. Differential Revision: https://reviews.llvm.org/D125914 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-07-28[llvm] Replace LLVM_ATTRIBUTE_NORETURN with C++11 [[noreturn]]Fangrui Song
[[noreturn]] can be used since Oct 2016 when the minimum compiler requirement was bumped to GCC 4.8/MSVC 2015. Note: the definition of LLVM_ATTRIBUTE_NORETURN is kept for now.
2021-05-22[Windows] Use TerminateProcess to exit without running destructorsMartin Storsjö
If exiting using _Exit or ExitProcess, DLLs are still unloaded cleanly before exiting, running destructors and other cleanup in those DLLs. When the caller expects to exit without cleanup, running destructors in some loaded DLLs (which can be either libLLVM.dll or e.g. libc++.dll) can cause deadlocks occasionally. This is an alternative to D102684. Differential Revision: https://reviews.llvm.org/D102944
2021-03-18[libsupport] Silence a bogus valgrind warning.Chris Lattner
Valgrind is reporting this bogus warning because it doesn't model pthread_sigmask fully accurately. This is a valgrind bug, but silencing it has effectively no cost, so just do it. ==73662== Syscall param __pthread_sigmask(set) points to uninitialised byte(s) ==73662== at 0x101E9D4C2: __pthread_sigmask (in /usr/lib/system/libsystem_kernel.dylib) ==73662== by 0x101EFB5EA: pthread_sigmask (in /usr/lib/system/libsystem_pthread.dylib) ==73662== by 0x1000D9F6D: llvm::sys::Process::SafelyCloseFileDescriptor(int) (in /Users/chrisl/Projects/circt/build/bin/firtool) ==73662== by 0x100072795: llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > > getFileAux<llvm::MemoryBuffer>(llvm::Twine const&, long long, unsigned long long, unsigned long long, bool, bool) (in /Users/chrisl/Projects/circt/build/bin/firtool) ==73662== by 0x100072573: llvm::MemoryBuffer::getFileOrSTDIN(llvm::Twine const&, long long, bool) (in /Users/chrisl/Projects/circt/build/bin/firtool) ==73662== by 0x100282C25: mlir::openInputFile(llvm::StringRef, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) (in /Users/chrisl/Projects/circt/build/bin Differential Revision: https://reviews.llvm.org/D98830
2021-03-11Save and restore previous terminal after setting the terminal for checking ↵Augusto Noronha
if terminal supports colors. The call to "set_curterm" inside the "terminalHasColors" function breaks the EditLine configuration on some Linux distributions, causing certain characters that have functions bound to them to not show up and backspace to stop deleting characters (only visually). This patch ensures that term struct is restored after the routine for cheking if terminal supports colors is done, which fixes the aforementioned issue. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D95230
2021-02-10Fix deprecated usage of `mallinfo`Ta-Wei Tu
glibc deprecates `mallinfo` in the latest version of 2.33. This patch replaces the usage of `mallinfo` with the new `mallinfo2` when it's available. Reviewed By: lattner Differential Revision: https://reviews.llvm.org/D96359
2020-08-31[CMake] Use find_library for ncursesPetr Hosek
Currently it is hard to avoid having LLVM link to the system install of ncurses, since it uses check_library_exists to find e.g. libtinfo and not find_library or find_package. With this change the ncurses lib is found with find_library, which also considers CMAKE_PREFIX_PATH. This solves an issue for the spack package manager, where we want to use the zlib installed by spack, and spack provides the CMAKE_PREFIX_PATH for it. This is a similar change as https://reviews.llvm.org/D79219, which just landed in master. Patch By: haampie Differential Revision: https://reviews.llvm.org/D85820
2020-08-27Revert "Use find_library for ncurses"Harmen Stoppels
The introduction of find_library for ncurses caused more issues than it solved problems. The current open issue is it makes the static build of LLVM fail. It is better to revert for now, and get back to it later. Revert "[CMake] Fix an issue where get_system_libname creates an empty regex capture on windows" This reverts commit 1ed1e16ab83f55d85c90ae43a05cbe08a00c20e0. Revert "Fix msan build" This reverts commit 34fe9613dda3c7d8665b609136a8c12deb122382. Revert "[CMake] Always mark terminfo as unavailable on Windows" This reverts commit 76bf26236f6fd453343666c3cd91de8f74ffd89d. Revert "[CMake] Fix OCaml build failure because of absolute path in system libs" This reverts commit 8e4acb82f71ad4effec8895b8fc957189ce95933. Revert "[CMake] Don't look for terminfo libs when LLVM_ENABLE_TERMINFO=OFF" This reverts commit 495f91fd33d492941c39424a32cf24bcfe192f35. Revert "Use find_library for ncurses" This reverts commit a52173a3e56553d7b795bcf3cdadcf6433117107. Differential revision: https://reviews.llvm.org/D86521
2020-08-17Use find_library for ncursesHarmen Stoppels
Currently it is hard to avoid having LLVM link to the system install of ncurses, since it uses check_library_exists to find e.g. libtinfo and not find_library or find_package. With this change the ncurses lib is found with find_library, which also considers CMAKE_PREFIX_PATH. This solves an issue for the spack package manager, where we want to use the zlib installed by spack, and spack provides the CMAKE_PREFIX_PATH for it. This is a similar change as https://reviews.llvm.org/D79219, which just landed in master. Differential revision: https://reviews.llvm.org/D85820
2020-04-16Introduce llvm::sys::Process::getProcessId() and adopt itSergej Jaskiewicz
Differential Revision: https://reviews.llvm.org/D78022
2020-03-31[Support] Delete ioctl TIOCGWINSZFangrui Song
D61326 essentially disabled `ioctl(FileID, TIOCGWINSZ, &ws)`. Nobody has complained for one year. So let's just delete the code.
2019-08-19[Support] Replace sys::Mutex with their standard equivalents.Benjamin Kramer
Only use a recursive mutex if it can be locked recursively. llvm-svn: 369295
2019-08-07Replace llvm::MutexGuard/UniqueLock with their standard equivalentsBenjamin Kramer
All supported platforms have <mutex> now, so we don't need our own copies any longer. No functionality change intended. llvm-svn: 368149
2019-05-16Fixes for builds that require strict X/Open and POSIX compatiblityXing Xue
Summary: - Use alternative to MAP_ANONYMOUS for allocating mapped memory if it isn't available - Use strtok_r instead of strsep as part of getting program path - Don't try to find the width of a terminal using "struct winsize" and TIOCGWINSZ on POSIX builds. These aren't defined under POSIX (even though some platforms make them available when they shouldn't), so just check if we are doing a X/Open or POSIX compliant build first. Author: daltenty Reviewers: hubert.reinterpretcast, xingxue, andusy Reviewed By: hubert.reinterpretcast Subscribers: MaskRay, jsji, hiraditya, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61326 llvm-svn: 360898
2019-05-08[Support] Add error handling to sys::Process::getPageSize().Lang Hames
This patch changes the return type of sys::Process::getPageSize to Expected<unsigned> to account for the fact that the underlying syscalls used to obtain the page size may fail (see below). For clients who use the page size as an optimization only this patch adds a new method, getPageSizeEstimate, which calls through to getPageSize but discards any error returned and substitues a "reasonable" page size estimate estimate instead. All existing LLVM clients are updated to call getPageSizeEstimate rather than getPageSize. On Unix, sys::Process::getPageSize is implemented in terms of getpagesize or sysconf, depending on which macros are set. The sysconf call is documented to return -1 on failure. On Darwin getpagesize is implemented in terms of sysconf and may also fail (though the manpage documentation does not mention this). These failures have been observed in practice when highly restrictive sandbox permissions have been applied. Without this patch, the result is that getPageSize returns -1, which wreaks havoc on any subsequent code that was assuming a sane page size value. <rdar://problem/41654857> Reviewers: dblaikie, echristo Subscribers: kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59107 llvm-svn: 360221
2019-02-06build: Remove the cmake check for malloc.h.Peter Collingbourne
As far as I can tell, malloc.h is only being used here to provide a definition of mallinfo (malloc itself is declared in stdlib.h via cstdlib). We already have a macro for whether mallinfo is available, so switch to using that instead. Differential Revision: https://reviews.llvm.org/D57807 llvm-svn: 353329
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. 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: 351636
2018-08-27Use a lambda for calls to ::open in RetryAfterSignalHans Wennborg
In Bionic, open can be overloaded for _FORTIFY_SOURCE support, causing compile errors of RetryAfterSignal due to overload resolution. Wrapping the call in a lambda avoids this. Based on a patch by Chih-Wei Huang <cwhuang@linux.org.tw>! llvm-svn: 340751
2018-06-11Fix build errors on some configurationsPavel Labath
It's been reported <http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180611/559616.html> that template argument deduction for RetryAfterSignal fails if open is not prefixed with "::". This should help us build correctly on those platforms and explicitly specifying the namespace is more correct anyway. llvm-svn: 334403
2018-06-10Cleanup. NFCFangrui Song
llvm-svn: 334357
2018-04-30IWYU for llvm-config.h in llvm, additions.Nico Weber
See r331124 for how I made a list of files missing the include. I then ran this Python script: for f in open('filelist.txt'): f = f.strip() fl = open(f).readlines() found = False for i in xrange(len(fl)): p = '#include "llvm/' if not fl[i].startswith(p): continue if fl[i][len(p):] > 'Config': fl.insert(i, '#include "llvm/Config/llvm-config.h"\n') found = True break if not found: print 'not found', f else: open(f, 'w').write(''.join(fl)) and then looked through everything with `svn diff | diffstat -l | xargs -n 1000 gvim -p` and tried to fix include ordering and whatnot. No intended behavior change. llvm-svn: 331184
2018-04-17Rename sys::Process::GetArgumentVector -> sys::windows::GetCommandLineArgumentsRui Ueyama
GetArgumentVector (or GetCommandLineArguments) is very Windows-specific. I think it doesn't make much sense to provide that function from sys::Process. I also made a change so that the function takes a BumpPtrAllocator instead of a SpecificBumpPtrAllocator. The latter is the class to call dtors, but since char * is trivially destructible, we should use the former class. Differential Revision: https://reviews.llvm.org/D45641 llvm-svn: 330216
2018-01-19Fallback option for colorized output when terminfo isn't availablePetr Hosek
Try to detect the terminal color support by checking the value of the TERM environment variable. This is not great, but it's better than nothing when terminfo library isn't available, which may still be the case on some Linux distributions. Differential Revision: https://reviews.llvm.org/D42055 llvm-svn: 322962
2017-07-21Remove Bitrig: LLVM ChangesErich Keane
Bitrig code has been merged back to OpenBSD, thus the OS has been abandoned. Differential Revision: https://reviews.llvm.org/D35707 llvm-svn: 308799
2017-06-29Recommit "[Support] Add RetryAfterSignal helper function"Pavel Labath
The difference from the previous version is the use of decltype, as the implementation of std::result_of in libc++ did not work correctly for variadic function like open(2). Original summary: This function retries an operation if it was interrupted by a signal (failed with EINTR). It's inspired by the TEMP_FAILURE_RETRY macro in glibc, but I've turned that into a template function. I've also added a fail-value argument, to enable the function to be used with e.g. fopen(3), which is documented to fail for any reason that open(2) can fail (which includes EINTR). The main user of this function will be lldb, but there were also a couple of uses within llvm that I could simplify using this function. Reviewers: zturner, silvas, joerg Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D33895 llvm-svn: 306671
2017-06-22Revert "[Support] Add RetryAfterSignal helper function" and subsequent fixPavel Labath
The fix in r306003 uncovered a pretty fundamental problem that libc++ implementation of std::result_of does not handle the prototype of open(2) correctly (presumably because it contains ...). This makes the whole function unusable in its current form, so I am also reverting the original commit (r305892), which introduced the function, at least until I figure out a way to solve the libc++ issue. llvm-svn: 306005
2017-06-21[Support] Add RetryAfterSignal helper functionPavel Labath
Summary: This function retries an operation if it was interrupted by a signal (failed with EINTR). It's inspired by the TEMP_FAILURE_RETRY macro in glibc, but I've turned that into a template function. I've also added a fail-value argument, to enable the function to be used with e.g. fopen(3), which is documented to fail for any reason that open(2) can fail (which includes EINTR). The main user of this function will be lldb, but there were also a couple of uses within llvm that I could simplify using this function. Reviewers: zturner, silvas, joerg Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D33895 llvm-svn: 305892