[compiler-rt] r340884 - Add a RingBuffer class to sanitizer_common

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 29 05:41:36 PDT 2018


The test doesn't pass on Windows (see below). I've reverted this and
the follow-up in r340924

On Wed, Aug 29, 2018 at 1:32 AM, Kostya Serebryany via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: kcc
> Date: Tue Aug 28 16:32:56 2018
> New Revision: 340884
>
> URL: http://llvm.org/viewvc/llvm-project?rev=340884&view=rev
> Log:
> Add a RingBuffer class to sanitizer_common
>
> Summary: a constrained RingBuffer optimized for fast push
>
> Reviewers: eugenis
>
> Reviewed By: eugenis
>
> Subscribers: kubamracek, mgorny, delcypher, #sanitizers, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D51196

> +class RingBuffer {
> + public:
> +  static RingBuffer *New(uptr Size) {
> +    void *Ptr = MmapOrDie(SizeInBytes(Size), "RingBuffer");
> +    RingBuffer *RB = reinterpret_cast<RingBuffer*>(Ptr);
> +    uptr End = reinterpret_cast<uptr>(Ptr) + SizeInBytes(Size);
> +    RB->last_ = RB->next_ = reinterpret_cast<T*>(End - sizeof(T));
> +    CHECK_EQ(sizeof(T) % sizeof(void*), 0U);

Perhaps this should be a static_assert instead, to catch bad T's at
compile-time? That would also remove the need to have death tests for
this.

> +TEST(RingBuffer, Construct) {
> +
> +  RingBuffer<long> *RBlong = RingBuffer<long>::New(20);

long is 4 bytes on 64-bit windows, so doesn't pass the "multiple of
sizeof(void*)" test.


More information about the llvm-commits mailing list