122 lines
3.0 KiB
C++
122 lines
3.0 KiB
C++
/***
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: CpuBitId.hpp
|
|
Date: 2022-1-24
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
namespace Aurora::HWInfo
|
|
{
|
|
/**
|
|
* @brief Represents one or more CPU IDs via a long bitmask as defined by your global ABI
|
|
*/
|
|
struct CpuBitId
|
|
{
|
|
AuUInt64 lower {};
|
|
AuUInt64 upper {};
|
|
#if defined(_AU_MASSIVE_CPUID)
|
|
AuUInt64 upper2 {};
|
|
AuUInt64 upper3 {};
|
|
#endif
|
|
|
|
inline CpuBitId();
|
|
inline ~CpuBitId();
|
|
|
|
inline CpuBitId(AuUInt8 id);
|
|
|
|
/**
|
|
* @brief Null check
|
|
* @return
|
|
*/
|
|
inline bool HasValue() const;
|
|
|
|
/**
|
|
* @brief Performs an OR operation on this of the input parameter.
|
|
* Effectively adds/merges a cpu bit array from one bitmap to another
|
|
* @param id
|
|
*/
|
|
inline void Add(const CpuBitId &id);
|
|
|
|
/**
|
|
* @brief Returns a new bitmap of the NOT of this
|
|
* @return
|
|
*/
|
|
inline CpuBitId Not() const;
|
|
|
|
/**
|
|
* @brief Returns a new bitmap of the AND of this and the input parameter
|
|
* @return
|
|
*/
|
|
inline CpuBitId And(const CpuBitId &id) const;
|
|
|
|
/**
|
|
* @brief Returns a new bitmap of the XOR of this and the input parameter
|
|
* @return
|
|
*/
|
|
inline CpuBitId Xor(const CpuBitId &id) const;
|
|
|
|
/**
|
|
* @brief Returns a new bitmap of the OR of this and the input parameter
|
|
* @return
|
|
*/
|
|
inline CpuBitId Or(const CpuBitId &id) const;
|
|
|
|
/**
|
|
* @brief Iteration via bitscanfwd
|
|
* @return
|
|
*/
|
|
inline bool CpuBitScanForward(AuUInt8 &index, AuUInt8 offset) const;
|
|
|
|
/**
|
|
* @brief Counts the amount of CPUs selected in the bitmap
|
|
* @return
|
|
*/
|
|
inline AuUInt8 CpuBitCount() const;
|
|
|
|
/**
|
|
* @brief Tests bit (0-max)
|
|
* @return
|
|
*/
|
|
inline bool TestCpuIdx(AuUInt8 idx) const;
|
|
|
|
/**
|
|
* @brief Sets all bits to zero
|
|
*/
|
|
inline void Clear();
|
|
|
|
inline void SetBit(AuUInt8 idx);
|
|
|
|
inline void ClearBit(AuUInt8 idx);
|
|
|
|
inline bool TestBit(AuUInt8 idx) const;
|
|
|
|
inline AuString ToString() const;
|
|
|
|
inline CpuBitId &operator=(const CpuBitId &id);
|
|
|
|
inline operator bool() const;
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
|
|
/**
|
|
* @brief Returns each modern CpuSet-id of each bit in the bitmap
|
|
* @return
|
|
*/
|
|
inline AuList<unsigned long> ToCpuSets() const;
|
|
|
|
/**
|
|
* @brief Calculates the GROUP_AFFINITY of the bitmap for older Win32 apis
|
|
* @return
|
|
*/
|
|
inline void ToMsWin7GroupAffinity(void *ptr) const;
|
|
|
|
#endif
|
|
};
|
|
}
|
|
|
|
#include "CpuBitId.inl"
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
#include "CpuBitId.NT.inl"
|
|
#endif |