Correct formatting
Change-Id: If54521eb6f7642241441a7924434b3a54dffac2a
diff --git a/common/vsoc/lib/circqueue_impl.h b/common/vsoc/lib/circqueue_impl.h
index 154dbbb..fae406a 100644
--- a/common/vsoc/lib/circqueue_impl.h
+++ b/common/vsoc/lib/circqueue_impl.h
@@ -18,8 +18,8 @@
#include <string.h>
-#include "common/vsoc/shm/circqueue.h"
#include "common/vsoc/lib/region_signaling_interface.h"
+#include "common/vsoc/shm/circqueue.h"
namespace {
// Increases the given index until it is naturally aligned for T.
@@ -80,10 +80,7 @@
template <uint32_t SizeLog2>
intptr_t CircularQueueBase<SizeLog2>::WriteReserveLocked(
- RegionSignalingInterface* r,
- size_t bytes,
- Range* t,
- bool non_blocking) {
+ RegionSignalingInterface* r, size_t bytes, Range* t, bool non_blocking) {
// Can't write more than the buffer will hold
if (bytes > BufferSize) {
return -ENOSPC;
@@ -109,8 +106,8 @@
}
template <uint32_t SizeLog2>
-intptr_t CircularByteQueue<SizeLog2>::Read(RegionSignalingInterface* r, char* buffer_out,
- size_t max_size) {
+intptr_t CircularByteQueue<SizeLog2>::Read(RegionSignalingInterface* r,
+ char* buffer_out, size_t max_size) {
this->lock_.Lock();
this->WaitForDataLocked(r);
Range t;
@@ -131,11 +128,9 @@
}
template <uint32_t SizeLog2>
-intptr_t CircularByteQueue<SizeLog2>::Write(
- RegionSignalingInterface* r,
- const char* buffer_in,
- size_t bytes,
- bool non_blocking) {
+intptr_t CircularByteQueue<SizeLog2>::Write(RegionSignalingInterface* r,
+ const char* buffer_in, size_t bytes,
+ bool non_blocking) {
Range range;
this->lock_.Lock();
intptr_t rval = this->WriteReserveLocked(r, bytes, &range, non_blocking);
@@ -161,9 +156,8 @@
}
template <uint32_t SizeLog2, uint32_t MaxPacketSize>
-intptr_t CircularPacketQueue<SizeLog2, MaxPacketSize>::Read(RegionSignalingInterface* r,
- char* buffer_out,
- size_t max_size) {
+intptr_t CircularPacketQueue<SizeLog2, MaxPacketSize>::Read(
+ RegionSignalingInterface* r, char* buffer_out, size_t max_size) {
this->lock_.Lock();
this->WaitForDataLocked(r);
uint32_t packet_size = *reinterpret_cast<uint32_t*>(
@@ -186,9 +180,7 @@
template <uint32_t SizeLog2, uint32_t MaxPacketSize>
intptr_t CircularPacketQueue<SizeLog2, MaxPacketSize>::Write(
- RegionSignalingInterface* r,
- const char* buffer_in,
- uint32_t bytes,
+ RegionSignalingInterface* r, const char* buffer_in, uint32_t bytes,
bool non_blocking) {
if (bytes > MaxPacketSize) {
return -ENOSPC;
@@ -205,9 +197,9 @@
Range header = range;
header.end_idx = header.start_idx + sizeof(uint32_t);
uint32_t sizeof_uint32_t = sizeof(uint32_t);
- Range payload{static_cast<uint32_t>(range.start_idx + sizeof(uint32_t)),
- static_cast<uint32_t>(
- range.start_idx + sizeof(uint32_t) + bytes)};
+ Range payload{
+ static_cast<uint32_t>(range.start_idx + sizeof(uint32_t)),
+ static_cast<uint32_t>(range.start_idx + sizeof(uint32_t) + bytes)};
this->CopyInRange(reinterpret_cast<const char*>(&bytes), header);
this->CopyInRange(buffer_in, payload);
this->w_pub_ = range.end_idx;
diff --git a/common/vsoc/lib/mock_region_view.h b/common/vsoc/lib/mock_region_view.h
index b6951f7..29ccad9 100644
--- a/common/vsoc/lib/mock_region_view.h
+++ b/common/vsoc/lib/mock_region_view.h
@@ -40,7 +40,7 @@
template <typename Layout>
class MockRegionView : public vsoc::RegionSignalingInterface {
public:
- explicit MockRegionView() {};
+ explicit MockRegionView(){};
virtual ~MockRegionView() {
if (region_base_) {
free(region_base_);
@@ -83,15 +83,15 @@
// Check wait status on a specificy thread
bool IsBlocking(std::thread::id tid) {
- while(1) {
+ while (1) {
std::unique_lock<std::mutex> lock(mutex_);
if (tid_to_addr_.find(tid) != tid_to_addr_.end()) {
return true;
}
// Allow some time as tid map might not be updated yet
- while(tid_to_addr_.find(tid) == tid_to_addr_.end()) {
- if (map_changed_.wait_for(
- lock, std::chrono::seconds(kWaitTimeoutInSec)) ==
+ while (tid_to_addr_.find(tid) == tid_to_addr_.end()) {
+ if (map_changed_.wait_for(lock,
+ std::chrono::seconds(kWaitTimeoutInSec)) ==
std::cv_status::timeout) {
return false;
}
@@ -104,7 +104,7 @@
// Timeout to avoid a race on checking if a thread is blocked
static constexpr int kWaitTimeoutInSec = 5;
- void *region_base_{};
+ void* region_base_{};
std::mutex mutex_;
std::condition_variable map_changed_;
std::unordered_map<std::thread::id, uint32_t*> tid_to_addr_;
@@ -113,6 +113,5 @@
template <typename Layout>
constexpr int MockRegionView<Layout>::kWaitTimeoutInSec;
-
} // namespace test
} // namespace vsoc
diff --git a/common/vsoc/lib/region_signaling_interface.h b/common/vsoc/lib/region_signaling_interface.h
index 9adffa5..b997387 100644
--- a/common/vsoc/lib/region_signaling_interface.h
+++ b/common/vsoc/lib/region_signaling_interface.h
@@ -27,7 +27,7 @@
*/
class RegionSignalingInterface {
public:
- virtual ~RegionSignalingInterface() {};
+ virtual ~RegionSignalingInterface(){};
// Post a signal to the guest, the host, or both.
// See futex(2) FUTEX_WAKE for details.
@@ -35,7 +35,8 @@
// sides_to_signal: controls where the signal is sent
//
// signal_addr: the memory location to signal. Must be within the region.
- virtual void SendSignal(layout::Sides sides_to_signal, uint32_t* signal_addr) = 0;
+ virtual void SendSignal(layout::Sides sides_to_signal,
+ uint32_t* signal_addr) = 0;
// This implements the following:
// if (*signal_addr == last_observed_value)
@@ -48,7 +49,8 @@
// signal_addr: the memory that will be signaled. Must be within the region.
//
// last_observed_value: the value that motivated the calling code to wait.
- virtual void WaitForSignal(uint32_t* signal_addr, uint32_t last_observed_value) = 0;
+ virtual void WaitForSignal(uint32_t* signal_addr,
+ uint32_t last_observed_value) = 0;
};
} // namespace vsoc
diff --git a/common/vsoc/lib/region_view.cpp b/common/vsoc/lib/region_view.cpp
index fbd0393..5c53b12 100644
--- a/common/vsoc/lib/region_view.cpp
+++ b/common/vsoc/lib/region_view.cpp
@@ -22,9 +22,9 @@
if (stopping_) {
return;
}
- region_->ProcessSignalsFromPeer([](uint32_t* uaddr){
- syscall(SYS_futex, uaddr, FUTEX_WAKE, -1, nullptr, nullptr, 0);
- });
+ region_->ProcessSignalsFromPeer([](uint32_t* uaddr) {
+ syscall(SYS_futex, uaddr, FUTEX_WAKE, -1, nullptr, nullptr, 0);
+ });
}
}
@@ -94,7 +94,7 @@
if (offset) {
bool round_trip = offset & UADDR_OFFSET_ROUND_TRIP_FLAG;
uint32_t* uaddr =
- region_offset_to_pointer<uint32_t>(offset & UADDR_OFFSET_MASK);
+ region_offset_to_pointer<uint32_t>(offset & UADDR_OFFSET_MASK);
signal_handler(uaddr);
if (round_trip) {
SendSignalToPeer(uaddr, false);
diff --git a/common/vsoc/lib/region_view.h b/common/vsoc/lib/region_view.h
index 5210924..0c366ee 100644
--- a/common/vsoc/lib/region_view.h
+++ b/common/vsoc/lib/region_view.h
@@ -100,8 +100,7 @@
// signal_handler: An action to perform on every offset signalled by our
// peer, usually a FUTEX_WAKE call, but can be customized for other
// purposes.
- void ProcessSignalsFromPeer(
- std::function<void(uint32_t*)> signal_handler);
+ void ProcessSignalsFromPeer(std::function<void(uint32_t*)> signal_handler);
// Post a signal to the guest, the host, or both.
// See futex(2) FUTEX_WAKE for details.
@@ -142,7 +141,8 @@
std::unique_ptr<RegionWorker> StartWorker();
// Returns a pointer to the start of region data that is cast to the given
- // type. Initializers that run in the launcher use this to get a typed view of the region. Most other cases should be handled via TypedRegionView.
+ // type. Initializers that run in the launcher use this to get a typed view
+ // of the region. Most other cases should be handled via TypedRegionView.
template <typename LayoutType>
LayoutType* GetLayoutPointer() {
return this->region_offset_to_pointer<LayoutType>(
diff --git a/common/vsoc/shm/circqueue.h b/common/vsoc/shm/circqueue.h
index 5422b8e..8c5b966 100644
--- a/common/vsoc/shm/circqueue.h
+++ b/common/vsoc/shm/circqueue.h
@@ -38,6 +38,7 @@
CircularQueueBase() = delete;
CircularQueueBase(const CircularQueueBase&) = delete;
CircularQueueBase& operator=(const CircularQueueBase&) = delete;
+
protected:
/**
* Specifies a part of the queue. Note, the given indexes must be masked
@@ -79,10 +80,8 @@
* bytes > the queue size, -EWOULDBLOCK indicates that the call would block
* waiting for space but was requested non bloking.
*/
- intptr_t WriteReserveLocked(RegionSignalingInterface* r,
- size_t bytes,
- Range* t,
- bool non_blocking);
+ intptr_t WriteReserveLocked(RegionSignalingInterface* r, size_t bytes,
+ Range* t, bool non_blocking);
// Note: Both of these fields may hold values larger than the buffer size,
// they should be interpreted modulo the buffer size. This fact along with the
@@ -110,7 +109,8 @@
/**
* Read at most max_size bytes from the qeueue, placing them in buffer_out
*/
- intptr_t Read(RegionSignalingInterface* r, char* buffer_out, std::size_t max_size);
+ intptr_t Read(RegionSignalingInterface* r, char* buffer_out,
+ std::size_t max_size);
/**
* Write all of the given bytes into the queue. If non_blocking isn't set the
* call may block until there is enough available space in the queue. On
@@ -119,10 +119,8 @@
* write. -EWOULDBLOCK: If non_blocking is true and there is not enough free
* space.
*/
- intptr_t Write(RegionSignalingInterface* r,
- const char* buffer_in,
- std::size_t bytes,
- bool non_blocking = false);
+ intptr_t Write(RegionSignalingInterface* r, const char* buffer_in,
+ std::size_t bytes, bool non_blocking = false);
protected:
using Range = typename CircularQueueBase<SizeLog2>::Range;
@@ -143,7 +141,8 @@
* If max_size indicates that buffer_out cannot hold the entire packet
* this function will return -ENOSPC.
*/
- intptr_t Read(RegionSignalingInterface* r, char* buffer_out, std::size_t max_size);
+ intptr_t Read(RegionSignalingInterface* r, char* buffer_out,
+ std::size_t max_size);
/**
* Writes [buffer_in, buffer_in + bytes) to the queue.
@@ -152,10 +151,8 @@
* If non_blocking is true and there is not enogh free space on the queue to
* write all the data -EWOULDBLOCK will be returned.
*/
- intptr_t Write(RegionSignalingInterface* r,
- const char* buffer_in,
- uint32_t bytes,
- bool non_blocking = false);
+ intptr_t Write(RegionSignalingInterface* r, const char* buffer_in,
+ uint32_t bytes, bool non_blocking = false);
protected:
static_assert(CircularQueueBase<SizeLog2>::BufferSize >= MaxPacketSize,
diff --git a/guest/vsoc/lib/guest_region_e2e_test.cpp b/guest/vsoc/lib/guest_region_e2e_test.cpp
index 4b71249..b91c1c1 100644
--- a/guest/vsoc/lib/guest_region_e2e_test.cpp
+++ b/guest/vsoc/lib/guest_region_e2e_test.cpp
@@ -42,7 +42,7 @@
}
template <typename View>
-void DeathTestView(View *r) {
+void DeathTestView(View* r) {
disable_tombstones();
// region.Open should never return.
EXPECT_FALSE(r->Open());
@@ -117,21 +117,21 @@
primary.SendSignal(side, &primary.data()->guest_to_host_signal);
LOG(INFO) << "Signal sent. Waiting for first signal from peer";
primary.WaitForInterrupt();
- int count = 0; // counts the number of signals received.
- primary.ProcessSignalsFromPeer([&primary, &count](uint32_t* uaddr){
- ++count;
- EXPECT_TRUE(uaddr == &primary.data()->host_to_guest_signal);
- });
+ int count = 0; // counts the number of signals received.
+ primary.ProcessSignalsFromPeer([&primary, &count](uint32_t* uaddr) {
+ ++count;
+ EXPECT_TRUE(uaddr == &primary.data()->host_to_guest_signal);
+ });
EXPECT_TRUE(count == 1);
LOG(INFO) << "Signal received on primary region";
secondary.SendSignal(side, &secondary.data()->guest_to_host_signal);
LOG(INFO) << "Signal sent. Waiting for second signal from peer";
secondary.WaitForInterrupt();
count = 0;
- secondary.ProcessSignalsFromPeer([&secondary, &count](uint32_t* uaddr){
- ++count;
- EXPECT_TRUE(uaddr == &secondary.data()->host_to_guest_signal);
- });
+ secondary.ProcessSignalsFromPeer([&secondary, &count](uint32_t* uaddr) {
+ ++count;
+ EXPECT_TRUE(uaddr == &secondary.data()->host_to_guest_signal);
+ });
EXPECT_TRUE(count == 1);
LOG(INFO) << "Signal received on secondary region";
@@ -207,8 +207,7 @@
TEST(ManagedRegionTest, ManagedRegionFailMap) {
ManagedRegionTest test;
- EXPECT_EXIT(test.testManagedRegionFailMap(),
- testing::ExitedWithCode(2),
+ EXPECT_EXIT(test.testManagedRegionFailMap(), testing::ExitedWithCode(2),
".*" DEATH_TEST_MESSAGE ".*");
}
diff --git a/host/vsoc/lib/host_region_e2e_test.cpp b/host/vsoc/lib/host_region_e2e_test.cpp
index d4f9e29..dc87f46 100644
--- a/host/vsoc/lib/host_region_e2e_test.cpp
+++ b/host/vsoc/lib/host_region_e2e_test.cpp
@@ -86,21 +86,21 @@
primary.SendSignal(side, &primary.data()->host_to_guest_signal);
LOG(INFO) << "Signal sent. Waiting for first signal from peer";
primary.WaitForInterrupt();
- int count = 0; // counts the number of signals received.
- primary.ProcessSignalsFromPeer([&primary, &count](uint32_t* uaddr){
- ++count;
- EXPECT_TRUE(uaddr == &primary.data()->guest_to_host_signal);
- });
+ int count = 0; // counts the number of signals received.
+ primary.ProcessSignalsFromPeer([&primary, &count](uint32_t* uaddr) {
+ ++count;
+ EXPECT_TRUE(uaddr == &primary.data()->guest_to_host_signal);
+ });
EXPECT_TRUE(count == 1);
LOG(INFO) << "Signal received on primary region";
secondary.SendSignal(side, &secondary.data()->host_to_guest_signal);
LOG(INFO) << "Signal sent. Waiting for second signal from peer";
secondary.WaitForInterrupt();
count = 0;
- secondary.ProcessSignalsFromPeer([&secondary, &count](uint32_t* uaddr){
- ++count;
- EXPECT_TRUE(uaddr == &secondary.data()->guest_to_host_signal);
- });
+ secondary.ProcessSignalsFromPeer([&secondary, &count](uint32_t* uaddr) {
+ ++count;
+ EXPECT_TRUE(uaddr == &secondary.data()->guest_to_host_signal);
+ });
EXPECT_TRUE(count == 1);
LOG(INFO) << "Signal received on secondary region";