summaryrefslogtreecommitdiff
path: root/lib/xray/xray_log_interface.cc
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2017-03-17 21:56:09 +0000
committerEric Christopher <echristo@gmail.com>2017-03-17 21:56:09 +0000
commit97e140242d3085562afa1340578d5f531a82ad69 (patch)
tree01b83b21c101526f8f7a2bfe9d76b0cdc0d47284 /lib/xray/xray_log_interface.cc
parent55008eb10a1265ceff6252916850d451467451fd (diff)
parent708f1d628eae3fabb0f28c8469e73b3b57cdea0a (diff)
downloadcompiler-rt-97e140242d3085562afa1340578d5f531a82ad69.tar.gz
Updating branches/google/testing to r297704
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/branches/google/testing@298145 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/xray/xray_log_interface.cc')
-rw-r--r--lib/xray/xray_log_interface.cc57
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/xray/xray_log_interface.cc b/lib/xray/xray_log_interface.cc
new file mode 100644
index 000000000..c7cfe5080
--- /dev/null
+++ b/lib/xray/xray_log_interface.cc
@@ -0,0 +1,57 @@
+//===-- xray_log_interface.cc ---------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of XRay, a function call tracing system.
+//
+//===----------------------------------------------------------------------===//
+#include "xray/xray_log_interface.h"
+
+#include "xray/xray_interface.h"
+#include "xray_defs.h"
+
+#include <memory>
+#include <mutex>
+
+std::mutex XRayImplMutex;
+std::unique_ptr<XRayLogImpl> GlobalXRayImpl;
+
+void __xray_set_log_impl(XRayLogImpl Impl) XRAY_NEVER_INSTRUMENT {
+ if (Impl.log_init == nullptr || Impl.log_finalize == nullptr ||
+ Impl.handle_arg0 == nullptr || Impl.flush_log == nullptr) {
+ std::lock_guard<std::mutex> Guard(XRayImplMutex);
+ GlobalXRayImpl.reset();
+ return;
+ }
+
+ std::lock_guard<std::mutex> Guard(XRayImplMutex);
+ GlobalXRayImpl.reset(new XRayLogImpl);
+ *GlobalXRayImpl = Impl;
+}
+
+XRayLogInitStatus __xray_init(size_t BufferSize, size_t MaxBuffers, void *Args,
+ size_t ArgsSize) XRAY_NEVER_INSTRUMENT {
+ std::lock_guard<std::mutex> Guard(XRayImplMutex);
+ if (!GlobalXRayImpl)
+ return XRayLogInitStatus::XRAY_LOG_UNINITIALIZED;
+ return GlobalXRayImpl->log_init(BufferSize, MaxBuffers, Args, ArgsSize);
+}
+
+XRayLogInitStatus __xray_log_finalize() XRAY_NEVER_INSTRUMENT {
+ std::lock_guard<std::mutex> Guard(XRayImplMutex);
+ if (!GlobalXRayImpl)
+ return XRayLogInitStatus::XRAY_LOG_UNINITIALIZED;
+ return GlobalXRayImpl->log_finalize();
+}
+
+XRayLogFlushStatus __xray_log_flushLog() XRAY_NEVER_INSTRUMENT {
+ std::lock_guard<std::mutex> Guard(XRayImplMutex);
+ if (!GlobalXRayImpl)
+ return XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING;
+ return GlobalXRayImpl->flush_log();
+}