[patch][rfc] Add pwrite to raw_stream

Chandler Carruth chandlerc at google.com
Wed Apr 8 20:34:28 PDT 2015


Sorry I'm late to the party, but I think I agree with Sean.

This makes absolutely no sense to me on the raw_ostream interface. That
interface is entirely about streaming output. I don't think the seek
interface makes any sense either honestly.

I think the right way to layer these things is the other way around. Build
the abstraction you want for IO, but don't tie it to raw_ostream in any
way. You could make it *also* implement the raw_ostream interface if you
want so that you can use it in that context, but I don't know why
raw_ostream would ever be aware of this.

On Wed, Apr 8, 2015 at 6:46 PM Rafael EspĂ­ndola <rafael.espindola at gmail.com>
wrote:

> On 8 April 2015 at 21:06, Sean Silva <chisophugis at gmail.com> wrote:
> >
> >
> > On Wed, Apr 8, 2015 at 5:35 PM, Rafael EspĂ­ndola
> > <rafael.espindola at gmail.com> wrote:
> >>
> >> On 8 April 2015 at 20:25, Sean Silva <chisophugis at gmail.com> wrote:
> >> > It stops being a "stream" when you add the ability to write at a
> >> > specified
> >> > offset. It's like adding operator+= to something with "outputiterator"
> >> > in
> >> > the name. Is there a reason that this has to live inside raw_ostream?
> >>
> >> The object writer has to write to something. It can do it better if
> >> that something supports at least pwrite.
> >
> >
> > Well, it's not only that; it just seems to sort of violate the whole
> idea of
> > raw_ostream:
> >
> > 00035 /// raw_ostream - This class implements an extremely fast bulk
> output
> > stream
> > 00036 /// that can *only* output to a stream.  It does not support
> seeking,
> > reopening,
> > 00037 /// rewinding, line buffered disciplines etc. It is a simple buffer
> > that outputs
> > 00038 /// a chunk at a time.
> >
> >
> > I think it would be better to not tie this directly into raw_ostream.
>
> I can update the comment to say that some of the base classes support
> pwrite. Note that raw_fd_stream already supports seek.
>
> But there is a practical need for a stream_with_pwrite and it can be
> added to the classes we need without violation the *reason* that
> comment exists: raw_ostream has to be fast.
>
> Cheers,
> Rafael
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150409/826505fa/attachment.html>


More information about the llvm-commits mailing list