add static lifetime to constexpr values to force compile time evaluation where possible
Signed-off-by: arades79 <scravers@protonmail.com>
This commit is contained in:
parent
5f5a6e4b2e
commit
45e13b03f3
101 changed files with 309 additions and 303 deletions
|
@ -871,7 +871,7 @@ void Module::Interface::StoreSaveDataThumbnailApplication(Kernel::HLERequestCont
|
|||
// TODO(ogniK): Check if application ID is zero on acc initialize. As we don't have a reliable
|
||||
// way of confirming things like the TID, we're going to assume a non zero value for the time
|
||||
// being.
|
||||
constexpr u64 tid{1};
|
||||
constexpr static u64 tid{1};
|
||||
StoreSaveDataThumbnail(ctx, uuid, tid);
|
||||
}
|
||||
|
||||
|
|
|
@ -1086,7 +1086,7 @@ private:
|
|||
|
||||
// We require a non-zero handle to be valid. Using 0xdeadbeef allows us to trace if this is
|
||||
// actually used anywhere
|
||||
constexpr u64 handle = 0xdeadbeef;
|
||||
constexpr static u64 handle = 0xdeadbeef;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
|
@ -1570,7 +1570,7 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
|
|||
const auto& version = res.first->GetVersionString();
|
||||
std::copy(version.begin(), version.end(), version_string.begin());
|
||||
} else {
|
||||
constexpr char default_version[]{"1.0.0"};
|
||||
constexpr static char default_version[]{"1.0.0"};
|
||||
std::memcpy(version_string.data(), default_version, sizeof(default_version));
|
||||
}
|
||||
|
||||
|
@ -1638,7 +1638,7 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
|
|||
void IApplicationFunctions::IsGamePlayRecordingSupported(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
|
||||
constexpr bool gameplay_recording_supported = false;
|
||||
constexpr static bool gameplay_recording_supported = false;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
|
|
|
@ -1180,7 +1180,7 @@ void SoftwareKeyboard::ReplyChangedStringV2() {
|
|||
.cursor_position{current_cursor_position},
|
||||
};
|
||||
|
||||
constexpr u8 flag = 0;
|
||||
constexpr static u8 flag = 0;
|
||||
|
||||
std::memcpy(reply.data() + REPLY_BASE_SIZE, current_text.data(),
|
||||
current_text.size() * sizeof(char16_t));
|
||||
|
@ -1204,7 +1204,7 @@ void SoftwareKeyboard::ReplyMovedCursorV2() {
|
|||
.cursor_position{current_cursor_position},
|
||||
};
|
||||
|
||||
constexpr u8 flag = 0;
|
||||
constexpr static u8 flag = 0;
|
||||
|
||||
std::memcpy(reply.data() + REPLY_BASE_SIZE, current_text.data(),
|
||||
current_text.size() * sizeof(char16_t));
|
||||
|
@ -1232,7 +1232,7 @@ void SoftwareKeyboard::ReplyChangedStringUtf8V2() {
|
|||
.cursor_position{current_cursor_position},
|
||||
};
|
||||
|
||||
constexpr u8 flag = 0;
|
||||
constexpr static u8 flag = 0;
|
||||
|
||||
std::memcpy(reply.data() + REPLY_BASE_SIZE, utf8_current_text.data(), utf8_current_text.size());
|
||||
std::memcpy(reply.data() + REPLY_BASE_SIZE + REPLY_UTF8_SIZE, &changed_string_arg,
|
||||
|
@ -1257,7 +1257,7 @@ void SoftwareKeyboard::ReplyMovedCursorUtf8V2() {
|
|||
.cursor_position{current_cursor_position},
|
||||
};
|
||||
|
||||
constexpr u8 flag = 0;
|
||||
constexpr static u8 flag = 0;
|
||||
|
||||
std::memcpy(reply.data() + REPLY_BASE_SIZE, utf8_current_text.data(), utf8_current_text.size());
|
||||
std::memcpy(reply.data() + REPLY_BASE_SIZE + REPLY_UTF8_SIZE, &moved_cursor_arg,
|
||||
|
|
|
@ -56,7 +56,7 @@ void Controller::SetPerformanceConfiguration(PerformanceMode mode,
|
|||
}
|
||||
|
||||
void Controller::SetFromCpuBoostMode(CpuBoostMode mode) {
|
||||
constexpr std::array<PerformanceConfiguration, 3> BOOST_MODE_TO_CONFIG_MAP{{
|
||||
constexpr static std::array<PerformanceConfiguration, 3> BOOST_MODE_TO_CONFIG_MAP{{
|
||||
PerformanceConfiguration::Config7,
|
||||
PerformanceConfiguration::Config13,
|
||||
PerformanceConfiguration::Config15,
|
||||
|
|
|
@ -77,7 +77,7 @@ void AudCtl::GetTargetVolumeMin(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
// This service function is currently hardcoded on the
|
||||
// actual console to this value (as of 8.0.0).
|
||||
constexpr s32 target_min_volume = 0;
|
||||
constexpr static s32 target_min_volume = 0;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
|
@ -89,7 +89,7 @@ void AudCtl::GetTargetVolumeMax(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
// This service function is currently hardcoded on the
|
||||
// actual console to this value (as of 8.0.0).
|
||||
constexpr s32 target_max_volume = 15;
|
||||
constexpr static s32 target_max_volume = 15;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
|
|
|
@ -209,7 +209,7 @@ private:
|
|||
|
||||
std::size_t WorkerBufferSize(u32 channel_count) {
|
||||
ASSERT_MSG(channel_count == 1 || channel_count == 2, "Invalid channel count");
|
||||
constexpr int num_streams = 1;
|
||||
constexpr static int num_streams = 1;
|
||||
const int num_stereo_streams = channel_count == 2 ? 1 : 0;
|
||||
return opus_multistream_decoder_get_size(num_streams, num_stereo_streams);
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ void CAPS_U::GetAlbumContentsFileListForApplication(Kernel::HLERequestContext& c
|
|||
|
||||
// TODO: Update this when we implement the album.
|
||||
// Currently we do not have a method of accessing album entries, set this to 0 for now.
|
||||
constexpr u32 total_entries_1{};
|
||||
constexpr u32 total_entries_2{};
|
||||
constexpr static u32 total_entries_1{};
|
||||
constexpr static u32 total_entries_2{};
|
||||
|
||||
LOG_WARNING(
|
||||
Service_Capture,
|
||||
|
|
|
@ -942,7 +942,7 @@ void FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(
|
|||
|
||||
const auto parameters = rp.PopRaw<Parameters>();
|
||||
// Stub this to None for now, backend needs an impl to read/write the SaveDataExtraData
|
||||
constexpr auto flags = static_cast<u32>(FileSys::SaveDataFlags::None);
|
||||
constexpr static auto flags = static_cast<u32>(FileSys::SaveDataFlags::None);
|
||||
|
||||
LOG_WARNING(Service_FS,
|
||||
"(STUBBED) called, flags={}, space_id={}, attribute.title_id={:016X}\n"
|
||||
|
|
|
@ -439,7 +439,7 @@ void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) {
|
|||
using btn = Core::HID::NpadButton;
|
||||
pad_entry.npad_buttons.raw = btn::None;
|
||||
if (controller_type != Core::HID::NpadStyleIndex::JoyconLeft) {
|
||||
constexpr btn right_button_mask = btn::A | btn::B | btn::X | btn::Y | btn::StickR | btn::R |
|
||||
constexpr static btn right_button_mask = btn::A | btn::B | btn::X | btn::Y | btn::StickR | btn::R |
|
||||
btn::ZR | btn::Plus | btn::StickRLeft | btn::StickRUp |
|
||||
btn::StickRRight | btn::StickRDown;
|
||||
pad_entry.npad_buttons.raw = button_state.raw & right_button_mask;
|
||||
|
@ -447,7 +447,7 @@ void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) {
|
|||
}
|
||||
|
||||
if (controller_type != Core::HID::NpadStyleIndex::JoyconRight) {
|
||||
constexpr btn left_button_mask =
|
||||
constexpr static btn left_button_mask =
|
||||
btn::Left | btn::Up | btn::Right | btn::Down | btn::StickL | btn::L | btn::ZL |
|
||||
btn::Minus | btn::StickLLeft | btn::StickLUp | btn::StickLRight | btn::StickLDown;
|
||||
pad_entry.npad_buttons.raw |= button_state.raw & left_button_mask;
|
||||
|
@ -759,7 +759,7 @@ Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const {
|
|||
}
|
||||
|
||||
Result Controller_NPad::SetSupportedNpadIdTypes(std::span<const u8> data) {
|
||||
constexpr std::size_t max_number_npad_ids = 0xa;
|
||||
constexpr static std::size_t max_number_npad_ids = 0xa;
|
||||
const auto length = data.size();
|
||||
ASSERT(length > 0 && (length % sizeof(u32)) == 0);
|
||||
const std::size_t elements = length / sizeof(u32);
|
||||
|
|
|
@ -670,7 +670,7 @@ ResultVal<std::vector<MiiInfoElement>> MiiManager::GetDefault(SourceFlag source_
|
|||
}
|
||||
|
||||
Result MiiManager::GetIndex([[maybe_unused]] const CharInfo& info, u32& index) {
|
||||
constexpr u32 INVALID_INDEX{0xFFFFFFFF};
|
||||
constexpr static u32 INVALID_INDEX{0xFFFFFFFF};
|
||||
|
||||
index = INVALID_INDEX;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ bool IsAmiiboValid(const EncryptedNTAG215File& ntag_file) {
|
|||
LOG_DEBUG(Service_NFP, "tag_CFG1=0x{0:x}", ntag_file.CFG1);
|
||||
|
||||
// Validate UUID
|
||||
constexpr u8 CT = 0x88; // As defined in `ISO / IEC 14443 - 3`
|
||||
constexpr static u8 CT = 0x88; // As defined in `ISO / IEC 14443 - 3`
|
||||
if ((CT ^ ntag_file.uuid.uid[0] ^ ntag_file.uuid.uid[1] ^ ntag_file.uuid.uid[2]) !=
|
||||
ntag_file.uuid.uid[3]) {
|
||||
return false;
|
||||
|
@ -247,7 +247,7 @@ void Cipher(const DerivedKeys& keys, const NTAG215File& in_data, NTAG215File& ou
|
|||
mbedtls_aes_setkey_enc(&aes, keys.aes_key.data(), aes_key_size);
|
||||
memcpy(nonce_counter.data(), keys.aes_iv.data(), sizeof(keys.aes_iv));
|
||||
|
||||
constexpr std::size_t encrypted_data_size = HMAC_TAG_START - SETTINGS_START;
|
||||
constexpr static std::size_t encrypted_data_size = HMAC_TAG_START - SETTINGS_START;
|
||||
mbedtls_aes_crypt_ctr(&aes, encrypted_data_size, &nc_off, nonce_counter.data(),
|
||||
stream_block.data(),
|
||||
reinterpret_cast<const unsigned char*>(&in_data.settings),
|
||||
|
@ -317,13 +317,13 @@ bool DecodeAmiibo(const EncryptedNTAG215File& encrypted_tag_data, NTAG215File& t
|
|||
Cipher(data_keys, encoded_data, tag_data);
|
||||
|
||||
// Regenerate tag HMAC. Note: order matters, data HMAC depends on tag HMAC!
|
||||
constexpr std::size_t input_length = DYNAMIC_LOCK_START - UUID_START;
|
||||
constexpr static std::size_t input_length = DYNAMIC_LOCK_START - UUID_START;
|
||||
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), tag_keys.hmac_key.data(),
|
||||
sizeof(HmacKey), reinterpret_cast<const unsigned char*>(&tag_data.uid),
|
||||
input_length, reinterpret_cast<unsigned char*>(&tag_data.hmac_tag));
|
||||
|
||||
// Regenerate data HMAC
|
||||
constexpr std::size_t input_length2 = DYNAMIC_LOCK_START - WRITE_COUNTER_START;
|
||||
constexpr static std::size_t input_length2 = DYNAMIC_LOCK_START - WRITE_COUNTER_START;
|
||||
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), data_keys.hmac_key.data(),
|
||||
sizeof(HmacKey),
|
||||
reinterpret_cast<const unsigned char*>(&tag_data.write_counter), input_length2,
|
||||
|
@ -357,8 +357,8 @@ bool EncodeAmiibo(const NTAG215File& tag_data, EncryptedNTAG215File& encrypted_t
|
|||
NTAG215File encoded_tag_data{};
|
||||
|
||||
// Generate tag HMAC
|
||||
constexpr std::size_t input_length = DYNAMIC_LOCK_START - UUID_START;
|
||||
constexpr std::size_t input_length2 = HMAC_TAG_START - WRITE_COUNTER_START;
|
||||
constexpr static std::size_t input_length = DYNAMIC_LOCK_START - UUID_START;
|
||||
constexpr static std::size_t input_length2 = HMAC_TAG_START - WRITE_COUNTER_START;
|
||||
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), tag_keys.hmac_key.data(),
|
||||
sizeof(HmacKey), reinterpret_cast<const unsigned char*>(&tag_data.uid),
|
||||
input_length, reinterpret_cast<unsigned char*>(&encoded_tag_data.hmac_tag));
|
||||
|
|
|
@ -512,7 +512,7 @@ void IGeneralService::GetInternetConnectionStatus(Kernel::HLERequestContext& ctx
|
|||
};
|
||||
static_assert(sizeof(Output) == 0x3, "Output has incorrect size.");
|
||||
|
||||
constexpr Output out{};
|
||||
constexpr static Output out{};
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
namespace Service::Nvidia::NvCore {
|
||||
|
||||
SyncpointManager::SyncpointManager(Tegra::Host1x::Host1x& host1x_) : host1x{host1x_} {
|
||||
constexpr u32 VBlank0SyncpointId{26};
|
||||
constexpr u32 VBlank1SyncpointId{27};
|
||||
constexpr static u32 VBlank0SyncpointId{26};
|
||||
constexpr static u32 VBlank1SyncpointId{27};
|
||||
|
||||
// Reserve both vblank syncpoints as client managed as they use Continuous Mode
|
||||
// Refer to section 14.3.5.3 of the TRM for more information on Continuous Mode
|
||||
|
|
|
@ -45,7 +45,7 @@ Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer,
|
|||
|
||||
// If expected_present is specified, we may not want to return a buffer yet.
|
||||
if (expected_present.count() != 0) {
|
||||
constexpr auto MAX_REASONABLE_NSEC = 1000000000LL; // 1 second
|
||||
constexpr static auto MAX_REASONABLE_NSEC = 1000000000LL; // 1 second
|
||||
|
||||
// The expected_present argument indicates when the buffer is expected to be presented
|
||||
// on-screen.
|
||||
|
|
|
@ -55,7 +55,7 @@ private:
|
|||
LOG_WARNING(Service_OLSC, "(STUBBED) called");
|
||||
|
||||
// backup_setting is set to 0 since real value is unknown
|
||||
constexpr u64 backup_setting = 0;
|
||||
constexpr static u64 backup_setting = 0;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
|
|
|
@ -116,7 +116,7 @@ private:
|
|||
void GetTransmissionStatus(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_PREPO, "(STUBBED) called");
|
||||
|
||||
constexpr s32 status = 0;
|
||||
constexpr static s32 status = 0;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
|
@ -126,7 +126,7 @@ private:
|
|||
void GetSystemSessionId(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_PREPO, "(STUBBED) called");
|
||||
|
||||
constexpr u64 system_session_id = 0;
|
||||
constexpr static u64 system_session_id = 0;
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(system_session_id);
|
||||
|
|
|
@ -92,7 +92,7 @@ static std::vector<u8> SerializeAddrInfo(const addrinfo* addrinfo, s32 result_co
|
|||
static_assert(sizeof(SerializedResponseHeader) == 0x18,
|
||||
"Response header size must be 0x18 bytes");
|
||||
|
||||
constexpr auto header_size = sizeof(SerializedResponseHeader);
|
||||
constexpr static auto header_size = sizeof(SerializedResponseHeader);
|
||||
const auto addr_size =
|
||||
current->ai_addr && current->ai_addrlen > 0 ? current->ai_addrlen : 4;
|
||||
const auto canonname_size = current->ai_canonname ? strlen(current->ai_canonname) + 1 : 1;
|
||||
|
@ -103,7 +103,7 @@ static std::vector<u8> SerializeAddrInfo(const addrinfo* addrinfo, s32 result_co
|
|||
// Header in network byte order
|
||||
SerializedResponseHeader header{};
|
||||
|
||||
constexpr auto HEADER_MAGIC = 0xBEEFCAFE;
|
||||
constexpr static auto HEADER_MAGIC = 0xBEEFCAFE;
|
||||
header.magic = htonl(HEADER_MAGIC);
|
||||
header.family = htonl(current->ai_family);
|
||||
header.flags = htonl(current->ai_flags);
|
||||
|
|
|
@ -103,7 +103,7 @@ private:
|
|||
const auto certificate_format = rp.PopEnum<CertificateFormat>();
|
||||
[[maybe_unused]] const auto pkcs_12_certificates = ctx.ReadBuffer(0);
|
||||
|
||||
constexpr u64 server_id = 0;
|
||||
constexpr static u64 server_id = 0;
|
||||
|
||||
LOG_WARNING(Service_SSL, "(STUBBED) called, certificate_format={}", certificate_format);
|
||||
|
||||
|
@ -122,7 +122,7 @@ private:
|
|||
return std::span<const u8>{};
|
||||
}();
|
||||
|
||||
constexpr u64 client_id = 0;
|
||||
constexpr static u64 client_id = 0;
|
||||
|
||||
LOG_WARNING(Service_SSL, "(STUBBED) called");
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ static constexpr int TransitionTime(int year, Rule rule, int offset) {
|
|||
}
|
||||
|
||||
static bool ParsePosixName(const char* name, TimeZoneRule& rule) {
|
||||
constexpr char default_rule[]{",M4.1.0,M10.5.0"};
|
||||
constexpr static char default_rule[]{",M4.1.0,M10.5.0"};
|
||||
const char* std_name{name};
|
||||
int std_len{};
|
||||
int offset{};
|
||||
|
@ -512,8 +512,8 @@ static bool ParseTimeZoneBinary(TimeZoneRule& time_zone_rule, FileSys::VirtualFi
|
|||
return {};
|
||||
}
|
||||
|
||||
constexpr s32 time_zone_max_leaps{50};
|
||||
constexpr s32 time_zone_max_chars{50};
|
||||
constexpr static s32 time_zone_max_leaps{50};
|
||||
constexpr static s32 time_zone_max_chars{50};
|
||||
if (!(0 <= header.leap_count && header.leap_count < time_zone_max_leaps &&
|
||||
0 < header.type_count && header.type_count < s32(time_zone_rule.ttis.size()) &&
|
||||
0 <= header.time_count && header.time_count < s32(time_zone_rule.ats.size()) &&
|
||||
|
@ -610,7 +610,7 @@ static bool ParseTimeZoneBinary(TimeZoneRule& time_zone_rule, FileSys::VirtualFi
|
|||
if (bytes_read < 0) {
|
||||
return {};
|
||||
}
|
||||
constexpr s32 time_zone_name_max{255};
|
||||
constexpr static s32 time_zone_name_max{255};
|
||||
if (bytes_read > (time_zone_name_max + 1)) {
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -725,8 +725,8 @@ private:
|
|||
|
||||
// TODO: Figure out what these are
|
||||
|
||||
constexpr s64 unknown_result_1 = 0;
|
||||
constexpr s64 unknown_result_2 = 0;
|
||||
constexpr static s64 unknown_result_1 = 0;
|
||||
constexpr static s64 unknown_result_2 = 0;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 6};
|
||||
rb.Push(unknown_result_1);
|
||||
|
@ -740,8 +740,8 @@ private:
|
|||
const auto height = rp.Pop<u64>();
|
||||
LOG_DEBUG(Service_VI, "called width={}, height={}", width, height);
|
||||
|
||||
constexpr u64 base_size = 0x20000;
|
||||
constexpr u64 alignment = 0x1000;
|
||||
constexpr static u64 base_size = 0x20000;
|
||||
constexpr static u64 alignment = 0x1000;
|
||||
const auto texture_size = width * height * 4;
|
||||
const auto out_size = (texture_size + base_size - 1) / base_size * base_size;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue