From 7d8f1151852fa49bfbe1f09f10b50b34d9ef65f0 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Thu, 6 Sep 2018 16:03:28 -0400 Subject: [PATCH] Prefix all size_t with std:: done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2` --- src/audio_core/audio_types.h | 2 +- src/audio_core/codec.cpp | 30 +++++------ src/audio_core/codec.h | 6 +-- src/audio_core/cubeb_sink.cpp | 7 +-- src/audio_core/cubeb_sink.h | 4 +- src/audio_core/dsp_interface.cpp | 4 +- src/audio_core/dsp_interface.h | 2 +- src/audio_core/hle/common.h | 2 +- src/audio_core/hle/filter.cpp | 4 +- src/audio_core/hle/hle.cpp | 21 ++++---- src/audio_core/hle/hle.h | 2 +- src/audio_core/hle/mixers.cpp | 22 ++++---- src/audio_core/hle/source.cpp | 14 +++--- src/audio_core/hle/source.h | 6 +-- src/audio_core/interpolate.cpp | 11 ++-- src/audio_core/interpolate.h | 5 +- src/audio_core/null_sink.h | 4 +- src/audio_core/sdl2_sink.cpp | 19 +++---- src/audio_core/sdl2_sink.h | 4 +- src/audio_core/sink.h | 2 +- src/audio_core/time_stretch.cpp | 22 ++++---- src/audio_core/time_stretch.h | 6 +-- src/citra/citra.cpp | 2 +- .../graphics/graphics_breakpoints.cpp | 3 +- src/citra_qt/main.cpp | 6 +-- src/citra_qt/main.h | 6 +-- src/common/alignment.h | 4 +- src/common/bit_field.h | 4 +- src/common/bit_set.h | 6 +-- src/common/cityhash.cpp | 22 ++++---- src/common/cityhash.h | 12 ++--- src/common/file_util.cpp | 8 +-- src/common/file_util.h | 20 ++++---- src/common/hash.h | 4 +- src/common/logging/backend.cpp | 2 +- src/common/logging/backend.h | 2 +- src/common/logging/filter.cpp | 5 +- src/common/logging/filter.h | 2 +- src/common/memory_util.cpp | 12 ++--- src/common/memory_util.h | 12 ++--- src/common/misc.cpp | 2 +- src/common/string_util.cpp | 42 ++++++++-------- src/common/string_util.h | 4 +- src/common/thread.h | 10 ++-- src/common/x64/xbyak_abi.h | 21 ++++---- src/common/x64/xbyak_util.h | 2 +- src/core/arm/arm_interface.h | 10 ++-- src/core/arm/dynarmic/arm_dynarmic.cpp | 14 +++--- src/core/arm/dynarmic/arm_dynarmic.h | 2 +- src/core/arm/dyncom/arm_dyncom.cpp | 10 ++-- src/core/arm/dyncom/arm_dyncom.h | 2 +- src/core/arm/dyncom/arm_dyncom_thumb.cpp | 2 +- src/core/arm/dyncom/arm_dyncom_trans.cpp | 6 +-- src/core/arm/dyncom/arm_dyncom_trans.h | 4 +- src/core/file_sys/archive_backend.cpp | 2 +- src/core/file_sys/archive_extsavedata.cpp | 9 ++-- src/core/file_sys/archive_extsavedata.h | 2 +- src/core/file_sys/archive_ncch.cpp | 19 +++---- src/core/file_sys/archive_ncch.h | 5 +- src/core/file_sys/archive_sdmc.cpp | 2 +- src/core/file_sys/archive_selfncch.cpp | 7 +-- src/core/file_sys/cia_container.cpp | 10 ++-- src/core/file_sys/cia_container.h | 16 +++--- src/core/file_sys/delay_generator.h | 4 +- src/core/file_sys/directory_backend.h | 2 +- src/core/file_sys/disk_archive.cpp | 15 +++--- src/core/file_sys/disk_archive.h | 5 +- src/core/file_sys/file_backend.h | 7 +-- src/core/file_sys/ivfc_archive.cpp | 24 +++++---- src/core/file_sys/ivfc_archive.h | 16 +++--- src/core/file_sys/ncch_container.cpp | 4 +- src/core/file_sys/savedata_archive.cpp | 2 +- src/core/file_sys/title_metadata.cpp | 18 +++---- src/core/file_sys/title_metadata.h | 4 +- src/core/gdbstub/gdbstub.cpp | 12 ++--- src/core/hle/applets/swkbd.cpp | 2 +- src/core/hle/ipc.h | 8 +-- src/core/hle/ipc_helpers.h | 4 +- src/core/hle/kernel/handle_table.cpp | 2 +- src/core/hle/kernel/handle_table.h | 2 +- src/core/hle/kernel/hle_ipc.cpp | 19 +++---- src/core/hle/kernel/hle_ipc.h | 8 +-- src/core/hle/kernel/ipc.cpp | 11 ++-- src/core/hle/kernel/process.cpp | 6 +-- src/core/hle/kernel/process.h | 4 +- src/core/hle/kernel/shared_memory.h | 2 +- src/core/hle/kernel/svc.cpp | 4 +- src/core/hle/kernel/thread.cpp | 2 +- src/core/hle/kernel/vm_manager.cpp | 4 +- src/core/hle/kernel/vm_manager.h | 8 +-- src/core/hle/service/am/am.cpp | 50 ++++++++++--------- src/core/hle/service/am/am.h | 13 ++--- src/core/hle/service/apt/applet_manager.cpp | 20 ++++---- src/core/hle/service/apt/applet_manager.h | 2 +- src/core/hle/service/apt/apt.cpp | 2 +- src/core/hle/service/cam/cam.cpp | 2 +- src/core/hle/service/cfg/cfg.cpp | 4 +- src/core/hle/service/dsp/dsp_dsp.cpp | 6 +-- src/core/hle/service/dsp/dsp_dsp.h | 4 +- src/core/hle/service/frd/frd.cpp | 4 +- src/core/hle/service/fs/archive.cpp | 6 +-- src/core/hle/service/gsp/gsp_gpu.cpp | 4 +- src/core/hle/service/http_c.cpp | 2 +- src/core/hle/service/ir/ir_user.cpp | 4 +- src/core/hle/service/nwm/nwm_uds.cpp | 22 ++++---- src/core/hle/service/nwm/nwm_uds.h | 2 +- src/core/hle/service/nwm/uds_beacon.cpp | 8 +-- src/core/hle/service/nwm/uds_data.cpp | 6 +-- src/core/hle/service/service.cpp | 4 +- src/core/hle/service/service.h | 6 +-- src/core/hle/service/sm/srv.cpp | 4 +- src/core/hle/service/y2r_u.cpp | 2 +- src/core/hw/aes/ccm.cpp | 4 +- src/core/hw/aes/ccm.h | 9 ++-- src/core/hw/aes/key.cpp | 14 +++--- src/core/hw/aes/key.h | 14 +++--- src/core/hw/gpu.cpp | 8 +-- src/core/hw/gpu.h | 10 ++-- src/core/hw/lcd.h | 2 +- src/core/hw/y2r.cpp | 18 +++---- src/core/loader/3dsx.cpp | 2 +- src/core/loader/elf.cpp | 4 +- src/core/memory.cpp | 49 +++++++++--------- src/core/memory.h | 18 +++---- src/core/mmio.h | 4 +- src/core/movie.h | 2 +- src/core/tracer/recorder.cpp | 2 +- src/input_common/udp/client.cpp | 8 +-- src/input_common/udp/protocol.cpp | 6 +-- src/input_common/udp/protocol.h | 4 +- src/network/room.cpp | 2 +- src/network/room.h | 2 +- src/tests/core/arm/arm_test_common.cpp | 9 ++-- src/tests/core/arm/arm_test_common.h | 8 +-- src/video_core/command_processor.cpp | 2 +- src/video_core/debug_utils/debug_utils.cpp | 4 +- src/video_core/geometry_pipeline.cpp | 4 +- src/video_core/regs.h | 8 +-- src/video_core/regs_texturing.h | 2 +- .../renderer_opengl/gl_rasterizer.cpp | 24 ++++----- .../renderer_opengl/gl_rasterizer.h | 14 +++--- .../renderer_opengl/gl_rasterizer_cache.cpp | 19 +++---- .../renderer_opengl/gl_rasterizer_cache.h | 8 +-- .../renderer_opengl/gl_shader_decompiler.cpp | 9 ++-- .../renderer_opengl/gl_shader_gen.cpp | 8 +-- .../renderer_opengl/gl_shader_gen.h | 8 +-- .../renderer_opengl/gl_shader_manager.cpp | 2 +- src/video_core/renderer_opengl/gl_state.cpp | 2 +- .../renderer_opengl/gl_stream_buffer.cpp | 2 +- src/video_core/renderer_opengl/pica_to_gl.h | 14 +++--- .../renderer_opengl/renderer_opengl.cpp | 2 +- src/video_core/shader/shader.cpp | 8 +-- src/video_core/shader/shader.h | 10 ++-- .../shader/shader_jit_x64_compiler.cpp | 20 ++++---- .../shader/shader_jit_x64_compiler.h | 2 +- src/video_core/swrasterizer/clipper.cpp | 4 +- src/video_core/swrasterizer/lighting.cpp | 12 ++--- src/video_core/texture/texture_decode.cpp | 6 +-- 158 files changed, 669 insertions(+), 634 deletions(-) diff --git a/src/audio_core/audio_types.h b/src/audio_core/audio_types.h index de3dbacc8..b5adc254f 100644 --- a/src/audio_core/audio_types.h +++ b/src/audio_core/audio_types.h @@ -26,7 +26,7 @@ using QuadFrame32 = std::array, samples_per_frame>; /// A variable length buffer of signed PCM16 stereo samples. using StereoBuffer16 = std::deque>; -constexpr size_t num_dsp_pipe = 8; +constexpr std::size_t num_dsp_pipe = 8; enum class DspPipe { Debug = 0, Dma = 1, diff --git a/src/audio_core/codec.cpp b/src/audio_core/codec.cpp index 9677a9fbe..a280c5c04 100644 --- a/src/audio_core/codec.cpp +++ b/src/audio_core/codec.cpp @@ -14,26 +14,26 @@ namespace AudioCore { namespace Codec { -StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, +StereoBuffer16 DecodeADPCM(const u8* const data, const std::size_t sample_count, const std::array& adpcm_coeff, ADPCMState& state) { // GC-ADPCM with scale factor and variable coefficients. // Frames are 8 bytes long containing 14 samples each. // Samples are 4 bits (one nibble) long. - constexpr size_t FRAME_LEN = 8; - constexpr size_t SAMPLES_PER_FRAME = 14; + constexpr std::size_t FRAME_LEN = 8; + constexpr std::size_t SAMPLES_PER_FRAME = 14; constexpr std::array SIGNED_NIBBLES = { {0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1}}; - const size_t ret_size = + const std::size_t ret_size = sample_count % 2 == 0 ? sample_count : sample_count + 1; // Ensure multiple of two. StereoBuffer16 ret(ret_size); int yn1 = state.yn1, yn2 = state.yn2; - const size_t NUM_FRAMES = + const std::size_t NUM_FRAMES = (sample_count + (SAMPLES_PER_FRAME - 1)) / SAMPLES_PER_FRAME; // Round up. - for (size_t framei = 0; framei < NUM_FRAMES; framei++) { + for (std::size_t framei = 0; framei < NUM_FRAMES; framei++) { const int frame_header = data[framei * FRAME_LEN]; const int scale = 1 << (frame_header & 0xF); const int idx = (frame_header >> 4) & 0x7; @@ -58,9 +58,9 @@ StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, return (s16)val; }; - size_t outputi = framei * SAMPLES_PER_FRAME; - size_t datai = framei * FRAME_LEN + 1; - for (size_t i = 0; i < SAMPLES_PER_FRAME && outputi < sample_count; i += 2) { + std::size_t outputi = framei * SAMPLES_PER_FRAME; + std::size_t datai = framei * FRAME_LEN + 1; + for (std::size_t i = 0; i < SAMPLES_PER_FRAME && outputi < sample_count; i += 2) { const s16 sample1 = decode_sample(SIGNED_NIBBLES[data[datai] >> 4]); ret[outputi].fill(sample1); outputi++; @@ -80,7 +80,7 @@ StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, } StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data, - const size_t sample_count) { + const std::size_t sample_count) { ASSERT(num_channels == 1 || num_channels == 2); const auto decode_sample = [](u8 sample) { @@ -90,11 +90,11 @@ StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data, StereoBuffer16 ret(sample_count); if (num_channels == 1) { - for (size_t i = 0; i < sample_count; i++) { + for (std::size_t i = 0; i < sample_count; i++) { ret[i].fill(decode_sample(data[i])); } } else { - for (size_t i = 0; i < sample_count; i++) { + for (std::size_t i = 0; i < sample_count; i++) { ret[i][0] = decode_sample(data[i * 2 + 0]); ret[i][1] = decode_sample(data[i * 2 + 1]); } @@ -104,19 +104,19 @@ StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data, } StereoBuffer16 DecodePCM16(const unsigned num_channels, const u8* const data, - const size_t sample_count) { + const std::size_t sample_count) { ASSERT(num_channels == 1 || num_channels == 2); StereoBuffer16 ret(sample_count); if (num_channels == 1) { - for (size_t i = 0; i < sample_count; i++) { + for (std::size_t i = 0; i < sample_count; i++) { s16 sample; std::memcpy(&sample, data + i * sizeof(s16), sizeof(s16)); ret[i].fill(sample); } } else { - for (size_t i = 0; i < sample_count; ++i) { + for (std::size_t i = 0; i < sample_count; ++i) { std::memcpy(&ret[i], data + i * sizeof(s16) * 2, 2 * sizeof(s16)); } } diff --git a/src/audio_core/codec.h b/src/audio_core/codec.h index 7574bc562..86cf44437 100644 --- a/src/audio_core/codec.h +++ b/src/audio_core/codec.h @@ -26,7 +26,7 @@ struct ADPCMState { * @param state ADPCM state, this is updated with new state * @return Decoded stereo signed PCM16 data, sample_count in length */ -StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, +StereoBuffer16 DecodeADPCM(const u8* const data, const std::size_t sample_count, const std::array& adpcm_coeff, ADPCMState& state); /** @@ -36,7 +36,7 @@ StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, * @return Decoded stereo signed PCM16 data, sample_count in length */ StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data, - const size_t sample_count); + const std::size_t sample_count); /** * @param num_channels Number of channels @@ -45,6 +45,6 @@ StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data, * @return Decoded stereo signed PCM16 data, sample_count in length */ StereoBuffer16 DecodePCM16(const unsigned num_channels, const u8* const data, - const size_t sample_count); + const std::size_t sample_count); } // namespace Codec } // namespace AudioCore diff --git a/src/audio_core/cubeb_sink.cpp b/src/audio_core/cubeb_sink.cpp index 699f5b47c..6163588bf 100644 --- a/src/audio_core/cubeb_sink.cpp +++ b/src/audio_core/cubeb_sink.cpp @@ -95,7 +95,7 @@ unsigned int CubebSink::GetNativeSampleRate() const { return impl->sample_rate; } -void CubebSink::EnqueueSamples(const s16* samples, size_t sample_count) { +void CubebSink::EnqueueSamples(const s16* samples, std::size_t sample_count) { if (!impl->ctx) return; @@ -123,7 +123,8 @@ long CubebSink::Impl::DataCallback(cubeb_stream* stream, void* user_data, const std::lock_guard lock{impl->queue_mutex}; - size_t frames_to_write = std::min(impl->queue.size() / 2, static_cast(num_frames)); + std::size_t frames_to_write = + std::min(impl->queue.size() / 2, static_cast(num_frames)); memcpy(buffer, impl->queue.data(), frames_to_write * sizeof(s16) * 2); impl->queue.erase(impl->queue.begin(), impl->queue.begin() + frames_to_write * 2); @@ -152,7 +153,7 @@ std::vector ListCubebSinkDevices() { if (cubeb_enumerate_devices(ctx, CUBEB_DEVICE_TYPE_OUTPUT, &collection) != CUBEB_OK) { LOG_WARNING(Audio_Sink, "Audio output device enumeration not supported"); } else { - for (size_t i = 0; i < collection.count; i++) { + for (std::size_t i = 0; i < collection.count; i++) { const cubeb_device_info& device = collection.device[i]; if (device.friendly_name) { device_list.emplace_back(device.friendly_name); diff --git a/src/audio_core/cubeb_sink.h b/src/audio_core/cubeb_sink.h index a2ef228aa..59e633562 100644 --- a/src/audio_core/cubeb_sink.h +++ b/src/audio_core/cubeb_sink.h @@ -17,9 +17,9 @@ public: unsigned int GetNativeSampleRate() const override; - void EnqueueSamples(const s16* samples, size_t sample_count) override; + void EnqueueSamples(const s16* samples, std::size_t sample_count) override; - size_t SamplesInQueue() const override; + std::size_t SamplesInQueue() const override; private: struct Impl; diff --git a/src/audio_core/dsp_interface.cpp b/src/audio_core/dsp_interface.cpp index da8319a2e..d52440967 100644 --- a/src/audio_core/dsp_interface.cpp +++ b/src/audio_core/dsp_interface.cpp @@ -46,7 +46,7 @@ void DspInterface::OutputFrame(StereoFrame16& frame) { // Implementation of the hardware volume slider with a dynamic range of 60 dB double volume_scale_factor = std::exp(6.90775 * Settings::values.volume) * 0.001; - for (size_t i = 0; i < frame.size(); i++) { + for (std::size_t i = 0; i < frame.size(); i++) { frame[i][0] = static_cast(frame[i][0] * volume_scale_factor); frame[i][1] = static_cast(frame[i][1] * volume_scale_factor); } @@ -56,7 +56,7 @@ void DspInterface::OutputFrame(StereoFrame16& frame) { std::vector stretched_samples = time_stretcher.Process(sink->SamplesInQueue()); sink->EnqueueSamples(stretched_samples.data(), stretched_samples.size() / 2); } else { - constexpr size_t maximum_sample_latency = 2048; // about 64 miliseconds + constexpr std::size_t maximum_sample_latency = 2048; // about 64 miliseconds if (sink->SamplesInQueue() > maximum_sample_latency) { // This can occur if we're running too fast and samples are starting to back up. // Just drop the samples. diff --git a/src/audio_core/dsp_interface.h b/src/audio_core/dsp_interface.h index 8bc40ff5e..f3004d657 100644 --- a/src/audio_core/dsp_interface.h +++ b/src/audio_core/dsp_interface.h @@ -54,7 +54,7 @@ public: * @return The amount of data remaning in the pipe. This is the maximum length PipeRead will * return. */ - virtual size_t GetPipeReadableSize(DspPipe pipe_number) const = 0; + virtual std::size_t GetPipeReadableSize(DspPipe pipe_number) const = 0; /** * Write to a DSP pipe. diff --git a/src/audio_core/hle/common.h b/src/audio_core/hle/common.h index 43b6b6a4c..e7b36ac6c 100644 --- a/src/audio_core/hle/common.h +++ b/src/audio_core/hle/common.h @@ -10,7 +10,7 @@ namespace AudioCore { namespace HLE { -constexpr size_t num_sources = 24; +constexpr std::size_t num_sources = 24; /** * This performs the filter operation defined by FilterT::ProcessSample on the frame in-place. diff --git a/src/audio_core/hle/filter.cpp b/src/audio_core/hle/filter.cpp index 0547b46be..7cc4659ce 100644 --- a/src/audio_core/hle/filter.cpp +++ b/src/audio_core/hle/filter.cpp @@ -66,7 +66,7 @@ void SourceFilters::SimpleFilter::Configure( std::array SourceFilters::SimpleFilter::ProcessSample(const std::array& x0) { std::array y0; - for (size_t i = 0; i < 2; i++) { + for (std::size_t i = 0; i < 2; i++) { const s32 tmp = (b0 * x0[i] + a1 * y1[i]) >> 15; y0[i] = std::clamp(tmp, -32768, 32767); } @@ -100,7 +100,7 @@ void SourceFilters::BiquadFilter::Configure( std::array SourceFilters::BiquadFilter::ProcessSample(const std::array& x0) { std::array y0; - for (size_t i = 0; i < 2; i++) { + for (std::size_t i = 0; i < 2; i++) { const s32 tmp = (b0 * x0[i] + b1 * x1[i] + b2 * x2[i] + a1 * y1[i] + a2 * y2[i]) >> 14; y0[i] = std::clamp(tmp, -32768, 32767); } diff --git a/src/audio_core/hle/hle.cpp b/src/audio_core/hle/hle.cpp index a88bc6b8d..58604d861 100644 --- a/src/audio_core/hle/hle.cpp +++ b/src/audio_core/hle/hle.cpp @@ -29,7 +29,7 @@ public: DspState GetDspState() const; std::vector PipeRead(DspPipe pipe_number, u32 length); - size_t GetPipeReadableSize(DspPipe pipe_number) const; + std::size_t GetPipeReadableSize(DspPipe pipe_number) const; void PipeWrite(DspPipe pipe_number, const std::vector& buffer); std::array& GetDspMemory(); @@ -41,7 +41,7 @@ private: void WriteU16(DspPipe pipe_number, u16 value); void AudioPipeWriteStructAddresses(); - size_t CurrentRegionIndex() const; + std::size_t CurrentRegionIndex() const; HLE::SharedMemory& ReadRegion(); HLE::SharedMemory& WriteRegion(); @@ -87,7 +87,7 @@ DspState DspHle::Impl::GetDspState() const { } std::vector DspHle::Impl::PipeRead(DspPipe pipe_number, u32 length) { - const size_t pipe_index = static_cast(pipe_number); + const std::size_t pipe_index = static_cast(pipe_number); if (pipe_index >= num_dsp_pipe) { LOG_ERROR(Audio_DSP, "pipe_number = {} invalid", pipe_index); @@ -118,7 +118,7 @@ std::vector DspHle::Impl::PipeRead(DspPipe pipe_number, u32 length) { } size_t DspHle::Impl::GetPipeReadableSize(DspPipe pipe_number) const { - const size_t pipe_index = static_cast(pipe_number); + const std::size_t pipe_index = static_cast(pipe_number); if (pipe_index >= num_dsp_pipe) { LOG_ERROR(Audio_DSP, "pipe_number = {} invalid", pipe_index); @@ -183,7 +183,8 @@ void DspHle::Impl::PipeWrite(DspPipe pipe_number, const std::vector& buffer) return; } default: - LOG_CRITICAL(Audio_DSP, "pipe_number = {} unimplemented", static_cast(pipe_number)); + LOG_CRITICAL(Audio_DSP, "pipe_number = {} unimplemented", + static_cast(pipe_number)); UNIMPLEMENTED(); return; } @@ -205,7 +206,7 @@ void DspHle::Impl::ResetPipes() { } void DspHle::Impl::WriteU16(DspPipe pipe_number, u16 value) { - const size_t pipe_index = static_cast(pipe_number); + const std::size_t pipe_index = static_cast(pipe_number); std::vector& data = pipe_data.at(pipe_index); // Little endian @@ -280,10 +281,10 @@ StereoFrame16 DspHle::Impl::GenerateCurrentFrame() { std::array intermediate_mixes = {}; // Generate intermediate mixes - for (size_t i = 0; i < HLE::num_sources; i++) { + for (std::size_t i = 0; i < HLE::num_sources; i++) { write.source_statuses.status[i] = sources[i].Tick(read.source_configurations.config[i], read.adpcm_coefficients.coeff[i]); - for (size_t mix = 0; mix < 3; mix++) { + for (std::size_t mix = 0; mix < 3; mix++) { sources[i].MixInto(intermediate_mixes[mix], mix); } } @@ -295,8 +296,8 @@ StereoFrame16 DspHle::Impl::GenerateCurrentFrame() { StereoFrame16 output_frame = mixers.GetOutput(); // Write current output frame to the shared memory region - for (size_t samplei = 0; samplei < output_frame.size(); samplei++) { - for (size_t channeli = 0; channeli < output_frame[0].size(); channeli++) { + for (std::size_t samplei = 0; samplei < output_frame.size(); samplei++) { + for (std::size_t channeli = 0; channeli < output_frame[0].size(); channeli++) { write.final_samples.pcm16[samplei][channeli] = s16_le(output_frame[samplei][channeli]); } } diff --git a/src/audio_core/hle/hle.h b/src/audio_core/hle/hle.h index e93abf4bc..a957ee2f4 100644 --- a/src/audio_core/hle/hle.h +++ b/src/audio_core/hle/hle.h @@ -23,7 +23,7 @@ public: DspState GetDspState() const override; std::vector PipeRead(DspPipe pipe_number, u32 length) override; - size_t GetPipeReadableSize(DspPipe pipe_number) const override; + std::size_t GetPipeReadableSize(DspPipe pipe_number) const override; void PipeWrite(DspPipe pipe_number, const std::vector& buffer) override; std::array& GetDspMemory() override; diff --git a/src/audio_core/hle/mixers.cpp b/src/audio_core/hle/mixers.cpp index 297969a16..ea0fd4a7a 100644 --- a/src/audio_core/hle/mixers.cpp +++ b/src/audio_core/hle/mixers.cpp @@ -68,7 +68,7 @@ void Mixers::ParseConfig(DspConfiguration& config) { config.output_format_dirty.Assign(0); state.output_format = config.output_format; LOG_TRACE(Audio_DSP, "mixers output_format = {}", - static_cast(config.output_format)); + static_cast(config.output_format)); } if (config.headphones_connected_dirty) { @@ -131,7 +131,7 @@ void Mixers::DownmixAndMixIntoCurrentFrame(float gain, const QuadFrame32& sample return; } - UNREACHABLE_MSG("Invalid output_format {}", static_cast(state.output_format)); + UNREACHABLE_MSG("Invalid output_format {}", static_cast(state.output_format)); } void Mixers::AuxReturn(const IntermediateMixSamples& read_samples) { @@ -139,8 +139,8 @@ void Mixers::AuxReturn(const IntermediateMixSamples& read_samples) { // QuadFrame32. if (state.mixer1_enabled) { - for (size_t sample = 0; sample < samples_per_frame; sample++) { - for (size_t channel = 0; channel < 4; channel++) { + for (std::size_t sample = 0; sample < samples_per_frame; sample++) { + for (std::size_t channel = 0; channel < 4; channel++) { state.intermediate_mix_buffer[1][sample][channel] = read_samples.mix1.pcm32[channel][sample]; } @@ -148,8 +148,8 @@ void Mixers::AuxReturn(const IntermediateMixSamples& read_samples) { } if (state.mixer2_enabled) { - for (size_t sample = 0; sample < samples_per_frame; sample++) { - for (size_t channel = 0; channel < 4; channel++) { + for (std::size_t sample = 0; sample < samples_per_frame; sample++) { + for (std::size_t channel = 0; channel < 4; channel++) { state.intermediate_mix_buffer[2][sample][channel] = read_samples.mix2.pcm32[channel][sample]; } @@ -165,8 +165,8 @@ void Mixers::AuxSend(IntermediateMixSamples& write_samples, state.intermediate_mix_buffer[0] = input[0]; if (state.mixer1_enabled) { - for (size_t sample = 0; sample < samples_per_frame; sample++) { - for (size_t channel = 0; channel < 4; channel++) { + for (std::size_t sample = 0; sample < samples_per_frame; sample++) { + for (std::size_t channel = 0; channel < 4; channel++) { write_samples.mix1.pcm32[channel][sample] = input[1][sample][channel]; } } @@ -175,8 +175,8 @@ void Mixers::AuxSend(IntermediateMixSamples& write_samples, } if (state.mixer2_enabled) { - for (size_t sample = 0; sample < samples_per_frame; sample++) { - for (size_t channel = 0; channel < 4; channel++) { + for (std::size_t sample = 0; sample < samples_per_frame; sample++) { + for (std::size_t channel = 0; channel < 4; channel++) { write_samples.mix2.pcm32[channel][sample] = input[2][sample][channel]; } } @@ -188,7 +188,7 @@ void Mixers::AuxSend(IntermediateMixSamples& write_samples, void Mixers::MixCurrentFrame() { current_frame.fill({}); - for (size_t mix = 0; mix < 3; mix++) { + for (std::size_t mix = 0; mix < 3; mix++) { DownmixAndMixIntoCurrentFrame(state.intermediate_mixer_volume[mix], state.intermediate_mix_buffer[mix]); } diff --git a/src/audio_core/hle/source.cpp b/src/audio_core/hle/source.cpp index 4b232c9fb..bc209571f 100644 --- a/src/audio_core/hle/source.cpp +++ b/src/audio_core/hle/source.cpp @@ -26,12 +26,12 @@ SourceStatus::Status Source::Tick(SourceConfiguration::Configuration& config, return GetCurrentStatus(); } -void Source::MixInto(QuadFrame32& dest, size_t intermediate_mix_id) const { +void Source::MixInto(QuadFrame32& dest, std::size_t intermediate_mix_id) const { if (!state.enabled) return; const std::array& gains = state.gain.at(intermediate_mix_id); - for (size_t samplei = 0; samplei < samples_per_frame; samplei++) { + for (std::size_t samplei = 0; samplei < samples_per_frame; samplei++) { // Conversion from stereo (current_frame) to quadraphonic (dest) occurs here. dest[samplei][0] += static_cast(gains[0] * current_frame[samplei][0]); dest[samplei][1] += static_cast(gains[1] * current_frame[samplei][1]); @@ -141,21 +141,21 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config, config.interpolation_dirty.Assign(0); state.interpolation_mode = config.interpolation_mode; LOG_TRACE(Audio_DSP, "source_id={} interpolation_mode={}", source_id, - static_cast(state.interpolation_mode)); + static_cast(state.interpolation_mode)); } if (config.format_dirty || config.embedded_buffer_dirty) { config.format_dirty.Assign(0); state.format = config.format; LOG_TRACE(Audio_DSP, "source_id={} format={}", source_id, - static_cast(state.format)); + static_cast(state.format)); } if (config.mono_or_stereo_dirty || config.embedded_buffer_dirty) { config.mono_or_stereo_dirty.Assign(0); state.mono_or_stereo = config.mono_or_stereo; LOG_TRACE(Audio_DSP, "source_id={} mono_or_stereo={}", source_id, - static_cast(state.mono_or_stereo)); + static_cast(state.mono_or_stereo)); } u32_dsp play_position = {}; @@ -195,7 +195,7 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config, if (config.buffer_queue_dirty) { config.buffer_queue_dirty.Assign(0); - for (size_t i = 0; i < 4; i++) { + for (std::size_t i = 0; i < 4; i++) { if (config.buffers_dirty & (1 << i)) { const auto& b = config.buffers[i]; state.input_queue.emplace(Buffer{ @@ -236,7 +236,7 @@ void Source::GenerateFrame() { return; } - size_t frame_position = 0; + std::size_t frame_position = 0; state.current_sample_number = state.next_sample_number; while (frame_position < current_frame.size()) { diff --git a/src/audio_core/hle/source.h b/src/audio_core/hle/source.h index 3a6388956..2e24c5eab 100644 --- a/src/audio_core/hle/source.h +++ b/src/audio_core/hle/source.h @@ -28,7 +28,7 @@ namespace HLE { */ class Source final { public: - explicit Source(size_t source_id_) : source_id(source_id_) { + explicit Source(std::size_t source_id_) : source_id(source_id_) { Reset(); } @@ -52,10 +52,10 @@ public: * @param dest The QuadFrame32 to mix into. * @param intermediate_mix_id The id of the intermediate mix whose gains we are using. */ - void MixInto(QuadFrame32& dest, size_t intermediate_mix_id) const; + void MixInto(QuadFrame32& dest, std::size_t intermediate_mix_id) const; private: - const size_t source_id; + const std::size_t source_id; StereoFrame16 current_frame; using Format = SourceConfiguration::Configuration::Format; diff --git a/src/audio_core/interpolate.cpp b/src/audio_core/interpolate.cpp index 83fb6f013..1ac9486de 100644 --- a/src/audio_core/interpolate.cpp +++ b/src/audio_core/interpolate.cpp @@ -18,7 +18,7 @@ constexpr u64 scale_mask = scale_factor - 1; /// Three adjacent samples are passed to fn each step. template static void StepOverSamples(State& state, StereoBuffer16& input, float rate, StereoFrame16& output, - size_t& outputi, Function fn) { + std::size_t& outputi, Function fn) { ASSERT(rate > 0); if (input.empty()) @@ -28,10 +28,10 @@ static void StepOverSamples(State& state, StereoBuffer16& input, float rate, Ste const u64 step_size = static_cast(rate * scale_factor); u64 fposition = state.fposition; - size_t inputi = 0; + std::size_t inputi = 0; while (outputi < output.size()) { - inputi = static_cast(fposition / scale_factor); + inputi = static_cast(fposition / scale_factor); if (inputi + 2 >= input.size()) { inputi = input.size() - 2; @@ -51,14 +51,15 @@ static void StepOverSamples(State& state, StereoBuffer16& input, float rate, Ste input.erase(input.begin(), std::next(input.begin(), inputi + 2)); } -void None(State& state, StereoBuffer16& input, float rate, StereoFrame16& output, size_t& outputi) { +void None(State& state, StereoBuffer16& input, float rate, StereoFrame16& output, + std::size_t& outputi) { StepOverSamples( state, input, rate, output, outputi, [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { return x0; }); } void Linear(State& state, StereoBuffer16& input, float rate, StereoFrame16& output, - size_t& outputi) { + std::size_t& outputi) { // Note on accuracy: Some values that this produces are +/- 1 from the actual firmware. StepOverSamples(state, input, rate, output, outputi, [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { diff --git a/src/audio_core/interpolate.h b/src/audio_core/interpolate.h index bf172a5ad..79aff02ca 100644 --- a/src/audio_core/interpolate.h +++ b/src/audio_core/interpolate.h @@ -32,7 +32,8 @@ struct State { * @param output The resampled audio buffer. * @param outputi The index of output to start writing to. */ -void None(State& state, StereoBuffer16& input, float rate, StereoFrame16& output, size_t& outputi); +void None(State& state, StereoBuffer16& input, float rate, StereoFrame16& output, + std::size_t& outputi); /** * Linear interpolation. This is equivalent to a first-order hold. There is a two-sample predelay. @@ -44,7 +45,7 @@ void None(State& state, StereoBuffer16& input, float rate, StereoFrame16& output * @param outputi The index of output to start writing to. */ void Linear(State& state, StereoBuffer16& input, float rate, StereoFrame16& output, - size_t& outputi); + std::size_t& outputi); } // namespace AudioInterp } // namespace AudioCore diff --git a/src/audio_core/null_sink.h b/src/audio_core/null_sink.h index 97a228f28..bc60b0784 100644 --- a/src/audio_core/null_sink.h +++ b/src/audio_core/null_sink.h @@ -19,9 +19,9 @@ public: return native_sample_rate; } - void EnqueueSamples(const s16*, size_t) override {} + void EnqueueSamples(const s16*, std::size_t) override {} - size_t SamplesInQueue() const override { + std::size_t SamplesInQueue() const override { return 0; } }; diff --git a/src/audio_core/sdl2_sink.cpp b/src/audio_core/sdl2_sink.cpp index f18da8845..e3b90b176 100644 --- a/src/audio_core/sdl2_sink.cpp +++ b/src/audio_core/sdl2_sink.cpp @@ -74,7 +74,7 @@ unsigned int SDL2Sink::GetNativeSampleRate() const { return impl->sample_rate; } -void SDL2Sink::EnqueueSamples(const s16* samples, size_t sample_count) { +void SDL2Sink::EnqueueSamples(const s16* samples, std::size_t sample_count) { if (impl->audio_device_id <= 0) return; @@ -89,12 +89,13 @@ size_t SDL2Sink::SamplesInQueue() const { SDL_LockAudioDevice(impl->audio_device_id); - size_t total_size = std::accumulate(impl->queue.begin(), impl->queue.end(), - static_cast(0), [](size_t sum, const auto& buffer) { - // Division by two because each stereo sample is made of - // two s16. - return sum + buffer.size() / 2; - }); + std::size_t total_size = + std::accumulate(impl->queue.begin(), impl->queue.end(), static_cast(0), + [](std::size_t sum, const auto& buffer) { + // Division by two because each stereo sample is made of + // two s16. + return sum + buffer.size() / 2; + }); SDL_UnlockAudioDevice(impl->audio_device_id); @@ -104,8 +105,8 @@ size_t SDL2Sink::SamplesInQueue() const { void SDL2Sink::Impl::Callback(void* impl_, u8* buffer, int buffer_size_in_bytes) { Impl* impl = reinterpret_cast(impl_); - size_t remaining_size = static_cast(buffer_size_in_bytes) / - sizeof(s16); // Keep track of size in 16-bit increments. + std::size_t remaining_size = static_cast(buffer_size_in_bytes) / + sizeof(s16); // Keep track of size in 16-bit increments. while (remaining_size > 0 && !impl->queue.empty()) { if (impl->queue.front().size() <= remaining_size) { diff --git a/src/audio_core/sdl2_sink.h b/src/audio_core/sdl2_sink.h index 33b5df283..46b1c28b6 100644 --- a/src/audio_core/sdl2_sink.h +++ b/src/audio_core/sdl2_sink.h @@ -17,9 +17,9 @@ public: unsigned int GetNativeSampleRate() const override; - void EnqueueSamples(const s16* samples, size_t sample_count) override; + void EnqueueSamples(const s16* samples, std::size_t sample_count) override; - size_t SamplesInQueue() const override; + std::size_t SamplesInQueue() const override; private: struct Impl; diff --git a/src/audio_core/sink.h b/src/audio_core/sink.h index 723756b67..5d97f424b 100644 --- a/src/audio_core/sink.h +++ b/src/audio_core/sink.h @@ -29,7 +29,7 @@ public: * @param samples Samples in interleaved stereo PCM16 format. * @param sample_count Number of samples. */ - virtual void EnqueueSamples(const s16* samples, size_t sample_count) = 0; + virtual void EnqueueSamples(const s16* samples, std::size_t sample_count) = 0; /// Samples enqueued that have not been played yet. virtual std::size_t SamplesInQueue() const = 0; diff --git a/src/audio_core/time_stretch.cpp b/src/audio_core/time_stretch.cpp index 6a9a7704e..df116d233 100644 --- a/src/audio_core/time_stretch.cpp +++ b/src/audio_core/time_stretch.cpp @@ -23,9 +23,9 @@ static double ClampRatio(double ratio) { return std::clamp(ratio, MIN_RATIO, MAX_RATIO); } -constexpr double MIN_DELAY_TIME = 0.05; // Units: seconds -constexpr double MAX_DELAY_TIME = 0.25; // Units: seconds -constexpr size_t DROP_FRAMES_SAMPLE_DELAY = 16000; // Units: samples +constexpr double MIN_DELAY_TIME = 0.05; // Units: seconds +constexpr double MAX_DELAY_TIME = 0.25; // Units: seconds +constexpr std::size_t DROP_FRAMES_SAMPLE_DELAY = 16000; // Units: samples constexpr double SMOOTHING_FACTOR = 0.007; @@ -33,14 +33,14 @@ struct TimeStretcher::Impl { soundtouch::SoundTouch soundtouch; steady_clock::time_point frame_timer = steady_clock::now(); - size_t samples_queued = 0; + std::size_t samples_queued = 0; double smoothed_ratio = 1.0; double sample_rate = static_cast(native_sample_rate); }; -std::vector TimeStretcher::Process(size_t samples_in_queue) { +std::vector TimeStretcher::Process(std::size_t samples_in_queue) { // This is a very simple algorithm without any fancy control theory. It works and is stable. double ratio = CalculateCurrentRatio(); @@ -76,7 +76,7 @@ void TimeStretcher::SetOutputSampleRate(unsigned int sample_rate) { impl->soundtouch.setRate(static_cast(native_sample_rate) / impl->sample_rate); } -void TimeStretcher::AddSamples(const s16* buffer, size_t num_samples) { +void TimeStretcher::AddSamples(const s16* buffer, std::size_t num_samples) { impl->soundtouch.putSamples(buffer, static_cast(num_samples)); impl->samples_queued += num_samples; } @@ -115,9 +115,11 @@ double TimeStretcher::CalculateCurrentRatio() { return ratio; } -double TimeStretcher::CorrectForUnderAndOverflow(double ratio, size_t sample_delay) const { - const size_t min_sample_delay = static_cast(MIN_DELAY_TIME * impl->sample_rate); - const size_t max_sample_delay = static_cast(MAX_DELAY_TIME * impl->sample_rate); +double TimeStretcher::CorrectForUnderAndOverflow(double ratio, std::size_t sample_delay) const { + const std::size_t min_sample_delay = + static_cast(MIN_DELAY_TIME * impl->sample_rate); + const std::size_t max_sample_delay = + static_cast(MAX_DELAY_TIME * impl->sample_rate); if (sample_delay < min_sample_delay) { // Make the ratio bigger. @@ -133,7 +135,7 @@ double TimeStretcher::CorrectForUnderAndOverflow(double ratio, size_t sample_del std::vector TimeStretcher::GetSamples() { uint available = impl->soundtouch.numSamples(); - std::vector output(static_cast(available) * 2); + std::vector output(static_cast(available) * 2); impl->soundtouch.receiveSamples(output.data(), available); diff --git a/src/audio_core/time_stretch.h b/src/audio_core/time_stretch.h index c98b16705..ef0852ff5 100644 --- a/src/audio_core/time_stretch.h +++ b/src/audio_core/time_stretch.h @@ -27,7 +27,7 @@ public: * @param sample_buffer Buffer of samples in interleaved stereo PCM16 format. * @param num_samples Number of samples. */ - void AddSamples(const s16* sample_buffer, size_t num_samples); + void AddSamples(const s16* sample_buffer, std::size_t num_samples); /// Flush audio remaining in internal buffers. void Flush(); @@ -42,7 +42,7 @@ public: * played yet. * @return Samples to play in interleaved stereo PCM16 format. */ - std::vector Process(size_t sample_delay); + std::vector Process(std::size_t sample_delay); private: struct Impl; @@ -52,7 +52,7 @@ private: double CalculateCurrentRatio(); /// INTERNAL: If we have too many or too few samples downstream, nudge ratio in the appropriate /// direction. - double CorrectForUnderAndOverflow(double ratio, size_t sample_delay) const; + double CorrectForUnderAndOverflow(double ratio, std::size_t sample_delay) const; /// INTERNAL: Gets the time-stretched samples from SoundTouch. std::vector GetSamples(); }; diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index eae09cbac..20fb98663 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -171,7 +171,7 @@ int main(int argc, char** argv) { } break; case 'i': { - const auto cia_progress = [](size_t written, size_t total) { + const auto cia_progress = [](std::size_t written, std::size_t total) { LOG_INFO(Frontend, "{:02d}%", (written * 100 / total)); }; if (Service::AM::InstallCIA(std::string(optarg), cia_progress) != diff --git a/src/citra_qt/debugger/graphics/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics/graphics_breakpoints.cpp index 28e02d367..d3d32997c 100644 --- a/src/citra_qt/debugger/graphics/graphics_breakpoints.cpp +++ b/src/citra_qt/debugger/graphics/graphics_breakpoints.cpp @@ -42,7 +42,8 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const { {Pica::DebugContext::Event::BufferSwapped, tr("Buffers swapped")}, }; - DEBUG_ASSERT(map.size() == static_cast(Pica::DebugContext::Event::NumEvents)); + DEBUG_ASSERT(map.size() == + static_cast(Pica::DebugContext::Event::NumEvents)); return (map.find(event) != map.end()) ? map.at(event) : QString(); } diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 50890c190..3f0388d0a 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -113,7 +113,7 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { Settings::LogSettings(); // register types to use in slots and signals - qRegisterMetaType("size_t"); + qRegisterMetaType("std::size_t"); qRegisterMetaType("Service::AM::InstallStatus"); LoadTranslation(); @@ -1000,7 +1000,7 @@ void GMainWindow::OnMenuInstallCIA() { QtConcurrent::run([&, filepaths] { QString current_path; Service::AM::InstallStatus status; - const auto cia_progress = [&](size_t written, size_t total) { + const auto cia_progress = [&](std::size_t written, std::size_t total) { emit UpdateProgress(written, total); }; for (const auto current_path : filepaths) { @@ -1011,7 +1011,7 @@ void GMainWindow::OnMenuInstallCIA() { }); } -void GMainWindow::OnUpdateProgress(size_t written, size_t total) { +void GMainWindow::OnUpdateProgress(std::size_t written, std::size_t total) { progress_bar->setValue( static_cast(INT_MAX * (static_cast(written) / static_cast(total)))); } diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 1cb9aebe0..bbc0714c5 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -85,7 +85,7 @@ signals: */ void EmulationStopping(); - void UpdateProgress(size_t written, size_t total); + void UpdateProgress(std::size_t written, std::size_t total); void CIAInstallReport(Service::AM::InstallStatus status, QString filepath); void CIAInstallFinished(); // Signal that tells widgets to update icons to use the current theme @@ -161,7 +161,7 @@ private slots: void OnGameListShowList(bool show); void OnMenuLoadFile(); void OnMenuInstallCIA(); - void OnUpdateProgress(size_t written, size_t total); + void OnUpdateProgress(std::size_t written, std::size_t total); void OnCIAInstallReport(Service::AM::InstallStatus status, QString filepath); void OnCIAInstallFinished(); void OnMenuRecentFile(); @@ -255,5 +255,5 @@ protected: void dragMoveEvent(QDragMoveEvent* event) override; }; -Q_DECLARE_METATYPE(size_t); +Q_DECLARE_METATYPE(std::size_t); Q_DECLARE_METATYPE(Service::AM::InstallStatus); diff --git a/src/common/alignment.h b/src/common/alignment.h index b9dd38746..225770fab 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h @@ -8,13 +8,13 @@ namespace Common { template -constexpr T AlignUp(T value, size_t size) { +constexpr T AlignUp(T value, std::size_t size) { static_assert(std::is_unsigned_v, "T must be an unsigned value."); return static_cast(value + (size - value % size) % size); } template -constexpr T AlignDown(T value, size_t size) { +constexpr T AlignDown(T value, std::size_t size) { static_assert(std::is_unsigned_v, "T must be an unsigned value."); return static_cast(value - value % size); } diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 0616f5f1d..03da26fa4 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -125,8 +125,8 @@ public: BitField& operator=(const BitField&) = default; /// Constants to allow limited introspection of fields if needed - static constexpr size_t position = Position; - static constexpr size_t bits = Bits; + static constexpr std::size_t position = Position; + static constexpr std::size_t bits = Bits; static constexpr StorageType mask = (((StorageTypeU)~0) >> (8 * sizeof(T) - bits)) << position; /** diff --git a/src/common/bit_set.h b/src/common/bit_set.h index a5139f751..0598b60df 100644 --- a/src/common/bit_set.h +++ b/src/common/bit_set.h @@ -155,14 +155,14 @@ public: m_val |= (IntTy)1 << bit; } - static BitSet AllTrue(size_t count) { + static BitSet AllTrue(std::size_t count) { return BitSet(count == sizeof(IntTy) * 8 ? ~(IntTy)0 : (((IntTy)1 << count) - 1)); } - Ref operator[](size_t bit) { + Ref operator[](std::size_t bit) { return Ref(this, (IntTy)1 << bit); } - const Ref operator[](size_t bit) const { + const Ref operator[](std::size_t bit) const { return (*const_cast(this))[bit]; } bool operator==(BitSet other) const { diff --git a/src/common/cityhash.cpp b/src/common/cityhash.cpp index de31ffbd8..4e1d874b5 100644 --- a/src/common/cityhash.cpp +++ b/src/common/cityhash.cpp @@ -114,7 +114,7 @@ static uint64 HashLen16(uint64 u, uint64 v, uint64 mul) { return b; } -static uint64 HashLen0to16(const char* s, size_t len) { +static uint64 HashLen0to16(const char* s, std::size_t len) { if (len >= 8) { uint64 mul = k2 + len * 2; uint64 a = Fetch64(s) + k2; @@ -141,7 +141,7 @@ static uint64 HashLen0to16(const char* s, size_t len) { // This probably works well for 16-byte strings as well, but it may be overkill // in that case. -static uint64 HashLen17to32(const char* s, size_t len) { +static uint64 HashLen17to32(const char* s, std::size_t len) { uint64 mul = k2 + len * 2; uint64 a = Fetch64(s) * k1; uint64 b = Fetch64(s + 8); @@ -170,7 +170,7 @@ static pair WeakHashLen32WithSeeds(const char* s, uint64 a, uint } // Return an 8-byte hash for 33 to 64 bytes. -static uint64 HashLen33to64(const char* s, size_t len) { +static uint64 HashLen33to64(const char* s, std::size_t len) { uint64 mul = k2 + len * 2; uint64 a = Fetch64(s) * k2; uint64 b = Fetch64(s + 8); @@ -191,7 +191,7 @@ static uint64 HashLen33to64(const char* s, size_t len) { return b + x; } -uint64 CityHash64(const char* s, size_t len) { +uint64 CityHash64(const char* s, std::size_t len) { if (len <= 32) { if (len <= 16) { return HashLen0to16(s, len); @@ -212,7 +212,7 @@ uint64 CityHash64(const char* s, size_t len) { x = x * k1 + Fetch64(s); // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. - len = (len - 1) & ~static_cast(63); + len = (len - 1) & ~static_cast(63); do { x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1; y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1; @@ -229,17 +229,17 @@ uint64 CityHash64(const char* s, size_t len) { HashLen16(v.second, w.second) + x); } -uint64 CityHash64WithSeed(const char* s, size_t len, uint64 seed) { +uint64 CityHash64WithSeed(const char* s, std::size_t len, uint64 seed) { return CityHash64WithSeeds(s, len, k2, seed); } -uint64 CityHash64WithSeeds(const char* s, size_t len, uint64 seed0, uint64 seed1) { +uint64 CityHash64WithSeeds(const char* s, std::size_t len, uint64 seed0, uint64 seed1) { return HashLen16(CityHash64(s, len) - seed0, seed1); } // A subroutine for CityHash128(). Returns a decent 128-bit hash for strings // of any length representable in signed long. Based on City and Murmur. -static uint128 CityMurmur(const char* s, size_t len, uint128 seed) { +static uint128 CityMurmur(const char* s, std::size_t len, uint128 seed) { uint64 a = Uint128Low64(seed); uint64 b = Uint128High64(seed); uint64 c = 0; @@ -269,7 +269,7 @@ static uint128 CityMurmur(const char* s, size_t len, uint128 seed) { return uint128(a ^ b, HashLen16(b, a)); } -uint128 CityHash128WithSeed(const char* s, size_t len, uint128 seed) { +uint128 CityHash128WithSeed(const char* s, std::size_t len, uint128 seed) { if (len < 128) { return CityMurmur(s, len, seed); } @@ -313,7 +313,7 @@ uint128 CityHash128WithSeed(const char* s, size_t len, uint128 seed) { w.first *= 9; v.first *= k0; // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s. - for (size_t tail_done = 0; tail_done < len;) { + for (std::size_t tail_done = 0; tail_done < len;) { tail_done += 32; y = Rotate(x + y, 42) * k0 + v.second; w.first += Fetch64(s + len - tail_done + 16); @@ -331,7 +331,7 @@ uint128 CityHash128WithSeed(const char* s, size_t len, uint128 seed) { return uint128(HashLen16(x + v.second, w.second) + y, HashLen16(x + w.second, y + v.second)); } -uint128 CityHash128(const char* s, size_t len) { +uint128 CityHash128(const char* s, std::size_t len) { return len >= 16 ? CityHash128WithSeed(s + 16, len - 16, uint128(Fetch64(s), Fetch64(s + 8) + k0)) : CityHash128WithSeed(s, len, uint128(k0, k1)); diff --git a/src/common/cityhash.h b/src/common/cityhash.h index bcebdb150..4b94f8e18 100644 --- a/src/common/cityhash.h +++ b/src/common/cityhash.h @@ -63,7 +63,7 @@ #include #include -#include // for size_t. +#include // for std::size_t. namespace Common { @@ -77,22 +77,22 @@ inline uint64_t Uint128High64(const uint128& x) { } // Hash function for a byte array. -uint64_t CityHash64(const char* buf, size_t len); +uint64_t CityHash64(const char* buf, std::size_t len); // Hash function for a byte array. For convenience, a 64-bit seed is also // hashed into the result. -uint64_t CityHash64WithSeed(const char* buf, size_t len, uint64_t seed); +uint64_t CityHash64WithSeed(const char* buf, std::size_t len, uint64_t seed); // Hash function for a byte array. For convenience, two seeds are also // hashed into the result. -uint64_t CityHash64WithSeeds(const char* buf, size_t len, uint64_t seed0, uint64_t seed1); +uint64_t CityHash64WithSeeds(const char* buf, std::size_t len, uint64_t seed0, uint64_t seed1); // Hash function for a byte array. -uint128 CityHash128(const char* s, size_t len); +uint128 CityHash128(const char* s, std::size_t len); // Hash function for a byte array. For convenience, a 128-bit seed is also // hashed into the result. -uint128 CityHash128WithSeed(const char* s, size_t len, uint128 seed); +uint128 CityHash128WithSeed(const char* s, std::size_t len, uint128 seed); // Hash 128 input bits down to 64 bits of output. // This is intended to be a reasonably good hash function. diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 610064a10..34cc3136a 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -74,7 +74,7 @@ namespace FileUtil { // Modifies argument. static void StripTailDirSlashes(std::string& fname) { if (fname.length() > 1) { - size_t i = fname.length(); + std::size_t i = fname.length(); while (i > 0 && fname[i - 1] == DIR_SEP_CHR) --i; fname.resize(i); @@ -199,7 +199,7 @@ bool CreateFullPath(const std::string& fullPath) { return true; } - size_t position = 0; + std::size_t position = 0; while (true) { // Find next sub path position = fullPath.find(DIR_SEP_CHR, position); @@ -297,7 +297,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { std::array buffer; while (!feof(input.get())) { // read input - size_t rnum = fread(buffer.data(), sizeof(char), buffer.size(), input.get()); + std::size_t rnum = fread(buffer.data(), sizeof(char), buffer.size(), input.get()); if (rnum != buffer.size()) { if (ferror(input.get()) != 0) { LOG_ERROR(Common_Filesystem, "failed reading from source, {} --> {}: {}", @@ -307,7 +307,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { } // write output - size_t wnum = fwrite(buffer.data(), sizeof(char), rnum, output.get()); + std::size_t wnum = fwrite(buffer.data(), sizeof(char), rnum, output.get()); if (wnum != rnum) { LOG_ERROR(Common_Filesystem, "failed writing to output, {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg()); diff --git a/src/common/file_util.h b/src/common/file_util.h index 3e7faa43b..4b04edb3e 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -174,16 +174,16 @@ public: bool Close(); template - size_t ReadArray(T* data, size_t length) { + std::size_t ReadArray(T* data, std::size_t length) { static_assert(std::is_trivially_copyable_v, "Given array does not consist of trivially copyable objects"); if (!IsOpen()) { m_good = false; - return std::numeric_limits::max(); + return std::numeric_limits::max(); } - size_t items_read = std::fread(data, sizeof(T), length, m_file); + std::size_t items_read = std::fread(data, sizeof(T), length, m_file); if (items_read != length) m_good = false; @@ -191,16 +191,16 @@ public: } template - size_t WriteArray(const T* data, size_t length) { + std::size_t WriteArray(const T* data, std::size_t length) { static_assert(std::is_trivially_copyable_v, "Given array does not consist of trivially copyable objects"); if (!IsOpen()) { m_good = false; - return std::numeric_limits::max(); + return std::numeric_limits::max(); } - size_t items_written = std::fwrite(data, sizeof(T), length, m_file); + std::size_t items_written = std::fwrite(data, sizeof(T), length, m_file); if (items_written != length) m_good = false; @@ -208,24 +208,24 @@ public: } template - size_t ReadBytes(T* data, size_t length) { + std::size_t ReadBytes(T* data, std::size_t length) { static_assert(std::is_trivially_copyable_v, "T must be trivially copyable"); return ReadArray(reinterpret_cast(data), length); } template - size_t WriteBytes(const T* data, size_t length) { + std::size_t WriteBytes(const T* data, std::size_t length) { static_assert(std::is_trivially_copyable_v, "T must be trivially copyable"); return WriteArray(reinterpret_cast(data), length); } template - size_t WriteObject(const T& object) { + std::size_t WriteObject(const T& object) { static_assert(!std::is_pointer_v, "WriteObject arguments must not be a pointer"); return WriteArray(&object, 1); } - size_t WriteString(const std::string& str) { + std::size_t WriteString(const std::string& str) { return WriteArray(str.c_str(), str.length()); } diff --git a/src/common/hash.h b/src/common/hash.h index 2c761e545..40194d1ee 100644 --- a/src/common/hash.h +++ b/src/common/hash.h @@ -17,7 +17,7 @@ namespace Common { * @param len Length of data (in bytes) to compute hash over * @returns 64-bit hash value that was computed over the data block */ -static inline u64 ComputeHash64(const void* data, size_t len) { +static inline u64 ComputeHash64(const void* data, std::size_t len) { return CityHash64(static_cast(data), len); } @@ -63,7 +63,7 @@ struct HashableStruct { return !(*this == o); }; - size_t Hash() const { + std::size_t Hash() const { return Common::ComputeStructHash64(state); } }; diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 6d9989e14..d9e9ac725 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -132,7 +132,7 @@ FileBackend::FileBackend(const std::string& filename) void FileBackend::Write(const Entry& entry) { // prevent logs from going over the maximum size (in case its spamming and the user doesn't // know) - constexpr size_t MAX_BYTES_WRITTEN = 50 * 1024L * 1024L; + constexpr std::size_t MAX_BYTES_WRITTEN = 50 * 1024L * 1024L; if (!file.IsOpen() || bytes_written > MAX_BYTES_WRITTEN) { return; } diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index c540ec6e3..01e162bb2 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h @@ -101,7 +101,7 @@ public: private: FileUtil::IOFile file; - size_t bytes_written; + std::size_t bytes_written; }; void AddBackend(std::unique_ptr backend); diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 27fccf8ff..fa42b6047 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -71,7 +71,7 @@ void Filter::ResetAll(Level level) { } void Filter::SetClassLevel(Class log_class, Level level) { - class_levels[static_cast(log_class)] = level; + class_levels[static_cast(log_class)] = level; } void Filter::ParseFilterString(std::string_view filter_view) { @@ -93,6 +93,7 @@ void Filter::ParseFilterString(std::string_view filter_view) { } bool Filter::CheckMessage(Class log_class, Level level) const { - return static_cast(level) >= static_cast(class_levels[static_cast(log_class)]); + return static_cast(level) >= + static_cast(class_levels[static_cast(log_class)]); } } // namespace Log diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h index d0cde5c15..e887c32a1 100644 --- a/src/common/logging/filter.h +++ b/src/common/logging/filter.h @@ -46,6 +46,6 @@ public: bool CheckMessage(Class log_class, Level level) const; private: - std::array class_levels; + std::array class_levels; }; } // namespace Log diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index f73cea3e7..f85ebca02 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp @@ -26,7 +26,7 @@ // This is purposely not a full wrapper for virtualalloc/mmap, but it // provides exactly the primitive operations that Dolphin needs. -void* AllocateExecutableMemory(size_t size, bool low) { +void* AllocateExecutableMemory(std::size_t size, bool low) { #if defined(_WIN32) void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); #else @@ -75,7 +75,7 @@ void* AllocateExecutableMemory(size_t size, bool low) { return ptr; } -void* AllocateMemoryPages(size_t size) { +void* AllocateMemoryPages(std::size_t size) { #ifdef _WIN32 void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); #else @@ -91,7 +91,7 @@ void* AllocateMemoryPages(size_t size) { return ptr; } -void* AllocateAlignedMemory(size_t size, size_t alignment) { +void* AllocateAlignedMemory(std::size_t size, std::size_t alignment) { #ifdef _WIN32 void* ptr = _aligned_malloc(size, alignment); #else @@ -110,7 +110,7 @@ void* AllocateAlignedMemory(size_t size, size_t alignment) { return ptr; } -void FreeMemoryPages(void* ptr, size_t size) { +void FreeMemoryPages(void* ptr, std::size_t size) { if (ptr) { #ifdef _WIN32 if (!VirtualFree(ptr, 0, MEM_RELEASE)) @@ -131,7 +131,7 @@ void FreeAlignedMemory(void* ptr) { } } -void WriteProtectMemory(void* ptr, size_t size, bool allowExecute) { +void WriteProtectMemory(void* ptr, std::size_t size, bool allowExecute) { #ifdef _WIN32 DWORD oldValue; if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue)) @@ -141,7 +141,7 @@ void WriteProtectMemory(void* ptr, size_t size, bool allowExecute) { #endif } -void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute) { +void UnWriteProtectMemory(void* ptr, std::size_t size, bool allowExecute) { #ifdef _WIN32 DWORD oldValue; if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, diff --git a/src/common/memory_util.h b/src/common/memory_util.h index 76ca5a30c..aad071979 100644 --- a/src/common/memory_util.h +++ b/src/common/memory_util.h @@ -7,13 +7,13 @@ #include #include -void* AllocateExecutableMemory(size_t size, bool low = true); -void* AllocateMemoryPages(size_t size); -void FreeMemoryPages(void* ptr, size_t size); -void* AllocateAlignedMemory(size_t size, size_t alignment); +void* AllocateExecutableMemory(std::size_t size, bool low = true); +void* AllocateMemoryPages(std::size_t size); +void FreeMemoryPages(void* ptr, std::size_t size); +void* AllocateAlignedMemory(std::size_t size, std::size_t alignment); void FreeAlignedMemory(void* ptr); -void WriteProtectMemory(void* ptr, size_t size, bool executable = false); -void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute = false); +void WriteProtectMemory(void* ptr, std::size_t size, bool executable = false); +void UnWriteProtectMemory(void* ptr, std::size_t size, bool allowExecute = false); std::string MemUsage(); inline int GetPageSize() { diff --git a/src/common/misc.cpp b/src/common/misc.cpp index 3fa8a3bc4..68cb86cd1 100644 --- a/src/common/misc.cpp +++ b/src/common/misc.cpp @@ -16,7 +16,7 @@ // Call directly after the command or use the error num. // This function might change the error code. std::string GetLastErrorMsg() { - static const size_t buff_size = 255; + static const std::size_t buff_size = 255; char err_str[buff_size]; #ifdef _WIN32 diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 83475126f..8bbfb60a3 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -37,7 +37,7 @@ std::string ToUpper(std::string str) { } // For Debugging. Read out an u8 array. -std::string ArrayToString(const u8* data, size_t size, int line_len, bool spaces) { +std::string ArrayToString(const u8* data, std::size_t size, int line_len, bool spaces) { std::ostringstream oss; oss << std::setfill('0') << std::hex; @@ -56,7 +56,7 @@ std::string ArrayToString(const u8* data, size_t size, int line_len, bool spaces // Turns " hej " into "hej". Also handles tabs. std::string StripSpaces(const std::string& str) { - const size_t s = str.find_first_not_of(" \t\r\n"); + const std::size_t s = str.find_first_not_of(" \t\r\n"); if (str.npos != s) return str.substr(s, str.find_last_not_of(" \t\r\n") - s + 1); @@ -117,10 +117,10 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _ if (full_path.empty()) return false; - size_t dir_end = full_path.find_last_of("/" + std::size_t dir_end = full_path.find_last_of("/" // windows needs the : included for something like just "C:" to be considered a directory #ifdef _WIN32 - ":" + ":" #endif ); if (std::string::npos == dir_end) @@ -128,7 +128,7 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _ else dir_end += 1; - size_t fname_end = full_path.rfind('.'); + std::size_t fname_end = full_path.rfind('.'); if (fname_end < dir_end || std::string::npos == fname_end) fname_end = full_path.size(); @@ -168,7 +168,7 @@ void SplitString(const std::string& str, const char delim, std::vector& return {}; } - const size_t in_bytes = sizeof(T) * input.size(); + const std::size_t in_bytes = sizeof(T) * input.size(); // Multiply by 4, which is the max number of bytes to encode a codepoint - const size_t out_buffer_size = 4 * in_bytes; + const std::size_t out_buffer_size = 4 * in_bytes; std::string out_buffer(out_buffer_size, '\0'); auto src_buffer = &input[0]; - size_t src_bytes = in_bytes; + std::size_t src_bytes = in_bytes; auto dst_buffer = &out_buffer[0]; - size_t dst_bytes = out_buffer.size(); + std::size_t dst_bytes = out_buffer.size(); while (0 != src_bytes) { - size_t const iconv_result = + std::size_t const iconv_result = iconv(conv_desc, (char**)(&src_buffer), &src_bytes, &dst_buffer, &dst_bytes); - if (static_cast(-1) == iconv_result) { + if (static_cast(-1) == iconv_result) { if (EILSEQ == errno || EINVAL == errno) { // Try to skip the bad character if (0 != src_bytes) { @@ -322,22 +322,22 @@ std::u16string UTF8ToUTF16(const std::string& input) { return {}; } - const size_t in_bytes = sizeof(char) * input.size(); + const std::size_t in_bytes = sizeof(char) * input.size(); // Multiply by 4, which is the max number of bytes to encode a codepoint - const size_t out_buffer_size = 4 * sizeof(char16_t) * in_bytes; + const std::size_t out_buffer_size = 4 * sizeof(char16_t) * in_bytes; std::u16string out_buffer(out_buffer_size, char16_t{}); char* src_buffer = const_cast(&input[0]); - size_t src_bytes = in_bytes; + std::size_t src_bytes = in_bytes; char* dst_buffer = (char*)(&out_buffer[0]); - size_t dst_bytes = out_buffer.size(); + std::size_t dst_bytes = out_buffer.size(); while (0 != src_bytes) { - size_t const iconv_result = + std::size_t const iconv_result = iconv(conv_desc, &src_buffer, &src_bytes, &dst_buffer, &dst_bytes); - if (static_cast(-1) == iconv_result) { + if (static_cast(-1) == iconv_result) { if (EILSEQ == errno || EINVAL == errno) { // Try to skip the bad character if (0 != src_bytes) { @@ -377,8 +377,8 @@ std::string SHIFTJISToUTF8(const std::string& input) { #endif -std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, size_t max_len) { - size_t len = 0; +std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len) { + std::size_t len = 0; while (len < max_len && buffer[len] != '\0') ++len; diff --git a/src/common/string_util.h b/src/common/string_util.h index 3a6c9d159..c3a0504ff 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -19,7 +19,7 @@ std::string ToLower(std::string str); /// Make a string uppercase std::string ToUpper(std::string str); -std::string ArrayToString(const u8* data, size_t size, int line_len = 20, bool spaces = true); +std::string ArrayToString(const u8* data, std::size_t size, int line_len = 20, bool spaces = true); std::string StripSpaces(const std::string& s); std::string StripQuotes(const std::string& s); @@ -116,7 +116,7 @@ bool ComparePartialString(InIt begin, InIt end, const char* other) { * Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't * NUL-terminated then the string ends at max_len characters. */ -std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, size_t max_len); +std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len); /** * Attempts to trim an arbitrary prefix from `path`, leaving only the part starting at `root`. It's diff --git a/src/common/thread.h b/src/common/thread.h index db196c05f..4da3bd39c 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -88,12 +88,12 @@ private: class Barrier { public: - explicit Barrier(size_t count_) : count(count_), waiting(0), generation(0) {} + explicit Barrier(std::size_t count_) : count(count_), waiting(0), generation(0) {} /// Blocks until all "count" threads have called Sync() void Sync() { std::unique_lock lk(mutex); - const size_t current_generation = generation; + const std::size_t current_generation = generation; if (++waiting == count) { generation++; @@ -108,9 +108,9 @@ public: private: std::condition_variable condvar; std::mutex mutex; - const size_t count; - size_t waiting; - size_t generation; // Incremented once each time the barrier is used + const std::size_t count; + std::size_t waiting; + std::size_t generation; // Incremented once each time the barrier is used }; void SleepCurrentThread(int ms); diff --git a/src/common/x64/xbyak_abi.h b/src/common/x64/xbyak_abi.h index 927da9187..636a5c0f9 100644 --- a/src/common/x64/xbyak_abi.h +++ b/src/common/x64/xbyak_abi.h @@ -97,7 +97,7 @@ const BitSet32 ABI_ALL_CALLEE_SAVED = BuildRegSet({ Xbyak::util::xmm15, }); -constexpr size_t ABI_SHADOW_SPACE = 0x20; +constexpr std::size_t ABI_SHADOW_SPACE = 0x20; #else @@ -147,22 +147,23 @@ const BitSet32 ABI_ALL_CALLEE_SAVED = BuildRegSet({ Xbyak::util::r15, }); -constexpr size_t ABI_SHADOW_SPACE = 0; +constexpr std::size_t ABI_SHADOW_SPACE = 0; #endif -inline void ABI_CalculateFrameSize(BitSet32 regs, size_t rsp_alignment, size_t needed_frame_size, - s32* out_subtraction, s32* out_xmm_offset) { +inline void ABI_CalculateFrameSize(BitSet32 regs, std::size_t rsp_alignment, + std::size_t needed_frame_size, s32* out_subtraction, + s32* out_xmm_offset) { int count = (regs & ABI_ALL_GPRS).Count(); rsp_alignment -= count * 8; - size_t subtraction = 0; + std::size_t subtraction = 0; int xmm_count = (regs & ABI_ALL_XMMS).Count(); if (xmm_count) { // If we have any XMMs to save, we must align the stack here. subtraction = rsp_alignment & 0xF; } subtraction += 0x10 * xmm_count; - size_t xmm_base_subtraction = subtraction; + std::size_t xmm_base_subtraction = subtraction; subtraction += needed_frame_size; subtraction += ABI_SHADOW_SPACE; // Final alignment. @@ -173,8 +174,9 @@ inline void ABI_CalculateFrameSize(BitSet32 regs, size_t rsp_alignment, size_t n *out_xmm_offset = (s32)(subtraction - xmm_base_subtraction); } -inline size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, - size_t rsp_alignment, size_t needed_frame_size = 0) { +inline std::size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, + std::size_t rsp_alignment, + std::size_t needed_frame_size = 0) { s32 subtraction, xmm_offset; ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size, &subtraction, &xmm_offset); @@ -195,7 +197,8 @@ inline size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet } inline void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, - size_t rsp_alignment, size_t needed_frame_size = 0) { + std::size_t rsp_alignment, + std::size_t needed_frame_size = 0) { s32 subtraction, xmm_offset; ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size, &subtraction, &xmm_offset); diff --git a/src/common/x64/xbyak_util.h b/src/common/x64/xbyak_util.h index 02323a017..5cc8a8c76 100644 --- a/src/common/x64/xbyak_util.h +++ b/src/common/x64/xbyak_util.h @@ -34,7 +34,7 @@ inline bool IsWithin2G(const Xbyak::CodeGenerator& code, uintptr_t target) { template inline void CallFarFunction(Xbyak::CodeGenerator& code, const T f) { static_assert(std::is_pointer_v, "Argument must be a (function) pointer."); - size_t addr = reinterpret_cast(f); + std::size_t addr = reinterpret_cast(f); if (IsWithin2G(code, addr)) { code.call(f); } else { diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index 8ac2c043d..6e6da8626 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h @@ -20,12 +20,12 @@ public: virtual ~ThreadContext() = default; virtual void Reset() = 0; - virtual u32 GetCpuRegister(size_t index) const = 0; - virtual void SetCpuRegister(size_t index, u32 value) = 0; + virtual u32 GetCpuRegister(std::size_t index) const = 0; + virtual void SetCpuRegister(std::size_t index, u32 value) = 0; virtual u32 GetCpsr() const = 0; virtual void SetCpsr(u32 value) = 0; - virtual u32 GetFpuRegister(size_t index) const = 0; - virtual void SetFpuRegister(size_t index, u32 value) = 0; + virtual u32 GetFpuRegister(std::size_t index) const = 0; + virtual void SetFpuRegister(std::size_t index, u32 value) = 0; virtual u32 GetFpscr() const = 0; virtual void SetFpscr(u32 value) = 0; virtual u32 GetFpexc() const = 0; @@ -67,7 +67,7 @@ public: * @param start_address The starting address of the range to invalidate. * @param length The length (in bytes) of the range to invalidate. */ - virtual void InvalidateCacheRange(u32 start_address, size_t length) = 0; + virtual void InvalidateCacheRange(u32 start_address, std::size_t length) = 0; /// Notify CPU emulation that page tables have changed virtual void PageTableChanged() = 0; diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index a3dbefd67..4220ebd3c 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp @@ -30,10 +30,10 @@ public: fpexc = 0; } - u32 GetCpuRegister(size_t index) const override { + u32 GetCpuRegister(std::size_t index) const override { return ctx.Regs()[index]; } - void SetCpuRegister(size_t index, u32 value) override { + void SetCpuRegister(std::size_t index, u32 value) override { ctx.Regs()[index] = value; } u32 GetCpsr() const override { @@ -42,10 +42,10 @@ public: void SetCpsr(u32 value) override { ctx.SetCpsr(value); } - u32 GetFpuRegister(size_t index) const override { + u32 GetFpuRegister(std::size_t index) const override { return ctx.ExtRegs()[index]; } - void SetFpuRegister(size_t index, u32 value) override { + void SetFpuRegister(std::size_t index, u32 value) override { ctx.ExtRegs()[index] = value; } u32 GetFpscr() const override { @@ -99,7 +99,7 @@ public: Memory::Write64(vaddr, value); } - void InterpreterFallback(VAddr pc, size_t num_instructions) override { + void InterpreterFallback(VAddr pc, std::size_t num_instructions) override { parent.interpreter_state->Reg = parent.jit->Regs(); parent.interpreter_state->Cpsr = parent.jit->Cpsr(); parent.interpreter_state->Reg[15] = pc; @@ -126,7 +126,7 @@ public: void ExceptionRaised(VAddr pc, Dynarmic::A32::Exception exception) override { ASSERT_MSG(false, "ExceptionRaised(exception = {}, pc = {:08X}, code = {:08X})", - static_cast(exception), pc, MemoryReadCode(pc)); + static_cast(exception), pc, MemoryReadCode(pc)); } void AddTicks(std::uint64_t ticks) override { @@ -253,7 +253,7 @@ void ARM_Dynarmic::ClearInstructionCache() { interpreter_state->instruction_cache.clear(); } -void ARM_Dynarmic::InvalidateCacheRange(u32 start_address, size_t length) { +void ARM_Dynarmic::InvalidateCacheRange(u32 start_address, std::size_t length) { jit->InvalidateCacheRange(start_address, length); } diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index f8c395d0f..5a1f85e22 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h @@ -45,7 +45,7 @@ public: void PrepareReschedule() override; void ClearInstructionCache() override; - void InvalidateCacheRange(u32 start_address, size_t length) override; + void InvalidateCacheRange(u32 start_address, std::size_t length) override; void PageTableChanged() override; private: diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp index a46a71682..3dc1aa2f0 100644 --- a/src/core/arm/dyncom/arm_dyncom.cpp +++ b/src/core/arm/dyncom/arm_dyncom.cpp @@ -27,10 +27,10 @@ public: fpexc = 0; } - u32 GetCpuRegister(size_t index) const override { + u32 GetCpuRegister(std::size_t index) const override { return cpu_registers[index]; } - void SetCpuRegister(size_t index, u32 value) override { + void SetCpuRegister(std::size_t index, u32 value) override { cpu_registers[index] = value; } u32 GetCpsr() const override { @@ -39,10 +39,10 @@ public: void SetCpsr(u32 value) override { cpsr = value; } - u32 GetFpuRegister(size_t index) const override { + u32 GetFpuRegister(std::size_t index) const override { return fpu_registers[index]; } - void SetFpuRegister(size_t index, u32 value) override { + void SetFpuRegister(std::size_t index, u32 value) override { fpu_registers[index] = value; } u32 GetFpscr() const override { @@ -87,7 +87,7 @@ void ARM_DynCom::ClearInstructionCache() { trans_cache_buf_top = 0; } -void ARM_DynCom::InvalidateCacheRange(u32, size_t) { +void ARM_DynCom::InvalidateCacheRange(u32, std::size_t) { ClearInstructionCache(); } diff --git a/src/core/arm/dyncom/arm_dyncom.h b/src/core/arm/dyncom/arm_dyncom.h index 8eb109c9f..38d6a33c7 100644 --- a/src/core/arm/dyncom/arm_dyncom.h +++ b/src/core/arm/dyncom/arm_dyncom.h @@ -19,7 +19,7 @@ public: void Step() override; void ClearInstructionCache() override; - void InvalidateCacheRange(u32 start_address, size_t length) override; + void InvalidateCacheRange(u32 start_address, std::size_t length) override; void PageTableChanged() override; void SetPC(u32 pc) override; diff --git a/src/core/arm/dyncom/arm_dyncom_thumb.cpp b/src/core/arm/dyncom/arm_dyncom_thumb.cpp index 2a3dd0f53..a41a617eb 100644 --- a/src/core/arm/dyncom/arm_dyncom_thumb.cpp +++ b/src/core/arm/dyncom/arm_dyncom_thumb.cpp @@ -293,7 +293,7 @@ ThumbDecodeStatus TranslateThumbInstruction(u32 addr, u32 instr, u32* ainstr, u3 0xE6FF0FB0, // REVSH }; - size_t subset_index = BITS(tinstr, 6, 7); + std::size_t subset_index = BITS(tinstr, 6, 7); if (subset_index == 2) { valid = ThumbDecodeStatus::UNDEFINED; diff --git a/src/core/arm/dyncom/arm_dyncom_trans.cpp b/src/core/arm/dyncom/arm_dyncom_trans.cpp index d56299e6e..77dafbac7 100644 --- a/src/core/arm/dyncom/arm_dyncom_trans.cpp +++ b/src/core/arm/dyncom/arm_dyncom_trans.cpp @@ -9,8 +9,8 @@ char trans_cache_buf[TRANS_CACHE_SIZE]; size_t trans_cache_buf_top = 0; -static void* AllocBuffer(size_t size) { - size_t start = trans_cache_buf_top; +static void* AllocBuffer(std::size_t size) { + std::size_t start = trans_cache_buf_top; trans_cache_buf_top += size; ASSERT_MSG(trans_cache_buf_top <= TRANS_CACHE_SIZE, "Translation cache is full!"); return static_cast(&trans_cache_buf[start]); @@ -2015,4 +2015,4 @@ const transop_fp_t arm_instruction_trans[] = { INTERPRETER_TRANSLATE(blx_1_thumb), }; -const size_t arm_instruction_trans_len = sizeof(arm_instruction_trans) / sizeof(transop_fp_t); +const std::size_t arm_instruction_trans_len = sizeof(arm_instruction_trans) / sizeof(transop_fp_t); diff --git a/src/core/arm/dyncom/arm_dyncom_trans.h b/src/core/arm/dyncom/arm_dyncom_trans.h index 2a98e611e..e67df4249 100644 --- a/src/core/arm/dyncom/arm_dyncom_trans.h +++ b/src/core/arm/dyncom/arm_dyncom_trans.h @@ -491,8 +491,8 @@ typedef arm_inst* ARM_INST_PTR; typedef ARM_INST_PTR (*transop_fp_t)(unsigned int, int); extern const transop_fp_t arm_instruction_trans[]; -extern const size_t arm_instruction_trans_len; +extern const std::size_t arm_instruction_trans_len; #define TRANS_CACHE_SIZE (64 * 1024 * 2000) extern char trans_cache_buf[TRANS_CACHE_SIZE]; -extern size_t trans_cache_buf_top; +extern std::size_t trans_cache_buf_top; diff --git a/src/core/file_sys/archive_backend.cpp b/src/core/file_sys/archive_backend.cpp index 9ace371fe..a4bddcbce 100644 --- a/src/core/file_sys/archive_backend.cpp +++ b/src/core/file_sys/archive_backend.cpp @@ -102,7 +102,7 @@ std::vector Path::AsBinary() const { case LowPathType::Wchar: { // use two u8 for each character of u16str std::vector to_return(u16str.size() * 2); - for (size_t i = 0; i < u16str.size(); ++i) { + for (std::size_t i = 0; i < u16str.size(); ++i) { u16 tmp_char = u16str.at(i); to_return[i * 2] = (tmp_char & 0xFF00) >> 8; to_return[i * 2 + 1] = (tmp_char & 0x00FF); diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp index a6ce23883..e8da21193 100644 --- a/src/core/file_sys/archive_extsavedata.cpp +++ b/src/core/file_sys/archive_extsavedata.cpp @@ -37,11 +37,12 @@ public: return false; } - ResultVal Write(u64 offset, size_t length, bool flush, const u8* buffer) override { + ResultVal Write(u64 offset, std::size_t length, bool flush, + const u8* buffer) override { if (offset > size) { return ERR_WRITE_BEYOND_END; } else if (offset == size) { - return MakeResult(0); + return MakeResult(0); } if (offset + length > size) { @@ -57,7 +58,7 @@ private: class ExtSaveDataDelayGenerator : public DelayGenerator { public: - u64 GetReadDelayNs(size_t length) override { + u64 GetReadDelayNs(std::size_t length) override { // This is the delay measured for a savedate read, // not for extsaveData // For now we will take that @@ -275,7 +276,7 @@ ResultVal ArchiveFactory_ExtSaveData::GetFormatInfo(const Pat } void ArchiveFactory_ExtSaveData::WriteIcon(const Path& path, const u8* icon_data, - size_t icon_size) { + std::size_t icon_size) { std::string game_path = FileSys::GetExtSaveDataPath(GetMountPoint(), path); FileUtil::IOFile icon_file(game_path + "icon", "wb"); icon_file.WriteBytes(icon_data, icon_size); diff --git a/src/core/file_sys/archive_extsavedata.h b/src/core/file_sys/archive_extsavedata.h index 19814b5a0..79d266df4 100644 --- a/src/core/file_sys/archive_extsavedata.h +++ b/src/core/file_sys/archive_extsavedata.h @@ -44,7 +44,7 @@ public: * @param icon_data Binary data of the icon * @param icon_size Size of the icon data */ - void WriteIcon(const Path& path, const u8* icon_data, size_t icon_size); + void WriteIcon(const Path& path, const u8* icon_data, std::size_t icon_size); private: bool shared; ///< Whether this archive represents an ExtSaveData archive or a SharedExtSaveData diff --git a/src/core/file_sys/archive_ncch.cpp b/src/core/file_sys/archive_ncch.cpp index ff86d0a4e..94c0dd580 100644 --- a/src/core/file_sys/archive_ncch.cpp +++ b/src/core/file_sys/archive_ncch.cpp @@ -238,23 +238,24 @@ NCCHFile::NCCHFile(std::vector buffer, std::unique_ptr delay delay_generator = std::move(delay_generator_); } -ResultVal NCCHFile::Read(const u64 offset, const size_t length, u8* buffer) const { +ResultVal NCCHFile::Read(const u64 offset, const std::size_t length, + u8* buffer) const { LOG_TRACE(Service_FS, "called offset={}, length={}", offset, length); - size_t length_left = static_cast(data_size - offset); - size_t read_length = static_cast(std::min(length, length_left)); + std::size_t length_left = static_cast(data_size - offset); + std::size_t read_length = static_cast(std::min(length, length_left)); - size_t available_size = static_cast(file_buffer.size() - offset); - size_t copy_size = std::min(length, available_size); + std::size_t available_size = static_cast(file_buffer.size() - offset); + std::size_t copy_size = std::min(length, available_size); memcpy(buffer, file_buffer.data() + offset, copy_size); - return MakeResult(copy_size); + return MakeResult(copy_size); } -ResultVal NCCHFile::Write(const u64 offset, const size_t length, const bool flush, - const u8* buffer) { +ResultVal NCCHFile::Write(const u64 offset, const std::size_t length, const bool flush, + const u8* buffer) { LOG_ERROR(Service_FS, "Attempted to write to NCCH file"); // TODO(shinyquagsire23): Find error code - return MakeResult(0); + return MakeResult(0); } u64 NCCHFile::GetSize() const { diff --git a/src/core/file_sys/archive_ncch.h b/src/core/file_sys/archive_ncch.h index 31cdc2f5d..864b569f2 100644 --- a/src/core/file_sys/archive_ncch.h +++ b/src/core/file_sys/archive_ncch.h @@ -72,8 +72,9 @@ class NCCHFile : public FileBackend { public: explicit NCCHFile(std::vector buffer, std::unique_ptr delay_generator_); - ResultVal Read(u64 offset, size_t length, u8* buffer) const override; - ResultVal Write(u64 offset, size_t length, bool flush, const u8* buffer) override; + ResultVal Read(u64 offset, std::size_t length, u8* buffer) const override; + ResultVal Write(u64 offset, std::size_t length, bool flush, + const u8* buffer) override; u64 GetSize() const override; bool SetSize(u64 size) const override; bool Close() const override { diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index d826e0f8d..d6f3935eb 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp @@ -19,7 +19,7 @@ namespace FileSys { class SDMCDelayGenerator : public DelayGenerator { public: - u64 GetReadDelayNs(size_t length) override { + u64 GetReadDelayNs(std::size_t length) override { // This is the delay measured on O3DS and O2DS with // https://gist.github.com/B3n30/ac40eac20603f519ff106107f4ac9182 // from the results the average of each length was taken. diff --git a/src/core/file_sys/archive_selfncch.cpp b/src/core/file_sys/archive_selfncch.cpp index c08828aa8..6cadacbf5 100644 --- a/src/core/file_sys/archive_selfncch.cpp +++ b/src/core/file_sys/archive_selfncch.cpp @@ -36,7 +36,7 @@ class ExeFSSectionFile final : public FileBackend { public: explicit ExeFSSectionFile(std::shared_ptr> data_) : data(std::move(data_)) {} - ResultVal Read(u64 offset, size_t length, u8* buffer) const override { + ResultVal Read(u64 offset, std::size_t length, u8* buffer) const override { if (offset != 0) { LOG_ERROR(Service_FS, "offset must be zero!"); return ERROR_UNSUPPORTED_OPEN_FLAGS; @@ -48,10 +48,11 @@ public: } std::memcpy(buffer, data->data(), data->size()); - return MakeResult(data->size()); + return MakeResult(data->size()); } - ResultVal Write(u64 offset, size_t length, bool flush, const u8* buffer) override { + ResultVal Write(u64 offset, std::size_t length, bool flush, + const u8* buffer) override { LOG_ERROR(Service_FS, "The file is read-only!"); return ERROR_UNSUPPORTED_OPEN_FLAGS; } diff --git a/src/core/file_sys/cia_container.cpp b/src/core/file_sys/cia_container.cpp index 69abbff23..84aee77c7 100644 --- a/src/core/file_sys/cia_container.cpp +++ b/src/core/file_sys/cia_container.cpp @@ -22,7 +22,7 @@ Loader::ResultStatus CIAContainer::Load(const FileBackend& backend) { std::vector header_data(sizeof(Header)); // Load the CIA Header - ResultVal read_result = backend.Read(0, sizeof(Header), header_data.data()); + ResultVal read_result = backend.Read(0, sizeof(Header), header_data.data()); if (read_result.Failed() || *read_result != sizeof(Header)) return Loader::ResultStatus::Error; @@ -114,7 +114,8 @@ Loader::ResultStatus CIAContainer::Load(const std::vector& file_data) { return Loader::ResultStatus::Success; } -Loader::ResultStatus CIAContainer::LoadHeader(const std::vector& header_data, size_t offset) { +Loader::ResultStatus CIAContainer::LoadHeader(const std::vector& header_data, + std::size_t offset) { if (header_data.size() - offset < sizeof(Header)) return Loader::ResultStatus::Error; @@ -124,11 +125,12 @@ Loader::ResultStatus CIAContainer::LoadHeader(const std::vector& header_data } Loader::ResultStatus CIAContainer::LoadTitleMetadata(const std::vector& tmd_data, - size_t offset) { + std::size_t offset) { return cia_tmd.Load(tmd_data, offset); } -Loader::ResultStatus CIAContainer::LoadMetadata(const std::vector& meta_data, size_t offset) { +Loader::ResultStatus CIAContainer::LoadMetadata(const std::vector& meta_data, + std::size_t offset) { if (meta_data.size() - offset < sizeof(Metadata)) return Loader::ResultStatus::Error; diff --git a/src/core/file_sys/cia_container.h b/src/core/file_sys/cia_container.h index 19a5531b6..9ebe0aa34 100644 --- a/src/core/file_sys/cia_container.h +++ b/src/core/file_sys/cia_container.h @@ -23,11 +23,11 @@ namespace FileSys { class FileBackend; -constexpr size_t CIA_CONTENT_MAX_COUNT = 0x10000; -constexpr size_t CIA_CONTENT_BITS_SIZE = (CIA_CONTENT_MAX_COUNT / 8); -constexpr size_t CIA_HEADER_SIZE = 0x2020; -constexpr size_t CIA_DEPENDENCY_SIZE = 0x300; -constexpr size_t CIA_METADATA_SIZE = 0x400; +constexpr std::size_t CIA_CONTENT_MAX_COUNT = 0x10000; +constexpr std::size_t CIA_CONTENT_BITS_SIZE = (CIA_CONTENT_MAX_COUNT / 8); +constexpr std::size_t CIA_HEADER_SIZE = 0x2020; +constexpr std::size_t CIA_DEPENDENCY_SIZE = 0x300; +constexpr std::size_t CIA_METADATA_SIZE = 0x400; /** * Helper which implements an interface to read and write CTR Installable Archive (CIA) files. @@ -43,9 +43,9 @@ public: Loader::ResultStatus Load(const std::vector& header_data); // Load parts of CIAs (for CIAs streamed in) - Loader::ResultStatus LoadHeader(const std::vector& header_data, size_t offset = 0); - Loader::ResultStatus LoadTitleMetadata(const std::vector& tmd_data, size_t offset = 0); - Loader::ResultStatus LoadMetadata(const std::vector& meta_data, size_t offset = 0); + Loader::ResultStatus LoadHeader(const std::vector& header_data, std::size_t offset = 0); + Loader::ResultStatus LoadTitleMetadata(const std::vector& tmd_data, std::size_t offset = 0); + Loader::ResultStatus LoadMetadata(const std::vector& meta_data, std::size_t offset = 0); const TitleMetadata& GetTitleMetadata() const; std::array& GetDependencies(); diff --git a/src/core/file_sys/delay_generator.h b/src/core/file_sys/delay_generator.h index 410f60ee8..c43a5c026 100644 --- a/src/core/file_sys/delay_generator.h +++ b/src/core/file_sys/delay_generator.h @@ -8,14 +8,14 @@ namespace FileSys { class DelayGenerator { public: - virtual u64 GetReadDelayNs(size_t length) = 0; + virtual u64 GetReadDelayNs(std::size_t length) = 0; // TODO (B3N30): Add getter for all other file/directory io operations }; class DefaultDelayGenerator : public DelayGenerator { public: - u64 GetReadDelayNs(size_t length) override { + u64 GetReadDelayNs(std::size_t length) override { // This is the delay measured for a romfs read. // For now we will take that as a default static constexpr u64 slope(94); diff --git a/src/core/file_sys/directory_backend.h b/src/core/file_sys/directory_backend.h index 0c93f2074..e9f124b02 100644 --- a/src/core/file_sys/directory_backend.h +++ b/src/core/file_sys/directory_backend.h @@ -14,7 +14,7 @@ namespace FileSys { // Structure of a directory entry, from http://3dbrew.org/wiki/FSDir:Read#Entry_format -const size_t FILENAME_LENGTH = 0x20C / 2; +const std::size_t FILENAME_LENGTH = 0x20C / 2; struct Entry { char16_t filename[FILENAME_LENGTH]; // Entry name (UTF-16, null-terminated) std::array short_name; // 8.3 file name ('longfilename' -> 'LONGFI~1', null-terminated) diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp index 817601ebf..061460546 100644 --- a/src/core/file_sys/disk_archive.cpp +++ b/src/core/file_sys/disk_archive.cpp @@ -16,24 +16,25 @@ namespace FileSys { -ResultVal DiskFile::Read(const u64 offset, const size_t length, u8* buffer) const { +ResultVal DiskFile::Read(const u64 offset, const std::size_t length, + u8* buffer) const { if (!mode.read_flag) return ERROR_INVALID_OPEN_FLAGS; file->Seek(offset, SEEK_SET); - return MakeResult(file->ReadBytes(buffer, length)); + return MakeResult(file->ReadBytes(buffer, length)); } -ResultVal DiskFile::Write(const u64 offset, const size_t length, const bool flush, - const u8* buffer) { +ResultVal DiskFile::Write(const u64 offset, const std::size_t length, const bool flush, + const u8* buffer) { if (!mode.write_flag) return ERROR_INVALID_OPEN_FLAGS; file->Seek(offset, SEEK_SET); - size_t written = file->WriteBytes(buffer, length); + std::size_t written = file->WriteBytes(buffer, length); if (flush) file->Flush(); - return MakeResult(written); + return MakeResult(written); } u64 DiskFile::GetSize() const { @@ -70,7 +71,7 @@ u32 DiskDirectory::Read(const u32 count, Entry* entries) { LOG_TRACE(Service_FS, "File {}: size={} dir={}", filename, file.size, file.isDirectory); // TODO(Link Mauve): use a proper conversion to UTF-16. - for (size_t j = 0; j < FILENAME_LENGTH; ++j) { + for (std::size_t j = 0; j < FILENAME_LENGTH; ++j) { entry.filename[j] = filename[j]; if (!filename[j]) break; diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h index fd6983ed1..481aa470a 100644 --- a/src/core/file_sys/disk_archive.h +++ b/src/core/file_sys/disk_archive.h @@ -29,8 +29,9 @@ public: mode.hex = mode_.hex; } - ResultVal Read(u64 offset, size_t length, u8* buffer) const override; - ResultVal Write(u64 offset, size_t length, bool flush, const u8* buffer) override; + ResultVal Read(u64 offset, std::size_t length, u8* buffer) const override; + ResultVal Write(u64 offset, std::size_t length, bool flush, + const u8* buffer) override; u64 GetSize() const override; bool SetSize(u64 size) const override; bool Close() const override; diff --git a/src/core/file_sys/file_backend.h b/src/core/file_sys/file_backend.h index 0f2a8c730..103b81d60 100644 --- a/src/core/file_sys/file_backend.h +++ b/src/core/file_sys/file_backend.h @@ -28,7 +28,7 @@ public: * @param buffer Buffer to read data into * @return Number of bytes read, or error code */ - virtual ResultVal Read(u64 offset, size_t length, u8* buffer) const = 0; + virtual ResultVal Read(u64 offset, std::size_t length, u8* buffer) const = 0; /** * Write data to the file @@ -38,14 +38,15 @@ public: * @param buffer Buffer to read data from * @return Number of bytes written, or error code */ - virtual ResultVal Write(u64 offset, size_t length, bool flush, const u8* buffer) = 0; + virtual ResultVal Write(u64 offset, std::size_t length, bool flush, + const u8* buffer) = 0; /** * Get the amount of time a 3ds needs to read those data * @param length Length in bytes of data read from file * @return Nanoseconds for the delay */ - u64 GetReadDelayNs(size_t length) { + u64 GetReadDelayNs(std::size_t length) { if (delay_generator != nullptr) { return delay_generator->GetReadDelayNs(length); } diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp index 452c5a766..5a11e786d 100644 --- a/src/core/file_sys/ivfc_archive.cpp +++ b/src/core/file_sys/ivfc_archive.cpp @@ -90,16 +90,17 @@ IVFCFile::IVFCFile(std::shared_ptr file, delay_generator = std::move(delay_generator_); } -ResultVal IVFCFile::Read(const u64 offset, const size_t length, u8* buffer) const { +ResultVal IVFCFile::Read(const u64 offset, const std::size_t length, + u8* buffer) const { LOG_TRACE(Service_FS, "called offset={}, length={}", offset, length); - return MakeResult(romfs_file->ReadFile(offset, length, buffer)); + return MakeResult(romfs_file->ReadFile(offset, length, buffer)); } -ResultVal IVFCFile::Write(const u64 offset, const size_t length, const bool flush, - const u8* buffer) { +ResultVal IVFCFile::Write(const u64 offset, const std::size_t length, const bool flush, + const u8* buffer) { LOG_ERROR(Service_FS, "Attempted to write to IVFC file"); // TODO(Subv): Find error code - return MakeResult(0); + return MakeResult(0); } u64 IVFCFile::GetSize() const { @@ -119,19 +120,20 @@ IVFCFileInMemory::IVFCFileInMemory(std::vector bytes, u64 offset, u64 size, delay_generator = std::move(delay_generator_); } -ResultVal IVFCFileInMemory::Read(const u64 offset, const size_t length, u8* buffer) const { +ResultVal IVFCFileInMemory::Read(const u64 offset, const std::size_t length, + u8* buffer) const { LOG_TRACE(Service_FS, "called offset={}, length={}", offset, length); - size_t read_length = (size_t)std::min((u64)length, data_size - offset); + std::size_t read_length = (std::size_t)std::min((u64)length, data_size - offset); std::memcpy(buffer, romfs_file.data() + data_offset + offset, read_length); - return MakeResult(read_length); + return MakeResult(read_length); } -ResultVal IVFCFileInMemory::Write(const u64 offset, const size_t length, const bool flush, - const u8* buffer) { +ResultVal IVFCFileInMemory::Write(const u64 offset, const std::size_t length, + const bool flush, const u8* buffer) { LOG_ERROR(Service_FS, "Attempted to write to IVFC file"); // TODO(Subv): Find error code - return MakeResult(0); + return MakeResult(0); } u64 IVFCFileInMemory::GetSize() const { diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/ivfc_archive.h index 30afa7746..ded0b9075 100644 --- a/src/core/file_sys/ivfc_archive.h +++ b/src/core/file_sys/ivfc_archive.h @@ -22,7 +22,7 @@ namespace FileSys { class IVFCDelayGenerator : public DelayGenerator { - u64 GetReadDelayNs(size_t length) override { + u64 GetReadDelayNs(std::size_t length) override { // This is the delay measured for a romfs read. // For now we will take that as a default static constexpr u64 slope(94); @@ -35,7 +35,7 @@ class IVFCDelayGenerator : public DelayGenerator { class RomFSDelayGenerator : public DelayGenerator { public: - u64 GetReadDelayNs(size_t length) override { + u64 GetReadDelayNs(std::size_t length) override { // The delay was measured on O3DS and O2DS with // https://gist.github.com/B3n30/ac40eac20603f519ff106107f4ac9182 // from the results the average of each length was taken. @@ -49,7 +49,7 @@ public: class ExeFSDelayGenerator : public DelayGenerator { public: - u64 GetReadDelayNs(size_t length) override { + u64 GetReadDelayNs(std::size_t length) override { // The delay was measured on O3DS and O2DS with // https://gist.github.com/B3n30/ac40eac20603f519ff106107f4ac9182 // from the results the average of each length was taken. @@ -92,8 +92,9 @@ class IVFCFile : public FileBackend { public: IVFCFile(std::shared_ptr file, std::unique_ptr delay_generator_); - ResultVal Read(u64 offset, size_t length, u8* buffer) const override; - ResultVal Write(u64 offset, size_t length, bool flush, const u8* buffer) override; + ResultVal Read(u64 offset, std::size_t length, u8* buffer) const override; + ResultVal Write(u64 offset, std::size_t length, bool flush, + const u8* buffer) override; u64 GetSize() const override; bool SetSize(u64 size) const override; bool Close() const override { @@ -120,8 +121,9 @@ public: IVFCFileInMemory(std::vector bytes, u64 offset, u64 size, std::unique_ptr delay_generator_); - ResultVal Read(u64 offset, size_t length, u8* buffer) const override; - ResultVal Write(u64 offset, size_t length, bool flush, const u8* buffer) override; + ResultVal Read(u64 offset, std::size_t length, u8* buffer) const override; + ResultVal Write(u64 offset, std::size_t length, bool flush, + const u8* buffer) override; u64 GetSize() const override; bool SetSize(u64 size) const override; bool Close() const override { diff --git a/src/core/file_sys/ncch_container.cpp b/src/core/file_sys/ncch_container.cpp index e873d0dd9..70f1c27f9 100644 --- a/src/core/file_sys/ncch_container.cpp +++ b/src/core/file_sys/ncch_container.cpp @@ -394,8 +394,8 @@ Loader::ResultStatus NCCHContainer::LoadSectionExeFS(const char* name, std::vect // instead of the ExeFS. if (std::strcmp(name, "logo") == 0) { if (ncch_header.logo_region_offset && ncch_header.logo_region_size) { - size_t logo_offset = ncch_header.logo_region_offset * kBlockSize; - size_t logo_size = ncch_header.logo_region_size * kBlockSize; + std::size_t logo_offset = ncch_header.logo_region_offset * kBlockSize; + std::size_t logo_size = ncch_header.logo_region_size * kBlockSize; buffer.resize(logo_size); file.Seek(ncch_offset + logo_offset, SEEK_SET); diff --git a/src/core/file_sys/savedata_archive.cpp b/src/core/file_sys/savedata_archive.cpp index 7892a9d08..b2569e498 100644 --- a/src/core/file_sys/savedata_archive.cpp +++ b/src/core/file_sys/savedata_archive.cpp @@ -15,7 +15,7 @@ namespace FileSys { class SaveDataDelayGenerator : public DelayGenerator { public: - u64 GetReadDelayNs(size_t length) override { + u64 GetReadDelayNs(std::size_t length) override { // The delay was measured on O3DS and O2DS with // https://gist.github.com/B3n30/ac40eac20603f519ff106107f4ac9182 // from the results the average of each length was taken. diff --git a/src/core/file_sys/title_metadata.cpp b/src/core/file_sys/title_metadata.cpp index ec6b90992..97f0a78bd 100644 --- a/src/core/file_sys/title_metadata.cpp +++ b/src/core/file_sys/title_metadata.cpp @@ -50,8 +50,8 @@ Loader::ResultStatus TitleMetadata::Load(const std::string& file_path) { return result; } -Loader::ResultStatus TitleMetadata::Load(const std::vector file_data, size_t offset) { - size_t total_size = static_cast(file_data.size() - offset); +Loader::ResultStatus TitleMetadata::Load(const std::vector file_data, std::size_t offset) { + std::size_t total_size = static_cast(file_data.size() - offset); if (total_size < sizeof(u32_be)) return Loader::ResultStatus::Error; @@ -61,8 +61,8 @@ Loader::ResultStatus TitleMetadata::Load(const std::vector file_data, size_t u32 signature_size = GetSignatureSize(signature_type); // The TMD body start position is rounded to the nearest 0x40 after the signature - size_t body_start = Common::AlignUp(signature_size + sizeof(u32), 0x40); - size_t body_end = body_start + sizeof(Body); + std::size_t body_start = Common::AlignUp(signature_size + sizeof(u32), 0x40); + std::size_t body_end = body_start + sizeof(Body); if (total_size < body_end) return Loader::ResultStatus::Error; @@ -72,7 +72,7 @@ Loader::ResultStatus TitleMetadata::Load(const std::vector file_data, size_t memcpy(tmd_signature.data(), &file_data[offset + sizeof(u32_be)], signature_size); memcpy(&tmd_body, &file_data[offset + body_start], sizeof(TitleMetadata::Body)); - size_t expected_size = + std::size_t expected_size = body_start + sizeof(Body) + static_cast(tmd_body.content_count) * sizeof(ContentChunk); if (total_size < expected_size) { LOG_ERROR(Service_FS, "Malformed TMD, expected size 0x{:x}, got 0x{:x}!", expected_size, @@ -106,7 +106,7 @@ Loader::ResultStatus TitleMetadata::Save(const std::string& file_path) { return Loader::ResultStatus::Error; // The TMD body start position is rounded to the nearest 0x40 after the signature - size_t body_start = Common::AlignUp(signature_size + sizeof(u32), 0x40); + std::size_t body_start = Common::AlignUp(signature_size + sizeof(u32), 0x40); file.Seek(body_start, SEEK_SET); // Update our TMD body values and hashes @@ -126,7 +126,7 @@ Loader::ResultStatus TitleMetadata::Save(const std::string& file_path) { chunk_hash.Final(tmd_body.contentinfo[0].hash.data()); CryptoPP::SHA256 contentinfo_hash; - for (size_t i = 0; i < tmd_body.contentinfo.size(); i++) { + for (std::size_t i = 0; i < tmd_body.contentinfo.size(); i++) { chunk_hash.Update(reinterpret_cast(&tmd_body.contentinfo[i]), sizeof(ContentInfo)); } chunk_hash.Final(tmd_body.contentinfo_hash.data()); @@ -213,7 +213,7 @@ void TitleMetadata::Print() const { // Content info describes ranges of content chunks LOG_DEBUG(Service_FS, "Content info:"); - for (size_t i = 0; i < tmd_body.contentinfo.size(); i++) { + for (std::size_t i = 0; i < tmd_body.contentinfo.size(); i++) { if (tmd_body.contentinfo[i].command_count == 0) break; @@ -223,7 +223,7 @@ void TitleMetadata::Print() const { } // For each content info, print their content chunk range - for (size_t i = 0; i < tmd_body.contentinfo.size(); i++) { + for (std::size_t i = 0; i < tmd_body.contentinfo.size(); i++) { u16 index = static_cast(tmd_body.contentinfo[i].index); u16 count = static_cast(tmd_body.contentinfo[i].command_count); diff --git a/src/core/file_sys/title_metadata.h b/src/core/file_sys/title_metadata.h index 1d2302e0e..6099c6a3a 100644 --- a/src/core/file_sys/title_metadata.h +++ b/src/core/file_sys/title_metadata.h @@ -94,14 +94,14 @@ public: #pragma pack(pop) Loader::ResultStatus Load(const std::string& file_path); - Loader::ResultStatus Load(const std::vector file_data, size_t offset = 0); + Loader::ResultStatus Load(const std::vector file_data, std::size_t offset = 0); Loader::ResultStatus Save(const std::string& file_path); u64 GetTitleID() const; u32 GetTitleType() const; u16 GetTitleVersion() const; u64 GetSystemVersion() const; - size_t GetContentCount() const; + std::size_t GetContentCount() const; u32 GetBootContentID() const; u32 GetManualContentID() const; u32 GetDLPContentID() const; diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index c1a875c08..f95b3c66e 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -262,7 +262,7 @@ static u8 NibbleToHex(u8 n) { * @param src Pointer to array of output hex string characters. * @param len Length of src array. */ -static u32 HexToInt(const u8* src, size_t len) { +static u32 HexToInt(const u8* src, std::size_t len) { u32 output = 0; while (len-- > 0) { output = (output << 4) | HexCharToValue(src[0]); @@ -278,7 +278,7 @@ static u32 HexToInt(const u8* src, size_t len) { * @param src Pointer to array of u8 bytes. * @param len Length of src array. */ -static void MemToGdbHex(u8* dest, const u8* src, size_t len) { +static void MemToGdbHex(u8* dest, const u8* src, std::size_t len) { while (len-- > 0) { u8 tmp = *src++; *dest++ = NibbleToHex(tmp >> 4); @@ -293,7 +293,7 @@ static void MemToGdbHex(u8* dest, const u8* src, size_t len) { * @param src Pointer to array of output hex string characters. * @param len Length of src array. */ -static void GdbHexToMem(u8* dest, const u8* src, size_t len) { +static void GdbHexToMem(u8* dest, const u8* src, std::size_t len) { while (len-- > 0) { *dest++ = (HexCharToValue(src[0]) << 4) | HexCharToValue(src[1]); src += 2; @@ -361,7 +361,7 @@ static u64 GdbHexToLong(const u8* src) { /// Read a byte from the gdb client. static u8 ReadByte() { u8 c; - size_t received_size = recv(gdbserver_socket, reinterpret_cast(&c), 1, MSG_WAITALL); + std::size_t received_size = recv(gdbserver_socket, reinterpret_cast(&c), 1, MSG_WAITALL); if (received_size != 1) { LOG_ERROR(Debug_GDBStub, "recv failed : {}", received_size); Shutdown(); @@ -371,7 +371,7 @@ static u8 ReadByte() { } /// Calculate the checksum of the current command buffer. -static u8 CalculateChecksum(const u8* buffer, size_t length) { +static u8 CalculateChecksum(const u8* buffer, std::size_t length) { return static_cast(std::accumulate(buffer, buffer + length, 0, std::plus())); } @@ -473,7 +473,7 @@ bool CheckBreakpoint(VAddr addr, BreakpointType type) { * @param packet Packet to be sent to client. */ static void SendPacket(const char packet) { - size_t sent_size = send(gdbserver_socket, &packet, 1, 0); + std::size_t sent_size = send(gdbserver_socket, &packet, 1, 0); if (sent_size != 1) { LOG_ERROR(Debug_GDBStub, "send failed"); } diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp index 94a4ab339..1b19b7d68 100644 --- a/src/core/hle/applets/swkbd.cpp +++ b/src/core/hle/applets/swkbd.cpp @@ -149,7 +149,7 @@ Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig( frontend_config.max_text_length = config.max_text_length; frontend_config.max_digits = config.max_digits; - size_t text_size = config.hint_text.size(); + std::size_t text_size = config.hint_text.size(); const auto text_end = std::find(config.hint_text.begin(), config.hint_text.end(), u'\0'); if (text_end != config.hint_text.end()) text_size = std::distance(config.hint_text.begin(), text_end); diff --git a/src/core/hle/ipc.h b/src/core/hle/ipc.h index 974a7f98c..adf2a9ec6 100644 --- a/src/core/hle/ipc.h +++ b/src/core/hle/ipc.h @@ -33,10 +33,10 @@ inline u32* GetCommandBuffer(const int offset = 0) { namespace IPC { /// Size of the command buffer area, in 32-bit words. -constexpr size_t COMMAND_BUFFER_LENGTH = 0x100 / sizeof(u32); +constexpr std::size_t COMMAND_BUFFER_LENGTH = 0x100 / sizeof(u32); // Maximum number of static buffers per thread. -constexpr size_t MAX_STATIC_BUFFERS = 16; +constexpr std::size_t MAX_STATIC_BUFFERS = 16; // These errors are commonly returned by invalid IPC translations, so alias them here for // convenience. @@ -113,7 +113,7 @@ union StaticBufferDescInfo { BitField<14, 18, u32> size; }; -inline u32 StaticBufferDesc(size_t size, u8 buffer_id) { +inline u32 StaticBufferDesc(std::size_t size, u8 buffer_id) { StaticBufferDescInfo info{}; info.descriptor_type.Assign(StaticBuffer); info.buffer_id.Assign(buffer_id); @@ -151,7 +151,7 @@ union MappedBufferDescInfo { BitField<4, 28, u32> size; }; -inline u32 MappedBufferDesc(size_t size, MappedBufferPermissions perms) { +inline u32 MappedBufferDesc(std::size_t size, MappedBufferPermissions perms) { MappedBufferDescInfo info{}; info.flags.Assign(MappedBuffer); info.perms.Assign(perms); diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 4345540fb..a9304f6e2 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -27,7 +27,7 @@ public: : context(&context), cmdbuf(context.CommandBuffer()), header(desired_header) {} /// Returns the total size of the request in words - size_t TotalSize() const { + std::size_t TotalSize() const { return 1 /* command header */ + header.normal_params_size + header.translate_params_size; } @@ -398,7 +398,7 @@ inline std::array, N> RequestParser::PopGeneri } namespace detail { -template +template std::tuple...> PopObjectsHelper( std::array, sizeof...(T)>&& pointers, std::index_sequence) { diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 8b24b7806..a0805a752 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp @@ -66,7 +66,7 @@ ResultCode HandleTable::Close(Handle handle) { } bool HandleTable::IsValid(Handle handle) const { - size_t slot = GetSlot(handle); + std::size_t slot = GetSlot(handle); u16 generation = GetGeneration(handle); return slot < MAX_COUNT && objects[slot] != nullptr && generations[slot] == generation; diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index 22ddda630..5497dd74a 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h @@ -93,7 +93,7 @@ private: * This is the maximum limit of handles allowed per process in CTR-OS. It can be further * reduced by ExHeader values, but this is not emulated here. */ - static const size_t MAX_COUNT = 4096; + static const std::size_t MAX_COUNT = 4096; static u16 GetSlot(Handle handle) { return handle >> 15; diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 5ab7af552..7c5f53452 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -100,13 +100,13 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* sr HandleTable& src_table) { IPC::Header header{src_cmdbuf[0]}; - size_t untranslated_size = 1u + header.normal_params_size; - size_t command_size = untranslated_size + header.translate_params_size; + std::size_t untranslated_size = 1u + header.normal_params_size; + std::size_t command_size = untranslated_size + header.translate_params_size; ASSERT(command_size <= IPC::COMMAND_BUFFER_LENGTH); // TODO(yuriks): Return error std::copy_n(src_cmdbuf, untranslated_size, cmd_buf.begin()); - size_t i = untranslated_size; + std::size_t i = untranslated_size; while (i < command_size) { u32 descriptor = cmd_buf[i] = src_cmdbuf[i]; i += 1; @@ -165,13 +165,13 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, P HandleTable& dst_table) const { IPC::Header header{cmd_buf[0]}; - size_t untranslated_size = 1u + header.normal_params_size; - size_t command_size = untranslated_size + header.translate_params_size; + std::size_t untranslated_size = 1u + header.normal_params_size; + std::size_t command_size = untranslated_size + header.translate_params_size; ASSERT(command_size <= IPC::COMMAND_BUFFER_LENGTH); std::copy_n(cmd_buf.begin(), untranslated_size, dst_cmdbuf); - size_t i = untranslated_size; + std::size_t i = untranslated_size; while (i < command_size) { u32 descriptor = dst_cmdbuf[i] = cmd_buf[i]; i += 1; @@ -201,7 +201,8 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, P // Grab the address that the target thread set up to receive the response static buffer // and write our data there. The static buffers area is located right after the command // buffer area. - size_t static_buffer_offset = IPC::COMMAND_BUFFER_LENGTH + 2 * buffer_info.buffer_id; + std::size_t static_buffer_offset = + IPC::COMMAND_BUFFER_LENGTH + 2 * buffer_info.buffer_id; IPC::StaticBufferDescInfo target_descriptor{dst_cmdbuf[static_buffer_offset]}; VAddr target_address = dst_cmdbuf[static_buffer_offset + 1]; @@ -237,13 +238,13 @@ MappedBuffer::MappedBuffer(const Process& process, u32 descriptor, VAddr address perms = desc.perms; } -void MappedBuffer::Read(void* dest_buffer, size_t offset, size_t size) { +void MappedBuffer::Read(void* dest_buffer, std::size_t offset, std::size_t size) { ASSERT(perms & IPC::R); ASSERT(offset + size <= this->size); Memory::ReadBlock(*process, address + static_cast(offset), dest_buffer, size); } -void MappedBuffer::Write(const void* src_buffer, size_t offset, size_t size) { +void MappedBuffer::Write(const void* src_buffer, std::size_t offset, std::size_t size) { ASSERT(perms & IPC::W); ASSERT(offset + size <= this->size); Memory::WriteBlock(*process, address + static_cast(offset), src_buffer, size); diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 5622be96f..3a2b81b16 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -98,9 +98,9 @@ public: MappedBuffer(const Process& process, u32 descriptor, VAddr address, u32 id); // interface for service - void Read(void* dest_buffer, size_t offset, size_t size); - void Write(const void* src_buffer, size_t offset, size_t size); - size_t GetSize() const { + void Read(void* dest_buffer, std::size_t offset, std::size_t size); + void Write(const void* src_buffer, std::size_t offset, std::size_t size); + std::size_t GetSize() const { return size; } @@ -118,7 +118,7 @@ private: u32 id; VAddr address; const Process* process; - size_t size; + std::size_t size; IPC::MappedBufferPermissions perms; }; diff --git a/src/core/hle/kernel/ipc.cpp b/src/core/hle/kernel/ipc.cpp index eed6c8c01..8db9d241f 100644 --- a/src/core/hle/kernel/ipc.cpp +++ b/src/core/hle/kernel/ipc.cpp @@ -24,8 +24,8 @@ ResultCode TranslateCommandBuffer(SharedPtr src_thread, SharedPtr src_thread, SharedPtr cmd_buf; Memory::ReadBlock(*src_process, src_address, cmd_buf.data(), command_size * sizeof(u32)); - size_t i = untranslated_size; + std::size_t i = untranslated_size; while (i < command_size) { u32 descriptor = cmd_buf[i]; i += 1; @@ -178,11 +178,12 @@ ResultCode TranslateCommandBuffer(SharedPtr src_thread, SharedPtr>(Memory::PAGE_SIZE); // Number of bytes until the next page. - size_t difference_to_page = + std::size_t difference_to_page = Common::AlignUp(source_address, Memory::PAGE_SIZE) - source_address; // If the data fits in one page we can just copy the required size instead of the // entire page. - size_t read_size = num_pages == 1 ? static_cast(size) : difference_to_page; + std::size_t read_size = + num_pages == 1 ? static_cast(size) : difference_to_page; Memory::ReadBlock(*src_process, source_address, buffer->data() + page_offset, read_size); diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index b69acd424..8f3efe5d9 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -46,8 +46,8 @@ SharedPtr Process::Create(SharedPtr code_set) { return process; } -void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) { - for (size_t i = 0; i < len; ++i) { +void Process::ParseKernelCaps(const u32* kernel_caps, std::size_t len) { + for (std::size_t i = 0; i < len; ++i) { u32 descriptor = kernel_caps[i]; u32 type = descriptor >> 20; @@ -253,7 +253,7 @@ ResultVal Process::LinearAllocate(VAddr target, u32 size, VMAPermission p // TODO(yuriks): As is, this lets processes map memory allocated by other processes from the // same region. It is unknown if or how the 3DS kernel checks against this. - size_t offset = target - GetLinearHeapBase(); + std::size_t offset = target - GetLinearHeapBase(); CASCADE_RESULT(auto vma, vm_manager.MapMemoryBlock(target, linheap_memory, offset, size, MemoryState::Continuous)); vm_manager.Reprotect(vma, perms); diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 4bb7202f9..1081be063 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -57,7 +57,7 @@ struct MemoryRegionInfo; struct CodeSet final : public Object { struct Segment { - size_t offset = 0; + std::size_t offset = 0; VAddr addr = 0; u32 size = 0; }; @@ -159,7 +159,7 @@ public: * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them * to this process. */ - void ParseKernelCaps(const u32* kernel_caps, size_t len); + void ParseKernelCaps(const u32* kernel_caps, std::size_t len); /** * Applies address space changes and launches the process main thread. diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index 2f9ced2d9..5ccd81572 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h @@ -114,7 +114,7 @@ public: /// Backing memory for this shared memory block. std::shared_ptr> backing_block; /// Offset into the backing block for this shared memory. - size_t backing_block_offset; + std::size_t backing_block_offset; /// Size of the memory block. Page-aligned. u32 size; /// Permission restrictions applied to the process which created the block. diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index fb78a2cc4..bfbf112ee 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -424,7 +424,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand thread->status = THREADSTATUS_WAIT_SYNCH_ANY; // Add the thread to each of the objects' waiting threads. - for (size_t i = 0; i < objects.size(); ++i) { + for (std::size_t i = 0; i < objects.size(); ++i) { WaitObject* object = objects[i].get(); object->AddWaitingThread(thread); } @@ -581,7 +581,7 @@ static ResultCode ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_ thread->status = THREADSTATUS_WAIT_SYNCH_ANY; // Add the thread to each of the objects' waiting threads. - for (size_t i = 0; i < objects.size(); ++i) { + for (std::size_t i = 0; i < objects.size(); ++i) { WaitObject* object = objects[i].get(); object->AddWaitingThread(thread); } diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index accc853d3..e9d1c811c 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -378,7 +378,7 @@ ResultVal> Thread::Create(std::string name, VAddr entry_point, return ERR_OUT_OF_MEMORY; } - size_t offset = linheap_memory->size(); + std::size_t offset = linheap_memory->size(); // Allocate some memory from the end of the linear heap for this region. linheap_memory->insert(linheap_memory->end(), Memory::PAGE_SIZE, 0); diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index e2891fded..36e24682b 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -73,7 +73,7 @@ VMManager::VMAHandle VMManager::FindVMA(VAddr target) const { ResultVal VMManager::MapMemoryBlock(VAddr target, std::shared_ptr> block, - size_t offset, u32 size, + std::size_t offset, u32 size, MemoryState state) { ASSERT(block != nullptr); ASSERT(offset + size <= block->size()); @@ -95,7 +95,7 @@ ResultVal VMManager::MapMemoryBlock(VAddr target, ResultVal VMManager::MapMemoryBlockToBase(VAddr base, u32 region_size, std::shared_ptr> block, - size_t offset, u32 size, MemoryState state) { + std::size_t offset, u32 size, MemoryState state) { // Find the first Free VMA. VMAHandle vma_handle = std::find_if(vma_map.begin(), vma_map.end(), [&](const auto& vma) { diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index fc6a26f01..7ac5c3b01 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -75,7 +75,7 @@ struct VirtualMemoryArea { /// Memory block backing this VMA. std::shared_ptr> backing_block = nullptr; /// Offset into the backing_memory the mapping starts from. - size_t offset = 0; + std::size_t offset = 0; // Settings for type = BackingMemory /// Pointer backing this VMA. It will not be destroyed or freed when the VMA is removed. @@ -142,7 +142,7 @@ public: * @param state MemoryState tag to attach to the VMA. */ ResultVal MapMemoryBlock(VAddr target, std::shared_ptr> block, - size_t offset, u32 size, MemoryState state); + std::size_t offset, u32 size, MemoryState state); /** * Maps part of a ref-counted block of memory at the first free address after the given base. @@ -156,8 +156,8 @@ public: * @returns The address at which the memory was mapped. */ ResultVal MapMemoryBlockToBase(VAddr base, u32 region_size, - std::shared_ptr> block, size_t offset, - u32 size, MemoryState state); + std::shared_ptr> block, + std::size_t offset, u32 size, MemoryState state); /** * Maps an unmanaged host memory pointer at a given address. * diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index beafb6e48..984f5fb83 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -74,12 +74,13 @@ struct TicketInfo { static_assert(sizeof(TicketInfo) == 0x18, "Ticket info structure size is wrong"); -ResultVal CIAFile::Read(u64 offset, size_t length, u8* buffer) const { +ResultVal CIAFile::Read(u64 offset, std::size_t length, u8* buffer) const { UNIMPLEMENTED(); - return MakeResult(length); + return MakeResult(length); } -ResultVal CIAFile::WriteTitleMetadata(u64 offset, size_t length, const u8* buffer) { +ResultVal CIAFile::WriteTitleMetadata(u64 offset, std::size_t length, + const u8* buffer) { container.LoadTitleMetadata(data, container.GetTitleMetadataOffset()); FileSys::TitleMetadata tmd = container.GetTitleMetadata(); tmd.Print(); @@ -111,10 +112,10 @@ ResultVal CIAFile::WriteTitleMetadata(u64 offset, size_t length, const u content_written.resize(container.GetTitleMetadata().GetContentCount()); install_state = CIAInstallState::TMDLoaded; - return MakeResult(length); + return MakeResult(length); } -ResultVal CIAFile::WriteContentData(u64 offset, size_t length, const u8* buffer) { +ResultVal CIAFile::WriteContentData(u64 offset, std::size_t length, const u8* buffer) { // Data is not being buffered, so we have to keep track of how much of each .app // has been written since we might get a written buffer which contains multiple .app // contents or only part of a larger .app's contents. @@ -153,10 +154,11 @@ ResultVal CIAFile::WriteContentData(u64 offset, size_t length, const u8* } } - return MakeResult(length); + return MakeResult(length); } -ResultVal CIAFile::Write(u64 offset, size_t length, bool flush, const u8* buffer) { +ResultVal CIAFile::Write(u64 offset, std::size_t length, bool flush, + const u8* buffer) { written += length; // TODO(shinyquagsire23): Can we assume that things will only be written in sequence? @@ -168,9 +170,9 @@ ResultVal CIAFile::Write(u64 offset, size_t length, bool flush, const u8 // content sizes so it ends up becoming a problem of keeping track of how much has been // written and what we have been able to pick up. if (install_state == CIAInstallState::InstallStarted) { - size_t buf_copy_size = std::min(length, FileSys::CIA_HEADER_SIZE); - size_t buf_max_size = - std::min(static_cast(offset + length), FileSys::CIA_HEADER_SIZE); + std::size_t buf_copy_size = std::min(length, FileSys::CIA_HEADER_SIZE); + std::size_t buf_max_size = + std::min(static_cast(offset + length), FileSys::CIA_HEADER_SIZE); data.resize(buf_max_size); memcpy(data.data() + offset, buffer, buf_copy_size); @@ -184,18 +186,18 @@ ResultVal CIAFile::Write(u64 offset, size_t length, bool flush, const u8 // If we don't have a header yet, we can't pull offsets of other sections if (install_state == CIAInstallState::InstallStarted) - return MakeResult(length); + return MakeResult(length); // If we have been given data before (or including) .app content, pull it into // our buffer, but only pull *up to* the content offset, no further. if (offset < container.GetContentOffset()) { - size_t buf_loaded = data.size(); - size_t copy_offset = std::max(static_cast(offset), buf_loaded); - size_t buf_offset = buf_loaded - offset; - size_t buf_copy_size = - std::min(length, static_cast(container.GetContentOffset() - offset)) - + std::size_t buf_loaded = data.size(); + std::size_t copy_offset = std::max(static_cast(offset), buf_loaded); + std::size_t buf_offset = buf_loaded - offset; + std::size_t buf_copy_size = + std::min(length, static_cast(container.GetContentOffset() - offset)) - buf_loaded; - size_t buf_max_size = std::min(offset + length, container.GetContentOffset()); + std::size_t buf_max_size = std::min(offset + length, container.GetContentOffset()); data.resize(buf_max_size); memcpy(data.data() + copy_offset, buffer + buf_offset, buf_copy_size); } @@ -212,14 +214,14 @@ ResultVal CIAFile::Write(u64 offset, size_t length, bool flush, const u8 // Content data sizes can only be retrieved from TMD data if (install_state != CIAInstallState::TMDLoaded) - return MakeResult(length); + return MakeResult(length); // From this point forward, data will no longer be buffered in data auto result = WriteContentData(offset, length, buffer); if (result.Failed()) return result; - return MakeResult(length); + return MakeResult(length); } u64 CIAFile::GetSize() const { @@ -232,7 +234,7 @@ bool CIAFile::SetSize(u64 size) const { bool CIAFile::Close() const { bool complete = true; - for (size_t i = 0; i < container.GetTitleMetadata().GetContentCount(); i++) { + for (std::size_t i = 0; i < container.GetTitleMetadata().GetContentCount(); i++) { if (content_written[i] < container.GetContentSize(static_cast(i))) complete = false; } @@ -294,7 +296,7 @@ InstallStatus InstallCIA(const std::string& path, Service::AM::CIAFile installFile( Service::AM::GetTitleMediaType(container.GetTitleMetadata().GetTitleID())); - for (size_t i = 0; i < container.GetTitleMetadata().GetContentCount(); i++) { + for (std::size_t i = 0; i < container.GetTitleMetadata().GetContentCount(); i++) { if (container.GetTitleMetadata().GetContentTypeByIndex(static_cast(i)) & FileSys::TMDContentTypeFlag::Encrypted) { LOG_ERROR(Service_AM, "File {} is encrypted! Aborting...", path); @@ -307,9 +309,9 @@ InstallStatus InstallCIA(const std::string& path, return InstallStatus::ErrorFailedToOpenFile; std::array buffer; - size_t total_bytes_read = 0; + std::size_t total_bytes_read = 0; while (total_bytes_read != file.GetSize()) { - size_t bytes_read = file.ReadBytes(buffer.data(), buffer.size()); + std::size_t bytes_read = file.ReadBytes(buffer.data(), buffer.size()); auto result = installFile.Write(static_cast(total_bytes_read), bytes_read, true, static_cast(buffer.data())); @@ -525,7 +527,7 @@ void Module::Interface::FindDLCContentInfos(Kernel::HLERequestContext& ctx) { if (tmd.Load(tmd_path) == Loader::ResultStatus::Success) { std::size_t write_offset = 0; // Get info for each content index requested - for (size_t i = 0; i < content_count; i++) { + for (std::size_t i = 0; i < content_count; i++) { std::shared_ptr romfs_file; u64 romfs_offset = 0; diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 40414b6d6..6729a6b36 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -53,10 +53,10 @@ enum class InstallStatus : u32 { }; // Title ID valid length -constexpr size_t TITLE_ID_VALID_LENGTH = 16; +constexpr std::size_t TITLE_ID_VALID_LENGTH = 16; // Progress callback for InstallCIA, receives bytes written and total bytes -using ProgressCallback = void(size_t, size_t); +using ProgressCallback = void(std::size_t, std::size_t); // A file handled returned for CIAs to be written into and subsequently installed. class CIAFile final : public FileSys::FileBackend { @@ -66,10 +66,11 @@ public: Close(); } - ResultVal Read(u64 offset, size_t length, u8* buffer) const override; - ResultVal WriteTitleMetadata(u64 offset, size_t length, const u8* buffer); - ResultVal WriteContentData(u64 offset, size_t length, const u8* buffer); - ResultVal Write(u64 offset, size_t length, bool flush, const u8* buffer) override; + ResultVal Read(u64 offset, std::size_t length, u8* buffer) const override; + ResultVal WriteTitleMetadata(u64 offset, std::size_t length, const u8* buffer); + ResultVal WriteContentData(u64 offset, std::size_t length, const u8* buffer); + ResultVal Write(u64 offset, std::size_t length, bool flush, + const u8* buffer) override; u64 GetSize() const override; bool SetSize(u64 size) const override; bool Close() const override; diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp index f0091e3b8..1f312c059 100644 --- a/src/core/hle/service/apt/applet_manager.cpp +++ b/src/core/hle/service/apt/applet_manager.cpp @@ -19,11 +19,11 @@ struct AppletTitleData { std::array applet_ids; // There's a specific TitleId per region for each applet. - static constexpr size_t NumRegions = 7; + static constexpr std::size_t NumRegions = 7; std::array title_ids; }; -static constexpr size_t NumApplets = 29; +static constexpr std::size_t NumApplets = 29; static constexpr std::array applet_titleids = {{ {AppletId::HomeMenu, AppletId::None, 0x4003000008202, 0x4003000008F02, 0x4003000009802, 0x4003000008202, 0x400300000A102, 0x400300000A902, 0x400300000B102}, @@ -84,7 +84,7 @@ static u64 GetTitleIdForApplet(AppletId id) { AppletManager::AppletSlotData* AppletManager::GetAppletSlotData(AppletId id) { auto GetSlot = [this](AppletSlot slot) -> AppletSlotData* { - return &applet_slots[static_cast(slot)]; + return &applet_slots[static_cast(slot)]; }; if (id == AppletId::Application) { @@ -160,9 +160,9 @@ AppletManager::AppletSlotData* AppletManager::GetAppletSlotData(AppletAttributes // The Home Menu is a system applet, however, it has its own applet slot so that it can run // concurrently with other system applets. if (slot == AppletSlot::SystemApplet && attributes.is_home_menu) - return &applet_slots[static_cast(AppletSlot::HomeMenu)]; + return &applet_slots[static_cast(AppletSlot::HomeMenu)]; - return &applet_slots[static_cast(slot)]; + return &applet_slots[static_cast(slot)]; } void AppletManager::CancelAndSendParameter(const MessageParameter& parameter) { @@ -314,7 +314,7 @@ ResultCode AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) { ErrorSummary::InvalidState, ErrorLevel::Status); } - const auto& slot = applet_slots[static_cast(AppletSlot::LibraryApplet)]; + const auto& slot = applet_slots[static_cast(AppletSlot::LibraryApplet)]; if (slot.registered) { return ResultCode(ErrorDescription::AlreadyExists, ErrorModule::Applet, @@ -341,7 +341,7 @@ ResultCode AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) { } ResultCode AppletManager::PreloadLibraryApplet(AppletId applet_id) { - const auto& slot = applet_slots[static_cast(AppletSlot::LibraryApplet)]; + const auto& slot = applet_slots[static_cast(AppletSlot::LibraryApplet)]; if (slot.registered) { return ResultCode(ErrorDescription::AlreadyExists, ErrorModule::Applet, @@ -369,7 +369,7 @@ ResultCode AppletManager::PreloadLibraryApplet(AppletId applet_id) { ResultCode AppletManager::FinishPreloadingLibraryApplet(AppletId applet_id) { // TODO(Subv): This function should fail depending on the applet preparation state. - auto& slot = applet_slots[static_cast(AppletSlot::LibraryApplet)]; + auto& slot = applet_slots[static_cast(AppletSlot::LibraryApplet)]; slot.loaded = true; return RESULT_SUCCESS; } @@ -417,7 +417,7 @@ ResultCode AppletManager::PrepareToCloseLibraryApplet(bool not_pause, bool exiti ResultCode AppletManager::CloseLibraryApplet(Kernel::SharedPtr object, std::vector buffer) { - auto& slot = applet_slots[static_cast(AppletSlot::LibraryApplet)]; + auto& slot = applet_slots[static_cast(AppletSlot::LibraryApplet)]; MessageParameter param; // TODO(Subv): The destination id should be the "current applet slot id", which changes @@ -467,7 +467,7 @@ ResultVal AppletManager::GetAppletInfo(AppletId app_i } AppletManager::AppletManager() { - for (size_t slot = 0; slot < applet_slots.size(); ++slot) { + for (std::size_t slot = 0; slot < applet_slots.size(); ++slot) { auto& slot_data = applet_slots[slot]; slot_data.slot = static_cast(slot); slot_data.applet_id = AppletId::None; diff --git a/src/core/hle/service/apt/applet_manager.h b/src/core/hle/service/apt/applet_manager.h index 17626efae..7c17eccff 100644 --- a/src/core/hle/service/apt/applet_manager.h +++ b/src/core/hle/service/apt/applet_manager.h @@ -146,7 +146,7 @@ private: /// TODO(Subv): Use std::optional once we migrate to C++17. boost::optional next_parameter; - static constexpr size_t NumAppletSlot = 4; + static constexpr std::size_t NumAppletSlot = 4; enum class AppletSlot : u8 { Application, diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index cca5c16da..656e2fd77 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -533,7 +533,7 @@ void Module::Interface::StartLibraryApplet(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x1E, 2, 4); // 0x1E0084 AppletId applet_id = rp.PopEnum(); - size_t buffer_size = rp.Pop(); + std::size_t buffer_size = rp.Pop(); Kernel::SharedPtr object = rp.PopGenericObject(); std::vector buffer = rp.PopStaticBuffer(); diff --git a/src/core/hle/service/cam/cam.cpp b/src/core/hle/service/cam/cam.cpp index 28abd437a..4df0f774f 100644 --- a/src/core/hle/service/cam/cam.cpp +++ b/src/core/hle/service/cam/cam.cpp @@ -128,7 +128,7 @@ void Module::CompletionEventCallBack(u64 port_id, s64) { port.dest_size, buffer_size); } Memory::WriteBlock(*port.dest_process, port.dest, buffer.data(), - std::min(port.dest_size, buffer_size)); + std::min(port.dest_size, buffer_size)); } port.is_receiving = false; diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index b7ed429b0..49d17c190 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -477,7 +477,7 @@ ResultCode Module::FormatConfig() { u16_le country_name_buffer[16][0x40] = {}; std::u16string region_name = Common::UTF8ToUTF16("Gensokyo"); - for (size_t i = 0; i < 16; ++i) { + for (std::size_t i = 0; i < 16; ++i) { std::copy(region_name.cbegin(), region_name.cend(), country_name_buffer[i]); } // 0x000B0001 - Localized names for the profile Country @@ -627,7 +627,7 @@ std::u16string Module::GetUsername() { // the username string in the block isn't null-terminated, // so we need to find the end manually. std::u16string username(block.username, ARRAY_SIZE(block.username)); - const size_t pos = username.find(u'\0'); + const std::size_t pos = username.find(u'\0'); if (pos != std::u16string::npos) username.erase(pos); return username; diff --git a/src/core/hle/service/dsp/dsp_dsp.cpp b/src/core/hle/service/dsp/dsp_dsp.cpp index 47b352702..5568eb9d0 100644 --- a/src/core/hle/service/dsp/dsp_dsp.cpp +++ b/src/core/hle/service/dsp/dsp_dsp.cpp @@ -330,16 +330,16 @@ Kernel::SharedPtr& DSP_DSP::GetInterruptEvent(InterruptType type, case InterruptType::One: return interrupt_one; case InterruptType::Pipe: { - const size_t pipe_index = static_cast(pipe); + const std::size_t pipe_index = static_cast(pipe); ASSERT(pipe_index < AudioCore::num_dsp_pipe); return pipes[pipe_index]; } } - UNREACHABLE_MSG("Invalid interrupt type = {}", static_cast(type)); + UNREACHABLE_MSG("Invalid interrupt type = {}", static_cast(type)); } bool DSP_DSP::HasTooManyEventsRegistered() const { - size_t number = + std::size_t number = std::count_if(pipes.begin(), pipes.end(), [](const auto& evt) { return evt != nullptr; }); if (interrupt_zero != nullptr) diff --git a/src/core/hle/service/dsp/dsp_dsp.h b/src/core/hle/service/dsp/dsp_dsp.h index c7213cce4..144ea75f1 100644 --- a/src/core/hle/service/dsp/dsp_dsp.h +++ b/src/core/hle/service/dsp/dsp_dsp.h @@ -18,11 +18,11 @@ public: ~DSP_DSP(); /// There are three types of interrupts - static constexpr size_t NUM_INTERRUPT_TYPE = 3; + static constexpr std::size_t NUM_INTERRUPT_TYPE = 3; enum class InterruptType : u32 { Zero = 0, One = 1, Pipe = 2 }; /// Actual service implementation only has 6 'slots' for interrupts. - static constexpr size_t max_number_of_interrupt_events = 6; + static constexpr std::size_t max_number_of_interrupt_events = 6; /// Signal interrupt on pipe void SignalInterrupt(InterruptType type, AudioCore::DspPipe pipe); diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp index 04bb16e41..e9681e4c1 100644 --- a/src/core/hle/service/frd/frd.cpp +++ b/src/core/hle/service/frd/frd.cpp @@ -106,8 +106,8 @@ void Module::Interface::GetMyScreenName(Kernel::HLERequestContext& ctx) { } void Module::Interface::UnscrambleLocalFriendCode(Kernel::HLERequestContext& ctx) { - const size_t scrambled_friend_code_size = 12; - const size_t friend_code_size = 8; + const std::size_t scrambled_friend_code_size = 12; + const std::size_t friend_code_size = 8; IPC::RequestParser rp(ctx, 0x1C, 1, 2); const u32 friend_code_count = rp.Pop(); diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index e4ed0a40a..79fb1847f 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -94,7 +94,7 @@ void File::Read(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); std::vector data(length); - ResultVal read = backend->Read(offset, data.size(), data.data()); + ResultVal read = backend->Read(offset, data.size(), data.data()); if (read.Failed()) { rb.Push(read.Code()); rb.Push(0); @@ -136,7 +136,7 @@ void File::Write(Kernel::HLERequestContext& ctx) { std::vector data(length); buffer.Read(data.data(), 0, data.size()); - ResultVal written = backend->Write(offset, data.size(), flush != 0, data.data()); + ResultVal written = backend->Write(offset, data.size(), flush != 0, data.data()); if (written.Failed()) { rb.Push(written.Code()); rb.Push(0); @@ -268,7 +268,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) { return; } - size_t end = offset + size; + std::size_t end = offset + size; // TODO(Subv): Check for overflow and return ERR_WRITE_BEYOND_END diff --git a/src/core/hle/service/gsp/gsp_gpu.cpp b/src/core/hle/service/gsp/gsp_gpu.cpp index 493d39034..0de369b4e 100644 --- a/src/core/hle/service/gsp/gsp_gpu.cpp +++ b/src/core/hle/service/gsp/gsp_gpu.cpp @@ -128,7 +128,7 @@ static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, const std::ve LOG_ERROR(Service_GSP, "Misaligned size 0x{:08x}", size_in_bytes); return ERR_REGS_MISALIGNED; } else { - size_t offset = 0; + std::size_t offset = 0; while (size_in_bytes > 0) { u32 value; std::memcpy(&value, &data[offset], sizeof(u32)); @@ -172,7 +172,7 @@ static ResultCode WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, LOG_ERROR(Service_GSP, "Misaligned size 0x{:08x}", size_in_bytes); return ERR_REGS_MISALIGNED; } else { - size_t offset = 0; + std::size_t offset = 0; while (size_in_bytes > 0) { const u32 reg_address = base_address + REGS_BEGIN; diff --git a/src/core/hle/service/http_c.cpp b/src/core/hle/service/http_c.cpp index 54b72437a..1872f4820 100644 --- a/src/core/hle/service/http_c.cpp +++ b/src/core/hle/service/http_c.cpp @@ -131,7 +131,7 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) { return; } - static constexpr size_t MaxConcurrentHTTPContexts = 8; + static constexpr std::size_t MaxConcurrentHTTPContexts = 8; if (session_data->num_http_contexts >= MaxConcurrentHTTPContexts) { // There can only be 8 HTTP contexts open at the same time for any particular session. LOG_ERROR(Service_HTTP, "Tried to open too many HTTP contexts"); diff --git a/src/core/hle/service/ir/ir_user.cpp b/src/core/hle/service/ir/ir_user.cpp index 1ac00663f..65ccb6171 100644 --- a/src/core/hle/service/ir/ir_user.cpp +++ b/src/core/hle/service/ir/ir_user.cpp @@ -105,7 +105,7 @@ public: SetPacketInfo(info.end_index, packet_info); // writes packet data - for (size_t i = 0; i < packet.size(); ++i) { + for (std::size_t i = 0; i < packet.size(); ++i) { *GetDataBufferPointer((write_offset + i) % max_data_size) = packet[i]; } @@ -184,7 +184,7 @@ private: /// Wraps the payload into packet and puts it to the receive buffer void IR_USER::PutToReceive(const std::vector& payload) { LOG_TRACE(Service_IR, "called, data={}", Common::ArrayToString(payload.data(), payload.size())); - size_t size = payload.size(); + std::size_t size = payload.size(); std::vector packet; diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index c461f5a04..8e0dfece9 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -100,7 +100,7 @@ static std::mutex beacon_mutex; // Number of beacons to store before we start dropping the old ones. // TODO(Subv): Find a more accurate value for this limit. -constexpr size_t MaxBeaconFrames = 15; +constexpr std::size_t MaxBeaconFrames = 15; // List of the last beacons received from the network. static std::list received_beacons; @@ -160,11 +160,11 @@ static void BroadcastNodeMap() { packet.channel = network_channel; packet.type = Network::WifiPacket::PacketType::NodeMap; packet.destination_address = Network::BroadcastMac; - size_t size = node_map.size(); + std::size_t size = node_map.size(); using node_t = decltype(node_map)::value_type; packet.data.resize(sizeof(size) + (sizeof(node_t::first) + sizeof(node_t::second)) * size); std::memcpy(packet.data.data(), &size, sizeof(size)); - size_t offset = sizeof(size); + std::size_t offset = sizeof(size); for (const auto& node : node_map) { std::memcpy(packet.data.data() + offset, node.first.data(), sizeof(node.first)); std::memcpy(packet.data.data() + offset + sizeof(node.first), &node.second, @@ -178,12 +178,12 @@ static void BroadcastNodeMap() { static void HandleNodeMapPacket(const Network::WifiPacket& packet) { std::lock_guard lock(connection_status_mutex); node_map.clear(); - size_t num_entries; + std::size_t num_entries; Network::MacAddress address; u16 id; std::memcpy(&num_entries, packet.data.data(), sizeof(num_entries)); - size_t offset = sizeof(num_entries); - for (size_t i = 0; i < num_entries; ++i) { + std::size_t offset = sizeof(num_entries); + for (std::size_t i = 0; i < num_entries; ++i) { std::memcpy(&address, packet.data.data() + offset, sizeof(address)); std::memcpy(&id, packet.data.data() + offset + sizeof(address), sizeof(id)); node_map[address] = id; @@ -306,7 +306,7 @@ static void HandleEAPoLPacket(const Network::WifiPacket& packet) { node_info.clear(); node_info.reserve(network_info.max_nodes); - for (size_t index = 0; index < logoff.connected_nodes; ++index) { + for (std::size_t index = 0; index < logoff.connected_nodes; ++index) { connection_status.node_bitmask |= 1 << index; connection_status.changed_nodes |= 1 << index; connection_status.nodes[index] = logoff.nodes[index].network_node_id; @@ -332,7 +332,7 @@ static void HandleEAPoLPacket(const Network::WifiPacket& packet) { node_info.clear(); node_info.reserve(network_info.max_nodes); - for (size_t index = 0; index < logoff.connected_nodes; ++index) { + for (std::size_t index = 0; index < logoff.connected_nodes; ++index) { if ((connection_status.node_bitmask & (1 << index)) == 0) { connection_status.changed_nodes |= 1 << index; } @@ -584,7 +584,7 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) { Kernel::MappedBuffer out_buffer = rp.PopMappedBuffer(); ASSERT(out_buffer.GetSize() == out_buffer_size); - size_t cur_buffer_size = sizeof(BeaconDataReplyHeader); + std::size_t cur_buffer_size = sizeof(BeaconDataReplyHeader); // Retrieve all beacon frames that were received from the desired mac address. auto beacons = GetReceivedBeacons(mac_address); @@ -736,7 +736,7 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) { return; } - constexpr size_t MaxBindNodes = 16; + constexpr std::size_t MaxBindNodes = 16; if (channel_data.size() >= MaxBindNodes) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(ResultCode(ErrorDescription::OutOfMemory, ErrorModule::UDS, @@ -1027,7 +1027,7 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) { dest_address = network_info.host_mac_address; } - constexpr size_t MaxSize = 0x5C6; + constexpr std::size_t MaxSize = 0x5C6; if (data_size > MaxSize) { rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS, ErrorSummary::WrongArgument, ErrorLevel::Usage)); diff --git a/src/core/hle/service/nwm/nwm_uds.h b/src/core/hle/service/nwm/nwm_uds.h index 763eb8dc0..6111c6995 100644 --- a/src/core/hle/service/nwm/nwm_uds.h +++ b/src/core/hle/service/nwm/nwm_uds.h @@ -16,7 +16,7 @@ namespace Service { namespace NWM { -const size_t ApplicationDataSize = 0xC8; +const std::size_t ApplicationDataSize = 0xC8; const u8 DefaultNetworkChannel = 11; // Number of milliseconds in a TU. diff --git a/src/core/hle/service/nwm/uds_beacon.cpp b/src/core/hle/service/nwm/uds_beacon.cpp index 020876d73..d616386ff 100644 --- a/src/core/hle/service/nwm/uds_beacon.cpp +++ b/src/core/hle/service/nwm/uds_beacon.cpp @@ -241,8 +241,8 @@ void DecryptBeacon(const NetworkInfo& network_info, std::vector& buffer) { */ std::vector GenerateNintendoFirstEncryptedDataTag(const NetworkInfo& network_info, const NodeList& nodes) { - const size_t payload_size = - std::min(EncryptedDataSizeCutoff, nodes.size() * sizeof(NodeInfo)); + const std::size_t payload_size = + std::min(EncryptedDataSizeCutoff, nodes.size() * sizeof(NodeInfo)); EncryptedDataTag tag{}; tag.header.tag_id = static_cast(TagId::VendorSpecific); @@ -273,9 +273,9 @@ std::vector GenerateNintendoSecondEncryptedDataTag(const NetworkInfo& networ if (nodes.size() * sizeof(NodeInfo) <= EncryptedDataSizeCutoff) return {}; - const size_t payload_size = nodes.size() * sizeof(NodeInfo) - EncryptedDataSizeCutoff; + const std::size_t payload_size = nodes.size() * sizeof(NodeInfo) - EncryptedDataSizeCutoff; - const size_t tag_length = sizeof(EncryptedDataTag) - sizeof(TagHeader) + payload_size; + const std::size_t tag_length = sizeof(EncryptedDataTag) - sizeof(TagHeader) + payload_size; // TODO(Subv): What does the 3DS do when a game has too much data to fit into the tag? ASSERT_MSG(tag_length <= 255, "Data is too big."); diff --git a/src/core/hle/service/nwm/uds_data.cpp b/src/core/hle/service/nwm/uds_data.cpp index 16d20166c..1f227de6d 100644 --- a/src/core/hle/service/nwm/uds_data.cpp +++ b/src/core/hle/service/nwm/uds_data.cpp @@ -203,7 +203,7 @@ static std::vector DecryptDataFrame(const std::vector& encrypted_payload df.ChannelMessageEnd(CryptoPP::DEFAULT_CHANNEL); df.SetRetrievalChannel(CryptoPP::DEFAULT_CHANNEL); - size_t size = df.MaxRetrievable(); + std::size_t size = df.MaxRetrievable(); std::vector pdata(size); df.Get(pdata.data(), size); @@ -257,7 +257,7 @@ static std::vector EncryptDataFrame(const std::vector& payload, df.SetRetrievalChannel(CryptoPP::DEFAULT_CHANNEL); - size_t size = df.MaxRetrievable(); + std::size_t size = df.MaxRetrievable(); std::vector cipher(size); df.Get(cipher.data(), size); @@ -357,7 +357,7 @@ std::vector GenerateEAPoLLogoffFrame(const MacAddress& mac_address, u16 netw eapol_logoff.connected_nodes = total_nodes; eapol_logoff.max_nodes = max_nodes; - for (size_t index = 0; index < total_nodes; ++index) { + for (std::size_t index = 0; index < total_nodes; ++index) { const auto& node_info = nodes[index]; auto& node = eapol_logoff.nodes[index]; diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index b30efb620..caad3f4b2 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -152,9 +152,9 @@ void ServiceFrameworkBase::InstallAsNamedPort() { AddNamedPort(service_name, std::move(client_port)); } -void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, size_t n) { +void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) { handlers.reserve(handlers.size() + n); - for (size_t i = 0; i < n; ++i) { + for (std::size_t i = 0; i < n; ++i) { // Usually this array is sorted by id already, so hint to insert at the end handlers.emplace_hint(handlers.cend(), functions[i].expected_header, functions[i]); } diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index a67c3499a..11ceef2be 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -83,7 +83,7 @@ private: ServiceFrameworkBase(const char* service_name, u32 max_sessions, InvokerFn* handler_invoker); ~ServiceFrameworkBase(); - void RegisterHandlersBase(const FunctionInfoBase* functions, size_t n); + void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n); void ReportUnimplementedFunction(u32* cmd_buf, const FunctionInfoBase* info); /// Identifier string used to connect to the service. @@ -147,7 +147,7 @@ protected: : ServiceFrameworkBase(service_name, max_sessions, Invoker) {} /// Registers handlers in the service. - template + template void RegisterHandlers(const FunctionInfo (&functions)[N]) { RegisterHandlers(functions, N); } @@ -156,7 +156,7 @@ protected: * Registers handlers in the service. Usually prefer using the other RegisterHandlers * overload in order to avoid needing to specify the array size. */ - void RegisterHandlers(const FunctionInfo* functions, size_t n) { + void RegisterHandlers(const FunctionInfo* functions, std::size_t n) { RegisterHandlersBase(functions, n); } diff --git a/src/core/hle/service/sm/srv.cpp b/src/core/hle/service/sm/srv.cpp index babcb1f9e..a8f2db4f0 100644 --- a/src/core/hle/service/sm/srv.cpp +++ b/src/core/hle/service/sm/srv.cpp @@ -85,7 +85,7 @@ void SRV::EnableNotification(Kernel::HLERequestContext& ctx) { void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x5, 4, 0); auto name_buf = rp.PopRaw>(); - size_t name_len = rp.Pop(); + std::size_t name_len = rp.Pop(); u32 flags = rp.Pop(); bool wait_until_available = (flags & 1) == 0; @@ -218,7 +218,7 @@ void SRV::RegisterService(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x3, 4, 0); auto name_buf = rp.PopRaw>(); - size_t name_len = rp.Pop(); + std::size_t name_len = rp.Pop(); u32 max_sessions = rp.Pop(); std::string name(name_buf.data(), std::min(name_len, name_buf.size())); diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp index c270c1efb..7d6109101 100644 --- a/src/core/hle/service/y2r_u.cpp +++ b/src/core/hle/service/y2r_u.cpp @@ -51,7 +51,7 @@ ResultCode ConversionConfiguration::SetInputLines(u16 lines) { ResultCode ConversionConfiguration::SetStandardCoefficient( StandardCoefficient standard_coefficient) { - size_t index = static_cast(standard_coefficient); + std::size_t index = static_cast(standard_coefficient); if (index >= ARRAY_SIZE(standard_coefficients)) { return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM, ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED diff --git a/src/core/hw/aes/ccm.cpp b/src/core/hw/aes/ccm.cpp index 71a682846..5074daa89 100644 --- a/src/core/hw/aes/ccm.cpp +++ b/src/core/hw/aes/ccm.cpp @@ -44,7 +44,7 @@ public: } // namespace std::vector EncryptSignCCM(const std::vector& pdata, const CCMNonce& nonce, - size_t slot_id) { + std::size_t slot_id) { if (!IsNormalKeyAvailable(slot_id)) { LOG_ERROR(HW_AES, "Key slot {} not available. Will use zero key.", slot_id); } @@ -65,7 +65,7 @@ std::vector EncryptSignCCM(const std::vector& pdata, const CCMNonce& non } std::vector DecryptVerifyCCM(const std::vector& cipher, const CCMNonce& nonce, - size_t slot_id) { + std::size_t slot_id) { if (!IsNormalKeyAvailable(slot_id)) { LOG_ERROR(HW_AES, "Key slot {} not available. Will use zero key.", slot_id); } diff --git a/src/core/hw/aes/ccm.h b/src/core/hw/aes/ccm.h index bf4146e80..36ccea126 100644 --- a/src/core/hw/aes/ccm.h +++ b/src/core/hw/aes/ccm.h @@ -12,8 +12,8 @@ namespace HW { namespace AES { -constexpr size_t CCM_NONCE_SIZE = 12; -constexpr size_t CCM_MAC_SIZE = 16; +constexpr std::size_t CCM_NONCE_SIZE = 12; +constexpr std::size_t CCM_MAC_SIZE = 16; using CCMNonce = std::array; @@ -24,7 +24,8 @@ using CCMNonce = std::array; * @param slot_id The slot ID of the key to use for encryption * @returns a vector of u8 containing the encrypted data with MAC at the end */ -std::vector EncryptSignCCM(const std::vector& pdata, const CCMNonce& nonce, size_t slot_id); +std::vector EncryptSignCCM(const std::vector& pdata, const CCMNonce& nonce, + std::size_t slot_id); /** * Decrypts and verify the MAC of the given data using AES-CCM algorithm. @@ -34,7 +35,7 @@ std::vector EncryptSignCCM(const std::vector& pdata, const CCMNonce& non * @returns a vector of u8 containing the decrypted data; an empty vector if the verification fails */ std::vector DecryptVerifyCCM(const std::vector& cipher, const CCMNonce& nonce, - size_t slot_id); + std::size_t slot_id); } // namespace AES } // namespace HW diff --git a/src/core/hw/aes/key.cpp b/src/core/hw/aes/key.cpp index c49713a3a..8d20ee781 100644 --- a/src/core/hw/aes/key.cpp +++ b/src/core/hw/aes/key.cpp @@ -62,7 +62,7 @@ AESKey HexToKey(const std::string& hex) { } AESKey key; - for (size_t i = 0; i < key.size(); ++i) { + for (std::size_t i = 0; i < key.size(); ++i) { key[i] = static_cast(std::stoi(hex.substr(i * 2, 2), 0, 16)); } @@ -102,7 +102,7 @@ void LoadPresetKeys() { continue; } - size_t slot_id; + std::size_t slot_id; char key_type; if (std::sscanf(name.c_str(), "slot0x%zXKey%c", &slot_id, &key_type) != 2) { LOG_ERROR(HW_AES, "Invalid key name {}", name); @@ -145,23 +145,23 @@ void SetGeneratorConstant(const AESKey& key) { generator_constant = key; } -void SetKeyX(size_t slot_id, const AESKey& key) { +void SetKeyX(std::size_t slot_id, const AESKey& key) { key_slots.at(slot_id).SetKeyX(key); } -void SetKeyY(size_t slot_id, const AESKey& key) { +void SetKeyY(std::size_t slot_id, const AESKey& key) { key_slots.at(slot_id).SetKeyY(key); } -void SetNormalKey(size_t slot_id, const AESKey& key) { +void SetNormalKey(std::size_t slot_id, const AESKey& key) { key_slots.at(slot_id).SetNormalKey(key); } -bool IsNormalKeyAvailable(size_t slot_id) { +bool IsNormalKeyAvailable(std::size_t slot_id) { return key_slots.at(slot_id).normal.is_initialized(); } -AESKey GetNormalKey(size_t slot_id) { +AESKey GetNormalKey(std::size_t slot_id) { return key_slots.at(slot_id).normal.value_or(AESKey{}); } diff --git a/src/core/hw/aes/key.h b/src/core/hw/aes/key.h index 915560359..b2c7311af 100644 --- a/src/core/hw/aes/key.h +++ b/src/core/hw/aes/key.h @@ -11,7 +11,7 @@ namespace HW { namespace AES { -enum KeySlotID : size_t { +enum KeySlotID : std::size_t { // Used to decrypt the SSL client cert/private-key stored in ClCertA. SSLKey = 0x0D, @@ -31,19 +31,19 @@ enum KeySlotID : size_t { MaxKeySlotID = 0x40, }; -constexpr size_t AES_BLOCK_SIZE = 16; +constexpr std::size_t AES_BLOCK_SIZE = 16; using AESKey = std::array; void InitKeys(); void SetGeneratorConstant(const AESKey& key); -void SetKeyX(size_t slot_id, const AESKey& key); -void SetKeyY(size_t slot_id, const AESKey& key); -void SetNormalKey(size_t slot_id, const AESKey& key); +void SetKeyX(std::size_t slot_id, const AESKey& key); +void SetKeyY(std::size_t slot_id, const AESKey& key); +void SetNormalKey(std::size_t slot_id, const AESKey& key); -bool IsNormalKeyAvailable(size_t slot_id); -AESKey GetNormalKey(size_t slot_id); +bool IsNormalKeyAvailable(std::size_t slot_id); +AESKey GetNormalKey(std::size_t slot_id); } // namespace AES } // namespace HW diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index ed94162fa..d68068cbb 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -114,8 +114,8 @@ static void MemoryFill(const Regs::MemoryFillConfig& config) { // fill with 32-bit values if (end > start) { u32 value = config.value_32bit; - size_t len = (end - start) / sizeof(u32); - for (size_t i = 0; i < len; ++i) + std::size_t len = (end - start) / sizeof(u32); + for (std::size_t i = 0; i < len; ++i) memcpy(&start[i * sizeof(u32)], &value, sizeof(u32)); } } else { @@ -348,12 +348,12 @@ static void TextureCopy(const Regs::DisplayTransferConfig& config) { return; } - size_t contiguous_input_size = + std::size_t contiguous_input_size = config.texture_copy.size / input_width * (input_width + input_gap); Memory::RasterizerFlushRegion(config.GetPhysicalInputAddress(), static_cast(contiguous_input_size)); - size_t contiguous_output_size = + std::size_t contiguous_output_size = config.texture_copy.size / output_width * (output_width + output_gap); // Only need to flush output if it has a gap const auto FlushInvalidate_fn = (output_gap != 0) ? Memory::RasterizerFlushAndInvalidateRegion diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index 04814d480..8184066da 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -30,11 +30,11 @@ constexpr float SCREEN_REFRESH_RATE = 60; #else // NOTE: Yeah, hacking in a static_assert here just to workaround the lacking MSVC compiler // really is this annoying. This macro just forwards its first argument to GPU_REG_INDEX -// and then performs a (no-op) cast to size_t iff the second argument matches the expected -// field offset. Otherwise, the compiler will fail to compile this code. +// and then performs a (no-op) cast to std::size_t iff the second argument matches the +// expected field offset. Otherwise, the compiler will fail to compile this code. #define GPU_REG_INDEX_WORKAROUND(field_name, backup_workaround_index) \ - ((typename std::enable_if::type) \ - GPU_REG_INDEX(field_name)) + ((typename std::enable_if::type) GPU_REG_INDEX(field_name)) #endif // MMIO region 0x1EFxxxxx @@ -268,7 +268,7 @@ struct Regs { INSERT_PADDING_WORDS(0x9c3); - static constexpr size_t NumIds() { + static constexpr std::size_t NumIds() { return sizeof(Regs) / sizeof(u32); } diff --git a/src/core/hw/lcd.h b/src/core/hw/lcd.h index d2db9700f..5e37121f7 100644 --- a/src/core/hw/lcd.h +++ b/src/core/hw/lcd.h @@ -37,7 +37,7 @@ struct Regs { u32 backlight_bottom; INSERT_PADDING_WORDS(0x16F); - static constexpr size_t NumIds() { + static constexpr std::size_t NumIds() { return sizeof(Regs) / sizeof(u32); } diff --git a/src/core/hw/y2r.cpp b/src/core/hw/y2r.cpp index 183ce3c70..c1f99b571 100644 --- a/src/core/hw/y2r.cpp +++ b/src/core/hw/y2r.cpp @@ -19,8 +19,8 @@ namespace Y2R { using namespace Service::Y2R; -static const size_t MAX_TILES = 1024 / 8; -static const size_t TILE_SIZE = 8 * 8; +static const std::size_t MAX_TILES = 1024 / 8; +static const std::size_t TILE_SIZE = 8 * 8; using ImageTile = std::array; /// Converts a image strip from the source YUV format into individual 8x8 RGB32 tiles. @@ -78,15 +78,15 @@ static void ConvertYUVToRGB(InputFormat input_format, const u8* input_Y, const u /// Simulates an incoming CDMA transfer. The N parameter is used to automatically convert 16-bit /// formats to 8-bit. -template -static void ReceiveData(u8* output, ConversionBuffer& buf, size_t amount_of_data) { +template +static void ReceiveData(u8* output, ConversionBuffer& buf, std::size_t amount_of_data) { const u8* input = Memory::GetPointer(buf.address); - size_t output_unit = buf.transfer_unit / N; + std::size_t output_unit = buf.transfer_unit / N; ASSERT(amount_of_data % output_unit == 0); while (amount_of_data > 0) { - for (size_t i = 0; i < output_unit; ++i) { + for (std::size_t i = 0; i < output_unit; ++i) { output[i] = input[i * N]; } @@ -263,7 +263,7 @@ void PerformConversion(ConversionConfiguration& cvt) { ASSERT(cvt.input_line_width % 8 == 0); ASSERT(cvt.block_alignment != BlockAlignment::Block8x8 || cvt.input_lines % 8 == 0); // Tiles per row - size_t num_tiles = cvt.input_line_width / 8; + std::size_t num_tiles = cvt.input_line_width / 8; ASSERT(num_tiles <= MAX_TILES); // Buffer used as a CDMA source/target. @@ -288,7 +288,7 @@ void PerformConversion(ConversionConfiguration& cvt) { unsigned int row_height = std::min(cvt.input_lines - y, 8u); // Total size in pixels of incoming data required for this strip. - const size_t row_data_size = row_height * cvt.input_line_width; + const std::size_t row_data_size = row_height * cvt.input_line_width; u8* input_Y = data_buffer.get(); u8* input_U = input_Y + 8 * cvt.input_line_width; @@ -329,7 +329,7 @@ void PerformConversion(ConversionConfiguration& cvt) { u32* output_buffer = reinterpret_cast(data_buffer.get()); - for (size_t i = 0; i < num_tiles; ++i) { + for (std::size_t i = 0; i < num_tiles; ++i) { int image_strip_width = 0; int output_stride = 0; diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp index b206a94e7..5ec3000e8 100644 --- a/src/core/loader/3dsx.cpp +++ b/src/core/loader/3dsx.cpp @@ -129,7 +129,7 @@ static THREEDSX_Error Load3DSXFile(FileUtil::IOFile& file, u32 base_addr, // Read the relocation headers std::vector relocs(n_reloc_tables * NUM_SEGMENTS); for (unsigned int current_segment = 0; current_segment < NUM_SEGMENTS; ++current_segment) { - size_t size = n_reloc_tables * sizeof(u32); + std::size_t size = n_reloc_tables * sizeof(u32); if (file.ReadBytes(&relocs[current_segment * n_reloc_tables], size) != size) return ERROR_READ; } diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index 8bc888acc..fd2bb23b3 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp @@ -297,7 +297,7 @@ SharedPtr ElfReader::LoadInto(u32 vaddr) { } std::vector program_image(total_image_size); - size_t current_image_position = 0; + std::size_t current_image_position = 0; SharedPtr codeset = CodeSet::Create("", 0); @@ -386,7 +386,7 @@ ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr& process) { // Reset read pointer in case this file has been read before. file.Seek(0, SEEK_SET); - size_t size = file.GetSize(); + std::size_t size = file.GetSize(); std::unique_ptr buffer(new u8[size]); if (file.ReadBytes(&buffer[0], size) != size) return ResultStatus::Error; diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 5663a4c33..26967ad36 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -472,15 +472,15 @@ u64 Read64(const VAddr addr) { } void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_buffer, - const size_t size) { + const std::size_t size) { auto& page_table = process.vm_manager.page_table; - size_t remaining_size = size; - size_t page_index = src_addr >> PAGE_BITS; - size_t page_offset = src_addr & PAGE_MASK; + std::size_t remaining_size = size; + std::size_t page_index = src_addr >> PAGE_BITS; + std::size_t page_offset = src_addr & PAGE_MASK; while (remaining_size > 0) { - const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); + const std::size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); const VAddr current_vaddr = static_cast((page_index << PAGE_BITS) + page_offset); switch (page_table.attributes[page_index]) { @@ -521,7 +521,7 @@ void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_ } } -void ReadBlock(const VAddr src_addr, void* dest_buffer, const size_t size) { +void ReadBlock(const VAddr src_addr, void* dest_buffer, const std::size_t size) { ReadBlock(*Kernel::g_current_process, src_addr, dest_buffer, size); } @@ -542,14 +542,14 @@ void Write64(const VAddr addr, const u64 data) { } void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const void* src_buffer, - const size_t size) { + const std::size_t size) { auto& page_table = process.vm_manager.page_table; - size_t remaining_size = size; - size_t page_index = dest_addr >> PAGE_BITS; - size_t page_offset = dest_addr & PAGE_MASK; + std::size_t remaining_size = size; + std::size_t page_index = dest_addr >> PAGE_BITS; + std::size_t page_offset = dest_addr & PAGE_MASK; while (remaining_size > 0) { - const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); + const std::size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); const VAddr current_vaddr = static_cast((page_index << PAGE_BITS) + page_offset); switch (page_table.attributes[page_index]) { @@ -589,20 +589,20 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi } } -void WriteBlock(const VAddr dest_addr, const void* src_buffer, const size_t size) { +void WriteBlock(const VAddr dest_addr, const void* src_buffer, const std::size_t size) { WriteBlock(*Kernel::g_current_process, dest_addr, src_buffer, size); } -void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const size_t size) { +void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const std::size_t size) { auto& page_table = process.vm_manager.page_table; - size_t remaining_size = size; - size_t page_index = dest_addr >> PAGE_BITS; - size_t page_offset = dest_addr & PAGE_MASK; + std::size_t remaining_size = size; + std::size_t page_index = dest_addr >> PAGE_BITS; + std::size_t page_offset = dest_addr & PAGE_MASK; static const std::array zeros = {}; while (remaining_size > 0) { - const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); + const std::size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); const VAddr current_vaddr = static_cast((page_index << PAGE_BITS) + page_offset); switch (page_table.attributes[page_index]) { @@ -641,18 +641,19 @@ void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const size } } -void ZeroBlock(const VAddr dest_addr, const size_t size) { +void ZeroBlock(const VAddr dest_addr, const std::size_t size) { ZeroBlock(*Kernel::g_current_process, dest_addr, size); } -void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, const size_t size) { +void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, + const std::size_t size) { auto& page_table = process.vm_manager.page_table; - size_t remaining_size = size; - size_t page_index = src_addr >> PAGE_BITS; - size_t page_offset = src_addr & PAGE_MASK; + std::size_t remaining_size = size; + std::size_t page_index = src_addr >> PAGE_BITS; + std::size_t page_offset = src_addr & PAGE_MASK; while (remaining_size > 0) { - const size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); + const std::size_t copy_amount = std::min(PAGE_SIZE - page_offset, remaining_size); const VAddr current_vaddr = static_cast((page_index << PAGE_BITS) + page_offset); switch (page_table.attributes[page_index]) { @@ -695,7 +696,7 @@ void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, } } -void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) { +void CopyBlock(VAddr dest_addr, VAddr src_addr, const std::size_t size) { CopyBlock(*Kernel::g_current_process, dest_addr, src_addr, size); } diff --git a/src/core/memory.h b/src/core/memory.h index 70d057ecc..73dbe091c 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -25,7 +25,7 @@ namespace Memory { const u32 PAGE_SIZE = 0x1000; const u32 PAGE_MASK = PAGE_SIZE - 1; const int PAGE_BITS = 12; -const size_t PAGE_TABLE_NUM_ENTRIES = 1 << (32 - PAGE_BITS); +const std::size_t PAGE_TABLE_NUM_ENTRIES = 1 << (32 - PAGE_BITS); enum class PageType { /// Page is unmapped and should cause an access error. @@ -196,15 +196,15 @@ void Write16(VAddr addr, u16 data); void Write32(VAddr addr, u32 data); void Write64(VAddr addr, u64 data); -void ReadBlock(const Kernel::Process& process, VAddr src_addr, void* dest_buffer, size_t size); -void ReadBlock(VAddr src_addr, void* dest_buffer, size_t size); +void ReadBlock(const Kernel::Process& process, VAddr src_addr, void* dest_buffer, std::size_t size); +void ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size); void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer, - size_t size); -void WriteBlock(VAddr dest_addr, const void* src_buffer, size_t size); -void ZeroBlock(const Kernel::Process& process, VAddr dest_addr, const size_t size); -void ZeroBlock(VAddr dest_addr, const size_t size); -void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, size_t size); -void CopyBlock(VAddr dest_addr, VAddr src_addr, size_t size); + std::size_t size); +void WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size); +void ZeroBlock(const Kernel::Process& process, VAddr dest_addr, const std::size_t size); +void ZeroBlock(VAddr dest_addr, const std::size_t size); +void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, std::size_t size); +void CopyBlock(VAddr dest_addr, VAddr src_addr, std::size_t size); u8* GetPointer(VAddr vaddr); diff --git a/src/core/mmio.h b/src/core/mmio.h index 5e3cc01af..30bafaf5f 100644 --- a/src/core/mmio.h +++ b/src/core/mmio.h @@ -24,14 +24,14 @@ public: virtual u32 Read32(VAddr addr) = 0; virtual u64 Read64(VAddr addr) = 0; - virtual bool ReadBlock(VAddr src_addr, void* dest_buffer, size_t size) = 0; + virtual bool ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size) = 0; virtual void Write8(VAddr addr, u8 data) = 0; virtual void Write16(VAddr addr, u16 data) = 0; virtual void Write32(VAddr addr, u32 data) = 0; virtual void Write64(VAddr addr, u64 data) = 0; - virtual bool WriteBlock(VAddr dest_addr, const void* src_buffer, size_t size) = 0; + virtual bool WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size) = 0; }; using MMIORegionPointer = std::shared_ptr; diff --git a/src/core/movie.h b/src/core/movie.h index 6923db3d5..20ab5a06e 100644 --- a/src/core/movie.h +++ b/src/core/movie.h @@ -120,6 +120,6 @@ private: std::string record_movie_file; std::vector recorded_input; std::function playback_completion_callback; - size_t current_byte = 0; + std::size_t current_byte = 0; }; } // namespace Core \ No newline at end of file diff --git a/src/core/tracer/recorder.cpp b/src/core/tracer/recorder.cpp index af032f0c9..73cacb47f 100644 --- a/src/core/tracer/recorder.cpp +++ b/src/core/tracer/recorder.cpp @@ -76,7 +76,7 @@ void Recorder::Finish(const std::string& filename) { try { // Open file and write header FileUtil::IOFile file(filename, "wb"); - size_t written = file.WriteObject(header); + std::size_t written = file.WriteObject(header); if (written != 1 || file.Tell() != initial.gpu_registers) throw "Failed to write header"; diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp index c0224bc6a..ce2fb78c3 100644 --- a/src/input_common/udp/client.cpp +++ b/src/input_common/udp/client.cpp @@ -90,13 +90,13 @@ private: Request::PortInfo port_info{1, {pad_index, 0, 0, 0}}; auto port_message = Request::Create(port_info, client_id); std::memcpy(&send_buffer1, &port_message, PORT_INFO_SIZE); - size_t len = socket.send_to(boost::asio::buffer(send_buffer1), send_endpoint); + std::size_t len = socket.send_to(boost::asio::buffer(send_buffer1), send_endpoint); // Send a request for getting pad data for the pad Request::PadData pad_data{Request::PadData::Flags::Id, pad_index, EMPTY_MAC_ADDRESS}; auto pad_message = Request::Create(pad_data, client_id); std::memcpy(send_buffer2.data(), &pad_message, PAD_DATA_SIZE); - size_t len2 = socket.send_to(boost::asio::buffer(send_buffer2), send_endpoint); + std::size_t len2 = socket.send_to(boost::asio::buffer(send_buffer2), send_endpoint); StartSend(timer.expiry()); } @@ -108,8 +108,8 @@ private: u32 client_id; u8 pad_index; - static constexpr size_t PORT_INFO_SIZE = sizeof(Message); - static constexpr size_t PAD_DATA_SIZE = sizeof(Message); + static constexpr std::size_t PORT_INFO_SIZE = sizeof(Message); + static constexpr std::size_t PAD_DATA_SIZE = sizeof(Message); std::array send_buffer1; std::array send_buffer2; udp::endpoint send_endpoint; diff --git a/src/input_common/udp/protocol.cpp b/src/input_common/udp/protocol.cpp index 9efac03af..ba3bb4c2f 100644 --- a/src/input_common/udp/protocol.cpp +++ b/src/input_common/udp/protocol.cpp @@ -9,7 +9,7 @@ namespace InputCommon::CemuhookUDP { -static const size_t GetSizeOfResponseType(Type t) { +static const std::size_t GetSizeOfResponseType(Type t) { switch (t) { case Type::Version: return sizeof(Response::Version); @@ -29,7 +29,7 @@ namespace Response { * Note: Modifies the buffer to zero out the crc (since thats the easiest way to check without * copying the buffer) */ -boost::optional Validate(u8* data, size_t size) { +boost::optional Validate(u8* data, std::size_t size) { if (size < sizeof(Header)) { LOG_DEBUG(Input, "Invalid UDP packet received"); return boost::none; @@ -53,7 +53,7 @@ boost::optional Validate(u8* data, size_t size) { // and also verify that the packet info mentions the correct size. Since the spec includes the // type of the packet as part of the data, we need to include it in size calculations here // ie: payload_length == sizeof(T) + sizeof(Type) - const size_t data_len = GetSizeOfResponseType(header.type); + const std::size_t data_len = GetSizeOfResponseType(header.type); if (header.payload_length != data_len + sizeof(Type) || size < data_len + sizeof(Header)) { LOG_ERROR( Input, diff --git a/src/input_common/udp/protocol.h b/src/input_common/udp/protocol.h index 8d9940a4e..ba1ad0562 100644 --- a/src/input_common/udp/protocol.h +++ b/src/input_common/udp/protocol.h @@ -14,7 +14,7 @@ namespace InputCommon::CemuhookUDP { -constexpr size_t MAX_PACKET_SIZE = 100; +constexpr std::size_t MAX_PACKET_SIZE = 100; constexpr u16 PROTOCOL_VERSION = 1001; constexpr u32 CLIENT_MAGIC = 0x43555344; // DSUC (but flipped for LE) constexpr u32 SERVER_MAGIC = 0x53555344; // DSUS (but flipped for LE) @@ -218,7 +218,7 @@ static_assert(sizeof(Message) == MAX_PACKET_SIZE, * @return boost::none if it failed to parse or Type if it succeeded. The client can then safely * copy the data into the appropriate struct for that Type */ -boost::optional Validate(u8* data, size_t size); +boost::optional Validate(u8* data, std::size_t size); } // namespace Response diff --git a/src/network/room.cpp b/src/network/room.cpp index 7184ca4b1..f0d229d40 100644 --- a/src/network/room.cpp +++ b/src/network/room.cpp @@ -364,7 +364,7 @@ MacAddress Room::RoomImpl::GenerateMacAddress() { NintendoOUI; // The first three bytes of each MAC address will be the NintendoOUI std::uniform_int_distribution<> dis(0x00, 0xFF); // Random byte between 0 and 0xFF do { - for (size_t i = 3; i < result_mac.size(); ++i) { + for (std::size_t i = 3; i < result_mac.size(); ++i) { result_mac[i] = dis(random_gen); } } while (!IsValidMacAddress(result_mac)); diff --git a/src/network/room.h b/src/network/room.h index ded4aa1c0..bff190c55 100644 --- a/src/network/room.h +++ b/src/network/room.h @@ -21,7 +21,7 @@ constexpr u32 MaxMessageSize = 500; /// Maximum number of concurrent connections allowed to this room. static constexpr u32 MaxConcurrentConnections = 254; -constexpr size_t NumChannels = 1; // Number of channels used for the connection +constexpr std::size_t NumChannels = 1; // Number of channels used for the connection struct RoomInformation { std::string name; ///< Name of the server diff --git a/src/tests/core/arm/arm_test_common.cpp b/src/tests/core/arm/arm_test_common.cpp index 8520f53b2..23c0411e7 100644 --- a/src/tests/core/arm/arm_test_common.cpp +++ b/src/tests/core/arm/arm_test_common.cpp @@ -85,11 +85,11 @@ u64 TestEnvironment::TestMemory::Read64(VAddr addr) { return Read32(addr) | static_cast(Read32(addr + 4)) << 32; } -bool TestEnvironment::TestMemory::ReadBlock(VAddr src_addr, void* dest_buffer, size_t size) { +bool TestEnvironment::TestMemory::ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size) { VAddr addr = src_addr; u8* data = static_cast(dest_buffer); - for (size_t i = 0; i < size; i++, addr++, data++) { + for (std::size_t i = 0; i < size; i++, addr++, data++) { *data = Read8(addr); } @@ -120,11 +120,12 @@ void TestEnvironment::TestMemory::Write64(VAddr addr, u64 data) { env->SetMemory64(addr, data); } -bool TestEnvironment::TestMemory::WriteBlock(VAddr dest_addr, const void* src_buffer, size_t size) { +bool TestEnvironment::TestMemory::WriteBlock(VAddr dest_addr, const void* src_buffer, + std::size_t size) { VAddr addr = dest_addr; const u8* data = static_cast(src_buffer); - for (size_t i = 0; i < size; i++, addr++, data++) { + for (std::size_t i = 0; i < size; i++, addr++, data++) { env->write_records.emplace_back(8, addr, *data); if (env->mutable_memory) env->SetMemory8(addr, *data); diff --git a/src/tests/core/arm/arm_test_common.h b/src/tests/core/arm/arm_test_common.h index 592c28594..44c63818a 100644 --- a/src/tests/core/arm/arm_test_common.h +++ b/src/tests/core/arm/arm_test_common.h @@ -12,8 +12,8 @@ namespace ArmTests { struct WriteRecord { - WriteRecord(size_t size, VAddr addr, u64 data) : size(size), addr(addr), data(data) {} - size_t size; + WriteRecord(std::size_t size, VAddr addr, u64 data) : size(size), addr(addr), data(data) {} + std::size_t size; VAddr addr; u64 data; bool operator==(const WriteRecord& o) const { @@ -64,14 +64,14 @@ private: u32 Read32(VAddr addr) override; u64 Read64(VAddr addr) override; - bool ReadBlock(VAddr src_addr, void* dest_buffer, size_t size) override; + bool ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size) override; void Write8(VAddr addr, u8 data) override; void Write16(VAddr addr, u16 data) override; void Write32(VAddr addr, u32 data) override; void Write64(VAddr addr, u64 data) override; - bool WriteBlock(VAddr dest_addr, const void* src_buffer, size_t size) override; + bool WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size) override; std::unordered_map data; }; diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 098f4c0d8..7aec9de98 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -351,7 +351,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { // Simple circular-replacement vertex cache // The size has been tuned for optimal balance between hit-rate and the cost of lookup - const size_t VERTEX_CACHE_SIZE = 32; + const std::size_t VERTEX_CACHE_SIZE = 32; std::array vertex_cache_valid{}; std::array vertex_cache_ids; std::array vertex_cache; diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index fcbe46195..a392feb89 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp @@ -315,7 +315,7 @@ std::unique_ptr FinishPicaTracing() { static std::string ReplacePattern(const std::string& input, const std::string& pattern, const std::string& replacement) { - size_t start = input.find(pattern); + std::size_t start = input.find(pattern); if (start == std::string::npos) return input; @@ -451,7 +451,7 @@ std::string GetTevStageConfigAlphaCombinerString(const TexturingRegs::TevStageCo void DumpTevStageConfig(const std::array& stages) { std::string stage_info = "Tev setup:\n"; - for (size_t index = 0; index < stages.size(); ++index) { + for (std::size_t index = 0; index < stages.size(); ++index) { const auto& tev_stage = stages[index]; stage_info += "Stage " + std::to_string(index) + ": " + GetTevStageConfigColorCombinerString(tev_stage) + " " + diff --git a/src/video_core/geometry_pipeline.cpp b/src/video_core/geometry_pipeline.cpp index 98ff2ccd3..ebe6ec90c 100644 --- a/src/video_core/geometry_pipeline.cpp +++ b/src/video_core/geometry_pipeline.cpp @@ -44,7 +44,7 @@ public: ASSERT(regs.pipeline.variable_primitive == 0); ASSERT(regs.gs.input_to_uniform == 0); vs_output_num = regs.pipeline.vs_outmap_total_minus_1_a + 1; - size_t gs_input_num = regs.gs.max_input_attribute_index + 1; + std::size_t gs_input_num = regs.gs.max_input_attribute_index + 1; ASSERT(gs_input_num % vs_output_num == 0); buffer_cur = attribute_buffer.attr; buffer_end = attribute_buffer.attr + gs_input_num; @@ -157,7 +157,7 @@ public: ASSERT(regs.gs.input_to_uniform == 1); vs_output_num = regs.pipeline.vs_outmap_total_minus_1_a + 1; ASSERT(vs_output_num == regs.pipeline.gs_config.stride_minus_1 + 1); - size_t vertex_num = regs.pipeline.gs_config.fixed_vertex_num_minus_1 + 1; + std::size_t vertex_num = regs.pipeline.gs_config.fixed_vertex_num_minus_1 + 1; buffer_cur = buffer_begin = setup.uniforms.f + regs.pipeline.gs_config.start_index; buffer_end = buffer_begin + vs_output_num * vertex_num; } diff --git a/src/video_core/regs.h b/src/video_core/regs.h index 9b0792752..7d70f56e1 100644 --- a/src/video_core/regs.h +++ b/src/video_core/regs.h @@ -37,15 +37,15 @@ namespace Pica { #else // NOTE: Yeah, hacking in a static_assert here just to workaround the lacking MSVC compiler // really is this annoying. This macro just forwards its first argument to PICA_REG_INDEX -// and then performs a (no-op) cast to size_t iff the second argument matches the expected -// field offset. Otherwise, the compiler will fail to compile this code. +// and then performs a (no-op) cast to std::size_t iff the second argument matches the +// expected field offset. Otherwise, the compiler will fail to compile this code. #define PICA_REG_INDEX_WORKAROUND(field_name, backup_workaround_index) \ ((typename std::enable_if::type) PICA_REG_INDEX(field_name)) + std::size_t>::type) PICA_REG_INDEX(field_name)) #endif // _MSC_VER struct Regs { - static constexpr size_t NUM_REGS = 0x300; + static constexpr std::size_t NUM_REGS = 0x300; union { struct { diff --git a/src/video_core/regs_texturing.h b/src/video_core/regs_texturing.h index 511838759..d07aa28b7 100644 --- a/src/video_core/regs_texturing.h +++ b/src/video_core/regs_texturing.h @@ -150,7 +150,7 @@ struct TexturingRegs { if (face != CubeFace::PositiveX) { // Bits [22:27] from the main texture address is shared with all cubemap additional // addresses. - auto& face_addr = cube_address[static_cast(face) - 1]; + auto& face_addr = cube_address[static_cast(face) - 1]; address &= ~face_addr.mask; address |= face_addr; } diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 1aab999e2..d4e378aa2 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -63,7 +63,7 @@ RasterizerOpenGL::RasterizerOpenGL(EmuWindow& window) state.clip_distance[0] = true; // Create sampler objects - for (size_t i = 0; i < texture_samplers.size(); ++i) { + for (std::size_t i = 0; i < texture_samplers.size(); ++i) { texture_samplers[i].Create(); state.texture_units[i].sampler = texture_samplers[i].sampler.handle; } @@ -91,11 +91,11 @@ RasterizerOpenGL::RasterizerOpenGL(EmuWindow& window) glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uniform_buffer_alignment); uniform_size_aligned_vs = - Common::AlignUp(sizeof(VSUniformData), uniform_buffer_alignment); + Common::AlignUp(sizeof(VSUniformData), uniform_buffer_alignment); uniform_size_aligned_gs = - Common::AlignUp(sizeof(GSUniformData), uniform_buffer_alignment); + Common::AlignUp(sizeof(GSUniformData), uniform_buffer_alignment); uniform_size_aligned_fs = - Common::AlignUp(sizeof(UniformData), uniform_buffer_alignment); + Common::AlignUp(sizeof(UniformData), uniform_buffer_alignment); // Set vertex attributes for software shader path state.draw.vertex_array = sw_vao.handle; @@ -1904,11 +1904,11 @@ void RasterizerOpenGL::SyncShadowBias() { } void RasterizerOpenGL::SyncAndUploadLUTs() { - constexpr size_t max_size = sizeof(GLvec2) * 256 * Pica::LightingRegs::NumLightingSampler + - sizeof(GLvec2) * 128 + // fog - sizeof(GLvec2) * 128 * 3 + // proctex: noise + color + alpha - sizeof(GLvec4) * 256 + // proctex - sizeof(GLvec4) * 256; // proctex diff + constexpr std::size_t max_size = sizeof(GLvec2) * 256 * Pica::LightingRegs::NumLightingSampler + + sizeof(GLvec2) * 128 + // fog + sizeof(GLvec2) * 128 * 3 + // proctex: noise + color + alpha + sizeof(GLvec4) * 256 + // proctex + sizeof(GLvec4) * 256; // proctex diff if (!uniform_block_data.lighting_lut_dirty_any && !uniform_block_data.fog_lut_dirty && !uniform_block_data.proctex_noise_lut_dirty && @@ -1921,7 +1921,7 @@ void RasterizerOpenGL::SyncAndUploadLUTs() { u8* buffer; GLintptr offset; bool invalidate; - size_t bytes_used = 0; + std::size_t bytes_used = 0; glBindBuffer(GL_TEXTURE_BUFFER, texture_buffer.GetHandle()); std::tie(buffer, offset, invalidate) = texture_buffer.Map(max_size, sizeof(GLvec4)); @@ -2068,9 +2068,9 @@ void RasterizerOpenGL::UploadUniforms(bool accelerate_draw, bool use_gs) { if (!sync_vs && !sync_gs && !sync_fs) return; - size_t uniform_size = + std::size_t uniform_size = uniform_size_aligned_vs + uniform_size_aligned_gs + uniform_size_aligned_fs; - size_t used_bytes = 0; + std::size_t used_bytes = 0; u8* uniforms; GLintptr offset; bool invalidate; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index b116a33cf..f3d3b46c8 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -272,10 +272,10 @@ private: std::unique_ptr shader_program_manager; // They shall be big enough for about one frame. - static constexpr size_t VERTEX_BUFFER_SIZE = 32 * 1024 * 1024; - static constexpr size_t INDEX_BUFFER_SIZE = 1 * 1024 * 1024; - static constexpr size_t UNIFORM_BUFFER_SIZE = 2 * 1024 * 1024; - static constexpr size_t TEXTURE_BUFFER_SIZE = 1 * 1024 * 1024; + static constexpr std::size_t VERTEX_BUFFER_SIZE = 32 * 1024 * 1024; + static constexpr std::size_t INDEX_BUFFER_SIZE = 1 * 1024 * 1024; + static constexpr std::size_t UNIFORM_BUFFER_SIZE = 2 * 1024 * 1024; + static constexpr std::size_t TEXTURE_BUFFER_SIZE = 1 * 1024 * 1024; OGLVertexArray sw_vao; // VAO for software shader draw OGLVertexArray hw_vao; // VAO for hardware shader / accelerate draw @@ -288,9 +288,9 @@ private: OGLStreamBuffer texture_buffer; OGLFramebuffer framebuffer; GLint uniform_buffer_alignment; - size_t uniform_size_aligned_vs; - size_t uniform_size_aligned_gs; - size_t uniform_size_aligned_fs; + std::size_t uniform_size_aligned_vs; + std::size_t uniform_size_aligned_gs; + std::size_t uniform_size_aligned_fs; SamplerInfo texture_cube_sampler; diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 9ca9532af..0de41043a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -61,10 +61,10 @@ static constexpr FormatTuple tex_tuple = {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}; static const FormatTuple& GetFormatTuple(PixelFormat pixel_format) { const SurfaceType type = SurfaceParams::GetFormatType(pixel_format); if (type == SurfaceType::Color) { - ASSERT(static_cast(pixel_format) < fb_format_tuples.size()); + ASSERT(static_cast(pixel_format) < fb_format_tuples.size()); return fb_format_tuples[static_cast(pixel_format)]; } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) { - size_t tuple_idx = static_cast(pixel_format) - 14; + std::size_t tuple_idx = static_cast(pixel_format) - 14; ASSERT(tuple_idx < depth_format_tuples.size()); return depth_format_tuples[tuple_idx]; } @@ -669,13 +669,13 @@ void CachedSurface::LoadGLBuffer(PAddr load_start, PAddr load_end) { for (unsigned x = rect.left; x < rect.right; ++x) { auto vec4 = Pica::Texture::LookupTexture(texture_src_data, x, height - 1 - y, tex_info); - const size_t offset = (x + (width * y)) * 4; + const std::size_t offset = (x + (width * y)) * 4; std::memcpy(&gl_buffer[offset], vec4.AsArray(), 4); } } } else { - morton_to_gl_fns[static_cast(pixel_format)](stride, height, &gl_buffer[0], addr, - load_start, load_end); + morton_to_gl_fns[static_cast(pixel_format)](stride, height, &gl_buffer[0], + addr, load_start, load_end); } } } @@ -720,8 +720,8 @@ void CachedSurface::FlushGLBuffer(PAddr flush_start, PAddr flush_end) { ASSERT(type == SurfaceType::Color); std::memcpy(dst_buffer + start_offset, &gl_buffer[start_offset], flush_end - flush_start); } else { - gl_to_morton_fns[static_cast(pixel_format)](stride, height, &gl_buffer[0], addr, - flush_start, flush_end); + gl_to_morton_fns[static_cast(pixel_format)](stride, height, &gl_buffer[0], + addr, flush_start, flush_end); } } @@ -738,7 +738,7 @@ void CachedSurface::UploadGLTexture(const MathUtil::Rectangle& rect, GLuint // Load data from memory to the surface GLint x0 = static_cast(rect.left); GLint y0 = static_cast(rect.bottom); - size_t buffer_offset = (y0 * stride + x0) * GetGLBytesPerPixel(pixel_format); + std::size_t buffer_offset = (y0 * stride + x0) * GetGLBytesPerPixel(pixel_format); const FormatTuple& tuple = GetFormatTuple(pixel_format); GLuint target_tex = texture.handle; @@ -811,7 +811,8 @@ void CachedSurface::DownloadGLTexture(const MathUtil::Rectangle& rect, GLui // Ensure no bad interactions with GL_PACK_ALIGNMENT ASSERT(stride * GetGLBytesPerPixel(pixel_format) % 4 == 0); glPixelStorei(GL_PACK_ROW_LENGTH, static_cast(stride)); - size_t buffer_offset = (rect.bottom * stride + rect.left) * GetGLBytesPerPixel(pixel_format); + std::size_t buffer_offset = + (rect.bottom * stride + rect.left) * GetGLBytesPerPixel(pixel_format); // If not 1x scale, blit scaled texture to a new 1x texture and use that to flush if (res_scale != 1) { diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 519395fb6..618c59322 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -115,8 +115,8 @@ struct SurfaceParams { 32, // D24S8 }; - assert(static_cast(format) < bpp_table.size()); - return bpp_table[static_cast(format)]; + assert(static_cast(format) < bpp_table.size()); + return bpp_table[static_cast(format)]; } unsigned int GetFormatBpp() const { return GetFormatBpp(pixel_format); @@ -321,7 +321,7 @@ struct CachedSurface : SurfaceParams, std::enable_shared_from_this gl_buffer; - size_t gl_buffer_size = 0; + std::size_t gl_buffer_size = 0; // Read/Write data in 3DS memory to/from gl_buffer void LoadGLBuffer(PAddr load_start, PAddr load_end); @@ -374,7 +374,7 @@ struct TextureCubeConfig { namespace std { template <> struct hash { - size_t operator()(const TextureCubeConfig& config) const { + std::size_t operator()(const TextureCubeConfig& config) const { std::size_t hash = 0; boost::hash_combine(hash, config.px); boost::hash_combine(hash, config.nx); diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 85bdf2f0f..198188140 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -201,7 +201,7 @@ public: void AddLine(const std::string& text) { DEBUG_ASSERT(scope >= 0); if (!text.empty()) { - shader_source += std::string(static_cast(scope) * 4, ' '); + shader_source += std::string(static_cast(scope) * 4, ' '); } shader_source += text + '\n'; } @@ -418,9 +418,10 @@ private: u32 CompileInstr(u32 offset) { const Instruction instr = {program_code[offset]}; - size_t swizzle_offset = instr.opcode.Value().GetInfo().type == OpCode::Type::MultiplyAdd - ? instr.mad.operand_desc_id - : instr.common.operand_desc_id; + std::size_t swizzle_offset = + instr.opcode.Value().GetInfo().type == OpCode::Type::MultiplyAdd + ? instr.mad.operand_desc_id + : instr.common.operand_desc_id; const SwizzlePattern swizzle = {swizzle_data[swizzle_offset]}; shader.AddLine("// " + std::to_string(offset) + ": " + instr.opcode.Value().GetInfo().name); diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index bae90e772..63de80305 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -129,7 +129,7 @@ PicaFSConfig PicaFSConfig::BuildFromRegs(const Pica::Regs& regs) { // shader uniform instead. const auto& tev_stages = regs.texturing.GetTevStages(); DEBUG_ASSERT(state.tev_stages.size() == tev_stages.size()); - for (size_t i = 0; i < tev_stages.size(); i++) { + for (std::size_t i = 0; i < tev_stages.size(); i++) { const auto& tev_stage = tev_stages[i]; state.tev_stages[i].sources_raw = tev_stage.sources_raw; state.tev_stages[i].modifiers_raw = tev_stage.modifiers_raw; @@ -272,8 +272,8 @@ void PicaGSConfigCommonRaw::Init(const Pica::Regs& regs) { regs.rasterizer.vs_output_attributes[attrib].map_w}; for (u32 comp = 0; comp < 4; ++comp) { const auto semantic = semantics[comp]; - if (static_cast(semantic) < 24) { - semantic_maps[static_cast(semantic)] = {attrib, comp}; + if (static_cast(semantic) < 24) { + semantic_maps[static_cast(semantic)] = {attrib, comp}; } else if (semantic != VSOutputAttributes::INVALID) { LOG_ERROR(Render_OpenGL, "Invalid/unknown semantic id: {}", static_cast(semantic)); @@ -1516,7 +1516,7 @@ vec4 secondary_fragment_color = vec4(0.0); out += "vec4 next_combiner_buffer = tev_combiner_buffer_color;\n"; out += "vec4 last_tex_env_out = vec4(0.0);\n"; - for (size_t index = 0; index < state.tev_stages.size(); ++index) + for (std::size_t index = 0; index < state.tev_stages.size(); ++index) WriteTevStage(out, config, (unsigned)index); if (state.alpha_test_func != FramebufferRegs::CompareFunc::Always) { diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h index 0467fa8d9..cc19a19bb 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.h +++ b/src/video_core/renderer_opengl/gl_shader_gen.h @@ -261,28 +261,28 @@ std::string GenerateFragmentShader(const PicaFSConfig& config, bool separable_sh namespace std { template <> struct hash { - size_t operator()(const GLShader::PicaFSConfig& k) const { + std::size_t operator()(const GLShader::PicaFSConfig& k) const { return k.Hash(); } }; template <> struct hash { - size_t operator()(const GLShader::PicaVSConfig& k) const { + std::size_t operator()(const GLShader::PicaVSConfig& k) const { return k.Hash(); } }; template <> struct hash { - size_t operator()(const GLShader::PicaFixedGSConfig& k) const { + std::size_t operator()(const GLShader::PicaFixedGSConfig& k) const { return k.Hash(); } }; template <> struct hash { - size_t operator()(const GLShader::PicaGSConfig& k) const { + std::size_t operator()(const GLShader::PicaGSConfig& k) const { return k.Hash(); } }; diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index 519c15691..4593eab6a 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -9,7 +9,7 @@ #include "video_core/renderer_opengl/gl_shader_manager.h" static void SetShaderUniformBlockBinding(GLuint shader, const char* name, UniformBindings binding, - size_t expected_size) { + std::size_t expected_size) { GLuint ub_index = glGetUniformBlockIndex(shader, name); if (ub_index == GL_INVALID_INDEX) { return; diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index 0d41242ee..6cf4894bb 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -317,7 +317,7 @@ void OpenGLState::Apply() const { } // Clip distance - for (size_t i = 0; i < clip_distance.size(); ++i) { + for (std::size_t i = 0; i < clip_distance.size(); ++i) { if (clip_distance[i] != cur_state.clip_distance[i]) { if (clip_distance[i]) { glEnable(GL_CLIP_DISTANCE0 + static_cast(i)); diff --git a/src/video_core/renderer_opengl/gl_stream_buffer.cpp b/src/video_core/renderer_opengl/gl_stream_buffer.cpp index d1aa324d4..965165dc2 100644 --- a/src/video_core/renderer_opengl/gl_stream_buffer.cpp +++ b/src/video_core/renderer_opengl/gl_stream_buffer.cpp @@ -60,7 +60,7 @@ std::tuple OGLStreamBuffer::Map(GLsizeiptr size, GLintptr a mapped_size = size; if (alignment > 0) { - buffer_pos = Common::AlignUp(buffer_pos, alignment); + buffer_pos = Common::AlignUp(buffer_pos, alignment); } bool invalidate = false; diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h index 3c6073a9a..0bdc63d4a 100644 --- a/src/video_core/renderer_opengl/pica_to_gl.h +++ b/src/video_core/renderer_opengl/pica_to_gl.h @@ -35,7 +35,7 @@ inline GLenum TextureFilterMode(Pica::TexturingRegs::TextureConfig::TextureFilte GL_LINEAR, // TextureFilter::Linear }}; - const auto index = static_cast(mode); + const auto index = static_cast(mode); // Range check table for input if (index >= filter_mode_table.size()) { @@ -72,7 +72,7 @@ inline GLenum WrapMode(Pica::TexturingRegs::TextureConfig::WrapMode mode) { GL_REPEAT, // WrapMode::Repeat3 }}; - const auto index = static_cast(mode); + const auto index = static_cast(mode); // Range check table for input if (index >= wrap_mode_table.size()) { @@ -111,7 +111,7 @@ inline GLenum BlendEquation(Pica::FramebufferRegs::BlendEquation equation) { GL_MAX, // BlendEquation::Max }}; - const auto index = static_cast(equation); + const auto index = static_cast(equation); // Range check table for input if (index >= blend_equation_table.size()) { @@ -143,7 +143,7 @@ inline GLenum BlendFunc(Pica::FramebufferRegs::BlendFactor factor) { GL_SRC_ALPHA_SATURATE, // BlendFactor::SourceAlphaSaturate }}; - const auto index = static_cast(factor); + const auto index = static_cast(factor); // Range check table for input if (index >= blend_func_table.size()) { @@ -176,7 +176,7 @@ inline GLenum LogicOp(Pica::FramebufferRegs::LogicOp op) { GL_OR_INVERTED, // OrInverted }}; - const auto index = static_cast(op); + const auto index = static_cast(op); // Range check table for input if (index >= logic_op_table.size()) { @@ -201,7 +201,7 @@ inline GLenum CompareFunc(Pica::FramebufferRegs::CompareFunc func) { GL_GEQUAL, // CompareFunc::GreaterThanOrEqual }}; - const auto index = static_cast(func); + const auto index = static_cast(func); // Range check table for input if (index >= compare_func_table.size()) { @@ -226,7 +226,7 @@ inline GLenum StencilOp(Pica::FramebufferRegs::StencilAction action) { GL_DECR_WRAP, // StencilAction::DecrementWrap }}; - const auto index = static_cast(action); + const auto index = static_cast(action); // Range check table for input if (index >= stencil_op_table.size()) { diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 79717b2be..f83d8d91f 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -176,7 +176,7 @@ void RendererOpenGL::LoadFBToScreenInfo(const GPU::Regs::FramebufferConfig& fram (int)framebuffer.height, (int)framebuffer.format); int bpp = GPU::Regs::BytesPerPixel(framebuffer.color_format); - size_t pixel_stride = framebuffer.stride / bpp; + std::size_t pixel_stride = framebuffer.stride / bpp; // OpenGL only supports specifying a stride in units of pixels, not bytes, unfortunately ASSERT(pixel_stride * bpp == framebuffer.stride); diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 341d8a453..7bf97e3fc 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -24,9 +24,9 @@ namespace Shader { void OutputVertex::ValidateSemantics(const RasterizerRegs& regs) { unsigned int num_attributes = regs.vs_output_total; ASSERT(num_attributes <= 7); - for (size_t attrib = 0; attrib < num_attributes; ++attrib) { + for (std::size_t attrib = 0; attrib < num_attributes; ++attrib) { u32 output_register_map = regs.vs_output_attributes[attrib].raw; - for (size_t comp = 0; comp < 4; ++comp) { + for (std::size_t comp = 0; comp < 4; ++comp) { u32 semantic = (output_register_map >> (8 * comp)) & 0x1F; ASSERT_MSG(semantic < 24 || semantic == RasterizerRegs::VSOutputAttributes::INVALID, "Invalid/unknown semantic id: {}", semantic); @@ -50,7 +50,7 @@ OutputVertex OutputVertex::FromAttributeBuffer(const RasterizerRegs& regs, "Struct and array have different sizes."); unsigned int num_attributes = regs.vs_output_total & 7; - for (size_t attrib = 0; attrib < num_attributes; ++attrib) { + for (std::size_t attrib = 0; attrib < num_attributes; ++attrib) { const auto output_register_map = regs.vs_output_attributes[attrib]; vertex_slots_overflow[output_register_map.map_x] = input.attr[attrib][0]; vertex_slots_overflow[output_register_map.map_y] = input.attr[attrib][1]; @@ -117,7 +117,7 @@ void GSEmitter::Emit(Math::Vec4 (&output_regs)[16]) { if (prim_emit) { if (winding) handlers->winding_setter(); - for (size_t i = 0; i < buffer.size(); ++i) { + for (std::size_t i = 0; i < buffer.size(); ++i) { handlers->vertex_handler(buffer[i]); } } diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index 86e902a1c..6340abddd 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -118,7 +118,7 @@ struct UnitState { GSEmitter* emitter_ptr; - static size_t InputOffset(const SourceRegister& reg) { + static std::size_t InputOffset(const SourceRegister& reg) { switch (reg.GetRegisterType()) { case RegisterType::Input: return offsetof(UnitState, registers.input) + @@ -134,7 +134,7 @@ struct UnitState { } } - static size_t OutputOffset(const DestRegister& reg) { + static std::size_t OutputOffset(const DestRegister& reg) { switch (reg.GetRegisterType()) { case RegisterType::Output: return offsetof(UnitState, registers.output) + @@ -182,15 +182,15 @@ struct Uniforms { std::array b; std::array, 4> i; - static size_t GetFloatUniformOffset(unsigned index) { + static std::size_t GetFloatUniformOffset(unsigned index) { return offsetof(Uniforms, f) + index * sizeof(Math::Vec4); } - static size_t GetBoolUniformOffset(unsigned index) { + static std::size_t GetBoolUniformOffset(unsigned index) { return offsetof(Uniforms, b) + index * sizeof(bool); } - static size_t GetIntUniformOffset(unsigned index) { + static std::size_t GetIntUniformOffset(unsigned index) { return offsetof(Uniforms, i) + index * sizeof(Math::Vec4); } }; diff --git a/src/video_core/shader/shader_jit_x64_compiler.cpp b/src/video_core/shader/shader_jit_x64_compiler.cpp index 02f6b2791..639cd914e 100644 --- a/src/video_core/shader/shader_jit_x64_compiler.cpp +++ b/src/video_core/shader/shader_jit_x64_compiler.cpp @@ -166,7 +166,7 @@ static void LogCritical(const char* msg) { void JitShader::Compile_Assert(bool condition, const char* msg) { if (!condition) { - mov(ABI_PARAM1, reinterpret_cast(msg)); + mov(ABI_PARAM1, reinterpret_cast(msg)); CallFarFunction(*this, LogCritical); } } @@ -181,7 +181,7 @@ void JitShader::Compile_Assert(bool condition, const char* msg) { void JitShader::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, Xmm dest) { Reg64 src_ptr; - size_t src_offset; + std::size_t src_offset; if (src_reg.GetRegisterType() == RegisterType::FloatUniform) { src_ptr = UNIFORMS; @@ -266,7 +266,7 @@ void JitShader::Compile_DestEnable(Instruction instr, Xmm src) { SwizzlePattern swiz = {(*swizzle_data)[operand_desc_id]}; - size_t dest_offset_disp = UnitState::OutputOffset(dest); + std::size_t dest_offset_disp = UnitState::OutputOffset(dest); // If all components are enabled, write the result to the destination register if (swiz.dest_mask == NO_DEST_REG_MASK) { @@ -354,7 +354,7 @@ void JitShader::Compile_EvaluateCondition(Instruction instr) { } void JitShader::Compile_UniformCondition(Instruction instr) { - size_t offset = Uniforms::GetBoolUniformOffset(instr.flow_control.bool_uniform_id); + std::size_t offset = Uniforms::GetBoolUniformOffset(instr.flow_control.bool_uniform_id); cmp(byte[UNIFORMS + offset], 0); } @@ -733,7 +733,7 @@ void JitShader::Compile_LOOP(Instruction instr) { // This decodes the fields from the integer uniform at index instr.flow_control.int_uniform_id. // The Y (LOOPCOUNT_REG) and Z (LOOPINC) component are kept multiplied by 16 (Left shifted by // 4 bits) to be used as an offset into the 16-byte vector registers later - size_t offset = Uniforms::GetIntUniformOffset(instr.flow_control.int_uniform_id); + std::size_t offset = Uniforms::GetIntUniformOffset(instr.flow_control.int_uniform_id); mov(LOOPCOUNT, dword[UNIFORMS + offset]); mov(LOOPCOUNT_REG, LOOPCOUNT); shr(LOOPCOUNT_REG, 4); @@ -789,7 +789,7 @@ void JitShader::Compile_EMIT(Instruction instr) { jnz(have_emitter); ABI_PushRegistersAndAdjustStack(*this, PersistentCallerSavedRegs(), 0); - mov(ABI_PARAM1, reinterpret_cast("Execute EMIT on VS")); + mov(ABI_PARAM1, reinterpret_cast("Execute EMIT on VS")); CallFarFunction(*this, LogCritical); ABI_PopRegistersAndAdjustStack(*this, PersistentCallerSavedRegs(), 0); jmp(end); @@ -811,7 +811,7 @@ void JitShader::Compile_SETE(Instruction instr) { jnz(have_emitter); ABI_PushRegistersAndAdjustStack(*this, PersistentCallerSavedRegs(), 0); - mov(ABI_PARAM1, reinterpret_cast("Execute SETEMIT on VS")); + mov(ABI_PARAM1, reinterpret_cast("Execute SETEMIT on VS")); CallFarFunction(*this, LogCritical); ABI_PopRegistersAndAdjustStack(*this, PersistentCallerSavedRegs(), 0); jmp(end); @@ -866,7 +866,7 @@ void JitShader::Compile_NextInstr() { void JitShader::FindReturnOffsets() { return_offsets.clear(); - for (size_t offset = 0; offset < program_code->size(); ++offset) { + for (std::size_t offset = 0; offset < program_code->size(); ++offset) { Instruction instr = {(*program_code)[offset]}; switch (instr.opcode.Value()) { @@ -922,12 +922,12 @@ void JitShader::Compile(const std::array* program_ // Used to set a register to one static const __m128 one = {1.f, 1.f, 1.f, 1.f}; - mov(rax, reinterpret_cast(&one)); + mov(rax, reinterpret_cast(&one)); movaps(ONE, xword[rax]); // Used to negate registers static const __m128 neg = {-0.f, -0.f, -0.f, -0.f}; - mov(rax, reinterpret_cast(&neg)); + mov(rax, reinterpret_cast(&neg)); movaps(NEGBIT, xword[rax]); // Jump to start of the shader program diff --git a/src/video_core/shader/shader_jit_x64_compiler.h b/src/video_core/shader/shader_jit_x64_compiler.h index 8e1c87346..20266aa11 100644 --- a/src/video_core/shader/shader_jit_x64_compiler.h +++ b/src/video_core/shader/shader_jit_x64_compiler.h @@ -24,7 +24,7 @@ namespace Pica { namespace Shader { /// Memory allocated for each compiled shader -constexpr size_t MAX_SHADER_SIZE = MAX_PROGRAM_CODE_LENGTH * 64; +constexpr std::size_t MAX_SHADER_SIZE = MAX_PROGRAM_CODE_LENGTH * 64; /** * This class implements the shader JIT compiler. It recompiles a Pica shader program into x86_64 diff --git a/src/video_core/swrasterizer/clipper.cpp b/src/video_core/swrasterizer/clipper.cpp index 6af36ca3a..79e61edf7 100644 --- a/src/video_core/swrasterizer/clipper.cpp +++ b/src/video_core/swrasterizer/clipper.cpp @@ -91,7 +91,7 @@ void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const Outpu // the new edge (or less in degenerate cases). As such, we can say that each clipping plane // introduces at most 1 new vertex to the polygon. Since we start with a triangle and have a // fixed 6 clipping planes, the maximum number of vertices of the clipped polygon is 3 + 6 = 9. - static const size_t MAX_VERTICES = 9; + static const std::size_t MAX_VERTICES = 9; static_vector buffer_a = {v0, v1, v2}; static_vector buffer_b; @@ -166,7 +166,7 @@ void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const Outpu InitScreenCoordinates((*output_list)[0]); InitScreenCoordinates((*output_list)[1]); - for (size_t i = 0; i < output_list->size() - 2; i++) { + for (std::size_t i = 0; i < output_list->size() - 2; i++) { Vertex& vtx0 = (*output_list)[0]; Vertex& vtx1 = (*output_list)[i + 1]; Vertex& vtx2 = (*output_list)[i + 2]; diff --git a/src/video_core/swrasterizer/lighting.cpp b/src/video_core/swrasterizer/lighting.cpp index 21dcdf8d2..ce345dd87 100644 --- a/src/video_core/swrasterizer/lighting.cpp +++ b/src/video_core/swrasterizer/lighting.cpp @@ -7,8 +7,8 @@ namespace Pica { -static float LookupLightingLut(const Pica::State::Lighting& lighting, size_t lut_index, u8 index, - float delta) { +static float LookupLightingLut(const Pica::State::Lighting& lighting, std::size_t lut_index, + u8 index, float delta) { ASSERT_MSG(lut_index < lighting.luts.size(), "Out of range lut"); ASSERT_MSG(index < lighting.luts[lut_index].size(), "Out of range index"); @@ -93,8 +93,8 @@ std::tuple, Math::Vec4> ComputeFragmentsColors( auto distance = (-view - position).Length(); float scale = Pica::float20::FromRaw(light_config.dist_atten_scale).ToFloat32(); float bias = Pica::float20::FromRaw(light_config.dist_atten_bias).ToFloat32(); - size_t lut = - static_cast(LightingRegs::LightingSampler::DistanceAttenuation) + num; + std::size_t lut = + static_cast(LightingRegs::LightingSampler::DistanceAttenuation) + num; float sample_loc = std::clamp(scale * distance + bias, 0.0f, 1.0f); @@ -168,8 +168,8 @@ std::tuple, Math::Vec4> ComputeFragmentsColors( } float scale = lighting.lut_scale.GetScale(scale_enum); - return scale * - LookupLightingLut(lighting_state, static_cast(sampler), index, delta); + return scale * LookupLightingLut(lighting_state, static_cast(sampler), + index, delta); }; // If enabled, compute spot light attenuation value diff --git a/src/video_core/texture/texture_decode.cpp b/src/video_core/texture/texture_decode.cpp index 015327c15..4032cabda 100644 --- a/src/video_core/texture/texture_decode.cpp +++ b/src/video_core/texture/texture_decode.cpp @@ -18,8 +18,8 @@ using TextureFormat = Pica::TexturingRegs::TextureFormat; namespace Pica { namespace Texture { -constexpr size_t TILE_SIZE = 8 * 8; -constexpr size_t ETC1_SUBTILES = 2 * 2; +constexpr std::size_t TILE_SIZE = 8 * 8; +constexpr std::size_t ETC1_SUBTILES = 2 * 2; size_t CalculateTileSize(TextureFormat format) { switch (format) { @@ -177,7 +177,7 @@ Math::Vec4 LookupTexelInTile(const u8* source, unsigned int x, unsigned int case TextureFormat::ETC1: case TextureFormat::ETC1A4: { bool has_alpha = (info.format == TextureFormat::ETC1A4); - size_t subtile_size = has_alpha ? 16 : 8; + std::size_t subtile_size = has_alpha ? 16 : 8; // ETC1 further subdivides each 8x8 tile into four 4x4 subtiles constexpr unsigned int subtile_width = 4;