- fixes for GCC on Linux

This commit is contained in:
Rachael Alexanderson 2023-09-14 01:37:31 -04:00 committed by Christoph Oelckers
parent a1cab9c9f8
commit 7610cade9f
7 changed files with 16 additions and 20 deletions

View file

@ -433,13 +433,13 @@ set( PLAT_POSIX_SOURCES
common/platform/posix/i_system_posix.cpp ) common/platform/posix/i_system_posix.cpp )
set( PLAT_SDL_SOURCES set( PLAT_SDL_SOURCES
common/platform/posix/sdl/crashcatcher.c common/platform/posix/sdl/crashcatcher.c
common/platform/posix/sdl/base_sysfb.cpp
common/platform/posix/sdl/hardware.cpp common/platform/posix/sdl/hardware.cpp
common/platform/posix/sdl/i_gui.cpp common/platform/posix/sdl/i_gui.cpp
common/platform/posix/sdl/i_input.cpp common/platform/posix/sdl/i_input.cpp
common/platform/posix/sdl/i_joystick.cpp common/platform/posix/sdl/i_joystick.cpp
common/platform/posix/sdl/i_main.cpp common/platform/posix/sdl/i_main.cpp
common/platform/posix/sdl/i_system.cpp common/platform/posix/sdl/i_system.cpp
common/platform/posix/sdl/sdlglvideo.cpp
common/platform/posix/sdl/st_start.cpp ) common/platform/posix/sdl/st_start.cpp )
set( PLAT_UNIX_SOURCES set( PLAT_UNIX_SOURCES
common/platform/posix/unix/i_specialpaths.cpp common/platform/posix/unix/i_specialpaths.cpp

View file

@ -29,7 +29,7 @@
# define WIN32_LEAN_AND_MEAN 1 # define WIN32_LEAN_AND_MEAN 1
# include <windows.h> # include <windows.h>
#else #else
# define _POSIX_C_SOURCE 1 //# define _POSIX_C_SOURCE 1
# include <fcntl.h> # include <fcntl.h>
# include <sys/mman.h> # include <sys/mman.h>
# include <sys/stat.h> # include <sys/stat.h>
@ -125,7 +125,7 @@ struct SFT_Font
/* function declarations */ /* function declarations */
/* generic utility functions */ /* 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_floor(double x);
static inline int fast_ceil (double x); static inline int fast_ceil (double x);
/* file loading */ /* file loading */
@ -406,11 +406,11 @@ failure:
* if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW */ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW */
#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) #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(). * A wrapper for realloc() that takes two size args like calloc().
* Useful because it eliminates common integer overflow bugs. */ * Useful because it eliminates common integer overflow bugs. */
static void * 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) && if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
nmemb > 0 && SIZE_MAX / nmemb < size) { nmemb > 0 && SIZE_MAX / nmemb < size) {
@ -497,7 +497,7 @@ map_file(SFT_Font *font, const char *filename)
{ {
struct stat info; struct stat info;
int fd; int fd;
font->memory = MAP_FAILED; font->memory = reinterpret_cast<const uint8_t*>(MAP_FAILED);
font->size = 0; font->size = 0;
font->source = SrcMapping; font->source = SrcMapping;
if ((fd = open(filename, O_RDONLY)) < 0) { if ((fd = open(filename, O_RDONLY)) < 0) {
@ -508,7 +508,7 @@ map_file(SFT_Font *font, const char *filename)
return -1; return -1;
} }
/* FIXME do some basic validation on info.st_size maybe - it is signed for example, so it *could* be negative .. */ /* 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<const uint8_t*>(mmap(NULL, (size_t) info.st_size, PROT_READ, MAP_PRIVATE, fd, 0));
font->size = (uint_fast32_t) info.st_size; font->size = (uint_fast32_t) info.st_size;
close(fd); close(fd);
return font->memory == MAP_FAILED ? -1 : 0; return font->memory == MAP_FAILED ? -1 : 0;
@ -636,7 +636,7 @@ grow_points(Outline *outl)
if (outl->capPoints > UINT16_MAX / 2) if (outl->capPoints > UINT16_MAX / 2)
return -1; return -1;
cap = (uint_fast16_t) (2U * outl->capPoints); 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; return -1;
outl->capPoints = (uint_least16_t) cap; outl->capPoints = (uint_least16_t) cap;
outl->points = (Point*)mem; outl->points = (Point*)mem;
@ -652,7 +652,7 @@ grow_curves(Outline *outl)
if (outl->capCurves > UINT16_MAX / 2) if (outl->capCurves > UINT16_MAX / 2)
return -1; return -1;
cap = (uint_fast16_t) (2U * outl->capCurves); 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; return -1;
outl->capCurves = (uint_least16_t) cap; outl->capCurves = (uint_least16_t) cap;
outl->curves = (Curve*)mem; outl->curves = (Curve*)mem;
@ -668,7 +668,7 @@ grow_lines(Outline *outl)
if (outl->capLines > UINT16_MAX / 2) if (outl->capLines > UINT16_MAX / 2)
return -1; return -1;
cap = (uint_fast16_t) (2U * outl->capLines); 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; return -1;
outl->capLines = (uint_least16_t) cap; outl->capLines = (uint_least16_t) cap;
outl->lines = (Line*)mem; 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; } pixel;
struct { int x, y; } dir; struct { int x, y; } dir;
int step, numSteps = 0; int step, numSteps = 0;
Cell *restrict cptr, cell; Cell *cptr = NULL, cell;
delta.x = goal.x - origin.x; delta.x = goal.x - origin.x;
delta.y = goal.y - origin.y; delta.y = goal.y - origin.y;

View file

@ -206,11 +206,6 @@ SDLVideo::SDLVideo ()
#ifdef HAVE_VULKAN #ifdef HAVE_VULKAN
Priv::CreateWindow(SDL_WINDOW_VULKAN | SDL_WINDOW_HIDDEN | (vid_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)); Priv::CreateWindow(SDL_WINDOW_VULKAN | SDL_WINDOW_HIDDEN | (vid_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0));
if (Priv::window == nullptr)
{
Priv::vulkanEnabled = false;
}
#endif #endif
} }

View file

@ -7,6 +7,7 @@
#include "bounds.h" #include "bounds.h"
#include "common/utility/matrix.h" #include "common/utility/matrix.h"
#include <memory> #include <memory>
#include <cstring>
#include <dp_rect_pack.h> #include <dp_rect_pack.h>

View file

@ -134,7 +134,7 @@ private:
struct struct
{ {
static const int BufferSize = 1 * 1024 * 1024; const int BufferSize = 1 * 1024 * 1024;
std::unique_ptr<VulkanBuffer> Buffer; std::unique_ptr<VulkanBuffer> Buffer;
SceneVertex* Vertices = nullptr; SceneVertex* Vertices = nullptr;
int Pos = 0; int Pos = 0;
@ -142,7 +142,7 @@ private:
struct struct
{ {
static const int BufferSize = 2 * 1024 * 1024; const int BufferSize = 2 * 1024 * 1024;
std::unique_ptr<VulkanBuffer> Buffer; std::unique_ptr<VulkanBuffer> Buffer;
LightInfo* Lights = nullptr; LightInfo* Lights = nullptr;
int Pos = 0; int Pos = 0;

View file

@ -20,8 +20,8 @@ public:
FFlatVertex* Vertices = nullptr; FFlatVertex* Vertices = nullptr;
unsigned int ShadowDataSize = 0; unsigned int ShadowDataSize = 0;
unsigned int CurIndex = 0; unsigned int CurIndex = 0;
static const unsigned int BUFFER_SIZE = 2000000; const unsigned int BUFFER_SIZE = 2000000;
static const unsigned int BUFFER_SIZE_TO_USE = BUFFER_SIZE - 500; const unsigned int BUFFER_SIZE_TO_USE = BUFFER_SIZE - 500;
std::unique_ptr<VulkanBuffer> IndexBuffer; std::unique_ptr<VulkanBuffer> IndexBuffer;
} Flatbuffer; } Flatbuffer;