Replaced all "long long" types with int64_t

Replaced all "unsigned long long" types with uint64_t.
These "new" types better communicate their meaning and they are
guaranteed to behave the same on all platforms & compilers.
This commit is contained in:
Vojtech Bubnik 2020-12-10 08:40:08 +01:00
parent fbf2978190
commit bd79036d13
9 changed files with 52 additions and 45 deletions

View File

@ -7,6 +7,7 @@
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/CustomGCode.hpp"
#include <cstdint>
#include <array>
#include <vector>
#include <string>
@ -298,7 +299,7 @@ namespace Slic3r {
PrintEstimatedTimeStatistics time_statistics;
#if ENABLE_GCODE_VIEWER_STATISTICS
long long time{ 0 };
int64_t time{ 0 };
void reset()
{
time = 0;

View File

@ -1,6 +1,7 @@
#ifndef slic3r_SLAPrint_hpp_
#define slic3r_SLAPrint_hpp_
#include <cstdint>
#include <mutex>
#include "PrintBase.hpp"
#include "SLA/RasterBase.hpp"
@ -37,7 +38,7 @@ using _SLAPrintObjectBase =
// Layers according to quantized height levels. This will be consumed by
// the printer (rasterizer) in the SLAPrint class.
// using coord_t = long long;
// using coord_t = int64_t;
enum SliceOrigin { soSupport, soModel };

View File

@ -1011,11 +1011,11 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
m_max_bounding_box.merge(m_paths_bounding_box.max + m_sequential_view.marker.get_bounding_box().size()[2] * Vec3d::UnitZ());
auto log_memory_usage = [this](const std::string& label, const std::vector<std::vector<float>>& vertices, const std::vector<MultiIndexBuffer>& indices) {
long long vertices_size = 0;
int64_t vertices_size = 0;
for (size_t i = 0; i < vertices.size(); ++i) {
vertices_size += SLIC3R_STDVEC_MEMSIZE(vertices[i], float);
}
long long indices_size = 0;
int64_t indices_size = 0;
for (size_t i = 0; i < indices.size(); ++i) {
for (size_t j = 0; j < indices[i].size(); ++j) {
indices_size += SLIC3R_STDVEC_MEMSIZE(indices[i][j], unsigned int);
@ -1432,7 +1432,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
buffer.vertices.count = buffer_vertices.size() / buffer.vertices.vertex_size_floats();
#if ENABLE_GCODE_VIEWER_STATISTICS
m_statistics.vertices_gpu_size += buffer_vertices.size() * sizeof(float);
m_statistics.max_vertices_in_vertex_buffer = std::max(m_statistics.max_vertices_in_vertex_buffer, static_cast<long long>(buffer.vertices.count));
m_statistics.max_vertices_in_vertex_buffer = std::max(m_statistics.max_vertices_in_vertex_buffer, static_cast<int64_t>(buffer.vertices.count));
#endif // ENABLE_GCODE_VIEWER_STATISTICS
glsafe(::glGenBuffers(1, &buffer.vertices.id));
@ -1538,7 +1538,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
ibuffer.count = buffer_indices.size();
#if ENABLE_GCODE_VIEWER_STATISTICS
m_statistics.indices_gpu_size += ibuffer.count * sizeof(unsigned int);
m_statistics.max_indices_in_index_buffer = std::max(m_statistics.max_indices_in_index_buffer, static_cast<long long>(ibuffer.count));
m_statistics.max_indices_in_index_buffer = std::max(m_statistics.max_indices_in_index_buffer, static_cast<int64_t>(ibuffer.count));
#endif // ENABLE_GCODE_VIEWER_STATISTICS
if (ibuffer.count > 0) {
@ -2803,7 +2803,7 @@ void GCodeViewer::render_statistics() const
ImGuiWrapper& imgui = *wxGetApp().imgui();
auto add_time = [this, &imgui](const std::string& label, long long time) {
auto add_time = [this, &imgui](const std::string& label, int64_t time) {
char buf[1024];
sprintf(buf, "%lld ms (%s)", time, get_time_dhms(static_cast<float>(time) * 0.001f).c_str());
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, label);
@ -2811,7 +2811,7 @@ void GCodeViewer::render_statistics() const
imgui.text(buf);
};
auto add_memory = [this, &imgui](const std::string& label, long long memory) {
auto add_memory = [this, &imgui](const std::string& label, int64_t memory) {
static const float mb = 1024.0f * 1024.0f;
static const float inv_mb = 1.0f / mb;
static const float gb = 1024.0f * mb;
@ -2826,7 +2826,7 @@ void GCodeViewer::render_statistics() const
imgui.text(buf);
};
auto add_counter = [this, &imgui](const std::string& label, long long counter) {
auto add_counter = [this, &imgui](const std::string& label, int64_t counter) {
char buf[1024];
sprintf(buf, "%lld", counter);
imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, label);
@ -2890,11 +2890,11 @@ void GCodeViewer::render_statistics() const
}
#endif // ENABLE_GCODE_VIEWER_STATISTICS
void GCodeViewer::log_memory_used(const std::string& label, long long additional) const
void GCodeViewer::log_memory_used(const std::string& label, int64_t additional) const
{
if (Slic3r::get_logging_level() >= 5) {
long long paths_size = 0;
long long render_paths_size = 0;
int64_t paths_size = 0;
int64_t render_paths_size = 0;
for (const TBuffer& buffer : m_buffers) {
paths_size += SLIC3R_STDVEC_MEMSIZE(buffer.paths, Path);
render_paths_size += SLIC3R_STDVEC_MEMSIZE(buffer.render_paths, RenderPath);
@ -2903,7 +2903,7 @@ void GCodeViewer::log_memory_used(const std::string& label, long long additional
render_paths_size += SLIC3R_STDVEC_MEMSIZE(path.offsets, size_t);
}
}
long long layers_size = SLIC3R_STDVEC_MEMSIZE(m_layers.get_zs(), double);
int64_t layers_size = SLIC3R_STDVEC_MEMSIZE(m_layers.get_zs(), double);
layers_size += SLIC3R_STDVEC_MEMSIZE(m_layers.get_endpoints(), Layers::Endpoints);
BOOST_LOG_TRIVIAL(trace) << label
<< format_memsize_MB(additional + paths_size + render_paths_size + layers_size)

View File

@ -5,6 +5,7 @@
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include "GLModel.hpp"
#include <cstdint>
#include <float.h>
namespace Slic3r {
@ -311,26 +312,26 @@ class GCodeViewer
struct Statistics
{
// time
long long results_time{ 0 };
long long load_time{ 0 };
long long refresh_time{ 0 };
long long refresh_paths_time{ 0 };
int64_t results_time{ 0 };
int64_t load_time{ 0 };
int64_t refresh_time{ 0 };
int64_t refresh_paths_time{ 0 };
// opengl calls
long long gl_multi_points_calls_count{ 0 };
long long gl_multi_lines_calls_count{ 0 };
long long gl_multi_triangles_calls_count{ 0 };
int64_t gl_multi_points_calls_count{ 0 };
int64_t gl_multi_lines_calls_count{ 0 };
int64_t gl_multi_triangles_calls_count{ 0 };
// memory
long long results_size{ 0 };
long long vertices_gpu_size{ 0 };
long long indices_gpu_size{ 0 };
long long paths_size{ 0 };
long long render_paths_size{ 0 };
int64_t results_size{ 0 };
int64_t vertices_gpu_size{ 0 };
int64_t indices_gpu_size{ 0 };
int64_t paths_size{ 0 };
int64_t render_paths_size{ 0 };
// other
long long travel_segments_count{ 0 };
long long wipe_segments_count{ 0 };
long long extrude_segments_count{ 0 };
long long max_vertices_in_vertex_buffer{ 0 };
long long max_indices_in_index_buffer{ 0 };
int64_t travel_segments_count{ 0 };
int64_t wipe_segments_count{ 0 };
int64_t extrude_segments_count{ 0 };
int64_t max_vertices_in_vertex_buffer{ 0 };
int64_t max_indices_in_index_buffer{ 0 };
void reset_all() {
reset_times();
@ -509,7 +510,7 @@ private:
return role < erCount && (m_extrusions.role_visibility_flags & (1 << role)) != 0;
}
bool is_visible(const Path& path) const { return is_visible(path.role); }
void log_memory_used(const std::string& label, long long additional = 0) const;
void log_memory_used(const std::string& label, int64_t additional = 0) const;
};
} // namespace GUI

View File

@ -1681,7 +1681,7 @@ void GLCanvas3D::render()
imgui.begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
imgui.text("Last frame:");
ImGui::SameLine();
long long average = m_render_stats.get_average();
int64_t average = m_render_stats.get_average();
imgui.text(std::to_string(average));
ImGui::SameLine();
imgui.text("ms");

View File

@ -4,6 +4,7 @@
#include <stddef.h>
#include <memory>
#include <chrono>
#include <cstdint>
#include "GLToolbar.hpp"
#include "Event.hpp"
@ -322,12 +323,12 @@ class GLCanvas3D
#if ENABLE_RENDER_STATISTICS
class RenderStats
{
std::queue<std::pair<long long, long long>> m_frames;
long long m_curr_total{ 0 };
std::queue<std::pair<int64_t, int64_t>> m_frames;
int64_t m_curr_total{ 0 };
public:
void add_frame(long long frame) {
long long now = wxGetLocalTimeMillis().GetValue();
void add_frame(int64_t frame) {
int64_t now = wxGetLocalTimeMillis().GetValue();
if (!m_frames.empty() && now - m_frames.front().first > 1000) {
m_curr_total -= m_frames.front().second;
m_frames.pop();
@ -335,7 +336,7 @@ class GLCanvas3D
m_curr_total += frame;
m_frames.push({ now, frame });
}
long long get_average() const { return m_frames.empty() ? 0 : m_curr_total / m_frames.size(); }
int64_t get_average() const { return m_frames.empty() ? 0 : m_curr_total / m_frames.size(); }
};
#endif // ENABLE_RENDER_STATISTICS

View File

@ -17,6 +17,7 @@
#include <fcntl.h>
#include <errno.h>
#include <optional>
#include <cstdint>
#ifdef _WIN32
#include <strsafe.h>
@ -83,9 +84,9 @@ namespace instance_check_internal
//check if other instances has same instance hash
//if not it is not same version(binary) as this version
HANDLE handle = GetProp(hwnd, L"Instance_Hash_Minor");
unsigned long long other_instance_hash = PtrToUint(handle);
unsigned long long other_instance_hash_major;
unsigned long long my_instance_hash = GUI::wxGetApp().get_instance_hash_int();
uint64_t other_instance_hash = PtrToUint(handle);
uint64_t other_instance_hash_major;
uint64_t my_instance_hash = GUI::wxGetApp().get_instance_hash_int();
handle = GetProp(hwnd, L"Instance_Hash_Major");
other_instance_hash_major = PtrToUint(handle);
other_instance_hash_major = other_instance_hash_major << 32;

View File

@ -1,6 +1,7 @@
#include <catch_main.hpp>
#include <fstream>
#include <cstdint>
#include <libnest2d/libnest2d.hpp>
#include "printer_parts.hpp"
@ -472,7 +473,7 @@ TEST_CASE("ArrangeRectanglesLoose", "[Nesting]")
namespace {
using namespace libnest2d;
template<long long SCALE = 1, class It>
template<int64_t SCALE = 1, class It>
void exportSVG(const char *loc, It from, It to) {
static const char* svg_header =
@ -512,7 +513,7 @@ R"raw(<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
// }
}
template<long long SCALE = 1>
template<int64_t SCALE = 1>
void exportSVG(std::vector<std::reference_wrapper<Item>>& result, int idx = 0) {
exportSVG((std::string("out") + std::to_string(idx) + ".svg").c_str(),
result.begin(), result.end());

View File

@ -1,6 +1,7 @@
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <cstdint>
#include "sla_test_utils.hpp"
@ -63,7 +64,7 @@ TEST_CASE("Support point generator should be deterministic if seeded",
point_gen.execute(slices, slicegrid);
auto get_chksum = [](const std::vector<sla::SupportPoint> &pts){
long long chksum = 0;
int64_t chksum = 0;
for (auto &pt : pts) {
auto p = scaled(pt.pos);
chksum += p.x() + p.y() + p.z();
@ -72,7 +73,7 @@ TEST_CASE("Support point generator should be deterministic if seeded",
return chksum;
};
long long checksum = get_chksum(point_gen.output());
int64_t checksum = get_chksum(point_gen.output());
size_t ptnum = point_gen.output().size();
REQUIRE(point_gen.output().size() > 0);