mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-12-02 00:52:19 +00:00
get qfvis working, including pthreads
This commit is contained in:
parent
c2053c4d07
commit
774b0adc2b
4 changed files with 37 additions and 29 deletions
17
configure.ac
17
configure.ac
|
@ -145,12 +145,12 @@ AC_CHECK_HEADERS(
|
||||||
dmedia/cdaudio.h dpmi.h dsound.h errno.h execinfo.h fcntl.h io.h \
|
dmedia/cdaudio.h dpmi.h dsound.h errno.h execinfo.h fcntl.h io.h \
|
||||||
libc.h limits.h linux/cdrom.h linux/joystick.h linux/soundcard.h \
|
libc.h limits.h linux/cdrom.h linux/joystick.h linux/soundcard.h \
|
||||||
machine/soundcard.h malloc.h math.h mgraph.h _mingw.h netdb.h \
|
machine/soundcard.h malloc.h math.h mgraph.h _mingw.h netdb.h \
|
||||||
netinet/in.h process.h pwd.h rpc/types.h setjmp.h signal.h stdarg.h \
|
netinet/in.h process.h pthread.h pwd.h rpc/types.h setjmp.h signal.h \
|
||||||
stdio.h stdlib.h string.h strings.h sys/asoundlib.h sys/audioio.h \
|
stdarg.h stdio.h stdlib.h string.h strings.h sys/asoundlib.h \
|
||||||
sys/filio.h sys/ioctl.h sys/io.h sys/ipc.h sys/mman.h sys/param.h \
|
sys/audioio.h sys/filio.h sys/ioctl.h sys/io.h sys/ipc.h sys/mman.h \
|
||||||
sys/poll.h sys/shm.h sys/signal.h sys/socket.h sys/soundcard.h \
|
sys/param.h sys/poll.h sys/shm.h sys/signal.h sys/socket.h \
|
||||||
sys/stat.h sys/time.h sys/types.h sys/uio.h termios.h time.h unistd.h \
|
sys/soundcard.h sys/stat.h sys/time.h sys/types.h sys/uio.h termios.h \
|
||||||
vgakeyboard.h vgamouse.h windows.h winsock.h
|
time.h unistd.h vgakeyboard.h vgamouse.h windows.h winsock.h
|
||||||
)
|
)
|
||||||
if test "x$mingw" = xyes; then
|
if test "x$mingw" = xyes; then
|
||||||
AC_MSG_CHECKING(for fnmatch.h)
|
AC_MSG_CHECKING(for fnmatch.h)
|
||||||
|
@ -160,6 +160,11 @@ else
|
||||||
AC_CHECK_HEADERS(fnmatch.h)
|
AC_CHECK_HEADERS(fnmatch.h)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "x$ac_cv_header_pthread_h" = "xyes"; then
|
||||||
|
PTHREAD_FLAGS=-pthread
|
||||||
|
fi
|
||||||
|
AC_SUBST(PTHREAD_FLAGS)
|
||||||
|
|
||||||
dnl ==================================================================
|
dnl ==================================================================
|
||||||
dnl Checks for typedefs, structures, and compiler characteristics
|
dnl Checks for typedefs, structures, and compiler characteristics
|
||||||
dnl ==================================================================
|
dnl ==================================================================
|
||||||
|
|
|
@ -3,6 +3,7 @@ AUTOMAKE_OPTIONS= foreign
|
||||||
QFVIS_LIBS=@QFVIS_LIBS@
|
QFVIS_LIBS=@QFVIS_LIBS@
|
||||||
QFVIS_DEPS=@QFVIS_DEPS@
|
QFVIS_DEPS=@QFVIS_DEPS@
|
||||||
QFVIS_INCS=@QFVIS_INCS@
|
QFVIS_INCS=@QFVIS_INCS@
|
||||||
|
PTHREAD_FLAGS=@PTHREAD_FLAGS@
|
||||||
|
|
||||||
INCLUDES= -I$(top_srcdir)/include $(QFVIS_INCS)
|
INCLUDES= -I$(top_srcdir)/include $(QFVIS_INCS)
|
||||||
|
|
||||||
|
@ -10,5 +11,6 @@ bin_PROGRAMS= qfvis
|
||||||
|
|
||||||
qfvis_SOURCES= flow.c options.c qfvis.c soundphs.c
|
qfvis_SOURCES= flow.c options.c qfvis.c soundphs.c
|
||||||
|
|
||||||
|
qfvis_LDFLAGS= $(PTHREAD_FLAGS)
|
||||||
qfvis_LDADD= $(QFVIS_LIBS)
|
qfvis_LDADD= $(QFVIS_LIBS)
|
||||||
qfvis_DEPENDENCIES= $(QFVIS_DEPS)
|
qfvis_DEPENDENCIES= $(QFVIS_DEPS)
|
||||||
|
|
|
@ -94,6 +94,7 @@ DecodeArgs (int argc, char **argv)
|
||||||
|
|
||||||
options.verbosity = 0;
|
options.verbosity = 0;
|
||||||
options.bspfile = NULL;
|
options.bspfile = NULL;
|
||||||
|
options.threads = 1;
|
||||||
|
|
||||||
while ((c = getopt_long (argc, argv, short_options, long_options, 0))
|
while ((c = getopt_long (argc, argv, short_options, long_options, 0))
|
||||||
!= EOF) {
|
!= EOF) {
|
||||||
|
|
|
@ -46,6 +46,9 @@ static const char rcsid[] =
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifdef HAVE_PTHREAD_H
|
||||||
|
# include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "QF/cmd.h"
|
#include "QF/cmd.h"
|
||||||
#include "QF/bspfile.h"
|
#include "QF/bspfile.h"
|
||||||
|
@ -60,11 +63,8 @@ static const char rcsid[] =
|
||||||
|
|
||||||
#define MAX_THREADS 4
|
#define MAX_THREADS 4
|
||||||
|
|
||||||
#ifdef __alpha
|
#ifdef HAVE_PTHREAD_H
|
||||||
pthread_mutex_t *my_mutex;
|
pthread_mutex_t *my_mutex;
|
||||||
int numthreads = 4;
|
|
||||||
#else
|
|
||||||
int numthreads = 1;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
options_t options;
|
options_t options;
|
||||||
|
@ -358,11 +358,7 @@ GetNextPortal (void)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __alpha
|
void *LeafThread (void *thread)
|
||||||
pthread_addr_t LeafThread (pthread_addr_t thread)
|
|
||||||
#else
|
|
||||||
void *LeafThread (int thread)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
portal_t *portal;
|
portal_t *portal;
|
||||||
|
|
||||||
|
@ -491,33 +487,32 @@ CalcPortalVis (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
leafon = 0;
|
leafon = 0;
|
||||||
|
#ifdef HAVE_PTHREAD_H
|
||||||
#ifdef __alpha
|
|
||||||
{
|
{
|
||||||
pthread_t work_threads[MAX_THREADS];
|
pthread_t work_threads[MAX_THREADS];
|
||||||
pthread_addr_t status;
|
void *status;
|
||||||
pthread_attr_t attrib;
|
pthread_attr_t attrib;
|
||||||
pthread_mutexattr_t mattrib;
|
pthread_mutexattr_t mattrib;
|
||||||
|
|
||||||
|
|
||||||
my_mutex = malloc (sizeof (*my_mutex));
|
my_mutex = malloc (sizeof (*my_mutex));
|
||||||
if (pthread_mutexattr_create (&mattrib) == -1)
|
if (pthread_mutexattr_init (&mattrib) == -1)
|
||||||
fprintf (stderr, "pthread_mutex_attr_create failed");
|
fprintf (stderr, "pthread_mutex_attr_create failed");
|
||||||
if (pthread_mutexattr_setkind_np (&mattrib, MUTEX_FAST_NP) == -1)
|
//if (pthread_mutexattr_settype (&mattrib, PTHREAD_MUTEX_ADAPTIVE_NP) == -1)
|
||||||
fprintf (stderr, "pthread_mutexattr_setkind_np failed");
|
// fprintf (stderr, "pthread_mutexattr_setkind_np failed");
|
||||||
if (pthread_mutex_init (my_mutex, mattrib) == -1)
|
if (pthread_mutex_init (my_mutex, &mattrib) == -1)
|
||||||
fprintf (stderr, "pthread_mutex_init failed");
|
fprintf (stderr, "pthread_mutex_init failed");
|
||||||
if (pthread_attr_create (&attrib) == -1)
|
if (pthread_attr_init (&attrib) == -1)
|
||||||
fprintf (stderr, "pthread_attr_create failed");
|
fprintf (stderr, "pthread_attr_create failed");
|
||||||
if (pthread_attr_setstacksize (&attrib, 0x100000) == -1)
|
if (pthread_attr_setstacksize (&attrib, 0x100000) == -1)
|
||||||
fprintf (stderr, "pthread_attr_setstacksize failed");
|
fprintf (stderr, "pthread_attr_setstacksize failed");
|
||||||
for (i = 0; i < numthreads; i++) {
|
for (i = 0; i < options.threads; i++) {
|
||||||
if (pthread_create (&work_threads[i], attrib, LeafThread,
|
if (pthread_create (&work_threads[i], &attrib, LeafThread,
|
||||||
(pthread_addr_t) i) == -1)
|
(void *) i) == -1)
|
||||||
fprintf (stderr, "pthread_create failed");
|
fprintf (stderr, "pthread_create failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < numthreads; i++) {
|
for (i = 0; i < options.threads; i++) {
|
||||||
if (pthread_join (work_threads[i], &status) == -1)
|
if (pthread_join (work_threads[i], &status) == -1)
|
||||||
fprintf (stderr, "pthread_join failed");
|
fprintf (stderr, "pthread_join failed");
|
||||||
}
|
}
|
||||||
|
@ -526,7 +521,7 @@ CalcPortalVis (void)
|
||||||
fprintf (stderr, "pthread_mutex_destroy failed");
|
fprintf (stderr, "pthread_mutex_destroy failed");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
LeafThread (0);
|
LeafThread (0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (options.verbosity >= 0) {
|
if (options.verbosity >= 0) {
|
||||||
|
@ -847,6 +842,7 @@ int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
double start, stop;
|
double start, stop;
|
||||||
|
dstring_t *portalfile = dstring_new ();
|
||||||
|
|
||||||
start = Sys_DoubleTime ();
|
start = Sys_DoubleTime ();
|
||||||
|
|
||||||
|
@ -865,7 +861,11 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
LoadBSPFile (options.bspfile);
|
LoadBSPFile (options.bspfile);
|
||||||
|
|
||||||
// LoadPortals (portalfile);
|
portalfile->size = strlen (options.bspfile) + 1;
|
||||||
|
dstring_adjust (portalfile);
|
||||||
|
COM_StripExtension (options.bspfile, portalfile->str);
|
||||||
|
dstring_appendstr (portalfile, ".prt");
|
||||||
|
LoadPortals (portalfile->str);
|
||||||
|
|
||||||
// uncompressed = malloc (bitbytes * portalleafs);
|
// uncompressed = malloc (bitbytes * portalleafs);
|
||||||
// memset (uncompressed, 0, bitbytes * portalleafs);
|
// memset (uncompressed, 0, bitbytes * portalleafs);
|
||||||
|
|
Loading…
Reference in a new issue