"Check" for the availability of pthreads.

Unfortunately, just because the header is there doesn't mean anything will
actually work :(. Also, the check is based on the host vendor/os for now.
Yes, it's rather lame but it will do for now.

With this, QF will build on an almost fresh ps3toolchain install. Only two
"fixes" are needed:
 o  In $PS3DEV/ppu/powerpc64-ps3-elf: ln -s ../include sys-include
 o  libsamplerate cross-built and installed.
This commit is contained in:
Bill Currie 2012-08-19 13:40:42 +09:00
parent 9bfcdad35a
commit a2f2d4d949
5 changed files with 17 additions and 11 deletions

View file

@ -1,10 +1,11 @@
if test "x$ac_cv_header_pthread_h" = "xyes"; then
save_LIBS="$LIBS"
echo $host_vendor-$host_os
HAVE_PTHREAD=yes
case "$host_vendor-$host_os" in
*android*) dnl android has all pthread* functions in the libc.
;;
*ps3*) dnl qnx has all pthread* functions in the libc.
*ps3*) dnl ps3toolchain doesn't have a working pthread yet
HAVE_PTHREAD=no
;;
*qnx*) dnl qnx has all pthread* functions in the libc.
;;
@ -31,5 +32,8 @@ if test "x$ac_cv_header_pthread_h" = "xyes"; then
LIBS="$save_LIBS"
PTHREAD_CFLAGS=-D_REENTRANT
fi
if test "x$HAVE_PTHREAD" = "xyes"; then
AC_DEFINE(HAVE_PTHREAD, 1, [Define if you have working pthread])
fi
AC_SUBST(PTHREAD_LDFLAGS)
AC_SUBST(PTHREAD_CFLAGS)

View file

@ -29,7 +29,7 @@
#ifndef __threads_h
#define __threads_h
#ifdef HAVE_PTHREAD_H
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
#include <pthread.h>
extern pthread_mutex_t *my_mutex;
#define LOCK do { if (options.threads > 1) pthread_mutex_lock (my_mutex); } while (0);

View file

@ -50,14 +50,14 @@
#include "options.h"
#include "threads.h"
#ifdef HAVE_PTHREAD_H
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
pthread_mutex_t *my_mutex;
#endif
void
InitThreads (void)
{
#ifdef HAVE_PTHREAD_H
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
if (options.threads > 1) {
pthread_mutexattr_t mattrib;
@ -75,7 +75,7 @@ InitThreads (void)
void
RunThreadsOn (threadfunc_t *func)
{
#ifdef HAVE_PTHREAD_H
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
if (options.threads > 1) {
pthread_t work_threads[256];
void *status;

View file

@ -33,7 +33,7 @@
# include "config.h"
#endif
#ifdef HAVE_PTHREAD_H
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
#include <pthread.h>
extern pthread_mutex_t *my_mutex;
#define LOCK do {if (options.threads > 1) pthread_mutex_lock (my_mutex); } while (0)

View file

@ -62,7 +62,7 @@
#define MAX_THREADS 4
#ifdef HAVE_PTHREAD_H
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
pthread_mutex_t *my_mutex;
#endif
@ -306,6 +306,7 @@ LeafThread (void *_thread)
return NULL;
}
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
static void *
WatchThread (void *_thread)
{
@ -340,6 +341,7 @@ WatchThread (void *_thread)
return NULL;
}
#endif
static int
CompressRow (byte *vis, byte *dest)
@ -449,7 +451,7 @@ CalcPortalVis (void)
return;
}
#ifdef HAVE_PTHREAD_H
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
{
pthread_t work_threads[MAX_THREADS + 1];
void *status;
@ -789,7 +791,7 @@ LoadPortals (char *name)
for (j = 0; j < numpoints; j++) {
// (%ld %ld %ld)
while (isspace (*line))
while (isspace ((byte) *line))
line++;
if (*line++ != '(')
Sys_Error ("LoadPortals: reading portal %i", i);
@ -801,7 +803,7 @@ LoadPortals (char *name)
line = err;
}
while (isspace (*line))
while (isspace ((byte) *line))
line++;
if (*line++ != ')')
Sys_Error ("LoadPortals: reading portal %i", i);