summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix
Commit message (Collapse)AuthorAgeFilesLines
...
* Cleanup the interface for creating soft or hard links.Rafael Espindola2014-03-111-2/+4
| | | | | | | | | | | | Before this patch the unix code for creating hardlinks was unused. The code for creating symbolic links was implemented in lib/Support/LockFileManager.cpp and the code for creating hard links in lib/Support/*/Path.inc. The only use we have for these is in LockFileManager.cpp and it can use both soft and hard links. Just have a create_link function that creates one or the other depending on the platform. llvm-svn: 203596
* Revert create_symbolic_link and both depending changesReid Kleckner2014-03-061-13/+0
| | | | | | | | | | This reverts commits r203136, r203137, and r203138. This code doesn't build on Windows. Even on Vista+, Windows requires elevated privileges to create a symlink. Therefore we can't use symlinks in the compiler. We'll have to find another approach. llvm-svn: 203143
* [Support/FileSystem] Introduce llvm::sys::fs::create_symbolic_link().Argyrios Kyrtzidis2014-03-061-0/+13
| | | | llvm-svn: 203136
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-1/+1
| | | | | | The old implementation is no longer needed in C++11. llvm-svn: 202644
* [C++11] Remove the R-value reference #if usage from the ADT and SupportChandler Carruth2014-03-011-2/+0
| | | | | | libraries. It is now always 1 in LLVM builds. llvm-svn: 202580
* Fix RWMutex to be thread-safe when pthread_rwlock is not availableMark Seaborn2014-03-011-6/+14
| | | | | | | | | | | | | | lib/Support/RWMutex.cpp contains an implementation of RWMutex that uses pthread_rwlock, but when pthread_rwlock is not available (such as under NaCl, when using newlib), it silently falls back to using the no-op definition in lib/Support/Unix/RWMutex.inc, which is not thread-safe. Fix this case to be thread-safe by using a normal mutex. Differential Revision: http://llvm-reviews.chandlerc.com/D2892 llvm-svn: 202570
* Share a createUniqueEntity implementation between unix and windows.Rafael Espindola2014-02-241-71/+6
| | | | | | | The only extra bit of functionality that had to be exposed for this be be implemented in Path.cpp is opening a file in rw mode. llvm-svn: 202005
* Delete dead code.Rafael Espindola2014-02-241-5/+0
| | | | llvm-svn: 202001
* Use static instead of an anonymous namespace.Rafael Espindola2014-02-231-14/+12
| | | | llvm-svn: 201983
* Simplify remove, create_directory and create_directories.Rafael Espindola2014-02-231-17/+11
| | | | | | | | | | | | | | | Before this patch they would take an boolean argument to say if the path already existed. This was redundant with the returned error_code which is able to represent that. This allowed for callers to incorrectly check only the existed flag instead of first checking the error code. Instead, pass in a boolean flag to say if the previous (non-)existence should be an error or not. Callers of the of the old simple versions are not affected. They still ignore the previous (non-)existence as they did before. llvm-svn: 201979
* Remove dead code.Rafael Espindola2014-02-131-13/+0
| | | | llvm-svn: 201327
* Remove TimeValue::toPosixTime() -- it is buggy, semantics are unclear, and itsDmitri Gribenko2014-02-111-2/+2
| | | | | | only current user should be using toEpochTime() instead. llvm-svn: 201136
* Using the helper API for random number generation.Aaron Ballman2014-02-111-1/+0
| | | | llvm-svn: 201125
* Fix configure to find arc4random via header files.Todd Fiala2014-02-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ISSUE: On Ubuntu 12.04 LTS, arc4random is provided by libbsd.so, which is a transitive dependency of libedit. If a system had libedit on it that was implemented in terms of libbsd.so, then the arc4random test, previously implemented as a linker test, would succeed with -ledit. However, on Ubuntu this would also require a #include <bsd/stdlib.h>. This caused a build breakage on configure-based Ubuntu 12.04 with libedit installed. FIX: This fix changes configure to test for arc4random by searching for it in the standard header files. On Ubuntu 12.04, this test now properly fails to find arc4random as it is not defined in the default header locations. It also tweaks the #define names to match the output of the header check command, which is slightly different than the linker function check #defines. I tested the following scenarios: (1) Ubuntu 12.04 without the libedit package [did not find arc4random, as expected] (2) Ubuntu 12.04 with libedit package [properly did not find arc4random, as expected] (3) Ubuntu 12.04 with most recent libedit, custom built, and not dependent on libbsd.so [properly did not find arc4random, as expected]. (4) FreeBSD 10.0B1 [properly found arc4random, as expected] llvm-svn: 200819
* Introduce llvm::sys::path::home_directory.Peter Collingbourne2014-01-311-0/+15
| | | | | | | | | This will be used by the line editor library to derive a default path to the history file. Differential Revision: http://llvm-reviews.chandlerc.com/D2199 llvm-svn: 200594
* Fix the "#ifndef HAVE_SYS_WAIT_H" code path in Program.inc to compileMark Seaborn2014-01-271-0/+1
| | | | | | Without this fix, WaitResult is not defined. llvm-svn: 200259
* Make sys::ThreadLocal<> zero-initialized on non-thread builds (PR18205)Hans Wennborg2013-12-191-1/+1
| | | | | | | | | | | | | According to the docs, ThreadLocal<>::get() should return NULL if no object has been set. This patch makes that the case also for non-thread builds and adds a very basic unit test to check it. (This was causing PR18205 because PrettyStackTraceHead didn't get zero- initialized and we'd crash trying to read past the end of that list. We didn't notice this so much on Linux since we'd crash after printing all the entries, but on Mac we print into a SmallString, and would crash before printing that.) llvm-svn: 197718
* Build fix for Android NDK which has neither futimes nor futimensAlp Toker2013-12-111-3/+6
| | | | | | Based on a patch by Neil Henning! llvm-svn: 197045
* Improve the detection of the pathSylvestre Ledru2013-12-091-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: When clang is used under GNU/Linux in a chroot without /proc mount, it falls back on the BSD method. However, since the buf variable is used twice and fails with snprintf to produce the correct path. When called as relatived (ie ./clang), it was failing with: "" -cc1 [...] -x c++ x.cc error: unable to execute command: Executable "" doesn't exist! I also took the opportunity to simply the code (the first arg of test_dir was useless). Reviewers: rafael Reviewed By: rafael CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2361 llvm-svn: 196791
* Correct word hyphenationsAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities and contractions in nearby lines. llvm-svn: 196471
* Rules adjustments in order to build on DragonFly BSD.Rafael Espindola2013-10-311-2/+3
| | | | | | Patch by Robin Hahling. llvm-svn: 193750
* Fix build on Solaris 11.Rafael Espindola2013-10-082-0/+7
| | | | | | | | | | | | | Patch by Vladimir Voskresensky. The erros were: Path.inc:274:3: error: ‘Dl_info’ was not declared in this scope ... and usr/include/spawn.h:52:14: error: expected ‘,’ or ‘...’ before ‘argv’ llvm-svn: 192185
* Revert "Revert "Windows: Add support for unicode command lines""David Majnemer2013-10-071-0/+8
| | | | | | | This reverts commit r192070 which reverted r192069, I forgot to regenerate the configure scripts. llvm-svn: 192079
* Revert "Windows: Add support for unicode command lines"David Majnemer2013-10-061-8/+0
| | | | | | | This is causing MinGW bots to fail. This reverts commit r192069. llvm-svn: 192070
* Windows: Add support for unicode command linesDavid Majnemer2013-10-061-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The MSVCRT deliberately sends main() code-page specific characters. This isn't too useful to LLVM as we end up converting the arguments to UTF-16 and subsequently attempt to use the result as, for example, a file name. Instead, we need to have the ability to access the Unicode command line and transform it to UTF-8. This has the distinct advantage over using the MSVC-specific wmain() function as our entry point because: - It doesn't work on cygwin. - It only work on MinGW with caveats and only then on certain versions. - We get to keep our entry point as main(). :) N.B. This patch includes fixes to other parts of lib/Support/Windows s.t. we would be able to take advantage of getting the Unicode paths. E.G. clang spawning clang -cc1 would want to give it Unicode arguments. Reviewers: aaron.ballman, Bigcheese, rnk, ruiu Reviewed By: rnk CC: llvm-commits, ygao Differential Revision: http://llvm-reviews.chandlerc.com/D1834 llvm-svn: 192069
* Add non-blocking Wait() for launched processesTareq A. Siraj2013-10-011-54/+70
| | | | | | | | | | | | | | | | | - New ProcessInfo class to encapsulate information about child processes. - Generalized the Wait() to support non-blocking wait on child processes. - ExecuteNoWait() now returns a ProcessInfo object with information about the launched child. Users will be able to use this object to perform non-blocking wait. - ExecuteNoWait() now accepts an ExecutionFailed param that tells if execution failed or not. These changes will allow users to implement basic process parallel tools. Differential Revision: http://llvm-reviews.chandlerc.com/D1728 llvm-svn: 191763
* Support ANSI escape code on WindowsNico Rieck2013-09-111-18/+4
| | | | | | | | In some cases (e.g. when a build system pipes stderr) the Windows console API cannot be used to color output. For these, provide a way to switch to ANSI escape codes. This is required for Clang's -fansi-escape-codes option. llvm-svn: 190460
* Add getenv() wrapper that works on multibyte environment variable.Rui Ueyama2013-09-101-0/+9
| | | | | | | | | | | | | | | | | | On Windows, character encoding of multibyte environment variable varies depending on settings. The only reliable way to handle it I think is to use GetEnvironmentVariableW(). GetEnvironmentVariableW() works on wchar_t string, which is on Windows UTF16 string. That's not ideal because we use UTF-8 as the internal encoding in LLVM. This patch defines a wrapper function which takes and returns UTF-8 string for GetEnvironmentVariableW(). The wrapper function does not do any conversion and just forwards the argument to getenv() on Unix. Differential Revision: http://llvm-reviews.chandlerc.com/D1612 llvm-svn: 190423
* Support/Process: Add comments about PageSize and AllocationGranularity on ↵NAKAMURA Takumi2013-09-041-2/+2
| | | | | | Cygwin and Win32. llvm-svn: 189940
* [conf] Add config variable to disable crash related overrides.Daniel Dunbar2013-08-301-2/+2
| | | | | | | | | | | | | | | | | | | | | - We do some nasty things w.r.t. installing or overriding signal handlers in order to improve our crash recovery support or interaction with crash reporting software, and those things are not necessarily appropriate when LLVM is being linked into a client application that has its own ideas about how to do things. This gives those clients a way to disable that handling at build time. - Currently, the code this guards is all Apple specific, but other platforms might have the same concerns so I went for a more generic configure name. Someone who is more familiar with library embedding on Windows can handle choosing which of the Windows/Signals.inc behaviors might make sense to go under this flag. - This also fixes the proper autoconf'ing of ENABLE_BACKTRACES. The code expects it to be undefined when disabled, but the autoconf check was just defining it to 0. llvm-svn: 189694
* Unix/Process.inc: Revert r72332, "Work around a page size issue on Cygwin."NAKAMURA Takumi2013-08-211-6/+3
| | | | | | | Offset in mmap(3) should be aligned to gepagesize(), 64k, or mmap(3) would fail. TODO: Invetigate places where 4096 would be required as pagesize, or 4096 would satisfy. llvm-svn: 188903
* Go through the really awkward dance required to delete the memoryChandler Carruth2013-08-181-2/+12
| | | | | | | | allocated by setupterm. Without this, some folks are seeing leaked memory whenever this routine is called more than once. Thanks to Craig Topper for the report. llvm-svn: 188615
* Removing unused functionality.Aaron Ballman2013-08-161-8/+0
| | | | llvm-svn: 188565
* GCC warns about removing const with a c-style cast.Benjamin Kramer2013-08-131-1/+1
| | | | llvm-svn: 188259
* Remove all checking for the various terminfo headers (term.h andChandler Carruth2013-08-121-24/+10
| | | | | | | | | | | | | | | | curses.h). Finding these headers is next to impossible. For example, on Debian systems libtinfo-dev provides the terminfo reading library we want, but *not* term.h. For the header, you have to use libncurses-dev. And libncursesw-dev provides a *different* term.h in a different location! These headers aren't worth it. We want two functions the signatures of which are clearly spec'ed in sys-v and other documentation. Just declare them ourselves and call them. This should fix some debian builders and provide better support for "minimal" debian systems that do want color autodetection. llvm-svn: 188165
* Target a minimal terminfo library rather than necessarily a full cursesChandler Carruth2013-08-121-11/+25
| | | | | | | | | | | | | | | | | | | | library for color support detection. This still will use a curses library if that is all we have available on the system. This change tries to use a smaller subset of the curses library, specifically the subset that is on some systems split off into a separate library. For example, if you install ncurses configured --with-tinfo, a 'libtinfo' is install that provides just the terminfo querying functionality. That library is now used instead of curses when it is available. This happens to fix a build error on systems with that library because when we tried to link ncurses into the binary, we didn't pull tinfo in as well. =] It should also provide an easy path for supporting the NetBSD libterminfo library, but as I don't have access to a NetBSD system I'm leaving adding that support to those folks. llvm-svn: 188160
* Check for $PWD in llvm::sys::current_path.Rafael Espindola2013-08-101-0/+12
| | | | | | | Some users (clang, libTooling) require this. After this patch we can remove the calls to getenv("PWD") from clang. llvm-svn: 188125
* Add support for linking against a curses library when available andChandler Carruth2013-08-071-10/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | using it to detect whether or not a terminal supports colors. This replaces a particularly egregious hack that merely compared the TERM environment variable to "dumb". That doesn't really translate to a reasonable experience for users that have actually ensured their terminal's capabilities are accurately reflected. This makes testing a terminal for color support somewhat more expensive, but it is called very rarely anyways. The important fast path when the output is being piped somewhere is already in place. The global lock may seem excessive, but the spec for calling into curses is *terrible*. The whole library is terrible, and I spent quite a bit of time looking for a better way of doing this before convincing myself that this was the fundamentally correct way to behave. The damage of the curses library is very narrowly confined, and we continue to use raw escape codes for actually manipulating the colors which is a much sane system than directly using curses here (IMO). If this causes trouble for folks, please let me know. I've tested it on Linux and will watch the bots carefully. I've also worked to account for the variances of curses interfaces that I could finde documentation for, but that may not have been sufficient. llvm-svn: 187874
* Make file_status::getUniqueID const.Rafael Espindola2013-07-291-1/+1
| | | | llvm-svn: 187383
* Include st_dev to make the result of getUniqueID actually unique.Rafael Espindola2013-07-291-12/+4
| | | | | | This will let us use getUniqueID instead of st_dev directly on clang. llvm-svn: 187378
* Revert "[PowerPC] Improve consistency in use of __ppc__, __powerpc__, etc."Rafael Espindola2013-07-261-2/+2
| | | | | | This reverts commit r187248. It broke many bots. llvm-svn: 187254
* [PowerPC] Improve consistency in use of __ppc__, __powerpc__, etc.Bill Schmidt2013-07-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Both GCC and LLVM will implicitly define __ppc__ and __powerpc__ for all PowerPC targets, whether 32- or 64-bit. They will both implicitly define __ppc64__ and __powerpc64__ for 64-bit PowerPC targets, and not for 32-bit targets. We cannot be sure that all other possible compilers used to compile Clang/LLVM define both __ppc__ and __powerpc__, for example, so it is best to check for both when relying on either inside the Clang/LLVM code base. This patch makes sure we always check for both variants. In addition, it fixes one unnecessary check in lib/Target/PowerPC/PPCJITInfo.cpp. (At least one of __ppc__ and __powerpc__ should always be defined when compiling for a PowerPC target, no matter which compiler is used, so testing for them is unnecessary.) There are some places in the compiler that check for other variants, like __POWERPC__ and _POWER, and I have left those in place. There is no need to add them elsewhere. This seems to be in Apple-specific code, and I won't take a chance on breaking it. There is no intended change in behavior; thus, no test cases are added. llvm-svn: 187248
* Add missing 'n'.Rafael Espindola2013-07-261-1/+1
| | | | | | Thanks to Han Finkel for noticing it. llvm-svn: 187241
* Remove dead or useless header checks from cmake and autoconfReid Kleckner2013-07-262-14/+4
| | | | | | | | | | On Windows, this improves clean cmake configuration time on my workstation from 1m58s to 1m32s, which is pretty significant. There's probably more that can be done here, but this is the low hanging fruit. Eric volunteered to regenerate ./configure for me. llvm-svn: 187209
* Extend the lifetime of the strings passed to posix_spawn_file_actions_addopen.Rafael Espindola2013-07-261-7/+21
| | | | | | Thanks to Hal Finkel for finding the bug and for the initial patch. llvm-svn: 187208
* Split openFileForWrite into windows and unix versions.Rafael Espindola2013-07-191-0/+25
| | | | | | It is similar to 186511, but for creating files for writing. llvm-svn: 186679
* Remove dead code.Rafael Espindola2013-07-181-59/+0
| | | | llvm-svn: 186561
* Split openFileForRead into Windows and Unix versions.Rafael Espindola2013-07-171-0/+9
| | | | | | | | | | | This has some advantages: * Lets us use native, utf16 windows functions. * Easy to produce good errors on windows about trying to use a directory when we want a file. * Simplifies the unix version a bit. llvm-svn: 186511
* Don't fallback to copy + delete in rename.Rafael Espindola2013-07-171-11/+2
| | | | | | | | | Rename's documentation says "Files are renamed as if by POSIX rename()". and it is used for atomically updating output files from a temporary. Having rename fallback to a non atomic copy has the potential to hide bugs, like using a temporary file in /tmp instead of a unique name next to the final destination. llvm-svn: 186483
* Add a version of sys::fs::status that uses fstat.Rafael Espindola2013-07-161-18/+30
| | | | llvm-svn: 186378
OpenPOWER on IntegriCloud