summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix detection of backtrace() availability on FreeBSDEd Maste2017-04-121-2/+2
| | | | | | | | | | | | On FreeBSD backtrace is not part of libc and depends on libexecinfo being available. Instead of using manual checks we can use the builtin CMake module FindBacktrace.cmake to detect availability of backtrace() in a portable way. Patch By: Alex Richardson Differential Revision: https://reviews.llvm.org/D27143 llvm-svn: 300062
* Remove name space pollution from Signals.cppKristof Beyls2017-03-311-3/+3
| | | | llvm-svn: 299224
* [Support] Avoid concurrency hazard in signal handler registrationBruno Cardoso Lopes2017-03-271-5/+1
| | | | | | | | | | | | | | | | | | Several static functions from the signal API can be invoked simultaneously; RemoveFileOnSignal for instance can be called indirectly by multiple parallel loadModule() invocations, which might lead to the assertion: Assertion failed: (NumRegisteredSignals < array_lengthof(RegisteredSignalInfo) && "Out of space for signal handlers!"), function RegisterHandler, file /llvm/lib/Support/Unix/Signals.inc, line 105. RemoveFileOnSignal calls RegisterHandlers(), which isn't currently mutex protected, leading to the behavior above. This potentially affect a few other users of RegisterHandlers() too. rdar://problem/30381224 llvm-svn: 298871
* Make home_directory look in the password database in addition to $HOME.Zachary Turner2017-03-221-5/+11
| | | | | | | | | | | | | This is something of an edge case, but when the $HOME environment variable is not set, we can still look in the password database to get the current user's home directory. Added a test for this by getting the value of $HOME, then unsetting it, then calling home_directory() and verifying that it succeeds and that the value is the same as what we originally read from the environment. llvm-svn: 298513
* [Support] Fill the file_status struct with link count.Zachary Turner2017-03-201-4/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D31110 llvm-svn: 298326
* Fix linux build.Zachary Turner2017-03-161-1/+2
| | | | llvm-svn: 298007
* [Support] Add support for getting file system permissions on Windows and ↵James Henderson2017-03-161-1/+10
| | | | | | | | | | | | | | | | | | implement sys::fs::set/getPermissions to work with them This change adds support for functions to set and get file permissions, in a similar manner to the C++17 permissions() function in <filesystem>. The setter uses chmod on Unix systems and SetFileAttributes on Windows, setting the permissions as passed in. The getter simply uses the existing status() function. Prior to this change, status() would always return an unknown value for the permissions on a Windows file, making it impossible to test the new function on Windows. I have therefore added support for this as well. On Linux, prior to this change, the permissions included the file type, which should actually be accessed via a different member of the file_status class. Note that on Windows, only the *_write permission bits have any affect - if any are set, the file is writable, and if not, the file is read-only. This is in common with what MSDN describes for their behaviour of std::filesystem::permissions(), and also what boost::filesystem does. The motivation behind this change is so that we can easily test behaviour on read-only files in LLVM unit tests, but I am sure that others may find it useful in some situations. Reviewers: zturner, amccarth, aaron.ballman Differential Revision: https://reviews.llvm.org/D30736 llvm-svn: 297945
* Reverting r297617 because it broke some bots:Aaron Ballman2017-03-131-15/+6
| | | | | | http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/49970 llvm-svn: 297618
* Add support for getting file system permissions and implement ↵Aaron Ballman2017-03-131-6/+15
| | | | | | | | sys::fs::permissions to set them. Patch by James Henderson. llvm-svn: 297617
* Add llvm::sys::fs::real_path.Zachary Turner2017-03-101-1/+63
| | | | | | | | | | | | | | | | | | | | | LLVM already has real_path like functionality, but it is cumbersome to use and involves clean up after (e.g. you have to call openFileForRead, then close the resulting FD). Furthermore, on Windows it doesn't work for directories since opening a directory and opening a file require slightly different flags. So I add a simple function `real_path` which works for all paths on all platforms and has a simple to use interface. In doing so, I add the ability to opt in to resolving tilde expressions (e.g. ~/foo), which are normally handled by the shell. Differential Revision: https://reviews.llvm.org/D30668 llvm-svn: 297483
* fix build on CygwinNuno Lopes2017-03-091-0/+3
| | | | llvm-svn: 297378
* [Support] Add llvm::sys::fs::remove_directories.Zachary Turner2017-03-081-2/+43
| | | | | | | | | | | | | | | | | | | | | We already have a function create_directories() which can create an entire tree, and remove() which can remove an empty directory, but we do not have remove_directories() which can remove an entire tree. This patch adds such a function. Because removing a directory tree can have dangerous consequences when the tree contains a directory symlink, the patch here updates the existing directory_iterator construct to optionally not follow symlinks (previously it would always follow symlinks). The delete algorithm uses this flag so that for symlinks, only the links are removed, and not the targets. On Windows this is implemented with SHFileOperation, which also does not recurse into symbolic links or junctions. Differential Revision: https://reviews.llvm.org/D30676 llvm-svn: 297314
* [fs] Make sure to check S_ISLNK() in fillStatus.Zachary Turner2017-03-071-0/+2
| | | | llvm-svn: 297167
* [Support] Add the option to not follow symlinks on stat.Zachary Turner2017-03-071-2/+2
| | | | llvm-svn: 297154
* Try to fix thread name truncation on non-Windows.Zachary Turner2017-03-041-6/+13
| | | | llvm-svn: 296976
* Improve the Threading code on NetBSDKamil Rytarowski2017-03-041-5/+2
| | | | | | | | Do not include <sys/user.h> on NetBSD. It's dead file and will be removed. No need to include <sys/sysctl.h> in this code context on NetBSD. llvm-svn: 296973
* Truncate thread names if they're too long.Zachary Turner2017-03-041-3/+27
| | | | llvm-svn: 296972
* Silence a warning, NFCKrzysztof Parzyszek2017-03-031-0/+1
| | | | llvm-svn: 296917
* Detect the existence of pthread_{s,g}etname_np in libpthread on LinuxKrzysztof Parzyszek2017-03-031-0/+4
| | | | | | Older Linux distributions may not have those functions. llvm-svn: 296915
* Add missing #includes for FreeBSD.Zachary Turner2017-03-031-4/+9
| | | | llvm-svn: 296902
* Try again to appease the FreeBSD bot.Zachary Turner2017-03-031-7/+2
| | | | | | | The actual logic was wrong, not just the type conversion. This should get it correct. llvm-svn: 296899
* Try to appease the FreeBSD bots.Zachary Turner2017-03-031-2/+2
| | | | | | | | pthread_self() returns a pthread_t, but we were setting it to an int. It seems the cast to int when calling sysctl is still the correct thing to do, though. llvm-svn: 296892
* Add #include for unistd.h on Linux.Zachary Turner2017-03-031-0/+1
| | | | llvm-svn: 296890
* [Support] Provide access to current thread name/thread id.Zachary Turner2017-03-031-0/+181
| | | | | | | | | | | | | | | | Applications often need the current thread id when making system calls, and some operating systems provide the notion of a thread name, which can be useful in enabling better diagnostics when debugging or logging. This patch adds an accessor for the thread id, and "best effort" getters and setters for the thread name. Since this is non critical functionality, no error is returned to indicate that a platform doesn't support thread names. Differential Revision: https://reviews.llvm.org/D30526 llvm-svn: 296887
* [Support] Re-add the special OSX flags on mmap.Zachary Turner2017-02-221-0/+19
| | | | | | | | The problem appears to be that these flags can only be used when mapping a file for read-only, not for readwrite. So we do that here. llvm-svn: 295880
* [Support] Provide linux/magic.h fallback for older kernelsMichal Gorny2017-02-221-0/+15
| | | | | | | | | | | | | | | | | | | | | The function for distinguishing local and remote files added in r295768 unconditionally uses linux/magic.h header to provide necessary filesystem magic numbers. However, in kernel headers predating 2.6.18 the magic numbers are spread throughout multiple include files. Furthermore, LLVM did not require kernel headers being installed so far. To increase the portability across different versions of Linux kernel and different Linux systems, add CMake header checks for linux/magic.h and -- if it is missing -- the linux/nfs_fs.h and linux/smb.h headers which contained the numbers previously. Furthermore, since the numbers are static and the feature does not seem critical enough to make LLVM require kernel headers at all, add fallback constants for the case when none of the necessary headers is available. Differential Revision: https://reviews.llvm.org/D30261 llvm-svn: 295854
* Try to fix the buildbot on OSX.Zachary Turner2017-02-211-16/+0
| | | | | | | | | Since I'm only seeing failures on OSX, and it's saying permission denied, I'm suspecting this is due to the addition of the MAP_RESILIENT_CODESIGN and/or MAP_RESILIENT_MEDIA flags. Speculatively trying to remove those to get the bots working. llvm-svn: 295770
* Try to fix Android build.Zachary Turner2017-02-211-1/+3
| | | | llvm-svn: 295769
* [Support] Add a function to check if a file resides locally.Zachary Turner2017-02-211-3/+63
| | | | | | Differential Revision: https://reviews.llvm.org/D30010 llvm-svn: 295768
* Fix LLDB Android AArch64 GCC debug info buildOmair Javaid2017-02-022-2/+2
| | | | | | | | | Committing after fixing suggested changes and tested release/debug builds on x86_64-linux and arm/aarch64 builds. Differential revision: https://reviews.llvm.org/D29042 llvm-svn: 293850
* [Support] Use O_CLOEXEC only when declaredPavel Labath2017-01-241-2/+20
| | | | | | | | | | | | | | | | | | | Summary: Use the O_CLOEXEC flag only when it is available. Some old systems (e.g. SLES10) do not support this flag. POSIX explicitly guarantees that this flag can be checked for using #if, so there is no need for a CMake check. In case O_CLOEXEC is not supported, fall back to fcntl(FD_CLOEXEC) instead. Reviewers: rnk, rafael, mgorny Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D28894 llvm-svn: 292912
* [Support] Add sys::fs::set_current_path() (aka chdir)Pavel Labath2017-01-241-0/+10
| | | | | | | | | | | | | | | Summary: This adds a cross-platform way of setting the current working directory analogous to the existing current_path() function used for retrieving it. The function will be used in lldb. Reviewers: rafael, silvas, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29035 llvm-svn: 292907
* raw_fd_ostream: Make file handles non-inheritable by defaultPavel Labath2017-01-181-2/+2
| | | | | | | | | | | | | | | | Summary: This makes the file descriptors on unix platform non-inheritable (O_CLOEXEC). There is no change in behavior on windows, as the handles were already non-inheritable there. Reviewers: rnk, rafael Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D28854 llvm-svn: 292401
* Revert "Use _Unwind_Backtrace on Apple platforms."Bob Wilson2017-01-061-1/+1
| | | | | | | | | | | This reverts commit 63165f6ae3bac1623be36d4b3ce63afa1d51a30a. After making this change, I discovered that _Unwind_Backtrace is unable to unwind past a signal handler after an assertion failure. I filed a bug report about that issue in rdar://29866587 but even if we get a fix soon, it will be awhile before it get released. llvm-svn: 291207
* [ThinLTO] Add an API to trigger file-based API for returning objects to the ↵Mehdi Amini2016-12-141-0/+13
| | | | | | | | | | | | | | | | | | | | linker Summary: The motivation is to support better the -object_path_lto option on Darwin. The linker needs to write down the generate object files on disk for later use by lldb or dsymutil (debug info are not present in the final binary). We're moving this into libLTO so that we can be smarter when a cache is enabled and hard-link when possible instead of duplicating the files. Reviewers: tejohnson, deadalnix, pcc Subscribers: dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D27507 llvm-svn: 289631
* Fix comment typos. NFC.Simon Pilgrim2016-11-201-1/+1
| | | | | | Identified by Pedro Giffuni in PR27636. llvm-svn: 287490
* Use _Unwind_Backtrace on Apple platforms.Bob Wilson2016-11-141-1/+1
| | | | | | | | | | | | | Darwin's backtrace() function does not work with sigaltstack (which was enabled when available with r270395) — it does a sanity check to make sure that the current frame pointer is within the expected stack area (which it is not when using an alternate stack) and gives up otherwise. The alternative of _Unwind_Backtrace seems to work fine on macOS, so use that when backtrace() fails. Note that we then use backtrace_symbols_fd() with the addresses from _Unwind_Backtrace, but I’ve tested that and it also seems to work fine. rdar://problem/28646552 llvm-svn: 286851
* Zero-initialize chrono duration objectsPavel Labath2016-11-091-1/+1
| | | | | | | The default duration constructor does not zero-initialize the object, we need to do that manually. llvm-svn: 286359
* Correct mprotect page boundries to round up end page. Fixes PR30905.Alina Sbirlea2016-11-051-1/+4
| | | | | | | | | | | | | | Summary: Update the boundries for mprotect. Patch by Andrew Adams. Fixes PR30905. Reviewers: loladiro, andrew.w.kaylor, chandlerc Subscribers: abadams, llvm-commits Differential Revision: https://reviews.llvm.org/D26312 llvm-svn: 286032
* [Chrono] Fix !HAVE_FUTIMENS buildPavel Labath2016-10-241-1/+2
| | | | | | | | If we don't have futimens(), we fall back to futimes(), which only supports microsecond timestamps. In that case, we need to explicitly cast away the extra precision in setLastModificationAndAccessTime(). llvm-svn: 284977
* Remove TimeValue usage from llvm/SupportPavel Labath2016-10-243-33/+50
| | | | | | | | | | | | | | | | | Summary: This is a follow-up to D25416. It removes all usages of TimeValue from llvm/Support library (except for the actual TimeValue declaration), and replaces them with appropriate usages of std::chrono. To facilitate this, I have added small utility functions for converting time points and durations into appropriate OS-specific types (FILETIME, struct timespec, ...). Reviewers: zturner, mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25730 llvm-svn: 284966
* Reapply "Add Chrono.h - std::chrono support header"Pavel Labath2016-10-201-54/+0
| | | | | | | | | This is a resubmission of r284590. The mingw build should be fixed now. The problem was we were matching time_t with _localtime_64s, which was incorrect on _USE_32BIT_TIME_T systems. Instead I use localtime_s, which should always evaluate to the correct function. llvm-svn: 284720
* Revert "Add Chrono.h - std::chrono support header"Pavel Labath2016-10-191-0/+54
| | | | | | | | | This reverts commit r284590 as it fails on the mingw buildbot. I think I know the fix, but I cannot test it right now. Will reapply when I verify it works ok. This reverts r284590. llvm-svn: 284615
* Add Chrono.h - std::chrono support headerPavel Labath2016-10-191-54/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: std::chrono mostly covers the functionality of llvm::sys::TimeValue and lldb_private::TimeValue. This header adds a bit of utility functions and typedefs, which make the usage of the library and porting code from TimeValues easier. Rationale: - TimePoint typedef - precision of system_clock is implementation defined - using a well-defined precision helps maintain consistency between platforms, makes it interact better with existing TimeValue classes, and avoids cases there a time point is implicitly convertible to a specific precision on some platforms but not on others. - system_clock::to_time_t only accepts time_points with the default system precision (even though time_t has only second precision on all platforms we support). To avoid the need for explicit casts, I have added a toTimeT() wrapper function. toTimePoint(time_t) was not strictly necessary, but I have added it for symmetry. Reviewers: zturner, mehdi_amini Subscribers: beanz, mgorny, llvm-commits, modocache Differential Revision: https://reviews.llvm.org/D25416 llvm-svn: 284590
* fix build on cygwinNuno Lopes2016-10-061-1/+1
| | | | | | Cygwin has dlfcn.h, but no Dl_info llvm-svn: 283427
* Deal with the (historic) MAP_ANONYMOUS vs MAP_ANON directly by using CPPJoerg Sonnenberger2016-09-301-2/+2
| | | | | | to check for the former, don't depend on (dangling) HAVE_MMAP_ANONYMOUS. llvm-svn: 282925
* Retire NEED_DEV_ZERO_FOR_MMAP. It should be needed only on outdatedJoerg Sonnenberger2016-09-301-16/+0
| | | | | | | systems. It wasn't even hooked up in cmake, so problems on such systems would be visible with 3.9 release already. llvm-svn: 282924
* Turn ENABLE_CRASH_OVERRIDES into a 0/1 definition.Joerg Sonnenberger2016-09-301-1/+1
| | | | llvm-svn: 282919
* Convert ENABLE_BACKTRACES into a 0/1 definition.Joerg Sonnenberger2016-09-301-4/+4
| | | | llvm-svn: 282918
* Make HAVE_DECL_ARC4RANDOM always defined. Sort the entry correctly.Joerg Sonnenberger2016-09-291-2/+2
| | | | llvm-svn: 282768
OpenPOWER on IntegriCloud