mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
Change-Id: If965c79d70392db26597aea4c2f3b7ae2820fe96 Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
30 lines
633 B
C++
30 lines
633 B
C++
/*
|
|
* Copyright (C) 2019 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include <cassert>
|
|
#include <cstdint>
|
|
#include <limits>
|
|
|
|
namespace NEO {
|
|
|
|
constexpr bool isBitSet(uint64_t field, uint64_t bitPosition) {
|
|
assert(bitPosition < std::numeric_limits<uint64_t>::digits); // undefined behavior
|
|
return (field & (1ull << bitPosition));
|
|
}
|
|
|
|
constexpr bool isValueSet(uint64_t field, uint64_t value) {
|
|
assert(value != 0);
|
|
return ((field & value) == value);
|
|
}
|
|
|
|
constexpr bool isFieldValid(uint64_t field, uint64_t acceptedBits) {
|
|
return ((field & (~acceptedBits)) == 0);
|
|
}
|
|
|
|
} // namespace NEO
|