From d4f576dff4122084599ac405ef9d62513e3a2185 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 6 Aug 2022 11:48:25 +0100 Subject: [PATCH 1/2] Couple of little updates. `register` keyword was necessary in the past, now they are obsolete even more so in C++. Using LLVM '__builtin_debugtrap`, a better fit than `__builtin_trap` as the comment explained, it does not play so nice with debuggers. --- neo/idlib/Lib.cpp | 6 +++++- neo/idlib/hashing/MD5.cpp | 2 +- neo/idlib/math/Simd_Generic.cpp | 4 ++-- neo/tools/compilers/roqvq/codec.cpp | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/neo/idlib/Lib.cpp b/neo/idlib/Lib.cpp index 0976c85e..11479d00 100644 --- a/neo/idlib/Lib.cpp +++ b/neo/idlib/Lib.cpp @@ -298,7 +298,7 @@ RESULTS Reverses the byte order in each of elcount elements. ===================================================================== */ ID_INLINE static void RevBytesSwap( void *bp, int elsize, int elcount ) { - register unsigned char *p, *q; + unsigned char *p, *q; p = ( unsigned char * ) bp; @@ -515,6 +515,10 @@ void AssertFailed( const char *file, int line, const char *expression ) { #ifdef _MSC_VER __debugbreak(); _exit(1); +#elif defined(__clang__) + // More appropriate than __builtin_trap, indeed it does trigger SIGILL + // but SIGTRAP instead. only clang supports for now (so far). + __builtin_debugtrap(); #elif defined(__unix__) // __builtin_trap() causes an illegal instruction which is kinda ugly. // especially if you'd like to be able to continue after the assertion during debugging diff --git a/neo/idlib/hashing/MD5.cpp b/neo/idlib/hashing/MD5.cpp index de9f855d..f4f98368 100644 --- a/neo/idlib/hashing/MD5.cpp +++ b/neo/idlib/hashing/MD5.cpp @@ -54,7 +54,7 @@ the data and converts bytes into longwords for this routine. ================= */ void MD5_Transform( unsigned int state[4], unsigned int in[16] ) { - register unsigned int a, b, c, d; + unsigned int a, b, c, d; a = state[0]; b = state[1]; diff --git a/neo/idlib/math/Simd_Generic.cpp b/neo/idlib/math/Simd_Generic.cpp index c20f6a4d..9ce25f6d 100644 --- a/neo/idlib/math/Simd_Generic.cpp +++ b/neo/idlib/math/Simd_Generic.cpp @@ -1802,7 +1802,7 @@ void VPCALL idSIMD_Generic::MatX_LowerTriangularSolve( const idMatX &L, float *x lptr = L[skip]; int i, j; - register double s0, s1, s2, s3; + double s0, s1, s2, s3; for ( i = skip; i < n; i++ ) { s0 = lptr[0] * x[0]; @@ -1928,7 +1928,7 @@ void VPCALL idSIMD_Generic::MatX_LowerTriangularSolveTranspose( const idMatX &L, } int i, j; - register double s0, s1, s2, s3; + double s0, s1, s2, s3; float *xptr; lptr = L.ToFloatPtr() + n * nc + n - 4; diff --git a/neo/tools/compilers/roqvq/codec.cpp b/neo/tools/compilers/roqvq/codec.cpp index a195ecce..5d7f920a 100644 --- a/neo/tools/compilers/roqvq/codec.cpp +++ b/neo/tools/compilers/roqvq/codec.cpp @@ -751,7 +751,7 @@ void codec::IRGBtab(void) float codec::Snr( byte *old, byte *bnew, int size ) { int i, j; float fsnr; -register int ind; +int ind; ind = 0; From ca68aabbccc9e5e10f61ce5a9ea80afc109abf5a Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 7 Aug 2022 09:57:53 +0100 Subject: [PATCH 2/2] idSlowChannel avoid messing with lowpass member which has virtual methods, so more `carefully` resetting. --- neo/sound/snd_emitter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/neo/sound/snd_emitter.cpp b/neo/sound/snd_emitter.cpp index e0230b35..e788515c 100644 --- a/neo/sound/snd_emitter.cpp +++ b/neo/sound/snd_emitter.cpp @@ -1147,9 +1147,8 @@ idSlowChannel::Reset =================== */ void idSlowChannel::Reset() { - memset( this, 0, sizeof( *this ) ); - - this->chan = chan; + active = false; + chan = nullptr; curPosition.Set( 0 ); newPosition.Set( 0 ); @@ -1157,6 +1156,7 @@ void idSlowChannel::Reset() { curSampleOffset = -10000; newSampleOffset = -10000; + playbackState = 0; triggerOffset = 0; }