From 9630a2339137d132269ce94da9aaae8257fc7b53 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 1 Jun 2002 03:00:13 +0000 Subject: [PATCH] more Sys_* cleanup --- libs/util/Makefile.am | 2 +- libs/util/sys.c | 27 +++++++ {nq/source => libs/util}/sys_ia32.S | 46 ++++++++--- nq/source/Makefile.am | 2 +- nq/source/sys_sdl.c | 12 --- nq/source/sys_unix.c | 12 --- nq/source/sys_unixd.c | 13 ---- nq/source/sys_win.c | 18 +---- nq/source/sys_wind.c | 25 ------ qw/source/Makefile.am | 2 +- qw/source/cl_sys_sdl.c | 12 --- qw/source/cl_sys_unix.c | 25 ------ qw/source/sys_x86.S | 116 ---------------------------- 13 files changed, 65 insertions(+), 247 deletions(-) rename {nq/source => libs/util}/sys_ia32.S (72%) delete mode 100644 qw/source/sys_x86.S diff --git a/libs/util/Makefile.am b/libs/util/Makefile.am index 7a89425b6..51896d4e8 100644 --- a/libs/util/Makefile.am +++ b/libs/util/Makefile.am @@ -10,7 +10,7 @@ else noinst_LTLIBRARIES= endif -asm_src= math.S +asm_src= math.S sys_ia32.S libasm_la_SOURCES= $(asm_src) diff --git a/libs/util/sys.c b/libs/util/sys.c index fbbaaeca5..f9bd89e4e 100644 --- a/libs/util/sys.c +++ b/libs/util/sys.c @@ -429,3 +429,30 @@ Sys_DebugLog (const char *file, const char *fmt, ...) write (fd, data, strlen (data)); close (fd); } + +#ifndef USE_INTEL_ASM +void +Sys_HighFPPrecision (void) +{ +} + +void +Sys_LowFPPrecision (void) +{ +} + +void +Sys_SetFPCW (void) +{ +} + +void +Sys_PushFPCW_SetHigh (void) +{ +} + +void +Sys_PopFPCW (void) +{ +} +#endif diff --git a/nq/source/sys_ia32.S b/libs/util/sys_ia32.S similarity index 72% rename from nq/source/sys_ia32.S rename to libs/util/sys_ia32.S index c28291f1a..fbea41bf5 100644 --- a/nq/source/sys_ia32.S +++ b/libs/util/sys_ia32.S @@ -33,19 +33,41 @@ #ifdef USE_INTEL_ASM + +#ifdef WIN32 +# undef PIC //no such thing in win32 +#endif + .data .align 4 fpenv: .long 0, 0, 0, 0, 0, 0, 0, 0 +#ifdef PIC +#define got_base(n) \ + call .Lpic##n ;\ +.Lpic##n: ;\ + popl %edx ;\ + addl $C(_GLOBAL_OFFSET_TABLE_)+[.-.Lpic##n],%edx + +#define got_var(v) v@GOT(%edx) +#else +#define got_base(n) +#define got_var(v) v +#endif + .text .globl C(MaskExceptions) +#ifdef PIC + .type C(MaskExceptions),@function +#endif C(MaskExceptions): - fnstenv fpenv + got_base(1) + fnstenv got_var(fpenv) orl $0x3F,fpenv - fldenv fpenv + fldenv got_var(fpenv) ret @@ -73,44 +95,44 @@ pushed_cw: .long 0 .globl C(Sys_LowFPPrecision) C(Sys_LowFPPrecision): - fldcw single_cw + fldcw got_var(single_cw) ret .globl C(Sys_HighFPPrecision) C(Sys_HighFPPrecision): - fldcw full_cw + fldcw got_var(full_cw) ret .globl C(Sys_PushFPCW_SetHigh) C(Sys_PushFPCW_SetHigh): - fnstcw pushed_cw - fldcw full_cw + fnstcw got_var(pushed_cw) + fldcw got_var(full_cw) ret .globl C(Sys_PopFPCW) C(Sys_PopFPCW): - fldcw pushed_cw + fldcw got_var(pushed_cw) ret .globl C(Sys_SetFPCW) C(Sys_SetFPCW): - fnstcw cw - movl cw,%eax + fnstcw got_var(cw) + movl got_var(cw),%eax andb $0xF0,%ah orb $0x03,%ah // round mode, 64-bit precision - movl %eax,full_cw + movl %eax,got_var(full_cw) andb $0xF0,%ah orb $0x0C,%ah // chop mode, single precision - movl %eax,single_cw + movl %eax,got_var(single_cw) andb $0xF0,%ah orb $0x08,%ah // ceil mode, single precision - movl %eax,ceil_cw + movl %eax,got_var(ceil_cw) ret #endif /* USE_INTEL_ASM */ diff --git a/nq/source/Makefile.am b/nq/source/Makefile.am index a844595b2..5f1b8120b 100644 --- a/nq/source/Makefile.am +++ b/nq/source/Makefile.am @@ -44,7 +44,7 @@ else asm= endif -asm_src= sys_ia32.S worlda.S +asm_src= worlda.S libasm_la_SOURCES= $(asm_src) diff --git a/nq/source/sys_sdl.c b/nq/source/sys_sdl.c index 6b1549793..100a6434a 100644 --- a/nq/source/sys_sdl.c +++ b/nq/source/sys_sdl.c @@ -130,18 +130,6 @@ Sys_ConsoleInput (void) return NULL; } -#ifndef USE_INTEL_ASM -void -Sys_HighFPPrecision (void) -{ -} - -void -Sys_LowFPPrecision (void) -{ -} -#endif - #ifndef SDL_main # define SDL_main main #endif diff --git a/nq/source/sys_unix.c b/nq/source/sys_unix.c index ce6de0301..e455c8e74 100644 --- a/nq/source/sys_unix.c +++ b/nq/source/sys_unix.c @@ -117,18 +117,6 @@ Sys_ConsoleInput (void) return NULL; } -#ifndef USE_INTEL_ASM -void -Sys_HighFPPrecision (void) -{ -} - -void -Sys_LowFPPrecision (void) -{ -} -#endif - int main (int c, const char *v[]) { diff --git a/nq/source/sys_unixd.c b/nq/source/sys_unixd.c index 936b6414f..b0ee0193b 100644 --- a/nq/source/sys_unixd.c +++ b/nq/source/sys_unixd.c @@ -110,19 +110,6 @@ Sys_ConsoleInput (void) return NULL; } -#ifndef USE_INTEL_ASM -void -Sys_HighFPPrecision (void) -{ -} - -void -Sys_LowFPPrecision (void) -{ -} - -#endif - int main (int argc, const char **argv) { diff --git a/nq/source/sys_win.c b/nq/source/sys_win.c index 7ba538db6..be5b122e5 100644 --- a/nq/source/sys_win.c +++ b/nq/source/sys_win.c @@ -97,28 +97,12 @@ findhandle (void) // SYSTEM IO ================================================================== + #ifndef USE_INTEL_ASM - -void -Sys_SetFPCW (void) -{ -} - -void -Sys_PushFPCW_SetHigh (void) -{ -} - -void -Sys_PopFPCW (void) -{ -} - void MaskExceptions (void) { } - #endif void diff --git a/nq/source/sys_wind.c b/nq/source/sys_wind.c index 75e1b3eaf..352d854db 100644 --- a/nq/source/sys_wind.c +++ b/nq/source/sys_wind.c @@ -47,31 +47,6 @@ static const char rcsid[] = qboolean isDedicated = true; -#if 0 -// FILE IO ==================================================================== - -#define MAX_HANDLES 10 -VFile *sys_handles[MAX_HANDLES]; - - -// SYSTEM IO ================================================================== - -void -IN_SendKeyEvents (void) -{ -} - -void -Sys_HighFPPrecision (void) -{ -} - -void -Sys_LowFPPrecision (void) -{ -} -#endif - const char * Sys_ConsoleInput (void) { diff --git a/qw/source/Makefile.am b/qw/source/Makefile.am index 5c8a3e5ff..810f7e1c8 100644 --- a/qw/source/Makefile.am +++ b/qw/source/Makefile.am @@ -45,7 +45,7 @@ else asm= endif -asm_src= sys_x86.S worlda.S +asm_src= worlda.S libasm_la_SOURCES= $(asm_src) diff --git a/qw/source/cl_sys_sdl.c b/qw/source/cl_sys_sdl.c index d01c6fb94..8c7dbcc85 100644 --- a/qw/source/cl_sys_sdl.c +++ b/qw/source/cl_sys_sdl.c @@ -115,18 +115,6 @@ shutdown (void) #endif } -#ifndef USE_INTEL_ASM -void -Sys_HighFPPrecision (void) -{ -} - -void -Sys_LowFPPrecision (void) -{ -} -#endif - #ifndef SDL_main # define SDL_main main #endif diff --git a/qw/source/cl_sys_unix.c b/qw/source/cl_sys_unix.c index e7a6aa8c6..76e9d4a8d 100644 --- a/qw/source/cl_sys_unix.c +++ b/qw/source/cl_sys_unix.c @@ -78,37 +78,12 @@ shutdown (void) fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK); } -void -Sys_Warn (char *warning, ...) -{ - va_list argptr; - char string[1024]; - - va_start (argptr, warning); - vsnprintf (string, sizeof (string), warning, argptr); - va_end (argptr); - fprintf (stderr, "Warning: %s", string); -} - void floating_point_exception_handler (int whatever) { -// Sys_Warn("floating point exception\n"); signal (SIGFPE, floating_point_exception_handler); } -#ifndef USE_INTEL_ASM -void -Sys_HighFPPrecision (void) -{ -} - -void -Sys_LowFPPrecision (void) -{ -} -#endif - int skipframes; int diff --git a/qw/source/sys_x86.S b/qw/source/sys_x86.S deleted file mode 100644 index b34494a1c..000000000 --- a/qw/source/sys_x86.S +++ /dev/null @@ -1,116 +0,0 @@ -/* - sys_x86.S - - x86 assembly-language dependent routines. - - Copyright (C) 1996-1997 Id Software, Inc. - - This program 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. - - This program 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 this program; if not, write to: - - Free Software Foundation, Inc. - 59 Temple Place - Suite 330 - Boston, MA 02111-1307, USA - - $Id$ -*/ - -#ifdef HAVE_CONFIG_H -# include -#endif -#include "asm_i386.h" - - -#ifdef USE_INTEL_ASM - .data - - .align 4 -fpenv: - .long 0, 0, 0, 0, 0, 0, 0, 0 - - .text - -.globl C(MaskExceptions) -C(MaskExceptions): - fnstenv fpenv - orl $0x3F,fpenv - fldenv fpenv - - ret - -#if 0 -.globl C(unmaskexceptions) -C(unmaskexceptions): - fnstenv fpenv - andl $0xFFFFFFE0,fpenv - fldenv fpenv - - ret -#endif - - .data - - .align 4 -.globl ceil_cw, single_cw, full_cw, cw, pushed_cw -ceil_cw: .long 0 -single_cw: .long 0 -full_cw: .long 0 -cw: .long 0 -pushed_cw: .long 0 - - .text - -.globl C(Sys_LowFPPrecision) -C(Sys_LowFPPrecision): - fldcw single_cw - - ret - -.globl C(Sys_HighFPPrecision) -C(Sys_HighFPPrecision): - fldcw full_cw - - ret - -.globl C(Sys_PushFPCW_SetHigh) -C(Sys_PushFPCW_SetHigh): - fnstcw pushed_cw - fldcw full_cw - - ret - -.globl C(Sys_PopFPCW) -C(Sys_PopFPCW): - fldcw pushed_cw - - ret - -.globl C(Sys_SetFPCW) -C(Sys_SetFPCW): - fnstcw cw - movl cw,%eax - andb $0xF0,%ah - orb $0x03,%ah // round mode, 64-bit precision - movl %eax,full_cw - - andb $0xF0,%ah - orb $0x0C,%ah // chop mode, single precision - movl %eax,single_cw - - andb $0xF0,%ah - orb $0x08,%ah // ceil mode, single precision - movl %eax,ceil_cw - - ret -#endif /* USE_INTEL_ASM */