Commit graph

65 commits

Author SHA1 Message Date
Daniel Gibson
ba6ba086b2 Don't use GCC's __builtin_alloca_with_align(), fix #572
turns out that __builtin_alloca_with_align() might releases the
allocated memory at the end of the block it was allocated in, instead
of the end of the function (which is the behavior of regular alloca()
and __builtin_alloca()): "The lifetime of the allocated object ends at
 the end of the block in which the function was called. The allocated
 storage is released no later than just before the calling function
 returns to its caller, but may be released at the end of the block in
 which the function was called."
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005falloca_005fwith_005falign

Clang also supports __builtin_alloca_with_align(), but always releases
the memory at the end of the function.

And it seems that newer GCC versions also tend to release it at the
end of the function, but GCC 4.7.2 (that I use for the official Linux
release binaries) didn't, and that caused weird graphical glitches.
But as I don't want to rely on newer GCC versions behaving like this
(and the documentation explicitly says that it *may* be released at
 the end of the block, but will definitely be released at the end of
 the function), I removed all usage of __builtin_alloca_with_align().

(Side-Note: GCC only started documenting the behavior of
 __builtin_alloca and __builtin_alloca_with_align at all with GCC 6.1.0)
2024-04-19 07:39:56 +02:00
Daniel Gibson
0aec4475c7 merge sys_public.h changes for gamepad support
not sure if any of this is relevant for mods, but shouldn't hurt..
2024-03-18 23:04:09 +01:00
Daniel Gibson
d27f2c2c40 Sync sys/platform.h, incl. Workaround for MCST-LCC compiler
Workaround for MCST-LCC compiler < 1.28 version

mcst-lcc < 1.28 does not support __builtin_alloca_with_align()
Ref: http://mcst.ru/lcc
2024-03-18 23:03:05 +01:00
Daniel Gibson
a09487b720 From dhewm3: Add absolute mouse mode and refactor mouse grabbing code
The only change really is adding SE_MOUSE_ABS to sysEventType_t.
In theory this breaks the ABI, but in practice I don't think mods use
sysEventType_t, and certainly not the ones above SE_MOUSE
(SE_JOYSTICK_AXIS doesn't make sense as Doom3 never supported Joysticks,
 SE_CONSOLE is for input from TTY or whatever, and doesn't make sense
 for mods to use in any way)

The change in Stub_SDL_endian.h is just me being paranoid.
(side-note: it *might* make sense to replace all that inline-asm in
 Stub_SDL_endian.h with compiler intrinsics like GCC/clangs
 __builtin_bswap* and MSVCs _byteswap_* - if they are supported in
 all relevant compiler versions. GCC supports 32 and 64 bit swaps since
 4.3, 16bit since 4.8 and 128bit since 11.x; clang supports 32 and
 64 bit swaps at least since 3.0 and 16bit swaps since 3.2;
 VS introduced _byteswap_ushort, .._ulong and .._uint64 in VS2003)
2022-05-17 07:17:46 +02:00
Daniel Gibson
541ba91e61 ID_MAYBE_INLINE for not-forced inlining
On Windows, ID_INLINE does __forceinline, which is bad if the function
calls alloca() and is called in a loop..
So use just __inline there so the compiler can choose not to inline
(if called in a loop).
This didn't cause actual stack overflows as far as I know, but it could
(and MSVC warns about it).

(This includes "Fix ID_MAYBE_INLINE on non-Windows platforms")
2020-09-06 04:36:40 +02:00
Daniel Gibson
02417dcecf It builds with VS 2017 now 2018-09-02 01:25:23 +02:00
Daniel Gibson
53db277bae Make it build as SDK
I created this repo from the original dhewm3 repo, but I used
git filter-branch to kill all the files that are not needed to just
build base.dll and d3xp.dll (or .so or .dylib or whatever).
So this is basically just the files the original Doom3 SDK had, but
taken from dhewm3 instead (and thus GPL licensed and patched for
64bit-support etc) + some dhewm3 specific stuff + CMakeLists.txt
to build them.

The git filter-branch details:

filter-branch -f --prune-empty --tree-filter /tmp/killkill.sh @

## /tmp/killkill.sh:

#!/bin/sh

find . -exec /tmp/removeothers.sh {} \;

exit 0

## /tmp/removeothers.sh:

#!/bin/bash

FNAME="$1"

if [[ $FNAME == \./\.git* ]] || [[ $FNAME == \./d3xp/* ]] || [[ $FNAME == \./game/* ]]
then
	#echo "ignoring $FNAME"
	exit 0
fi

if ! grep -Fxq "$FNAME" /tmp/d3sdklist.txt
then
	#echo "REMOVING $FNAME"
	rm -rf "$FNAME"
fi

exit 0

## /tmp/d3sdklist.txt was is just a textfile with one path per line with
   all the files (and directories!) I wanted to keep, like:

.
..
./sys/platform.h
./framework/Game.h
./config.h.in
./CMakeLists.txt
## ... and all the relevant files from the SDK
2018-08-26 01:43:10 +02:00
Kalamatee
2fb870b13f import AROS changes 2018-08-20 01:46:39 +02:00
David Carlier
45d826d31c make it compilable under openbsd 2018-08-20 01:46:39 +02:00
dhewg
caf580b3ff Get rid of Sys_SetFatalError()
Unnecessary.
2018-08-20 01:46:35 +02:00
dhewg
5c483d3349 Get rid of sysMemoryStats_t
Unused.
2018-08-20 01:46:35 +02:00
dhewg
49067a82aa Get rid of Sys_FPU_StackIsEmpty()
Same as with Sys_FPU_GetState().
2018-08-20 01:46:35 +02:00
dhewg
16871256f8 Get rid of Sys_FPU_GetState()
This was only implemented with MSVC style asm.
Comments suggest that it was used to help catch invalid FOV calculations,
which were probably only happening with ancient compiler bugs.
2018-08-20 01:46:35 +02:00
dhewg
763791ab24 Get rid of Sys_FPU_EnableExceptions()
No exceptions were ever enabled.
2018-08-20 01:46:35 +02:00
dhewg
4dc111e63f Use a more modern way to set the fpu precision 2018-08-20 01:46:35 +02:00
dhewg
8e323cb4ff Get rid of Sys_FPU_SetRounding()
Unused.
2018-08-20 01:46:35 +02:00
Andre d
a6834f2f39 Remove (faulty/outdated) video ram detection 2018-08-20 01:46:35 +02:00
dhewg
e85823f8ce Remove all OS specific gamepak code
Useless since there are no gamepaks.
2018-08-20 01:46:34 +02:00
dhewg
0025ad6cf7 Introduce fs_configpath
Split fs_savepath for config files. This is in preparation for
moving the writable paths on *nix to $XDG_DATA_HOME and
$XDG_CONFIG_HOME.
Affected files: config.spec, *.cfg, doomkey, xpkey.
2018-08-20 01:46:34 +02:00
dhewg
1f17040f0c Unify Sys_*Path() into Sys_GetPath() 2018-08-20 01:46:34 +02:00
dhewg
6b30d96d44 Get rid of CPU_EASYARGS
Never use the event callbacks with mismatching prototypes.
2018-08-20 01:46:32 +02:00
dhewg
151288e170 CMake: Use config.h for BUILD_OS and BUILD_CPU
This fixes, among others, FreeBSD 64bit builds where the build
system used a "amd64" suffix and runtime "x86_64".
2018-08-20 01:46:32 +02:00
dhewg
6dfe95e732 CMake: Create config.h
Use config.h for configure time settings.
2018-08-20 01:46:32 +02:00
dhewg
b87bd8040f Get rid of memory status functions
Unused.
2018-08-20 01:46:32 +02:00
dhewg
cdefb2ba7a Always allow multiple instances 2018-08-20 01:46:32 +02:00
dhewg
a1fe69f429 Get rid of Sys_DefaultCDPath()
Stub on all platforms.
2018-08-20 01:46:32 +02:00
dhewg
d0846bdae8 Include malloc.h for alloca for MinGW
Newer versions of MinGW do not seem to require this, but older
ones do.
2018-08-20 01:46:31 +02:00
dhewg
11eb754b41 Get rid of Sys_DoPreferences()
The OSX backend was the only one utilizing this to set CVars
for the video mode.
Not required anymore since its now based on SDL.
2018-08-20 01:46:31 +02:00
dhewg
7dd30d9db6 Make Sys_GetScanTable() only available on Windows
Sys_GetScanTable() and MapKey() are only used by the Windows backend
or the Windows-only tools.
Rename to Win_GetScanTable() and move MapKey() as Win_MapKey() to
win_input.cpp.
2018-08-20 01:46:30 +02:00
dhewg
4dbf6d2329 Rename Posix_ConsoleInput() to Sys_ConsoleInput()
Sync with Windows implementation and add it to sys_public.h in
preparation to move the event queue to SDL.
2018-08-20 01:46:30 +02:00
spiral
85a3a7089a Add ID_GAME_API for dllexport/attribute(visibility)
Delete obsolete Game.def exports files
2018-08-20 01:46:30 +02:00
spiral
3dc6127529 Remove MWERKS stuff 2018-08-20 01:46:29 +02:00
spiral
139726bc37 Add missing includes for MSVC
- MSVC doesn't provide C99 headers
- Default to min. req. 64Mb video mem if no COM present
- Move misplaced __attribute__((packed)) from MSVC to MinGW
2018-08-20 01:46:29 +02:00
dhewg
092059bd95 Get rid of the unused Sys_FPU_ClearStack 2018-08-20 01:46:29 +02:00
dhewg
cdeb7e7ff2 Get rid of Sys_GetProcessorString()
This was only used for a printf() and not implemented for all
the platforms we can now run on.
We also don't want to force a CPU type on Windows.
2018-08-20 01:46:29 +02:00
dhewg
975cda1637 Unify CPUID_FTZ and CPUID_DAZ
Get rid of the 2 CPUID flags and combine them with SSE in one
implementation.
SSE flags can now be set on all x86 and x86_64 platforms -
independent of -ffast-math.
Helper defines borrowed from STREFLOP.
2018-08-20 01:46:29 +02:00
dhewg
57b8d55db0 Get rid of unused CPUID flags 2018-08-20 01:46:29 +02:00
dhewg
a9e31c4225 Get rid of Sys_GetClockticks() and Sys_ClockTicksPerSecond()
Now unused.
2018-08-20 01:46:29 +02:00
dhewg
d26cf44a29 Add GetMilliseconds to idSys
To be used for the overhauled idTimer in idlib/.
2018-08-20 01:46:29 +02:00
dhewg
ae551ee106 Port Sys_Milliseconds() to SDL
Sync with SDL and use unsigned int as return type.
Code outside of sys/ still uses signed ints to store the result.
2018-08-20 01:46:29 +02:00
dhewg
9101f2e5a0 Port Sys_Sleep() to SDL 2018-08-20 01:46:29 +02:00
dhewg
f1a7b426fe Port all thread related functions to SDL
Setting thread priorities has been dropped (it is not portable).
The background download thread now exits gracefully.
g_threads is not public anymore.
2018-08-20 01:46:29 +02:00
dhewg
3c2c603cf4 Move MAX_THREADS as define to BuildDefines.h 2018-08-20 01:46:29 +02:00
dhewg
efbd47f4bc Port critical sections and events to SDL
Use SDL mutexes and conditions.
One new critical section CRITICAL_SECTION_SYS for events.
2018-08-20 01:46:29 +02:00
dhewg
f41d2347b1 Use SDL for everything endian 2018-08-20 01:46:29 +02:00
dhewg
4df3236c3e Adapt structs for easy forward declarations
Get rid of the tag namespace.
2018-08-20 01:46:27 +02:00
dhewg
8f4d16fd1b Move BuildDefines.h include to platform.h 2018-08-20 01:46:27 +02:00
dhewg
7a40472c5b Include cstddef for ptrdiff_t in platform.h 2018-08-20 01:46:27 +02:00
dhewg
487406d861 Move idlib typedefs to platform.h 2018-08-20 01:46:27 +02:00
dhewg
e522e719dd Move common includes from precompiled.h to platform.h 2018-08-20 01:46:27 +02:00