From dc00968bc183236109f923370f481021e7aafa57 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 23 Aug 2025 10:54:32 +0100 Subject: [PATCH] client: Remove i386 GNU assembler version of S_WriteLinearBlastStereo16() This was the last remaining GNU assembler code that was in its own independent source file, as opposed to being embedded in C code with GNU `__asm__ volatile` or MSVC `__asm` (which tends to be much easier to deal with in a modern build system). When the Quake 3 engine was originally written, this might have been an "expensive" function when written in portable C, but after 25 years of CPU development it's less likely to matter (and modern compilers might produce faster results from the C code anyway). Resolves: https://github.com/ioquake/ioq3/issues/778 Signed-off-by: Simon McVittie --- Makefile | 1 - cmake/compilers/gnu.cmake | 4 - code/asm/qasm.h | 37 ------ code/asm/snd_mixa.S | 106 ------------------ code/client/snd_mix.c | 8 +- code/qcommon/q_platform.h | 4 - misc/xcode/ioquake3.xcodeproj/project.pbxproj | 6 - 7 files changed, 3 insertions(+), 163 deletions(-) delete mode 100644 code/asm/qasm.h delete mode 100644 code/asm/snd_mixa.S diff --git a/Makefile b/Makefile index 98c1c7ba..5830fa6e 100644 --- a/Makefile +++ b/Makefile @@ -2172,7 +2172,6 @@ endif ifeq ($(ARCH),x86) Q3OBJ += \ - $(B)/client/snd_mixa.o \ $(B)/client/snapvector.o \ $(B)/client/ftola.o endif diff --git a/cmake/compilers/gnu.cmake b/cmake/compilers/gnu.cmake index 5a7ed5dc..298712b0 100644 --- a/cmake/compilers/gnu.cmake +++ b/cmake/compilers/gnu.cmake @@ -11,10 +11,6 @@ set(ASM_SOURCES ${SOURCE_DIR}/asm/snapvector.c ) -set(CLIENT_ASM_SOURCES - ${SOURCE_DIR}/asm/snd_mixa.S -) - add_compile_options(-Wall -Wimplicit -Wstrict-prototypes -Wformat=2 -Wformat-security -Wstrict-aliasing=2 -Wmissing-format-attribute diff --git a/code/asm/qasm.h b/code/asm/qasm.h deleted file mode 100644 index 777a3230..00000000 --- a/code/asm/qasm.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -#ifndef __ASM_I386__ -#define __ASM_I386__ - -#include "../qcommon/q_platform.h" - -#ifdef __ELF__ -.section .note.GNU-stack,"",@progbits -#endif - -#if defined(__ELF__) || defined(__WIN64__) -#define C(label) label -#else -#define C(label) _##label -#endif - -#endif diff --git a/code/asm/snd_mixa.S b/code/asm/snd_mixa.S deleted file mode 100644 index 0fe3a7a8..00000000 --- a/code/asm/snd_mixa.S +++ /dev/null @@ -1,106 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -// snd_mixa.s -// x86 assembly-language sound code -// - -#include "qasm.h" - -#if id386 - - .text - -//---------------------------------------------------------------------- -// Transfer of stereo buffer to 16-bit DMA buffer code -//---------------------------------------------------------------------- - -.globl C(S_WriteLinearBlastStereo16) -C(S_WriteLinearBlastStereo16): - pushl %edi - pushl %ebx - -// int i; -// int val; - movl C(snd_linear_count),%ecx - movl C(snd_p),%ebx - movl C(snd_out),%edi - -// for (i=0 ; i>8; -// if (val > 0x7fff) -// snd_out[i] = 0x7fff; -// else if (val < (short)0x8000) -// snd_out[i] = (short)0x8000; -// else -// snd_out[i] = val; - movl -8(%ebx,%ecx,4),%eax - sarl $8,%eax - cmpl $0x7FFF,%eax - jg LClampHigh - cmpl $0xFFFF8000,%eax - jnl LClampDone - movl $0xFFFF8000,%eax - jmp LClampDone -LClampHigh: - movl $0x7FFF,%eax -LClampDone: - -// val = (snd_p[i+1]*snd_vol)>>8; -// if (val > 0x7fff) -// snd_out[i+1] = 0x7fff; -// else if (val < (short)0x8000) -// snd_out[i+1] = (short)0x8000; -// else -// snd_out[i+1] = val; - movl -4(%ebx,%ecx,4),%edx - sarl $8,%edx - cmpl $0x7FFF,%edx - jg LClampHigh2 - cmpl $0xFFFF8000,%edx - jnl LClampDone2 - movl $0xFFFF8000,%edx - jmp LClampDone2 -LClampHigh2: - movl $0x7FFF,%edx -LClampDone2: - shll $16,%edx - andl $0xFFFF,%eax - orl %eax,%edx - movl %edx,-4(%edi,%ecx,2) - -// } - subl $2,%ecx - jnz LWLBLoopTop - -// snd_p += snd_linear_count; - - popl %ebx - popl %edi - - ret - -#endif // id386 - diff --git a/code/client/snd_mix.c b/code/client/snd_mix.c index b381861a..dce5ef90 100644 --- a/code/client/snd_mix.c +++ b/code/client/snd_mix.c @@ -31,7 +31,7 @@ int* snd_p; int snd_linear_count; short* snd_out; -#if !id386 // if configured not to use asm +#if defined(__GNUC__) || !id386 void S_WriteLinearBlastStereo16 (void) { @@ -57,10 +57,8 @@ void S_WriteLinearBlastStereo16 (void) snd_out[i+1] = val; } } -#elif defined(__GNUC__) -// uses snd_mixa.s -void S_WriteLinearBlastStereo16 (void); -#else + +#else // MSVC on i386 __declspec( naked ) void S_WriteLinearBlastStereo16 (void) { diff --git a/code/qcommon/q_platform.h b/code/qcommon/q_platform.h index 1af21825..6d3e0910 100644 --- a/code/qcommon/q_platform.h +++ b/code/qcommon/q_platform.h @@ -69,8 +69,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif -#ifndef __ASM_I386__ // don't include the C bits if included from qasm.h - // for windows fastcall option #define QDECL #define QCALL @@ -419,5 +417,3 @@ float FloatSwap (const float *f); #endif #endif - -#endif diff --git a/misc/xcode/ioquake3.xcodeproj/project.pbxproj b/misc/xcode/ioquake3.xcodeproj/project.pbxproj index 8e9f4c0a..858ac1ba 100644 --- a/misc/xcode/ioquake3.xcodeproj/project.pbxproj +++ b/misc/xcode/ioquake3.xcodeproj/project.pbxproj @@ -51,7 +51,6 @@ 2735379E14D8F13E000D6E73 /* botlib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2735379B14D8F13E000D6E73 /* botlib.a */; }; 274FAB79178FA81800B17C7A /* snd_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 274FAB78178FA81700B17C7A /* snd_main.c */; }; 274FAB7B178FA86E00B17C7A /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 274FAB7A178FA86E00B17C7A /* md5.c */; }; - 274FAB88178FA98E00B17C7A /* snd_mixa.s in Sources */ = {isa = PBXBuildFile; fileRef = 274FAB82178FA97100B17C7A /* snd_mixa.s */; }; 274FABFD178FAC4900B17C7A /* vm_x86.c in Sources */ = {isa = PBXBuildFile; fileRef = 2711BE9E14D136DF005EB142 /* vm_x86.c */; }; 274FABFE178FAC6E00B17C7A /* tr_noise.c in Sources */ = {isa = PBXBuildFile; fileRef = 27AAD064178E03620093DFC0 /* tr_noise.c */; }; 2758BB3317905B8F007F6582 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2758BB3217905B8F007F6582 /* IOKit.framework */; }; @@ -173,9 +172,7 @@ 274FAB7A178FA86E00B17C7A /* md5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = md5.c; sourceTree = ""; }; 274FAB7D178FA97100B17C7A /* ftola.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ftola.c; sourceTree = ""; }; 274FAB7F178FA97100B17C7A /* qasm-inline.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "qasm-inline.h"; sourceTree = ""; }; - 274FAB80178FA97100B17C7A /* qasm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = qasm.h; sourceTree = ""; }; 274FAB81178FA97100B17C7A /* snapvector.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = snapvector.c; sourceTree = ""; }; - 274FAB82178FA97100B17C7A /* snd_mixa.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = snd_mixa.s; sourceTree = ""; }; 274FAB83178FA97100B17C7A /* ftola.asm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm.asm; path = ftola.asm; sourceTree = ""; }; 274FAB84178FA97100B17C7A /* snapvector.asm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm.asm; path = snapvector.asm; sourceTree = ""; }; 274FAB85178FA97100B17C7A /* vm_x86_64.asm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm.asm; path = vm_x86_64.asm; sourceTree = ""; }; @@ -596,9 +593,7 @@ children = ( 274FAB7D178FA97100B17C7A /* ftola.c */, 274FAB7F178FA97100B17C7A /* qasm-inline.h */, - 274FAB80178FA97100B17C7A /* qasm.h */, 274FAB81178FA97100B17C7A /* snapvector.c */, - 274FAB82178FA97100B17C7A /* snd_mixa.s */, 274FAB83178FA97100B17C7A /* ftola.asm */, 274FAB84178FA97100B17C7A /* snapvector.asm */, 274FAB85178FA97100B17C7A /* vm_x86_64.asm */, @@ -921,7 +916,6 @@ 27AAD02D178E013E0093DFC0 /* sdl_snd.c in Sources */, 274FAB79178FA81800B17C7A /* snd_main.c in Sources */, 274FAB7B178FA86E00B17C7A /* md5.c in Sources */, - 274FAB88178FA98E00B17C7A /* snd_mixa.s in Sources */, 274FABFD178FAC4900B17C7A /* vm_x86.c in Sources */, 274FABFE178FAC6E00B17C7A /* tr_noise.c in Sources */, A1F318612603128500A11B0E /* snapvector.c in Sources */,