- More solaris patches from Vincent Cojot's first patches to

icculus.  (icculus patchset #65)
- Also including some bugfixes by a mythical 'eliasm' from
  the same patchset.
This commit is contained in:
Jamie Wilkinson 2003-01-11 05:18:59 +00:00
parent 0b0e9986ef
commit b796032faa
9 changed files with 223 additions and 81 deletions

View file

@ -1152,8 +1152,11 @@ void Z_Free (void *ptr)
z = ((zhead_t *)ptr) - 1;
if (z->magic != Z_MAGIC)
if (z->magic != Z_MAGIC) {
printf("free: %p failed\n", ptr);
abort();
Com_Error (ERR_FATAL, "Z_Free: bad magic");
}
z->prev->next = z->next;
z->next->prev = z->prev;

View file

@ -27,23 +27,23 @@
#include <stdio.h>
#include <GL/gl.h>
#ifdef HAVE_OPENGL_GLEXT
#include <GL/glext.h>
#endif // HAVE_OPENGL_GLEXT
# include <GL/glext.h>
#else /* HAVE_OPENGL_GLEXT */
# include <GL/glu.h>
# ifndef GL_COLOR_INDEX8_EXT
# define GL_COLOR_INDEX8_EXT GL_COLOR_INDEX
# endif
#endif /* HAVE_OPENGL_GLEXT */
#include <math.h>
#ifndef _WIN32
char *strlwr (char *s);
#endif
#ifdef __sun__
# ifndef GL_COLOR_INDEX8_EXT
# define GL_COLOR_INDEX8_EXT GL_COLOR_INDEX
# endif
#endif
#include "ref.h"
#include "qgl.h"
#define REF_VERSION "GL 0.01"

View file

@ -61,12 +61,39 @@
#include "game.h"
#include "rw.h"
#ifdef SOL8_XIL_WORKAROUND
#include <xil/xil.h>
typedef struct {
qboolean restart_sound;
int s_rate;
int s_width;
int s_channels;
int width;
int height;
byte * pic;
byte * pic_pending;
/* order 1 huffman stuff */
int * hnodes1; /* [256][256][2] */
int numhnodes1[256];
int h_used[512];
int h_count[512];
} cinematics_t;
#endif
cvar_t *nostdout;
unsigned sys_frame_time;
uid_t saved_euid;
qboolean stdin_active = true;
char display_name[1024];
/* FIXME: replace with configure test for hrtime_t */
#ifdef __sun__
hrtime_t base_hrtime;
#endif
// =======================================================================
// General routines
@ -126,7 +153,7 @@ void Sys_Error (char *error, ...)
va_list argptr;
char string[1024];
// change stdin to non blocking
/* change stdin to non blocking */
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
CL_Shutdown ();
@ -285,9 +312,42 @@ void Sys_SendKeyEvents (void)
}
/*****************************************************************************/
#ifdef SOL8_XIL_WORKAROUND
XilSystemState xil_state;
#endif
int main (int argc, char **argv) {
int time, oldtime, newtime;
sigset_t sigs;
#ifdef SOL8_XIL_WORKAROUND
{
extern cinematics_t cin;
if ((xil_state = xil_open()) == NULL) {
fprintf(stderr, "Can't open XIL\n");
exit(1);
}
memset(&cin, 0, sizeof(cin));
}
#endif
/* save the contents of the DISPLAY environment variable.
* if we don't, it gets overwritten after reloading
* the renderer libraries (solaris) */
{
char * tmp_name = getenv("DISPLAY");
if (tmp_name == NULL) {
display_name[0] = '\0';
} else {
strncpy(display_name, tmp_name, sizeof(display_name));
}
}
/* block the SIGPOLL signal so that only the audio thread gets it */
sigemptyset(&sigs);
sigaddset(&sigs, SIGPOLL);
pthread_sigmask(SIG_BLOCK, &sigs, NULL);
/* go back to real user for config loads */
saved_euid = geteuid();
@ -449,3 +509,39 @@ void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
}
#endif
size_t verify_fread(void * ptr, size_t size, size_t nitems, FILE * fp) {
size_t ret;
int err;
clearerr(fp);
ret = fread(ptr, size, nitems, fp);
err = errno;
if (ret != nitems) {
printf("verify_fread(...,%d,%d,...): return value: %d\n", size, nitems, ret);
if (ret == 0 && ferror(fp)) {
printf(" error: %s\n", strerror(err));
printf(" fileno=%d\n", fileno(fp));
}
/* sleep(5); */
}
return ret;
}
size_t verify_fwrite(void * ptr, size_t size, size_t nitems, FILE * fp) {
size_t ret;
int err;
clearerr(fp);
ret = fwrite(ptr, size, nitems, fp);
err = errno;
if (ret != nitems) {
printf("verify_fwrite(...,%d,%d,...) = %d\n", size, nitems, ret);
if (ret == 0 && ferror(fp)) {
printf(" error: %s\n", strerror(err));
printf(" fileno=%d\n", fileno(fp));
}
}
/* sleep(5); */
return ret;
}

View file

@ -1,22 +1,24 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <ctype.h>
#ifdef _WIN32
#include <io.h>
@ -3477,7 +3479,7 @@ static qboolean PlayerConfig_ScanDirectories( void )
char findname[1024];
char scratch[1024];
int ndirs = 0, npms = 0;
char **dirnames;
char **dirnames = NULL;
char *path = NULL;
int i;
@ -3491,6 +3493,11 @@ static qboolean PlayerConfig_ScanDirectories( void )
do
{
path = FS_NextPath( path );
/* If FS_NextPath returns NULL we get a segv on the next line on solaris.
* Other platforms work probably because path becomes the null string
* or something */
if (path == NULL)
break;
Com_sprintf( findname, sizeof(findname), "%s/players/*.*", path );
if ( ( dirnames = FS_ListFiles( findname, &ndirs, SFF_SUBDIR, 0 ) ) != 0 )

View file

@ -51,12 +51,15 @@ void *Hunk_Begin (int maxsize)
maxhunksize = maxsize + sizeof(int);
curhunksize = 0;
/* merged in from q_sh*.c -- jaq */
/* FIXME: clean all this up into configure tests for mmap, MAP_ANONYMOUS and malloc */
#if defined(__linux__)
membase = mmap(0, maxhunksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
#elif defined(__FreeBSD__) || defined(__bsd__) || defined(__NetBSD__)
membase = mmap(0, maxhunksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
#elif defined(__sun__) || defined(__sgi)
membase = malloc(maxhunksize);
/* the following line is for debugging purposes */
memset(membase, 0, maxhunksize);
#endif
if (membase == NULL || membase == (byte *)-1)
Sys_Error("unable to virtual allocate %d bytes", maxsize);
@ -170,6 +173,18 @@ Sys_Milliseconds
================
*/
int curtime;
/* FIXME: replace with a configure test for gethrtime() */
#ifdef __sun__
extern hrtime_t base_hrtime
int Sys_Milliseconds(void) {
hrtime_t curr_hrtime;
curr_hrtime = gethrtime();
curtime = (curr_hrtime - base_hrtime) / 1000000LL;
return curtime;
}
#else
int Sys_Milliseconds (void)
{
struct timeval tp;
@ -188,6 +203,7 @@ int Sys_Milliseconds (void)
return curtime;
}
#endif
void Sys_Mkdir (char *path)
{
@ -214,8 +230,10 @@ static DIR *fdir;
static qboolean CompareAttributes(char *path, char *name,
unsigned musthave, unsigned canthave )
{
#if 0
struct stat st;
char fn[MAX_OSPATH];
#endif
// . and .. never match
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
@ -223,10 +241,9 @@ static qboolean CompareAttributes(char *path, char *name,
/* FIXME: what's the point of the return? -- jaq */
#if 1
sprintf(fn, "%s/%s", path, name);
#else
return true;
#endif
#else
sprintf(fn, "%s/%s", path, name);
if (stat(fn, &st) == -1)
return false; // shouldn't happen
@ -238,6 +255,7 @@ static qboolean CompareAttributes(char *path, char *name,
return false;
return true;
#endif
}
char *Sys_FindFirst (char *path, unsigned musthave, unsigned canhave)

View file

@ -1209,3 +1209,7 @@ typedef struct
extern int vidref_val;
// PGM
// ==================
/* error save versions of fread and fwrite */
size_t verify_fread(void *, size_t, size_t, FILE *);
size_t verify_fwrite(void *, size_t, size_t, FILE *);

View file

@ -29,9 +29,10 @@
#endif
#include <GL/gl.h>
#ifdef HAVE_OPENGL_GLEXT
#include <GL/glext.h>
#endif // HAVE_OPENGL_GLEXT
# include <GL/glext.h>
#endif /* HAVE_OPENGL_GLEXT */
qboolean QGL_Init( const char *dllname );
void QGL_Shutdown( void );
@ -462,34 +463,32 @@ extern void (*qgl3DfxSetPaletteEXT)(GLuint *);
#define GL_TEXTURE0_SGIS 0x835E
#define GL_TEXTURE1_SGIS 0x835F
#ifndef HAVE_OPENGL_GLEXT
/* these are in glext.h */
/* extension constants */
# define GL_POINT_SIZE_MIN_EXT 0x8126
# define GL_POINT_SIZE_MAX_EXT 0x8127
# define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
# define GL_DISTANCE_ATTENUATION_EXT 0x8129
#ifndef HAVE_OPENGL_GLEXT // FIXME: these are in glext.h, delete after testing
// extension constants
#define GL_POINT_SIZE_MIN_EXT 0x8126
#define GL_POINT_SIZE_MAX_EXT 0x8127
#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
#define GL_DISTANCE_ATTENUATION_EXT 0x8129
# ifdef __sgi
# define GL_SHARED_TEXTURE_PALETTE_EXT GL_TEXTURE_COLOR_TABLE_SGI
# else
# define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
# endif
#ifdef __sgi
#define GL_SHARED_TEXTURE_PALETTE_EXT GL_TEXTURE_COLOR_TABLE_SGI
#else
#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
#endif
# ifdef GL_DISTANCE_ATTENUATION_ARB
# define GL_DISTANCE_ATTENUATION_EXT GL_DISTANCE_ATTENUATION_ARB
# endif /* GL_DISTANCE_ATTENUATION_ARB */
#ifdef __sun__
#ifdef GL_DISTANCE_ATTENUATION_ARB
#define GL_DISTANCE_ATTENUATION_EXT GL_DISTANCE_ATTENUATION_ARB
#endif // GL_DISTANCE_ATTENUATION_ARB
#endif // __sun__
# ifndef GL_TEXTURE0_ARB
# define GL_TEXTURE0_ARB 0x84C0
# endif
# ifndef GL_TEXTURE1_ARB
# define GL_TEXTURE1_ARB 0x84C1
# endif
#ifndef GL_TEXTURE0_ARB
#define GL_TEXTURE0_ARB 0x84C0
#endif
#ifndef GL_TEXTURE1_ARB
#define GL_TEXTURE1_ARB 0x84C1
#endif
#endif // HAVE_OPENGL_GLEXT, end of glext.h defines
#endif /* HAVE_OPENGL_GLEXT */
extern int QGL_TEXTURE0, QGL_TEXTURE1;

View file

@ -1,26 +1,28 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* model loading and caching
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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 the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// models.c -- model loading and caching
// models are the only shared resource between a client and server running
// on the same machine.
/* models are the only shared resource between a client and server running
* on the same machine. */
#include "r_local.h"
@ -386,6 +388,9 @@ void Mod_LoadVertexes (lump_t *l)
count = l->filelen / sizeof(*in);
out = Hunk_Alloc ( (count+8)*sizeof(*out)); // extra for skybox
/* stop the games dumping core when changing levels */
memset(out, 0, (count + 6) * sizeof(*out));
loadmodel->vertexes = out;
loadmodel->numvertexes = count;
@ -508,6 +513,9 @@ void Mod_LoadTexinfo (lump_t *l)
next = LittleLong (in->nexttexinfo);
if (next > 0)
out->next = loadmodel->texinfo + next;
else
/* stop game dumping core when loading a new level */
out->next = NULL;
Com_sprintf (name, sizeof(name), "textures/%s.wal", in->texture);
out->image = R_FindImage (name, it_wall);

View file

@ -905,8 +905,15 @@ void S_AddLoopSounds (void)
ch->rightvol = right_total;
ch->autosound = true; // remove next frame
ch->sfx = sfx;
/* sometimes, the sc->length argument can become 0, and in that
* case we get a SIGFPE in the next modulo. The workaround checks
* for this situation and sets the pos and end to zero if true */
if (sc->length == 0) {
ch->pos = ch->end = 0;
} else {
ch->pos = paintedtime % sc->length;
ch->end = paintedtime + sc->length - ch->pos;
}
}
}