From 9082d9807fbdfc5d35e82df0f8b79119f8590bba Mon Sep 17 00:00:00 2001 From: Thomas Otto Date: Tue, 16 Apr 2024 22:29:53 +0200 Subject: [PATCH 1/4] Remove superfluous typedefs --- Descent3/newui_core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Descent3/newui_core.h b/Descent3/newui_core.h index bf31cfbdf..e17a9d15b 100644 --- a/Descent3/newui_core.h +++ b/Descent3/newui_core.h @@ -140,14 +140,14 @@ class newuiHotspot; #define DEFAULT_NEWUID -5 -typedef enum tAlignment { NEWUI_ALIGN_VERT, NEWUI_ALIGN_HORIZ }; +enum tAlignment { NEWUI_ALIGN_VERT, NEWUI_ALIGN_HORIZ }; #define SLIDER_UNITS_INT 0 #define SLIDER_UNITS_PERCENT 1 #define SLIDER_UNITS_FLOAT 2 // used optionally for sliders. -typedef struct tSliderSettings { +struct tSliderSettings { union { int i; float f; @@ -157,7 +157,7 @@ typedef struct tSliderSettings { float f; } max_val; int type; // enumerated above in SLIDER_UNITS -} tSliderStruct; +}; #define NEWUI_EDIT_CANCELED_STR "\1" // if a newuiEditbox returns this, then we cancelled. invalid string From 7d2e1b5cba2f0bb400174dce42d24d34f644de99 Mon Sep 17 00:00:00 2001 From: Thomas Otto Date: Tue, 16 Apr 2024 22:31:48 +0200 Subject: [PATCH 2/4] gcc: disable `-Wnarrowing` via pragma in snd8to16.h --- libmve/snd8to16.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmve/snd8to16.h b/libmve/snd8to16.h index 932c8485f..a440d11f1 100644 --- a/libmve/snd8to16.h +++ b/libmve/snd8to16.h @@ -14,6 +14,7 @@ */ #pragma warning(disable : 4245) #pragma warning(disable : 4309) +#pragma GCC diagnostic ignored "-Wnarrowing" signed short snd_8to16[256] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, @@ -35,5 +36,7 @@ signed short snd_8to16[256] = { -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1}; + +#pragma GCC diagnostic pop #pragma warning(default : 4245) #pragma warning(default : 4309) From 6a9b345acc650e5dbf169f488a573a3871663169 Mon Sep 17 00:00:00 2001 From: Thomas Otto Date: Tue, 16 Apr 2024 22:32:10 +0200 Subject: [PATCH 3/4] Remove linux/ipx.h include This header was removed with linux 5.15 --- netcon/includes/inetgetfile.h | 1 - 1 file changed, 1 deletion(-) diff --git a/netcon/includes/inetgetfile.h b/netcon/includes/inetgetfile.h index 439260cae..7de0e97c4 100644 --- a/netcon/includes/inetgetfile.h +++ b/netcon/includes/inetgetfile.h @@ -85,7 +85,6 @@ // Linux includes/defines #if !MACOSX #include -#include // #include #endif From b58d3585bd3f3052d63380cc679fd740c9405b4c Mon Sep 17 00:00:00 2001 From: Thomas Otto Date: Tue, 16 Apr 2024 23:02:26 +0200 Subject: [PATCH 4/4] Remove unused osMutex code It was never Acquire'd, only Created and Destroyed; and it was a stub on Linux and macOS. --- lib/TaskSystem.h | 28 --------------------- lib/streamaudio.h | 1 - linux/CMakeLists.txt | 1 - linux/lnxtask.cpp | 34 ------------------------- mac/MACSTREAMAUDIO.CPP | 2 -- mac/MACTASK.CPP | 9 ------- stream_audio/streamaudio.cpp | 2 -- win32/wintask.cpp | 49 ------------------------------------ 8 files changed, 126 deletions(-) delete mode 100644 linux/lnxtask.cpp delete mode 100644 mac/MACTASK.CPP diff --git a/lib/TaskSystem.h b/lib/TaskSystem.h index d6a92a2ab..d2d11b9fe 100644 --- a/lib/TaskSystem.h +++ b/lib/TaskSystem.h @@ -73,32 +73,4 @@ class osTask { void resume(); // resumes task }; -// This establishes a mutual exclusion object. once one thread locks the object, -// any code in another thread that contains a mutex check will block or skip that code until -// the locking thread unlocks it. -class osMutex { -#if defined(DD_ACCESS_RING) -public: -#else -private: -#endif - -#if defined(WIN32) - unsigned mutex_os_handle; -#endif - -public: - osMutex(); - ~osMutex(); - - bool Create(); // creates a mutex object. - void Destroy(); // destroys a mutex object - - // calling thread will attempt to acquire mutex (wait until timeout in ms.) if timeout == -1, wait forever... - bool Acquire(int timeout = -1); - - // calling thread releases control of mutex. - void Release(); -}; - #endif diff --git a/lib/streamaudio.h b/lib/streamaudio.h index 02d5d0c26..dd532c97c 100644 --- a/lib/streamaudio.h +++ b/lib/streamaudio.h @@ -254,7 +254,6 @@ class AudioStream { int m_playbytesleft, m_playbytestotal; int m_curid; // stream's id # int *m_stopflag; // location of stop flag used in stop function - osMutex m_loopmutex; // stop flag is manipulated by caller and stream thread. bool m_loop; // are we looping? bool m_stopnextmeasure; // stop on next measure. bool m_start_on_frame; // we will play this stream on the next ::Frame call. diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index ee7118b11..08b9ed1f8 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -3,7 +3,6 @@ SET (CPPS lnxcon.cpp lnxcon_raw.cpp lnxdebug.cpp - lnxtask.cpp lnxapp.cpp lnxcon_null.cpp lnxdata.cpp diff --git a/linux/lnxtask.cpp b/linux/lnxtask.cpp deleted file mode 100644 index 83e74f368..000000000 --- a/linux/lnxtask.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * $Logfile: /DescentIII/Main/linux/lnxtask.cpp $ - * $Revision: 1.1.1.1 $ - * $Date: 2000/04/18 00:00:39 $ - * $Author: icculus $ - * - * Linux multitasking routines - * - * $Log: lnxtask.cpp,v $ - * Revision 1.1.1.1 2000/04/18 00:00:39 icculus - * initial checkin - * - * - * 3 7/14/99 9:09p Jeff - * added comment header - * - * $NoKeywords: $ - */ - -#include "DDAccess.h" -#include "TaskSystem.h" -#include "pserror.h" - -osMutex::osMutex() {} - -osMutex::~osMutex() { Destroy(); } - -bool osMutex::Create() { return false; } - -void osMutex::Destroy() {} - -bool osMutex::Acquire(int timeout) {} - -void osMutex::Release() {} \ No newline at end of file diff --git a/mac/MACSTREAMAUDIO.CPP b/mac/MACSTREAMAUDIO.CPP index 0bcac85a1..b4759c172 100644 --- a/mac/MACSTREAMAUDIO.CPP +++ b/mac/MACSTREAMAUDIO.CPP @@ -475,7 +475,6 @@ bool AudioStream::Open(const char *filename, int open_flags) { return false; } - m_loopmutex.Create(); AudioStream::SetLoopCount(1); m_laststate = m_state; mprintf((1, "opening: STRM[%d]: STOPPED sof %d\n", this->m_curid, m_start_on_frame)); @@ -497,7 +496,6 @@ void AudioStream::Close() { // stop the stream, close the archive, close the decoder. AudioStream::Stop(); m_archive.Close(); - m_loopmutex.Destroy(); m_curid = -1; // free streaming buffers and decoder if we need to. diff --git a/mac/MACTASK.CPP b/mac/MACTASK.CPP deleted file mode 100644 index 8b47ad7b0..000000000 --- a/mac/MACTASK.CPP +++ /dev/null @@ -1,9 +0,0 @@ -#include "DDAccess.h" -#include "TaskSystem.h" -#include "pserror.h" -osMutex::osMutex() {} -osMutex::~osMutex() { Destroy(); } -bool osMutex::Create() { return false; } -void osMutex::Destroy() {} -bool osMutex::Acquire(int timeout) {} -void osMutex::Release() {} \ No newline at end of file diff --git a/stream_audio/streamaudio.cpp b/stream_audio/streamaudio.cpp index b5895f450..ac9759953 100644 --- a/stream_audio/streamaudio.cpp +++ b/stream_audio/streamaudio.cpp @@ -368,7 +368,6 @@ bool AudioStream::Open(const char *filename, int open_flags) { if (!AudioStream::ReopenDigitalStream(0, nbufs)) { return false; } - m_loopmutex.Create(); AudioStream::SetLoopCount(1); m_laststate = m_state; m_state = STRM_STOPPED; @@ -383,7 +382,6 @@ void AudioStream::Close() { // stop the stream, close the archive, close the decoder. AudioStream::Stop(); m_archive.Close(); - m_loopmutex.Destroy(); m_curid = -1; // free streaming buffers and decoder if we need to. for (i = 0; i < STRM_BUFCOUNT; i++) { diff --git a/win32/wintask.cpp b/win32/wintask.cpp index 82f20d04d..64f5f6ccd 100644 --- a/win32/wintask.cpp +++ b/win32/wintask.cpp @@ -131,52 +131,3 @@ bool osEvent::error() const { else return 0; } - -// This establishes a mutual exclusion object. once one thread locks the object, -// any code in another thread that contains a mutex check will block or skip that code until -// the locking thread unlocks it. -osMutex::osMutex() { mutex_os_handle = 0; } - -osMutex::~osMutex() { Destroy(); } - -bool osMutex::Create() // creates a mutex object. -{ - if (!mutex_os_handle) { - mutex_os_handle = (unsigned)CreateMutex(NULL, FALSE, NULL); - return mutex_os_handle ? true : false; - } - - return false; -} - -void osMutex::Destroy() // destroys a mutex object -{ - if (mutex_os_handle) { - CloseHandle((HANDLE)mutex_os_handle); - mutex_os_handle = 0; - } -} - -// calling thread will attempt to acquire mutex (wait until timeout) if timeout == -1, wait forever... -bool osMutex::Acquire(int timeout) { - DWORD res; - - if (!mutex_os_handle) - return true; // we should return true because the caller will skip code if false is returned. - - if (timeout == -1) - timeout = INFINITE; - - res = WaitForSingleObject((HANDLE)mutex_os_handle, timeout); - if (res == WAIT_OBJECT_0 || res == WAIT_ABANDONED) - return true; - else - return false; -} - -// calling thread releases control of mutex. -void osMutex::Release() { - if (mutex_os_handle) { - ReleaseMutex((HANDLE)mutex_os_handle); - } -}