Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d708fa86 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5298233 from 03448604 to qt-release

Change-Id: Idf0c79242b6afdd34bf4581710acd21167c5b7f1
parents 1d9584cc 03448604
Loading
Loading
Loading
Loading
+31 −31
Original line number Original line Diff line number Diff line
@@ -24,12 +24,12 @@
#include <utils/Trace.h>
#include <utils/Trace.h>


using ::android::base::unique_fd;
using ::android::base::unique_fd;
using ::android::BufferHubDefs::AnyClientAcquired;
using ::android::BufferHubDefs::isAnyClientAcquired;
using ::android::BufferHubDefs::AnyClientGained;
using ::android::BufferHubDefs::isAnyClientGained;
using ::android::BufferHubDefs::IsClientAcquired;
using ::android::BufferHubDefs::isClientAcquired;
using ::android::BufferHubDefs::IsClientGained;
using ::android::BufferHubDefs::isClientGained;
using ::android::BufferHubDefs::IsClientPosted;
using ::android::BufferHubDefs::isClientPosted;
using ::android::BufferHubDefs::IsClientReleased;
using ::android::BufferHubDefs::isClientReleased;
using ::android::frameworks::bufferhub::V1_0::BufferHubStatus;
using ::android::frameworks::bufferhub::V1_0::BufferHubStatus;
using ::android::frameworks::bufferhub::V1_0::BufferTraits;
using ::android::frameworks::bufferhub::V1_0::BufferTraits;
using ::android::frameworks::bufferhub::V1_0::IBufferClient;
using ::android::frameworks::bufferhub::V1_0::IBufferClient;
@@ -39,22 +39,22 @@ using ::android::hardware::graphics::common::V1_2::HardwareBufferDescription;


namespace android {
namespace android {


std::unique_ptr<BufferHubBuffer> BufferHubBuffer::Create(uint32_t width, uint32_t height,
std::unique_ptr<BufferHubBuffer> BufferHubBuffer::create(uint32_t width, uint32_t height,
                                                         uint32_t layerCount, uint32_t format,
                                                         uint32_t layerCount, uint32_t format,
                                                         uint64_t usage, size_t userMetadataSize) {
                                                         uint64_t usage, size_t userMetadataSize) {
    auto buffer = std::unique_ptr<BufferHubBuffer>(
    auto buffer = std::unique_ptr<BufferHubBuffer>(
            new BufferHubBuffer(width, height, layerCount, format, usage, userMetadataSize));
            new BufferHubBuffer(width, height, layerCount, format, usage, userMetadataSize));
    return buffer->IsValid() ? std::move(buffer) : nullptr;
    return buffer->isValid() ? std::move(buffer) : nullptr;
}
}


std::unique_ptr<BufferHubBuffer> BufferHubBuffer::Import(const native_handle_t* token) {
std::unique_ptr<BufferHubBuffer> BufferHubBuffer::import(const native_handle_t* token) {
    if (token == nullptr) {
    if (token == nullptr) {
        ALOGE("%s: token cannot be nullptr!", __FUNCTION__);
        ALOGE("%s: token cannot be nullptr!", __FUNCTION__);
        return nullptr;
        return nullptr;
    }
    }


    auto buffer = std::unique_ptr<BufferHubBuffer>(new BufferHubBuffer(token));
    auto buffer = std::unique_ptr<BufferHubBuffer>(new BufferHubBuffer(token));
    return buffer->IsValid() ? std::move(buffer) : nullptr;
    return buffer->isValid() ? std::move(buffer) : nullptr;
}
}


BufferHubBuffer::BufferHubBuffer(uint32_t width, uint32_t height, uint32_t layerCount,
BufferHubBuffer::BufferHubBuffer(uint32_t width, uint32_t height, uint32_t layerCount,
@@ -169,8 +169,8 @@ int BufferHubBuffer::initWithBufferTraits(const BufferTraits& bufferTraits) {


    // Import fds. Dup fds because hidl_handle owns the fds.
    // Import fds. Dup fds because hidl_handle owns the fds.
    unique_fd ashmemFd(fcntl(bufferTraits.bufferInfo->data[0], F_DUPFD_CLOEXEC, 0));
    unique_fd ashmemFd(fcntl(bufferTraits.bufferInfo->data[0], F_DUPFD_CLOEXEC, 0));
    mMetadata = BufferHubMetadata::Import(std::move(ashmemFd));
    mMetadata = BufferHubMetadata::import(std::move(ashmemFd));
    if (!mMetadata.IsValid()) {
    if (!mMetadata.isValid()) {
        ALOGE("%s: Received an invalid metadata.", __FUNCTION__);
        ALOGE("%s: Received an invalid metadata.", __FUNCTION__);
        return -EINVAL;
        return -EINVAL;
    }
    }
@@ -196,20 +196,20 @@ int BufferHubBuffer::initWithBufferTraits(const BufferTraits& bufferTraits) {


    uint32_t userMetadataSize;
    uint32_t userMetadataSize;
    memcpy(&userMetadataSize, &bufferTraits.bufferInfo->data[4], sizeof(userMetadataSize));
    memcpy(&userMetadataSize, &bufferTraits.bufferInfo->data[4], sizeof(userMetadataSize));
    if (mMetadata.user_metadata_size() != userMetadataSize) {
    if (mMetadata.userMetadataSize() != userMetadataSize) {
        ALOGE("%s: user metadata size not match: expected %u, actual %zu.", __FUNCTION__,
        ALOGE("%s: user metadata size not match: expected %u, actual %zu.", __FUNCTION__,
              userMetadataSize, mMetadata.user_metadata_size());
              userMetadataSize, mMetadata.userMetadataSize());
        return -EINVAL;
        return -EINVAL;
    }
    }


    size_t metadataSize = static_cast<size_t>(mMetadata.metadata_size());
    size_t metadataSize = static_cast<size_t>(mMetadata.metadataSize());
    if (metadataSize < BufferHubDefs::kMetadataHeaderSize) {
    if (metadataSize < BufferHubDefs::kMetadataHeaderSize) {
        ALOGE("%s: metadata too small: %zu", __FUNCTION__, metadataSize);
        ALOGE("%s: metadata too small: %zu", __FUNCTION__, metadataSize);
        return -EINVAL;
        return -EINVAL;
    }
    }


    // Populate shortcuts to the atomics in metadata.
    // Populate shortcuts to the atomics in metadata.
    auto metadata_header = mMetadata.metadata_header();
    auto metadata_header = mMetadata.metadataHeader();
    mBufferState = &metadata_header->buffer_state;
    mBufferState = &metadata_header->buffer_state;
    mFenceState = &metadata_header->fence_state;
    mFenceState = &metadata_header->fence_state;
    mActiveClientsBitMask = &metadata_header->active_clients_bit_mask;
    mActiveClientsBitMask = &metadata_header->active_clients_bit_mask;
@@ -235,16 +235,16 @@ int BufferHubBuffer::initWithBufferTraits(const BufferTraits& bufferTraits) {
    return 0;
    return 0;
}
}


int BufferHubBuffer::Gain() {
int BufferHubBuffer::gain() {
    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
    if (IsClientGained(currentBufferState, mClientStateMask)) {
    if (isClientGained(currentBufferState, mClientStateMask)) {
        ALOGV("%s: Buffer is already gained by this client %" PRIx32 ".", __FUNCTION__,
        ALOGV("%s: Buffer is already gained by this client %" PRIx32 ".", __FUNCTION__,
              mClientStateMask);
              mClientStateMask);
        return 0;
        return 0;
    }
    }
    do {
    do {
        if (AnyClientGained(currentBufferState & (~mClientStateMask)) ||
        if (isAnyClientGained(currentBufferState & (~mClientStateMask)) ||
            AnyClientAcquired(currentBufferState)) {
            isAnyClientAcquired(currentBufferState)) {
            ALOGE("%s: Buffer is in use, id=%d mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
            ALOGE("%s: Buffer is in use, id=%d mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
                  __FUNCTION__, mId, mClientStateMask, currentBufferState);
                  __FUNCTION__, mId, mClientStateMask, currentBufferState);
            return -EBUSY;
            return -EBUSY;
@@ -258,11 +258,11 @@ int BufferHubBuffer::Gain() {
    return 0;
    return 0;
}
}


int BufferHubBuffer::Post() {
int BufferHubBuffer::post() {
    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
    uint32_t updatedBufferState = (~mClientStateMask) & BufferHubDefs::kHighBitsMask;
    uint32_t updatedBufferState = (~mClientStateMask) & BufferHubDefs::kHighBitsMask;
    do {
    do {
        if (!IsClientGained(currentBufferState, mClientStateMask)) {
        if (!isClientGained(currentBufferState, mClientStateMask)) {
            ALOGE("%s: Cannot post a buffer that is not gained by this client. buffer_id=%d "
            ALOGE("%s: Cannot post a buffer that is not gained by this client. buffer_id=%d "
                  "mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
                  "mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
                  __FUNCTION__, mId, mClientStateMask, currentBufferState);
                  __FUNCTION__, mId, mClientStateMask, currentBufferState);
@@ -277,16 +277,16 @@ int BufferHubBuffer::Post() {
    return 0;
    return 0;
}
}


int BufferHubBuffer::Acquire() {
int BufferHubBuffer::acquire() {
    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
    if (IsClientAcquired(currentBufferState, mClientStateMask)) {
    if (isClientAcquired(currentBufferState, mClientStateMask)) {
        ALOGV("%s: Buffer is already acquired by this client %" PRIx32 ".", __FUNCTION__,
        ALOGV("%s: Buffer is already acquired by this client %" PRIx32 ".", __FUNCTION__,
              mClientStateMask);
              mClientStateMask);
        return 0;
        return 0;
    }
    }
    uint32_t updatedBufferState = 0U;
    uint32_t updatedBufferState = 0U;
    do {
    do {
        if (!IsClientPosted(currentBufferState, mClientStateMask)) {
        if (!isClientPosted(currentBufferState, mClientStateMask)) {
            ALOGE("%s: Cannot acquire a buffer that is not in posted state. buffer_id=%d "
            ALOGE("%s: Cannot acquire a buffer that is not in posted state. buffer_id=%d "
                  "mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
                  "mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
                  __FUNCTION__, mId, mClientStateMask, currentBufferState);
                  __FUNCTION__, mId, mClientStateMask, currentBufferState);
@@ -301,9 +301,9 @@ int BufferHubBuffer::Acquire() {
    return 0;
    return 0;
}
}


int BufferHubBuffer::Release() {
int BufferHubBuffer::release() {
    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
    if (IsClientReleased(currentBufferState, mClientStateMask)) {
    if (isClientReleased(currentBufferState, mClientStateMask)) {
        ALOGV("%s: Buffer is already released by this client %" PRIx32 ".", __FUNCTION__,
        ALOGV("%s: Buffer is already released by this client %" PRIx32 ".", __FUNCTION__,
              mClientStateMask);
              mClientStateMask);
        return 0;
        return 0;
@@ -318,17 +318,17 @@ int BufferHubBuffer::Release() {
    return 0;
    return 0;
}
}


bool BufferHubBuffer::IsReleased() const {
bool BufferHubBuffer::isReleased() const {
    return (mBufferState->load(std::memory_order_acquire) &
    return (mBufferState->load(std::memory_order_acquire) &
            mActiveClientsBitMask->load(std::memory_order_acquire)) == 0;
            mActiveClientsBitMask->load(std::memory_order_acquire)) == 0;
}
}


bool BufferHubBuffer::IsValid() const {
bool BufferHubBuffer::isValid() const {
    return mBufferHandle.getNativeHandle() != nullptr && mId >= 0 && mClientStateMask != 0U &&
    return mBufferHandle.getNativeHandle() != nullptr && mId >= 0 && mClientStateMask != 0U &&
            mEventFd.get() >= 0 && mMetadata.IsValid() && mBufferClient != nullptr;
            mEventFd.get() >= 0 && mMetadata.isValid() && mBufferClient != nullptr;
}
}


native_handle_t* BufferHubBuffer::Duplicate() {
native_handle_t* BufferHubBuffer::duplicate() {
    if (mBufferClient == nullptr) {
    if (mBufferClient == nullptr) {
        ALOGE("%s: missing BufferClient!", __FUNCTION__);
        ALOGE("%s: missing BufferClient!", __FUNCTION__);
        return nullptr;
        return nullptr;
+4 −4
Original line number Original line Diff line number Diff line
@@ -34,7 +34,7 @@ using BufferHubDefs::kMetadataHeaderSize;
using BufferHubDefs::MetadataHeader;
using BufferHubDefs::MetadataHeader;


/* static */
/* static */
BufferHubMetadata BufferHubMetadata::Create(size_t userMetadataSize) {
BufferHubMetadata BufferHubMetadata::create(size_t userMetadataSize) {
    // The size the of metadata buffer is used as the "width" parameter during allocation. Thus it
    // The size the of metadata buffer is used as the "width" parameter during allocation. Thus it
    // cannot overflow uint32_t.
    // cannot overflow uint32_t.
    if (userMetadataSize >= (std::numeric_limits<uint32_t>::max() - kMetadataHeaderSize)) {
    if (userMetadataSize >= (std::numeric_limits<uint32_t>::max() - kMetadataHeaderSize)) {
@@ -59,11 +59,11 @@ BufferHubMetadata BufferHubMetadata::Create(size_t userMetadataSize) {
        return {};
        return {};
    }
    }


    return BufferHubMetadata::Import(std::move(ashmemFd));
    return BufferHubMetadata::import(std::move(ashmemFd));
}
}


/* static */
/* static */
BufferHubMetadata BufferHubMetadata::Import(unique_fd ashmemFd) {
BufferHubMetadata BufferHubMetadata::import(unique_fd ashmemFd) {
    if (!ashmem_valid(ashmemFd.get())) {
    if (!ashmem_valid(ashmemFd.get())) {
        ALOGE("BufferHubMetadata::Import: invalid ashmem fd.");
        ALOGE("BufferHubMetadata::Import: invalid ashmem fd.");
        return {};
        return {};
@@ -94,7 +94,7 @@ BufferHubMetadata::BufferHubMetadata(size_t userMetadataSize, unique_fd ashmemFd


BufferHubMetadata::~BufferHubMetadata() {
BufferHubMetadata::~BufferHubMetadata() {
    if (mMetadataHeader != nullptr) {
    if (mMetadataHeader != nullptr) {
        int ret = munmap(mMetadataHeader, metadata_size());
        int ret = munmap(mMetadataHeader, metadataSize());
        ALOGE_IF(ret != 0,
        ALOGE_IF(ret != 0,
                 "BufferHubMetadata::~BufferHubMetadata: failed to unmap ashmem, error=%d.", errno);
                 "BufferHubMetadata::~BufferHubMetadata: failed to unmap ashmem, error=%d.", errno);
        mMetadataHeader = nullptr;
        mMetadataHeader = nullptr;
+1 −1
Original line number Original line Diff line number Diff line
@@ -100,7 +100,7 @@ GraphicBuffer::GraphicBuffer(std::unique_ptr<BufferHubBuffer> buffer) : GraphicB
        return;
        return;
    }
    }


    mInitCheck = initWithHandle(buffer->DuplicateHandle(), /*method=*/TAKE_UNREGISTERED_HANDLE,
    mInitCheck = initWithHandle(buffer->duplicateHandle(), /*method=*/TAKE_UNREGISTERED_HANDLE,
                                buffer->desc().width, buffer->desc().height,
                                buffer->desc().width, buffer->desc().height,
                                static_cast<PixelFormat>(buffer->desc().format),
                                static_cast<PixelFormat>(buffer->desc().format),
                                buffer->desc().layers, buffer->desc().usage, buffer->desc().stride);
                                buffer->desc().layers, buffer->desc().usage, buffer->desc().stride);
+14 −14
Original line number Original line Diff line number Diff line
@@ -29,14 +29,14 @@ namespace android {
class BufferHubBuffer {
class BufferHubBuffer {
public:
public:
    // Allocates a standalone BufferHubBuffer.
    // Allocates a standalone BufferHubBuffer.
    static std::unique_ptr<BufferHubBuffer> Create(uint32_t width, uint32_t height,
    static std::unique_ptr<BufferHubBuffer> create(uint32_t width, uint32_t height,
                                                   uint32_t layerCount, uint32_t format,
                                                   uint32_t layerCount, uint32_t format,
                                                   uint64_t usage, size_t userMetadataSize);
                                                   uint64_t usage, size_t userMetadataSize);


    // Imports the given token to a BufferHubBuffer. Not taking ownership of the token. Caller
    // Imports the given token to a BufferHubBuffer. Not taking ownership of the token. Caller
    // should close and destroy the token after calling this function regardless of output.
    // should close and destroy the token after calling this function regardless of output.
    // TODO(b/122543147): use a movable wrapper for token
    // TODO(b/122543147): use a movable wrapper for token
    static std::unique_ptr<BufferHubBuffer> Import(const native_handle_t* token);
    static std::unique_ptr<BufferHubBuffer> import(const native_handle_t* token);


    BufferHubBuffer(const BufferHubBuffer&) = delete;
    BufferHubBuffer(const BufferHubBuffer&) = delete;
    void operator=(const BufferHubBuffer&) = delete;
    void operator=(const BufferHubBuffer&) = delete;
@@ -52,51 +52,51 @@ public:


    // Duplicate the underlying Gralloc buffer handle. Caller is responsible to free the handle
    // Duplicate the underlying Gralloc buffer handle. Caller is responsible to free the handle
    // after use.
    // after use.
    native_handle_t* DuplicateHandle() {
    native_handle_t* duplicateHandle() {
        return native_handle_clone(mBufferHandle.getNativeHandle());
        return native_handle_clone(mBufferHandle.getNativeHandle());
    }
    }


    const BufferHubEventFd& eventFd() const { return mEventFd; }
    const BufferHubEventFd& eventFd() const { return mEventFd; }


    // Returns the current value of MetadataHeader::buffer_state.
    // Returns the current value of MetadataHeader::buffer_state.
    uint32_t buffer_state() const { return mBufferState->load(std::memory_order_acquire); }
    uint32_t bufferState() const { return mBufferState->load(std::memory_order_acquire); }


    // A state mask which is unique to a buffer hub client among all its siblings sharing the same
    // A state mask which is unique to a buffer hub client among all its siblings sharing the same
    // concrete graphic buffer.
    // concrete graphic buffer.
    uint32_t client_state_mask() const { return mClientStateMask; }
    uint32_t clientStateMask() const { return mClientStateMask; }


    size_t user_metadata_size() const { return mMetadata.user_metadata_size(); }
    size_t userMetadataSize() const { return mMetadata.userMetadataSize(); }


    // Returns true if the BufferClient is still alive.
    // Returns true if the BufferClient is still alive.
    bool IsConnected() const { return mBufferClient->ping().isOk(); }
    bool isConnected() const { return mBufferClient->ping().isOk(); }


    // Returns true if the buffer is valid: non-null buffer handle, valid id, valid client bit mask,
    // Returns true if the buffer is valid: non-null buffer handle, valid id, valid client bit mask,
    // valid metadata and valid buffer client
    // valid metadata and valid buffer client
    bool IsValid() const;
    bool isValid() const;


    // Gains the buffer for exclusive write permission. Read permission is implied once a buffer is
    // Gains the buffer for exclusive write permission. Read permission is implied once a buffer is
    // gained.
    // gained.
    // The buffer can be gained as long as there is no other client in acquired or gained state.
    // The buffer can be gained as long as there is no other client in acquired or gained state.
    int Gain();
    int gain();


    // Posts the gained buffer for other buffer clients to use the buffer.
    // Posts the gained buffer for other buffer clients to use the buffer.
    // The buffer can be posted iff the buffer state for this client is gained.
    // The buffer can be posted iff the buffer state for this client is gained.
    // After posting the buffer, this client is put to released state and does not have access to
    // After posting the buffer, this client is put to released state and does not have access to
    // the buffer for this cycle of the usage of the buffer.
    // the buffer for this cycle of the usage of the buffer.
    int Post();
    int post();


    // Acquires the buffer for shared read permission.
    // Acquires the buffer for shared read permission.
    // The buffer can be acquired iff the buffer state for this client is posted.
    // The buffer can be acquired iff the buffer state for this client is posted.
    int Acquire();
    int acquire();


    // Releases the buffer.
    // Releases the buffer.
    // The buffer can be released from any buffer state.
    // The buffer can be released from any buffer state.
    // After releasing the buffer, this client no longer have any permissions to the buffer for the
    // After releasing the buffer, this client no longer have any permissions to the buffer for the
    // current cycle of the usage of the buffer.
    // current cycle of the usage of the buffer.
    int Release();
    int release();


    // Returns whether the buffer is released by all active clients or not.
    // Returns whether the buffer is released by all active clients or not.
    bool IsReleased() const;
    bool isReleased() const;


    // Creates a token that stands for this BufferHubBuffer client and could be used for Import to
    // Creates a token that stands for this BufferHubBuffer client and could be used for Import to
    // create another BufferHubBuffer. The new BufferHubBuffer will share the same underlying
    // create another BufferHubBuffer. The new BufferHubBuffer will share the same underlying
@@ -104,7 +104,7 @@ public:
    // should free it after use.
    // should free it after use.
    // Returns a valid token on success, nullptr on failure.
    // Returns a valid token on success, nullptr on failure.
    // TODO(b/122543147): use a movable wrapper for token
    // TODO(b/122543147): use a movable wrapper for token
    native_handle_t* Duplicate();
    native_handle_t* duplicate();


private:
private:
    BufferHubBuffer(uint32_t width, uint32_t height, uint32_t layerCount, uint32_t format,
    BufferHubBuffer(uint32_t width, uint32_t height, uint32_t layerCount, uint32_t format,
+8 −8
Original line number Original line Diff line number Diff line
@@ -63,19 +63,19 @@ static constexpr uint32_t kHighBitsMask = ~kLowbitsMask;
static constexpr uint32_t kFirstClientBitMask = (1U << kMaxNumberOfClients) + 1U;
static constexpr uint32_t kFirstClientBitMask = (1U << kMaxNumberOfClients) + 1U;


// Returns true if any of the client is in gained state.
// Returns true if any of the client is in gained state.
static inline bool AnyClientGained(uint32_t state) {
static inline bool isAnyClientGained(uint32_t state) {
    uint32_t high_bits = state >> kMaxNumberOfClients;
    uint32_t high_bits = state >> kMaxNumberOfClients;
    uint32_t low_bits = state & kLowbitsMask;
    uint32_t low_bits = state & kLowbitsMask;
    return high_bits == low_bits && low_bits != 0U;
    return high_bits == low_bits && low_bits != 0U;
}
}


// Returns true if the input client is in gained state.
// Returns true if the input client is in gained state.
static inline bool IsClientGained(uint32_t state, uint32_t client_bit_mask) {
static inline bool isClientGained(uint32_t state, uint32_t client_bit_mask) {
    return state == client_bit_mask;
    return state == client_bit_mask;
}
}


// Returns true if any of the client is in posted state.
// Returns true if any of the client is in posted state.
static inline bool AnyClientPosted(uint32_t state) {
static inline bool isAnyClientPosted(uint32_t state) {
    uint32_t high_bits = state >> kMaxNumberOfClients;
    uint32_t high_bits = state >> kMaxNumberOfClients;
    uint32_t low_bits = state & kLowbitsMask;
    uint32_t low_bits = state & kLowbitsMask;
    uint32_t posted_or_acquired = high_bits ^ low_bits;
    uint32_t posted_or_acquired = high_bits ^ low_bits;
@@ -83,7 +83,7 @@ static inline bool AnyClientPosted(uint32_t state) {
}
}


// Returns true if the input client is in posted state.
// Returns true if the input client is in posted state.
static inline bool IsClientPosted(uint32_t state, uint32_t client_bit_mask) {
static inline bool isClientPosted(uint32_t state, uint32_t client_bit_mask) {
    uint32_t client_bits = state & client_bit_mask;
    uint32_t client_bits = state & client_bit_mask;
    if (client_bits == 0U) return false;
    if (client_bits == 0U) return false;
    uint32_t low_bits = client_bits & kLowbitsMask;
    uint32_t low_bits = client_bits & kLowbitsMask;
@@ -91,7 +91,7 @@ static inline bool IsClientPosted(uint32_t state, uint32_t client_bit_mask) {
}
}


// Return true if any of the client is in acquired state.
// Return true if any of the client is in acquired state.
static inline bool AnyClientAcquired(uint32_t state) {
static inline bool isAnyClientAcquired(uint32_t state) {
    uint32_t high_bits = state >> kMaxNumberOfClients;
    uint32_t high_bits = state >> kMaxNumberOfClients;
    uint32_t low_bits = state & kLowbitsMask;
    uint32_t low_bits = state & kLowbitsMask;
    uint32_t posted_or_acquired = high_bits ^ low_bits;
    uint32_t posted_or_acquired = high_bits ^ low_bits;
@@ -99,7 +99,7 @@ static inline bool AnyClientAcquired(uint32_t state) {
}
}


// Return true if the input client is in acquired state.
// Return true if the input client is in acquired state.
static inline bool IsClientAcquired(uint32_t state, uint32_t client_bit_mask) {
static inline bool isClientAcquired(uint32_t state, uint32_t client_bit_mask) {
    uint32_t client_bits = state & client_bit_mask;
    uint32_t client_bits = state & client_bit_mask;
    if (client_bits == 0U) return false;
    if (client_bits == 0U) return false;
    uint32_t high_bits = client_bits & kHighBitsMask;
    uint32_t high_bits = client_bits & kHighBitsMask;
@@ -107,13 +107,13 @@ static inline bool IsClientAcquired(uint32_t state, uint32_t client_bit_mask) {
}
}


// Returns true if the input client is in released state.
// Returns true if the input client is in released state.
static inline bool IsClientReleased(uint32_t state, uint32_t client_bit_mask) {
static inline bool isClientReleased(uint32_t state, uint32_t client_bit_mask) {
    return (state & client_bit_mask) == 0U;
    return (state & client_bit_mask) == 0U;
}
}


// Returns the next available buffer client's client_state_masks.
// Returns the next available buffer client's client_state_masks.
// @params union_bits. Union of all existing clients' client_state_masks.
// @params union_bits. Union of all existing clients' client_state_masks.
static inline uint32_t FindNextAvailableClientStateMask(uint32_t union_bits) {
static inline uint32_t findNextAvailableClientStateMask(uint32_t union_bits) {
    uint32_t low_union = union_bits & kLowbitsMask;
    uint32_t low_union = union_bits & kLowbitsMask;
    if (low_union == kLowbitsMask) return 0U;
    if (low_union == kLowbitsMask) return 0U;
    uint32_t incremented = low_union + 1U;
    uint32_t incremented = low_union + 1U;
Loading