File more-32bit.patch of Package gzdoom-shared

From: Jan Engelhardt <ej@inai.de>
Date: Wed, 8 May 2024 13:33:41 +0200
Subject: [PATCH] build: portability fixes
References: https://github.com/ZDoom/gzdoom/pull/2562

Different architectures have different type sizes and alignments.
Don't test void* for a hardcoded size if there is not an inherent
dependency on the size. I have hereby tested gzdoom.i586 runs
inside a chroot-on-x64.

VkSurfaceKHR is not a pointer on some platforms but an integral type.
Using {} will clear it without running into a type error:

	sdlglvideo.cpp:294:54: error: cannot convert 'std::nullptr_t' to
	'VkSurfaceKHR' {aka 'long long unsigned int'} in initialization
		VkSurfaceKHR surfacehandle = nullptr;
---
 src/CMakeLists.txt                           |    5 +++++
 src/common/engine/i_interface.cpp            |    2 --
 src/common/platform/posix/sdl/sdlglvideo.cpp |    2 +-
 src/playsim/p_effect.h                       |    7 +++++--
 4 files changed, 11 insertions(+), 5 deletions(-)

Index: gzdoom-g4.12.2/src/CMakeLists.txt
===================================================================
--- gzdoom-g4.12.2.orig/src/CMakeLists.txt
+++ gzdoom-g4.12.2/src/CMakeLists.txt
@@ -44,6 +44,11 @@ if( ${TARGET_ARCHITECTURE} MATCHES "x86_
 	set( X64 64 )
 	add_definitions( -DARCH_IA32 )
 endif()
+if( ${TARGET_ARCHITECTURE} MATCHES "i386" )
+	# The production of _mm_load_si128 instructions requires flags.
+	# (This is independent of whether or not they are executed later.)
+	add_definitions( -mmmx -msse -msse2 -mfpmath=sse -DARCH_IA32 )
+endif()
 
 if( NOT PROJECT_LIBRARIES )
 	set( PROJECT_LIBRARIES "" )
Index: gzdoom-g4.12.2/src/common/engine/i_interface.cpp
===================================================================
--- gzdoom-g4.12.2.orig/src/common/engine/i_interface.cpp
+++ gzdoom-g4.12.2/src/common/engine/i_interface.cpp
@@ -5,8 +5,6 @@
 #include "c_cvars.h"
 #include "gstrings.h"
 
-static_assert(sizeof(void*) == 8, "32 builds are not supported");
-
 // Some global engine variables taken out of the backend code.
 FStartupScreen* StartWindow;
 SystemCallbacks sysCallbacks;
Index: gzdoom-g4.12.2/src/common/platform/posix/sdl/sdlglvideo.cpp
===================================================================
--- gzdoom-g4.12.2.orig/src/common/platform/posix/sdl/sdlglvideo.cpp
+++ gzdoom-g4.12.2/src/common/platform/posix/sdl/sdlglvideo.cpp
@@ -400,7 +400,7 @@ DFrameBuffer *SDLVideo::CreateFrameBuffe
 				builder.RequireExtension(names[i]);
 			auto instance = builder.Create();
 
-			VkSurfaceKHR surfacehandle = nullptr;
+			VkSurfaceKHR surfacehandle = {};
 			if (!I_CreateVulkanSurface(instance->Instance, &surfacehandle))
 				VulkanError("I_CreateVulkanSurface failed");
 
Index: gzdoom-g4.12.2/src/playsim/p_effect.h
===================================================================
--- gzdoom-g4.12.2.orig/src/playsim/p_effect.h
+++ gzdoom-g4.12.2/src/playsim/p_effect.h
@@ -70,7 +70,10 @@ enum EParticleFlags
 class DVisualThinker;
 struct particle_t
 {
-	subsector_t* subsector; //+8 = 8
+	union {
+		subsector_t* subsector;
+		uint64_t _pad0; //+8 = 8
+	};
     DVector3 Pos; //+24 = 32
     FVector3 Vel; //+12 = 44
     FVector3 Acc; //+12 = 56
@@ -83,7 +86,7 @@ struct particle_t
     float Roll, RollVel, RollAcc; //+12 = 100
     uint16_t    tnext, snext, tprev; //+6 = 106
 	uint16_t flags; //+2 = 108
-	// uint32_t padding; //+4 = 112
+	uint32_t padding; //+4 = 112
 	FStandaloneAnimation animData; //+16 = 128
 };
 
openSUSE Build Service is sponsored by