Commit Graph

90 Commits

Author SHA1 Message Date
Dan Gohman
06572793a7 Handle the case where open(2) or close(2) is interrupted by a signal when
automatic syscall restarting is disabled.

Also, fix the build on systems which don't define EWOULDBLOCK.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103158 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-06 02:06:20 +00:00
Dan Gohman
5fe89d0126 Handle EWOULDBLOCK as EAGAIN. And add a comment explaining why
EAGAIN and EWOULDBLOCK are used here.

Also, handle the case where a write call is interrupted after
some data has already been written.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103153 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-06 01:27:36 +00:00
Benjamin Kramer
66760be919 Try again if write(2) reports an recoverable error.
This should fix mysteriously crashing boost regression tests when stderr is
managed by bjam (PR7043).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103085 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-05 15:17:47 +00:00
Chris Lattner
21aa347c28 add minix support, patch by Kees van Reeuwijk! PR6797
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100895 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-09 20:45:04 +00:00
Chris Lattner
75361b69f3 rename llvm::llvm_report_error -> llvm::report_fatal_error
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100709 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-07 22:58:41 +00:00
Dan Gohman
16e02097d2 Fix minor style issues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99414 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24 19:38:02 +00:00
Chris Lattner
f071d4efeb add an assertion requested on llvmdev.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97769 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 00:49:08 +00:00
Chris Lattner
17f26b4fd2 enhance raw_svector_ostream::write_impl to work with unbuffered streams,
which may call write_impl on things that are not the usual buffer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96209 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-15 02:18:26 +00:00
Benjamin Kramer
4f17eb8721 Fix MSVC build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94809 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 15:19:06 +00:00
Benjamin Kramer
f304ff63d3 Use llvm::format instead of ftostr (which just calls sprintf).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94807 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 14:40:33 +00:00
Chris Lattner
14ca177beb Changes to fix buffering that I forgot to commit with previous patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94222 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 21:16:10 +00:00
Chris Lattner
d79d9dce47 add a new MCAsmStreamer::GetCommentOS method to simplify stuff
that doesn't want to use twines.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94199 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 19:17:48 +00:00
Chris Lattner
cd0129f5a6 Make some methods const. The only interesting change here is that
it changes raw_fd_ostream::preferred_buffer_size to return zero on
a scary stat failure instead of setting the stream to an error state.
This method really should not mutate the stream.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91740 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 01:38:42 +00:00
Dan Gohman
a4f8ecd85d Micro-optimize these functions in the case where they are not inlined.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91316 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 19:32:31 +00:00
Daniel Dunbar
522b113a75 Add raw_ostream::write_escaped, for writing escaped strings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84355 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 20:43:08 +00:00
Daniel Dunbar
c8213b7827 Drop the raw_ostream required buffer size to 1.
- As best I can tell, we have eliminated all the code which used to require a
   larger buffer size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81912 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 20:31:46 +00:00
Dan Gohman
ec080467f5 Fix llvm-extract's "writing bitcode to a terminal" warning, which wasn't
working. To support this, add an is_displayed() function to raw_ostream,
and generalize Process::StandardOutIsDisplayed and friends in order to
support it.

Also, call RemoveFileOnSignal before creating a file instead of after, so
that the file isn't left behind if the program is interrupted between when
the file is created and RemoveFileOnSignal is called.

While here, add a -S to llvm-extract and port it to IRReader so that it
supports assembly input.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81568 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-11 20:46:33 +00:00
Dan Gohman
baa26395cc Make LLVM command-line tools overwrite their output files without -f.
This is conventional command-line tool behavior. -f now just means
"enable binary output on terminals".

Add a -f option to llvm-extract and llvm-link, for consistency.

Remove F_Force from raw_fd_ostream and enable overwriting and
truncating by default. Introduce an F_Excl flag to permit users to
enable a failure when the file already exists. This flag is
currently unused.

Update Makefiles and documentation accordingly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79990 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 15:34:52 +00:00
Dan Gohman
cb1308b74a Correctly account for the Spaces array nul terminator. Thanks Chris!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79894 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-24 04:43:38 +00:00
Dan Gohman
61ee100b97 raw_ostream::indent is used for PadToColumn which often prints more
than 16 spaces. Make the Spaces array wide enough to handle common cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79890 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-24 04:13:01 +00:00
Chris Lattner
32e1eef631 split raw_os_ostream out to its own header and implementation file. This
means that raw_ostream no longer has to #include <iosfwd>.  Nothing in llvm
should use raw_os_ostream.h, but llvm-gcc and some unit tests do.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79886 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-24 04:02:06 +00:00
Chris Lattner
23132b188b prune the #includes in raw_ostream.h by moving a
member out of line. ftostr is not particularly speedy,
so that method is presumably not perf sensitive.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79885 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-24 03:52:50 +00:00
Daniel Dunbar
9441cfe488 Fix off-by-one in llvm::Format::print.
- This also shortens the Format.h implementation, and uses the print buffer
   fully (it was wasting a character).

 - This manifested as llvm-test failures, because one side effect was that
   raw_ostream would write garbage '\x00' values into the output stream if it
   happened that the string was at the end of the buffer. This meant that grep
   would report 'Binary file matches', which meant the silly pattern matching
   llvm-test eventually does would fail. Cute. :)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79862 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-23 20:31:39 +00:00
Benjamin Kramer
ae60324d46 Fix windows build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79845 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-23 08:57:52 +00:00
Chris Lattner
17e9edc4a7 Change raw_fd_ostream to take flags as an optional bitmask
instead of as two bools.  Use this to add a F_Append flag
which has the obvious behavior.

Other unrelated changes conflated into this patch:

1. REmove EH stuff from llvm-dis and llvm-as, the try blocks
   are dead.
2. Simplify the filename inference code in llvm-as/llvm-dis,
   because raw_fd_ostream does the right thing with '-'.
3. Switch machine verifier to use raw_ostream instead of ostream
   (Which is the thing that needed append in the first place).




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79807 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-23 02:51:22 +00:00
Chris Lattner
c5a227ddd1 add a raw_ostream::indent method, to be used like:
OS.indent(i) << "whatever";

people seem to like indenting things ;-)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79784 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-22 23:10:29 +00:00
Daniel Dunbar
d14787e497 Change raw_svector_ostream to reserve the input buffer if necessary, Ted was
right.
 - This class turns out to be much more convenient to use if we do this; clients
   can make sure the buffer is always big enough if they care (since our current
   idiom tends to be to use a SmallString<256> for the input to this we should
   generally be avoiding an unnecessary malloc).

Also, add a convenience raw_svector_ostream::str method which flushes the buffer
and returns a StringRef for the vector contents.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79446 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 18:40:58 +00:00
Daniel Dunbar
425d08c654 Switch raw_svector_ostream to use the vector as the ostream buffer.
- This avoids unnecessary malloc/free overhead in the common case, and
   unnecessary copying from the ostream buffer into the output vector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79434 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 17:54:29 +00:00
Daniel Dunbar
ecbd0bc478 Speculatively revert r79375, which may be breaking bootstrap, although in a
rather obscure way (the other candidate is r79377).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79426 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 16:25:25 +00:00
Daniel Dunbar
ecc67e2e1b raw_ostream: Simplify write(unsigned char) to match write(const char*, unsigned).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79386 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 00:23:39 +00:00
Daniel Dunbar
d29d497b53 raw_ostream: Remove pointless redefinitions of tell().
- The base class implementation is correct.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79385 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-19 00:14:25 +00:00
Daniel Dunbar
906d5b4455 raw_ostream: Add the capability for subclasses to manually install an external
buffer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79382 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-18 23:42:36 +00:00
Daniel Dunbar
3b3de924f5 Speed up raw_ostream::<<(unsigned long long) for 32-bit systems by doing most
div/mods in 32-bits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79375 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-18 22:24:00 +00:00
Dan Gohman
3731604f1f Fix a bug in raw_ostream::write(char) introduced by the change to
allow underlying stream classes to decline buffering. After
calling SetBuffered(), re-check whether the stream is Unbuffered
in order to handle the case where the underlying stream has
declined buffering.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79362 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-18 20:09:59 +00:00
Daniel Dunbar
35979c021e Revert r78924, disabling buffering defeats all the fast paths in raw_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79361 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-18 20:07:36 +00:00
Dan Gohman
b4741a7225 Mingw also doesn't have st_blksize.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 21:41:03 +00:00
Dan Gohman
d7be663d4f Always check to see if raw_fd_ostream's file descriptor is attached to
a terminal, not just when it's STDOUT_FILENO.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79066 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-15 02:05:19 +00:00
Dan Gohman
ec9b26100e When standard output is a terminal, set outs() to be unbuffered, to
mimic the behavior of stdtout, which is line-buffered when the output
is a terminal. This fixes some issues with bugpoint output appearing
being printed out of order.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78953 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 23:18:56 +00:00
Dan Gohman
c6126e8f7e Fix a compiler warning about comparing signed with unsigned.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78933 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 20:32:03 +00:00
Dan Gohman
4e8e642eaa Add an assert to check copy_to_buffer's precondition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78926 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 18:38:15 +00:00
Dan Gohman
0ba50bb056 Set raw_os_ostream, raw_string_ostream, and raw_svector_ostream to be
unbuffered. std::ostream does its own buffering, and std::string and
SmallVector both have allocation strategies intended to handle frequent
appending.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78924 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 17:41:40 +00:00
Dan Gohman
208ec0f32e Add support to raw_ostream for sizing the buffer according to the
needs of the underlying output mechanism. raw_fd_ostream now uses
st_blksize from fstat to determine a buffer size.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78923 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 17:27:29 +00:00
Dan Gohman
524dea4d4c Move SetBufferSize and SetUnbuffered out of line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78909 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 15:58:55 +00:00
Dan Gohman
33e49ef5e5 Fix the buffer handling logic so that write_impl is always called with
a full buffer, rather than often being called with a
slightly-less-than-full buffer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78907 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-13 15:44:52 +00:00
Daniel Dunbar
48018e08f0 Add raw_ostream::write_hex
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77614 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-30 18:21:23 +00:00
Daniel Dunbar
89ae98cb76 Perform simplification noticed by Reid.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77477 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 17:29:36 +00:00
Daniel Dunbar
78a3dd8fe1 raw_ostream: Follow the 32-bit path when printing "small" decimal numbers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77444 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 06:45:14 +00:00
Dan Gohman
f78c835faa Make raw_null_ostream flush its buffer in its destructor, so that
it conforms to the assertion added in r77245. This fixes a failure
in qa_override.c in clang's testsuite.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77255 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 21:46:02 +00:00
Dan Gohman
9a31254d0e Add an assertion check to raw_ostream's destructor to verify
that the subclass hasn't left any pending data in the buffer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77245 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 20:49:44 +00:00
Daniel Dunbar
34ccf037fe Add raw_null_ostream and llvm::nulls(), a raw_ostream that discards output.
- No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76103 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-16 21:17:53 +00:00