From 7610cade9ffe16f7913c74be7bd2d6cc6d7dabce Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 14 Sep 2023 01:37:31 -0400 Subject: [PATCH] - fixes for GCC on Linux --- src/CMakeLists.txt | 2 +- src/common/fonts/schrift.cpp | 20 +++++++++---------- .../sdl/{sdlglvideo.cpp => base_sysfb.cpp} | 5 ----- .../posix/sdl/{gl_sysfb.h => base_sysfb.h} | 0 .../rendering/hwrenderer/data/hw_levelmesh.h | 1 + .../vulkan/accelstructs/vk_lightmap.h | 4 ++-- .../rendering/vulkan/buffers/vk_rsbuffers.h | 4 ++-- 7 files changed, 16 insertions(+), 20 deletions(-) rename src/common/platform/posix/sdl/{sdlglvideo.cpp => base_sysfb.cpp} (99%) rename src/common/platform/posix/sdl/{gl_sysfb.h => base_sysfb.h} (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1f3bdc9d00..08d60f67b8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -433,13 +433,13 @@ set( PLAT_POSIX_SOURCES common/platform/posix/i_system_posix.cpp ) set( PLAT_SDL_SOURCES common/platform/posix/sdl/crashcatcher.c + common/platform/posix/sdl/base_sysfb.cpp common/platform/posix/sdl/hardware.cpp common/platform/posix/sdl/i_gui.cpp common/platform/posix/sdl/i_input.cpp common/platform/posix/sdl/i_joystick.cpp common/platform/posix/sdl/i_main.cpp common/platform/posix/sdl/i_system.cpp - common/platform/posix/sdl/sdlglvideo.cpp common/platform/posix/sdl/st_start.cpp ) set( PLAT_UNIX_SOURCES common/platform/posix/unix/i_specialpaths.cpp diff --git a/src/common/fonts/schrift.cpp b/src/common/fonts/schrift.cpp index 84f92f221f..dc4958e5ab 100644 --- a/src/common/fonts/schrift.cpp +++ b/src/common/fonts/schrift.cpp @@ -29,7 +29,7 @@ # define WIN32_LEAN_AND_MEAN 1 # include #else -# define _POSIX_C_SOURCE 1 +//# define _POSIX_C_SOURCE 1 # include # include # include @@ -125,7 +125,7 @@ struct SFT_Font /* function declarations */ /* generic utility functions */ -static void *reallocarray(void *optr, size_t nmemb, size_t size); +static void *schrift_reallocarray(void *optr, size_t nmemb, size_t size); static inline int fast_floor(double x); static inline int fast_ceil (double x); /* file loading */ @@ -406,11 +406,11 @@ failure: * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW */ #define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) -/* OpenBSD's reallocarray() standard libary function. +/* OpenBSD's schrift_reallocarray() standard libary function. * A wrapper for realloc() that takes two size args like calloc(). * Useful because it eliminates common integer overflow bugs. */ static void * -reallocarray(void *optr, size_t nmemb, size_t size) +schrift_reallocarray(void *optr, size_t nmemb, size_t size) { if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && nmemb > 0 && SIZE_MAX / nmemb < size) { @@ -497,7 +497,7 @@ map_file(SFT_Font *font, const char *filename) { struct stat info; int fd; - font->memory = MAP_FAILED; + font->memory = reinterpret_cast(MAP_FAILED); font->size = 0; font->source = SrcMapping; if ((fd = open(filename, O_RDONLY)) < 0) { @@ -508,7 +508,7 @@ map_file(SFT_Font *font, const char *filename) return -1; } /* FIXME do some basic validation on info.st_size maybe - it is signed for example, so it *could* be negative .. */ - font->memory = mmap(NULL, (size_t) info.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + font->memory = reinterpret_cast(mmap(NULL, (size_t) info.st_size, PROT_READ, MAP_PRIVATE, fd, 0)); font->size = (uint_fast32_t) info.st_size; close(fd); return font->memory == MAP_FAILED ? -1 : 0; @@ -636,7 +636,7 @@ grow_points(Outline *outl) if (outl->capPoints > UINT16_MAX / 2) return -1; cap = (uint_fast16_t) (2U * outl->capPoints); - if (!(mem = reallocarray(outl->points, cap, sizeof *outl->points))) + if (!(mem = schrift_reallocarray(outl->points, cap, sizeof *outl->points))) return -1; outl->capPoints = (uint_least16_t) cap; outl->points = (Point*)mem; @@ -652,7 +652,7 @@ grow_curves(Outline *outl) if (outl->capCurves > UINT16_MAX / 2) return -1; cap = (uint_fast16_t) (2U * outl->capCurves); - if (!(mem = reallocarray(outl->curves, cap, sizeof *outl->curves))) + if (!(mem = schrift_reallocarray(outl->curves, cap, sizeof *outl->curves))) return -1; outl->capCurves = (uint_least16_t) cap; outl->curves = (Curve*)mem; @@ -668,7 +668,7 @@ grow_lines(Outline *outl) if (outl->capLines > UINT16_MAX / 2) return -1; cap = (uint_fast16_t) (2U * outl->capLines); - if (!(mem = reallocarray(outl->lines, cap, sizeof *outl->lines))) + if (!(mem = schrift_reallocarray(outl->lines, cap, sizeof *outl->lines))) return -1; outl->capLines = (uint_least16_t) cap; outl->lines = (Line*)mem; @@ -1431,7 +1431,7 @@ draw_line(Raster buf, Point origin, Point goal) struct { int x, y; } pixel; struct { int x, y; } dir; int step, numSteps = 0; - Cell *restrict cptr, cell; + Cell *cptr = NULL, cell; delta.x = goal.x - origin.x; delta.y = goal.y - origin.y; diff --git a/src/common/platform/posix/sdl/sdlglvideo.cpp b/src/common/platform/posix/sdl/base_sysfb.cpp similarity index 99% rename from src/common/platform/posix/sdl/sdlglvideo.cpp rename to src/common/platform/posix/sdl/base_sysfb.cpp index f1271aac63..142f3b1bac 100644 --- a/src/common/platform/posix/sdl/sdlglvideo.cpp +++ b/src/common/platform/posix/sdl/base_sysfb.cpp @@ -206,11 +206,6 @@ SDLVideo::SDLVideo () #ifdef HAVE_VULKAN Priv::CreateWindow(SDL_WINDOW_VULKAN | SDL_WINDOW_HIDDEN | (vid_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)); - - if (Priv::window == nullptr) - { - Priv::vulkanEnabled = false; - } #endif } diff --git a/src/common/platform/posix/sdl/gl_sysfb.h b/src/common/platform/posix/sdl/base_sysfb.h similarity index 100% rename from src/common/platform/posix/sdl/gl_sysfb.h rename to src/common/platform/posix/sdl/base_sysfb.h diff --git a/src/common/rendering/hwrenderer/data/hw_levelmesh.h b/src/common/rendering/hwrenderer/data/hw_levelmesh.h index 739e978151..3e108b18f7 100644 --- a/src/common/rendering/hwrenderer/data/hw_levelmesh.h +++ b/src/common/rendering/hwrenderer/data/hw_levelmesh.h @@ -7,6 +7,7 @@ #include "bounds.h" #include "common/utility/matrix.h" #include +#include #include diff --git a/src/common/rendering/vulkan/accelstructs/vk_lightmap.h b/src/common/rendering/vulkan/accelstructs/vk_lightmap.h index b1002cd2c7..49f169f6f4 100644 --- a/src/common/rendering/vulkan/accelstructs/vk_lightmap.h +++ b/src/common/rendering/vulkan/accelstructs/vk_lightmap.h @@ -134,7 +134,7 @@ private: struct { - static const int BufferSize = 1 * 1024 * 1024; + const int BufferSize = 1 * 1024 * 1024; std::unique_ptr Buffer; SceneVertex* Vertices = nullptr; int Pos = 0; @@ -142,7 +142,7 @@ private: struct { - static const int BufferSize = 2 * 1024 * 1024; + const int BufferSize = 2 * 1024 * 1024; std::unique_ptr Buffer; LightInfo* Lights = nullptr; int Pos = 0; diff --git a/src/common/rendering/vulkan/buffers/vk_rsbuffers.h b/src/common/rendering/vulkan/buffers/vk_rsbuffers.h index d08802d24e..3df215a589 100644 --- a/src/common/rendering/vulkan/buffers/vk_rsbuffers.h +++ b/src/common/rendering/vulkan/buffers/vk_rsbuffers.h @@ -20,8 +20,8 @@ public: FFlatVertex* Vertices = nullptr; unsigned int ShadowDataSize = 0; unsigned int CurIndex = 0; - static const unsigned int BUFFER_SIZE = 2000000; - static const unsigned int BUFFER_SIZE_TO_USE = BUFFER_SIZE - 500; + const unsigned int BUFFER_SIZE = 2000000; + const unsigned int BUFFER_SIZE_TO_USE = BUFFER_SIZE - 500; std::unique_ptr IndexBuffer; } Flatbuffer;