summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/xray/xray_buffer_queue.h
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2017-03-22 04:40:32 +0000
committerDean Michael Berris <dberris@google.com>2017-03-22 04:40:32 +0000
commit6ba6673dfde0976f31918913507f4f86722fd1ca (patch)
tree0f14bcb37cc065aea19e7fbf8d063126f8906d9b /compiler-rt/lib/xray/xray_buffer_queue.h
parent600f04a435c6f400fd322bd7548a0e9683c90ca1 (diff)
downloadbcm5719-llvm-6ba6673dfde0976f31918913507f4f86722fd1ca.tar.gz
bcm5719-llvm-6ba6673dfde0976f31918913507f4f86722fd1ca.zip
[XRay][compiler-rt] Remove dependency on <system_error>
Summary: Depending on C++11 <system_error> introduces a link-time requirement to C++11 symbols. Removing it allows us to depend on header-only C++11 and up libraries. Partially fixes http://llvm.org/PR32274 -- we know there's more invasive work to be done, but we're doing it incrementally. Reviewers: dblaikie, kpw, pelikan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31233 llvm-svn: 298480
Diffstat (limited to 'compiler-rt/lib/xray/xray_buffer_queue.h')
-rw-r--r--compiler-rt/lib/xray/xray_buffer_queue.h37
1 files changed, 30 insertions, 7 deletions
diff --git a/compiler-rt/lib/xray/xray_buffer_queue.h b/compiler-rt/lib/xray/xray_buffer_queue.h
index 3898437e4ba..32f7ae96726 100644
--- a/compiler-rt/lib/xray/xray_buffer_queue.h
+++ b/compiler-rt/lib/xray/xray_buffer_queue.h
@@ -19,7 +19,6 @@
#include <cstdint>
#include <deque>
#include <mutex>
-#include <system_error>
#include <unordered_set>
#include <utility>
@@ -34,11 +33,11 @@ class BufferQueue {
public:
struct Buffer {
void *Buffer = nullptr;
- std::size_t Size = 0;
+ size_t Size = 0;
};
private:
- std::size_t BufferSize;
+ size_t BufferSize;
// We use a bool to indicate whether the Buffer has been used in this
// freelist implementation.
@@ -48,9 +47,33 @@ private:
std::atomic<bool> Finalizing;
public:
+ enum class ErrorCode : unsigned {
+ Ok,
+ NotEnoughMemory,
+ QueueFinalizing,
+ UnrecognizedBuffer,
+ AlreadyFinalized,
+ };
+
+ static const char *getErrorString(ErrorCode E) {
+ switch (E) {
+ case ErrorCode::Ok:
+ return "(none)";
+ case ErrorCode::NotEnoughMemory:
+ return "no available buffers in the queue";
+ case ErrorCode::QueueFinalizing:
+ return "queue already finalizing";
+ case ErrorCode::UnrecognizedBuffer:
+ return "buffer being returned not owned by buffer queue";
+ case ErrorCode::AlreadyFinalized:
+ return "queue already finalized";
+ }
+ return "unknown error";
+ }
+
/// Initialise a queue of size |N| with buffers of size |B|. We report success
/// through |Success|.
- BufferQueue(std::size_t B, std::size_t N, bool &Success);
+ BufferQueue(size_t B, size_t N, bool &Success);
/// Updates |Buf| to contain the pointer to an appropriate buffer. Returns an
/// error in case there are no available buffers to return when we will run
@@ -63,13 +86,13 @@ public:
/// - std::errc::not_enough_memory on exceeding MaxSize.
/// - no error when we find a Buffer.
/// - std::errc::state_not_recoverable on finalising BufferQueue.
- std::error_code getBuffer(Buffer &Buf);
+ ErrorCode getBuffer(Buffer &Buf);
/// Updates |Buf| to point to nullptr, with size 0.
///
/// Returns:
/// - ...
- std::error_code releaseBuffer(Buffer &Buf);
+ ErrorCode releaseBuffer(Buffer &Buf);
bool finalizing() const { return Finalizing.load(std::memory_order_acquire); }
@@ -80,7 +103,7 @@ public:
///
/// After a call to finalize succeeds, all subsequent calls to finalize will
/// fail with std::errc::state_not_recoverable.
- std::error_code finalize();
+ ErrorCode finalize();
/// Applies the provided function F to each Buffer in the queue, only if the
/// Buffer is marked 'used' (i.e. has been the result of getBuffer(...) and a
OpenPOWER on IntegriCloud