<div dir="ltr"><div dir="ltr">Thanks! <div>I've reapplied the patch with your suggestions in 340969.</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 29, 2018 at 5:41 AM Hans Wennborg <<a href="mailto:hans@chromium.org">hans@chromium.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The test doesn't pass on Windows (see below). I've reverted this and<br>
the follow-up in r340924<br>
<br>
On Wed, Aug 29, 2018 at 1:32 AM, Kostya Serebryany via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Author: kcc<br>
> Date: Tue Aug 28 16:32:56 2018<br>
> New Revision: 340884<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=340884&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=340884&view=rev</a><br>
> Log:<br>
> Add a RingBuffer class to sanitizer_common<br>
><br>
> Summary: a constrained RingBuffer optimized for fast push<br>
><br>
> Reviewers: eugenis<br>
><br>
> Reviewed By: eugenis<br>
><br>
> Subscribers: kubamracek, mgorny, delcypher, #sanitizers, llvm-commits<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D51196" rel="noreferrer" target="_blank">https://reviews.llvm.org/D51196</a><br>
<br>
> +class RingBuffer {<br>
> + public:<br>
> +  static RingBuffer *New(uptr Size) {<br>
> +    void *Ptr = MmapOrDie(SizeInBytes(Size), "RingBuffer");<br>
> +    RingBuffer *RB = reinterpret_cast<RingBuffer*>(Ptr);<br>
> +    uptr End = reinterpret_cast<uptr>(Ptr) + SizeInBytes(Size);<br>
> +    RB->last_ = RB->next_ = reinterpret_cast<T*>(End - sizeof(T));<br>
> +    CHECK_EQ(sizeof(T) % sizeof(void*), 0U);<br>
<br>
Perhaps this should be a static_assert instead, to catch bad T's at<br>
compile-time? That would also remove the need to have death tests for<br>
this.<br>
<br>
> +TEST(RingBuffer, Construct) {<br>
> +<br>
> +  RingBuffer<long> *RBlong = RingBuffer<long>::New(20);<br>
<br>
long is 4 bytes on 64-bit windows, so doesn't pass the "multiple of<br>
sizeof(void*)" test.<br>
</blockquote></div>