From bc31dae19285abf1b301d4faaab8a0daad708d71 Mon Sep 17 00:00:00 2001 From: alanh <> Date: Wed, 30 Aug 2000 08:26:57 +0000 Subject: [PATCH] swlibs patches for 64bit issues. --- glide3x/configure.in | 9 ++++++ swlibs/fxmisc/3dfx.h | 6 ++++ swlibs/fxmisc/fximg.c | 8 ++--- swlibs/fxmisc/fxos.c | 4 +-- swlibs/fxmisc/linutil.c | 2 +- swlibs/include/make/makefile.autoconf.bottom | 13 +++++++- swlibs/newpci/pcilib/fxlinux.c | 14 ++++---- swlibs/newpci/pcilib/fxpci.c | 34 +++++++++++--------- swlibs/newpci/pcilib/fxpci.h | 8 ++--- swlibs/newpci/pcilib/pcilib.h | 6 ++-- swlibs/texus/lib/texus.h | 6 ++++ swlibs/texus2/cmd/makefile.autoconf.am | 2 +- swlibs/texus2/lib/codec.c | 14 ++++---- swlibs/texus2/lib/texus.h | 6 ++++ 14 files changed, 86 insertions(+), 46 deletions(-) diff --git a/glide3x/configure.in b/glide3x/configure.in index 9e89a5d..ac1e350 100644 --- a/glide3x/configure.in +++ b/glide3x/configure.in @@ -171,7 +171,14 @@ GLIDE_SANITY_ALL=false GLIDE_SANITY_SIZE=false FX_DLL_BUILD=false FX_GLIDE_HW_CULL=false +# Here we define whether we use C versions of cpu detection and triangle setup FX_GLIDE_CTRISETUP=false +FX_GLIDE_C_CPU_DETECT=false +# Override based on architecture +if test "$FX_GLIDE_BUILD_ARCHITECTURE" = "alpha"; then +FX_GLIDE_CTRISETUP=true +FX_GLIDE_C_CPU_DETECT=true +fi # Next, we read some configuration options # statically. This is to avoid creating a bunch of # not-terribly-useful --enable options. @@ -209,6 +216,8 @@ AM_CONDITIONAL(FX_GLIDE_HW_CULL,dnl test x$FX_GLIDE_HW_CULL = xtrue) AM_CONDITIONAL(FX_GLIDE_CTRISETUP,dnl test x$FX_GLIDE_CTRISETUP = xtrue) +AM_CONDITIONAL(FX_GLIDE_C_CPU_DETECT,dnl + test x$FX_GLIDE_C_CPU_DETECT = xtrue) AM_CONDITIONAL(FX_GLIDE_PACKET_FIFO,dnl test x$FX_GLIDE_PACKET_FIFO = xtrue) AM_CONDITIONAL(FX_GLIDE_VERTEX_TABLE,dnl diff --git a/swlibs/fxmisc/3dfx.h b/swlibs/fxmisc/3dfx.h index ae6848d..fd65fe3 100644 --- a/swlibs/fxmisc/3dfx.h +++ b/swlibs/fxmisc/3dfx.h @@ -30,8 +30,14 @@ typedef unsigned char FxU8; typedef signed char FxI8; typedef unsigned short FxU16; typedef signed short FxI16; +#if defined(__alpha__) || defined (__LP64__) +typedef signed int FxI32; +typedef unsigned int FxU32; +#else typedef signed long FxI32; typedef unsigned long FxU32; +#endif +typedef unsigned long AnyPtr; typedef int FxBool; typedef float FxFloat; typedef double FxDouble; diff --git a/swlibs/fxmisc/fximg.c b/swlibs/fxmisc/fximg.c index bb167af..61d7553 100644 --- a/swlibs/fxmisc/fximg.c +++ b/swlibs/fxmisc/fximg.c @@ -197,7 +197,7 @@ FxBool _imgGuessType( FILE *stream, ImgType *type ) case 0xDA01: *type = IMG_RGT; break; - case 'EL': + case (('E'<<8) | 'L'): cookie = 0; if ( ( c = fgetc( stream ) ) == EOF ) { @@ -211,7 +211,7 @@ FxBool _imgGuessType( FILE *stream, ImgType *type ) return FXFALSE; } cookie = (cookie << 8) | c; - if (cookie == 'RS') + if (cookie == (('R'<<8) | 'S')) *type = IMG_SRLE; break; default: // Might Be TGA @@ -1470,7 +1470,7 @@ FxBool _imgWriteP6Header( FILE *stream, const P6Info *info ) { imgErrorString = "Image write error."; if ( 0 > fprintf( stream, "P6\n" ) ) return FXFALSE; - if ( 0 > fprintf( stream, "# PPM Comment\n", info->width ) ) return FXFALSE; + if ( 0 > fprintf( stream, "# PPM Comment\n" ) ) return FXFALSE; if ( 0 > fprintf( stream, "%d ", info->width ) ) return FXFALSE; if ( 0 > fprintf( stream, "%d\n", info->height ) ) return FXFALSE; if ( 0 > fprintf( stream, "255\n" ) ) return FXFALSE; @@ -1948,7 +1948,7 @@ FxBool imgReadFile(const char *filename, ImgInfo *info) if (prefix) { // if there's a path prefix char buf[1024], *p; strcpy(buf,prefix); // copy and replace semicolon - if (p = strchr(buf,';')) *p = '\0'; + if ((p = strchr(buf,';')) != NULL) *p = '\0'; fprintf(stderr,buf); fprintf(stderr,"/"); } diff --git a/swlibs/fxmisc/fxos.c b/swlibs/fxmisc/fxos.c index ee00afa..6bf342f 100644 --- a/swlibs/fxmisc/fxos.c +++ b/swlibs/fxmisc/fxos.c @@ -98,7 +98,7 @@ FILE *fxFopenPath(const char *filename, const char *mode, const char *path, cons // first try and open up the file in the current directory if (pprefix) *pprefix = NULL; - if (file = fopen(filename,mode)) + if ((file = fopen(filename,mode)) != NULL) return file; if (path == NULL) return NULL; @@ -115,7 +115,7 @@ FILE *fxFopenPath(const char *filename, const char *mode, const char *path, cons strcat(nameWithPath,"/"); // add directory separator strcat(nameWithPath,filename); // add filename if (pprefix) *pprefix = path; // save the prefix - if (file = fopen(nameWithPath,mode)) + if ((file = fopen(nameWithPath,mode)) != NULL) return file; path = psemi; // advance to next path element if (path) diff --git a/swlibs/fxmisc/linutil.c b/swlibs/fxmisc/linutil.c index 2141261..edbde09 100644 --- a/swlibs/fxmisc/linutil.c +++ b/swlibs/fxmisc/linutil.c @@ -27,7 +27,7 @@ #include #include "linutil.h" -static init_done=0; +static int init_done=0; static struct termios save_termdata; static void reset_term() { diff --git a/swlibs/include/make/makefile.autoconf.bottom b/swlibs/include/make/makefile.autoconf.bottom index 25108ec..c7219fa 100644 --- a/swlibs/include/make/makefile.autoconf.bottom +++ b/swlibs/include/make/makefile.autoconf.bottom @@ -51,10 +51,21 @@ ifeq ("@GLIDE_DEBUG@","true") GLIDE_DEBUG_GCFLAGS = -g -O GLIDE_DEBUG_GDEFS = -DGDBG_INFO_ON -DGLIDE_DEBUG else -GLIDE_DEBUG_GCFLAGS = -O6 -m486 +ifeq ("@FX_GLIDE_BUILD_ARCHITECTURE@","alpha") +GLIDE_DEBUG_GCFLAGS = -O2 -mcpu=ev6 +GLIDE_DEBUG_GDEFS = -DBIG_OPT +else +ifeq ("@FX_GLIDE_BUILD_ARCHITECTURE@","ia64") +GLIDE_DEBUG_GCFLAGS = -O3 +GLIDE_DEBUG_GDEFS = -fomit-frame-pointer \ + -fexpensive-optimizations -ffast-math -DBIG_OPT +else +GLIDE_DEBUG_GCFLAGS = -O2 GLIDE_DEBUG_GDEFS = -fomit-frame-pointer -funroll-loops \ -fexpensive-optimizations -ffast-math -DBIG_OPT endif +endif +endif GCFLAGS = $(GLIDE_DEBUG_GCFLAGS) # # Global DEFS diff --git a/swlibs/newpci/pcilib/fxlinux.c b/swlibs/newpci/pcilib/fxlinux.c index 876deb8..8a35cbf 100644 --- a/swlibs/newpci/pcilib/fxlinux.c +++ b/swlibs/newpci/pcilib/fxlinux.c @@ -35,10 +35,10 @@ static const char* pciIdentifyLinux(void); static FxBool pciOutputStringLinux(const char *msg); static FxBool pciInitializeLinux(void); static FxBool pciShutdownLinux(void); -static FxBool pciMapLinearLinux(FxU32, FxU32 physical_addr, FxU32 *linear_addr, +static FxBool pciMapLinearLinux(FxU32, FxU32 physical_addr, AnyPtr *linear_addr, FxU32 *length); -static FxBool pciUnmapLinearLinux(FxU32 linear_addr, FxU32 length); -static FxBool pciSetPermissionLinux(const FxU32, const FxU32, const FxBool); +static FxBool pciUnmapLinearLinux(AnyPtr linear_addr, FxU32 length); +static FxBool pciSetPermissionLinux(const AnyPtr, const FxU32, const FxBool); static FxU8 pciPortInByteLinux(unsigned short port); static FxU16 pciPortInWordLinux(unsigned short port); static FxU32 pciPortInLongLinux(unsigned short port); @@ -204,7 +204,7 @@ pciShutdownLinux(void) static FxBool pciMapLinearLinux(FxU32 bus, FxU32 physical_addr, - FxU32 *linear_addr, FxU32 *length) + AnyPtr *linear_addr, FxU32 *length) { int fd; if (linuxDevFd!=-1) { @@ -215,7 +215,7 @@ pciMapLinearLinux(FxU32 bus, FxU32 physical_addr, return FXFALSE; } } - if (((*linear_addr)=(FxU32)mmap(0, *length, PROT_READ|PROT_WRITE, + if (((*linear_addr)=(AnyPtr)mmap(0, *length, PROT_READ|PROT_WRITE, MAP_SHARED, fd, physical_addr))<0) { if (fd!=linuxDevFd) close(fd); return FXFALSE; @@ -225,14 +225,14 @@ pciMapLinearLinux(FxU32 bus, FxU32 physical_addr, } static FxBool -pciUnmapLinearLinux(FxU32 linear_addr, FxU32 length) +pciUnmapLinearLinux(AnyPtr linear_addr, FxU32 length) { munmap((void*)linear_addr, length); return FXTRUE; } static FxBool -pciSetPermissionLinux(const FxU32 addrBase, const FxU32 addrLen, +pciSetPermissionLinux(const AnyPtr addrBase, const FxU32 addrLen, const FxBool writePermP) { return FXTRUE; diff --git a/swlibs/newpci/pcilib/fxpci.c b/swlibs/newpci/pcilib/fxpci.c index d5fd1ac..ce428eb 100644 --- a/swlibs/newpci/pcilib/fxpci.c +++ b/swlibs/newpci/pcilib/fxpci.c @@ -60,7 +60,7 @@ typedef struct _pciDeviceNode struct { FxBool mapped; - FxU32 virtualAddress; + AnyPtr virtualAddress; } addresses[MAX_PCI_BASEADDRESSES]; struct _pciDeviceNode *next; @@ -108,7 +108,7 @@ static PCIErr pciError[] = { FX_ENTRY FxU8 FX_CALL pioInByte ( unsigned short port ) { - FxU8 data; + FxU8 data = 0; if (pciHwcCallbacks.pioInByte) data = pciHwcCallbacks.pioInByte(port); @@ -120,7 +120,7 @@ pioInByte ( unsigned short port ) FX_ENTRY FxU16 FX_CALL pioInWord ( unsigned short port ) { - FxU16 data; + FxU16 data = 0; if (pciHwcCallbacks.pioInWord) data = pciHwcCallbacks.pioInWord(port); @@ -132,7 +132,7 @@ pioInWord ( unsigned short port ) FX_ENTRY FxU32 FX_CALL pioInLong ( unsigned short port ) { - FxU32 data; + FxU32 data = 0; if (pciHwcCallbacks.pioInLong) data = pciHwcCallbacks.pioInLong(port); @@ -252,7 +252,7 @@ static void printDeviceList(pciDeviceNode *head) for(index=0; indexaddresses[index].mapped) - printf(" %s virtual address: 0x%x\n", baseName[index], + printf(" %s virtual address: 0x%lx\n", baseName[index], head->addresses[index].virtualAddress); } @@ -372,10 +372,10 @@ _pciUpdateRegister( FxU32 offset, FxU32 data, FxU32 size_in_bytes, return; } /* _pciUpdateRegister */ -static FxU32 +static AnyPtr find_mapped_address(FxU32 device_bus_func_number, FxU32 addrNum) { - FxU32 retVal = 0x00UL; + AnyPtr retVal = 0x00UL; FxU32 bus, slot, function; pciDeviceNode *current = pciDeviceList; @@ -406,7 +406,7 @@ find_mapped_address(FxU32 device_bus_func_number, FxU32 addrNum) } static void -set_mapped_address(FxU32 device_bus_func_number, FxU32 addrNum, FxU32 value) +set_mapped_address(FxU32 device_bus_func_number, FxU32 addrNum, AnyPtr value) { FxU32 bus, slot, function; pciDeviceNode *current = pciDeviceList; @@ -963,7 +963,8 @@ pciMapCardMulti(FxU32 vendorID, FxU32 deviceID, FxU32 cardNum, FxU32 addressNum) { FxU32 - physAddress, + physAddress; + AnyPtr virtAddress; /* 1) open the PCI device and scan it for devices @@ -974,7 +975,7 @@ pciMapCardMulti(FxU32 vendorID, FxU32 deviceID, /* 3) find the current physcial address of the card */ pciGetConfigData( baseAddresses[addressNum], *devNum, &physAddress ); - if (length <= 0) return (FxU32*)length; + if (length <= 0) return (FxU32*)(long)length; /* Mask the memory type information bits off. * [0]: Memory type indicator (0 memory/1 i/o) @@ -1030,7 +1031,8 @@ pciMapCardMultiFunc(FxU32 vendorID, FxU32 deviceID, FxU32 cardNum, FxU32 addressNum) { FxU32 - physAddress, + physAddress; + AnyPtr virtAddress; FxU32 functionNumber; @@ -1045,7 +1047,7 @@ pciMapCardMultiFunc(FxU32 vendorID, FxU32 deviceID, /* 3) find the current physcial address of the card */ pciGetConfigData( baseAddresses[addressNum], *devNum, &physAddress ); - if (length <= 0) return (FxU32*)length; + if (length <= 0) return (FxU32*)(long)length; /* Mask the memory type information bits off. * [0]: Memory type indicator (0 memory/1 i/o) @@ -1093,7 +1095,7 @@ pciMapCard(FxU32 vendorID, FxU32 deviceID, } /* pciMapCard */ FX_EXPORT FxBool FX_CSTYLE -pciMapPhysicalToLinear( FxU32 *linear_addr, FxU32 physical_addr, +pciMapPhysicalToLinear( AnyPtr *linear_addr, FxU32 physical_addr, FxU32 *length ) { return pciMapPhysicalDeviceToLinear(linear_addr, @@ -1102,7 +1104,7 @@ pciMapPhysicalToLinear( FxU32 *linear_addr, FxU32 physical_addr, } /* pciMapPhysicalToLinear */ FX_ENTRY FxBool FX_CALL -pciMapPhysicalDeviceToLinear(FxU32 *linear_addr, +pciMapPhysicalDeviceToLinear(AnyPtr *linear_addr, FxU32 busNumber, FxU32 physical_addr, FxU32 *length) { @@ -1112,7 +1114,7 @@ pciMapPhysicalDeviceToLinear(FxU32 *linear_addr, FX_EXPORT void FX_CSTYLE -pciUnmapPhysical( FxU32 linear_addr, FxU32 length ) +pciUnmapPhysical( AnyPtr linear_addr, FxU32 length ) { int baseAddressIndex; pciDeviceNode *current = pciDeviceList; @@ -1158,7 +1160,7 @@ pciOutputDebugString(const char* msg) } FX_EXPORT FxBool FX_CSTYLE -pciLinearRangeSetPermission(const FxU32 addrBase, const FxU32 addrLen, const FxBool writeableP) +pciLinearRangeSetPermission(const AnyPtr addrBase, const FxU32 addrLen, const FxBool writeableP) { return pciLinearRangeSetPermissionDD(addrBase, addrLen, writeableP); } diff --git a/swlibs/newpci/pcilib/fxpci.h b/swlibs/newpci/pcilib/fxpci.h index dbe5a94..5bfb956 100644 --- a/swlibs/newpci/pcilib/fxpci.h +++ b/swlibs/newpci/pcilib/fxpci.h @@ -180,15 +180,15 @@ pciSetConfigDataRaw( PciRegister reg, FxU32 device_bus_func_number, FxU32 *data * on bus0 which would not work across pci bridges or on agp devices. */ FX_ENTRY FxBool FX_CALL -pciMapPhysicalToLinear(FxU32 *linear_addr, FxU32 physical_addr,FxU32 *length); +pciMapPhysicalToLinear(AnyPtr *linear_addr, FxU32 physical_addr,FxU32 *length); FX_ENTRY FxBool FX_CALL -pciMapPhysicalDeviceToLinear(FxU32 *linear_addr, +pciMapPhysicalDeviceToLinear(AnyPtr *linear_addr, FxU32 busNumber, FxU32 physical_addr, FxU32 *length); FX_ENTRY void FX_CALL -pciUnmapPhysical( FxU32 linear_addr, FxU32 length ); +pciUnmapPhysical( AnyPtr linear_addr, FxU32 length ); const char * pciGetVendorName( FxU16 vendor_id ); @@ -235,7 +235,7 @@ FX_ENTRY FxBool FX_CALL pciOutputDebugString(const char* debugMsg); FX_ENTRY FxBool FX_CALL -pciLinearRangeSetPermission(const FxU32 addrBase, const FxU32 addrLen, const FxBool writeableP); +pciLinearRangeSetPermission(const AnyPtr addrBase, const FxU32 addrLen, const FxBool writeableP); #define PCI_ERR_NOERR 0 #define PCI_ERR_WINRTINIT 1 diff --git a/swlibs/newpci/pcilib/pcilib.h b/swlibs/newpci/pcilib/pcilib.h index 1c4b74e..691926d 100644 --- a/swlibs/newpci/pcilib/pcilib.h +++ b/swlibs/newpci/pcilib/pcilib.h @@ -74,13 +74,13 @@ typedef struct { /* Platform device address management */ FxBool (*addrMap)(FxU32 busNumber, FxU32 physAddr, - FxU32* linearAddr, FxU32* length); - FxBool (*addrUnmap)(FxU32 linearAddr, FxU32 length); + AnyPtr* linearAddr, FxU32* length); + FxBool (*addrUnmap)(AnyPtr linearAddr, FxU32 length); /* Optional things that a platform may or maynot support and clients * should not rely on the call to suceed. */ - FxBool (*addrSetPermission)(const FxU32 addrBase, const FxU32 addrLen, + FxBool (*addrSetPermission)(const AnyPtr addrBase, const FxU32 addrLen, const FxBool writePermP); FxBool (*msrGet)(MSRInfo* in, MSRInfo* out); diff --git a/swlibs/texus/lib/texus.h b/swlibs/texus/lib/texus.h index 39bdfa3..1056c55 100644 --- a/swlibs/texus/lib/texus.h +++ b/swlibs/texus/lib/texus.h @@ -38,8 +38,14 @@ extern "C" { typedef unsigned char FxU8; typedef unsigned short FxU16; typedef short FxI16; +#if defined(__alpha__) || defined(__LP64__) +typedef unsigned int FxU32; +typedef int FxI32; +#else typedef unsigned long FxU32; typedef long FxI32; +#endif +typedef unsigned long AnyPtr; typedef int FxBool; /* diff --git a/swlibs/texus2/cmd/makefile.autoconf.am b/swlibs/texus2/cmd/makefile.autoconf.am index f6562cf..20a1686 100644 --- a/swlibs/texus2/cmd/makefile.autoconf.am +++ b/swlibs/texus2/cmd/makefile.autoconf.am @@ -24,5 +24,5 @@ noinst_PROGRAMS = texus texus_SOURCES = cmd.c texus_LDADD = $(top_builddir)/swlibs/fxmisc/libfxmisc.la \ - $(top_builddir)/swlibs/texus2/lib/libtexus.la + $(top_builddir)/swlibs/texus2/lib/libtexus.la -lm diff --git a/swlibs/texus2/lib/codec.c b/swlibs/texus2/lib/codec.c index ad98f51..c808f30 100644 --- a/swlibs/texus2/lib/codec.c +++ b/swlibs/texus2/lib/codec.c @@ -753,7 +753,7 @@ encodeColors(int mode, int mixmode, int alpha, float c0[3], float c1[3], float c /* Map input colors to closest entry in the palette */ for (i=0; i<32; i++) { - index[i] = bestColor((float *) &input[i][0], fpal, 4); + index[i] = bestColor((float *) &input[i][0], (const float (*)[3])fpal, 4); } /* Now encode these into the 128 bits */ @@ -1043,7 +1043,7 @@ again: for (i=0; i<32; i++) { // for each input point float e; - j = bestColorError((float *) &input[i][0], colors, ncolors, &e); + j = bestColorError((float *) &input[i][0], (const float (*)[3])colors, ncolors, &e); counts[j] += 1.0f; sums[j][0] += (input[i][0]); sums[j][1] += (input[i][1]); @@ -1108,7 +1108,7 @@ again: float dr, dg, db; float e; /* distance according to the L-infinity metric */ - j = bestColor((float *) &input[i][0], colors, ncolors); /* distance according to the L-squared metric */ + j = bestColor((float *) &input[i][0], (const float (*)[3])colors, ncolors); /* distance according to the L-squared metric */ dr = ABS( input[i][0] - colors[j][0] ); dg = ABS( input[i][1] - colors[j][1] ); db = ABS( input[i][2] - colors[j][2] ); @@ -1363,7 +1363,7 @@ encodeAlpha( float input[][3], FxI32 ainput[], void *bits, FxU32 lerp) float fpal[4][4]; int i, index[32]; - vqChromaAlpha( input, ainput, 3, col, lerp); + vqChromaAlpha( (const float (*)[3])input, ainput, 3, col, lerp); if ( lerp ) { /* Deal with even block */ @@ -1454,7 +1454,7 @@ quantize4bpp_block(float input[][3], FxI32 ainput[], void *bits) #endif // whole block statistics - eigenStatistics(32, input, Wvalues, output, Wflo, Wfhi, Wavg /*not used*/, Wmin, Wmax, Werr); + eigenStatistics(32, (const float (*)[3])input, Wvalues, output, Wflo, Wfhi, Wavg /*not used*/, Wmin, Wmax, Werr); #if PRINT fprintf(stderr, "NEW TILE----------------------(%4d %4d)\n", globalX, globalY); @@ -1487,7 +1487,7 @@ quantize4bpp_block(float input[][3], FxI32 ainput[], void *bits) return; case TCC_CHROMA: - vqChroma( input, alpha ? 3 : 4, col); + vqChroma( (const float (*)[3])input, alpha ? 3 : 4, col); encodeColors( TCC_CHROMA, 0, 0, &col[0][0], &col[1][0], &col[2][0], &col[3][0], input, ainput, bits); _cc_chroma++; @@ -1551,7 +1551,7 @@ quantize4bpp_block(float input[][3], FxI32 ainput[], void *bits) } #endif - vqChroma( input, alpha ? 3 : 4, col); + vqChroma( (const float (*)[3])input, alpha ? 3 : 4, col); encodeColors( TCC_CHROMA, 0, alpha, &col[0][0], &col[1][0], &col[2][0], &col[3][0], input, ainput, bits); _cc_chroma++; diff --git a/swlibs/texus2/lib/texus.h b/swlibs/texus2/lib/texus.h index 153f980..8c08159 100644 --- a/swlibs/texus2/lib/texus.h +++ b/swlibs/texus2/lib/texus.h @@ -36,8 +36,14 @@ extern "C" { typedef unsigned char FxU8; typedef unsigned short FxU16; typedef short FxI16; +#if defined(__alpha__) || defined(__LP64__) +typedef unsigned int FxU32; +typedef int FxI32; +#else typedef unsigned long FxU32; typedef long FxI32; +#endif +typedef unsigned long AnyPtr; typedef int FxBool; /*